diff options
author | Ross <whim42+github@gmail.com> | 2019-01-03 14:19:59 -0800 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-01-04 06:04:07 +0000 |
commit | 29bfeccc8db0a880ad3aff282389298852c02323 (patch) | |
tree | 615f4ace49432bbf31630c767d960604e513543d /epan | |
parent | 9aa63d2406dc8248f6220e62bf0359ade597c309 (diff) |
CRC6: Fixed CRC lookup table and functions
* Generated code and 256-element lookup table with pycrc
* Combined 2 crc6 functions which both have same poly 0x6f and lookup table
* Using the example file from the bug report,
$ tshark -r ~/Downloads/M1_header_crc.pcapng -V | grep "Calculated CRC"
1101 00.. = Header CRC: 0x34 [Calculated CRC 0x34]
Header and Calculated CRC are now both 0x34 (correct value)
* pycrc settings for generation:
$ python pycrc.py --reflect-in False \
--reflect-out False \
--xor-in 0 \
--xor-out 0 \
--algorithm table-driven
--width 6 \
--poly 0x2f
* To manually check 3GPP protocol header CRCs, use above command with flag
--check-hexstring=<HEADER HEX>
Bug: 14875
Change-Id: I283f52fcae10b2f92f107df6988629d49d692428
Reviewed-on: https://code.wireshark.org/review/31356
Reviewed-by: Ross Jacobs <rossbjacobs@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/crc6-tvb.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-iuup.c | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/epan/crc6-tvb.c b/epan/crc6-tvb.c index 5f3306cb68..1b044abe44 100644 --- a/epan/crc6-tvb.c +++ b/epan/crc6-tvb.c @@ -23,7 +23,7 @@ crc6_compute_tvb(tvbuff_t *tvb, int len) tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */ buf = tvb_get_ptr(tvb, 0, len); - return crc6_compute(buf, len); + return crc6_0X6F(0, buf, len); } /* diff --git a/epan/dissectors/packet-iuup.c b/epan/dissectors/packet-iuup.c index 6c43a5ef0f..94f86977c4 100644 --- a/epan/dissectors/packet-iuup.c +++ b/epan/dissectors/packet-iuup.c @@ -604,6 +604,7 @@ static int dissect_iuup(tvbuff_t* tvb_in, packet_info* pinfo, proto_tree* tree, proto_item* ack_item = NULL; guint8 first_octet; guint8 second_octet; + guint8 octet_array[2]; guint8 pdutype; guint phdr = 0; guint16 hdrcrc6; @@ -627,10 +628,10 @@ static int dissect_iuup(tvbuff_t* tvb_in, packet_info* pinfo, proto_tree* tree, tvb = tvb_new_subset_length(tvb_in,2,len); } - first_octet = tvb_get_guint8(tvb,0); - second_octet = tvb_get_guint8(tvb,1); + octet_array[0] = first_octet = tvb_get_guint8(tvb,0); + octet_array[1] = second_octet = tvb_get_guint8(tvb,1); hdrcrc6 = tvb_get_guint8(tvb, 2) >> 2; - crccheck = update_crc6_by_bytes(hdrcrc6, first_octet, second_octet); + crccheck = crc6_0X6F(hdrcrc6, octet_array, 2); pdutype = ( first_octet & PDUTYPE_MASK ) >> 4; @@ -780,9 +781,10 @@ static gboolean dissect_iuup_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree guint8 first_octet = tvb_get_guint8(tvb,0); guint8 second_octet = tvb_get_guint8(tvb,1); + guint8 octet_array[] = {first_octet, second_octet}; guint16 hdrcrc6 = tvb_get_guint8(tvb, 2) >> 2; - if (update_crc6_by_bytes(hdrcrc6, first_octet, second_octet)) return FALSE; + if (crc6_0X6F(hdrcrc6, octet_array, second_octet)) return FALSE; switch ( first_octet & 0xf0 ) { case 0x00: { |