aboutsummaryrefslogtreecommitdiffstats
path: root/epan/crc8-tvb.c
diff options
context:
space:
mode:
authorPhilip Rosenberg-Watt <p.rosenberg-watt@cablelabs.com>2014-04-17 14:04:36 -0600
committerEvan Huus <eapache@gmail.com>2014-04-17 20:38:44 +0000
commit53ae83750e8d6409861feb9e5d3314bba310c806 (patch)
treea1b8c219e031b8e0daa9cf4fc6e90e4223b97d0f /epan/crc8-tvb.c
parentc531099875dfc1abc7dff22424f30b4ef0c25b1f (diff)
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>
Diffstat (limited to 'epan/crc8-tvb.c')
-rw-r--r--epan/crc8-tvb.c13
1 files changed, 12 insertions, 1 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;
+}