diff options
author | Philip Rosenberg-Watt <p.rosenberg-watt@cablelabs.com> | 2014-04-17 14:04:36 -0600 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-04-17 20:38:44 +0000 |
commit | 53ae83750e8d6409861feb9e5d3314bba310c806 (patch) | |
tree | a1b8c219e031b8e0daa9cf4fc6e90e4223b97d0f | |
parent | c531099875dfc1abc7dff22424f30b4ef0c25b1f (diff) | |
download | wireshark-53ae83750e8d6409861feb9e5d3314bba310c806.tar.gz |
Add CRC-8 calculator for EPON
See IEEE Standard 802.3-2012 Section 5, Clause 65
Change-Id: I83d8adfd5c4fd1f263175ac726854d51419b34e0
Reviewed-on: https://code.wireshark.org/review/1187
Reviewed-by: Evan Huus <eapache@gmail.com>
-rw-r--r-- | epan/crc8-tvb.c | 13 | ||||
-rw-r--r-- | epan/crc8-tvb.h | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/epan/crc8-tvb.c b/epan/crc8-tvb.c index da5affd530..8e7497b4df 100644 --- a/epan/crc8-tvb.c +++ b/epan/crc8-tvb.c @@ -61,7 +61,7 @@ static const guint8 crctable[256] = { /*reversed, 8-bit, poly=0x07*/ gboolean check_fcs(tvbuff_t *p, guint8 len, guint8 offset, guint8 received_fcs){ /*Init*/ - guint8 FCS=0xFF; + guint8 FCS = 0xFF; guint8 tmp = 0; /*len is the number of bytes in the message, p points to message*/ while (len--) { @@ -82,4 +82,15 @@ gboolean check_fcs(tvbuff_t *p, guint8 len, guint8 offset, guint8 received_fcs){ } } +guint8 get_crc8_ieee8023_epon(tvbuff_t *p, guint8 len, guint8 offset) { + guint8 FCS = 0x00; + guint8 tmp = 0; + while (len--) { + tmp = FCS^tvb_get_guint8(p,offset); + offset++; + FCS=crctable[tmp]; + } + + return FCS; +} diff --git a/epan/crc8-tvb.h b/epan/crc8-tvb.h index 667a1b4354..1d0a632b99 100644 --- a/epan/crc8-tvb.h +++ b/epan/crc8-tvb.h @@ -8,7 +8,9 @@ * Polynom: (x^8 + x^2 + x^1 + 1) * * 2011 Hans-Christoph Schemmel <hans-christoph.schemmel[AT]cinterion.com> - * + * 2014 Philip Rosenberg-Watt <p.rosenberg-watt[at]cablelabs.com> + * + Added CRC-8 for IEEE 802.3 EPON, with shift register initialized to 0x00 + * See IEEE Std 802.3-2012 Section 5, Clause 65.1.3.2.3. * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> @@ -44,5 +46,6 @@ #define __CRC8_TVB_H__ extern gboolean check_fcs(tvbuff_t *p, guint8 len, guint8 offset, guint8 received_fcs); +extern guint8 get_crc8_ieee8023_epon(tvbuff_t *p, guint8 len, guint8 offset); #endif /* __CRC8_TVB_H__ */ |