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>
This commit is contained in:
Ross 2019-01-03 14:19:59 -08:00 committed by Anders Broman
parent 9aa63d2406
commit 29bfeccc8d
5 changed files with 58 additions and 1075 deletions

View File

@ -31,7 +31,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
crc32c_calculate@Base 1.10.0
crc32c_calculate_no_swap@Base 1.10.0
crc32c_table_lookup@Base 1.10.0
crc6_compute@Base 1.12.0~rc1
crc6_0X6F@Base 1.12.0~rc1
crc7update@Base 1.10.0
crc8_0x2F@Base 1.10.0
crc8_0x37@Base 2.3.0
@ -165,7 +165,6 @@ libwsutil.so.0 libwsutil0 #MINVER#
ulaw2linear@Base 1.12.0~rc1
update_adler32@Base 1.12.0~rc1
update_crc10_by_bytes@Base 1.10.0
update_crc6_by_bytes@Base 1.10.0
ws_add_crash_info@Base 1.10.0
ws_ascii_strnatcasecmp@Base 1.99.1
ws_ascii_strnatcmp@Base 1.99.1

View File

@ -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);
}
/*

View File

@ -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: {

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,6 @@
#include "ws_symbol_export.h"
WS_DLL_PUBLIC guint16 update_crc6_by_bytes(guint16 crc6, guint8 byte1, guint8 byte2);
WS_DLL_PUBLIC guint16 crc6_compute(const guint8 *data_blk_ptr, int data_blk_size);
WS_DLL_PUBLIC guint16 crc6_0X6F(guint16 crc6, const guint8 *data_blk_ptr, int data_blk_size);
#endif /* __CRC6_H__ */