diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-08-08 11:08:35 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-08-08 18:09:02 +0000 |
commit | 6f104a0ffbfe2f01bb2b002aea91ea336daf8bf6 (patch) | |
tree | 9753037cdcff766f412af2800f4ad3ed4c7b5db1 /wsutil/crc10.c | |
parent | 9b9005eb94d9c89a02d93e8dda0c19b8e2d1a6d7 (diff) |
Clean up the CRC-10 code.
Have the wsutil routine just accumulate the stuff from the buffer handed
to us. Have the IUUP dissector deal with the extra stuff. Add a
update_crc10_by_bytes_tvb() routine, which is passed a tvbuff, offset,
and length, and use that rather than using tvb_get_ptr() in dissectors.
Change-Id: Iadd0823c764080e60d1339abb94d2e19150eabfe
Reviewed-on: https://code.wireshark.org/review/3509
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/crc10.c')
-rw-r--r-- | wsutil/crc10.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/wsutil/crc10.c b/wsutil/crc10.c index 9f04d93c04..17d6f1a291 100644 --- a/wsutil/crc10.c +++ b/wsutil/crc10.c @@ -69,25 +69,17 @@ static const guint16 byte_crc10_table[256] = { 0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1 }; -/* update the data block's CRC-10 remainder one byte at a time */ -guint16 update_crc10_by_bytes(guint16 crc10, const guint8 *data_blk_ptr, - int data_blk_size) +/* Update the data block's CRC-10 remainder one byte at a time */ +guint16 +update_crc10_by_bytes(guint16 crc10_accum, const guint8 *data_blk_ptr, + int data_blk_size) { register int i; - guint16 crc10_accum = 0; for (i = 0; i < data_blk_size; i++) { - crc10_accum = ((crc10_accum << 8) & 0x3ff) - ^ byte_crc10_table[( crc10_accum >> 2) & 0xff] - ^ *data_blk_ptr++; + crc10_accum = ((crc10_accum << 8) & 0x3ff) + ^ byte_crc10_table[( crc10_accum >> 2) & 0xff] + ^ *data_blk_ptr++; } - crc10_accum = ((crc10_accum << 8) & 0x3ff) - ^ byte_crc10_table[( crc10_accum >> 2) & 0xff] - ^ (crc10>>2); - crc10_accum = ((crc10_accum << 8) & 0x3ff) - ^ byte_crc10_table[( crc10_accum >> 2) & 0xff] - ^ ((crc10<<6) & 0xFF); - return crc10_accum; } - |