diff options
author | Anders Broman <anders.broman@ericsson.com> | 2011-10-03 04:53:17 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2011-10-03 04:53:17 +0000 |
commit | f08f09ecd42493885c2db0e2c97b5d4ffefc0995 (patch) | |
tree | 4d41cf36dedde631475e9d980680375b32c1dd8f /wsutil/crc32.c | |
parent | b7bdb4a98518e64c087d8bcbd4de7b3e476f92b9 (diff) |
From Michael Mann:
Condense all SCTP CRC routines to wsutil/crc32.[ch]. Also made
crc32_ccitt_table not explicitly accessible (must use crc32_ccitt_table_lookup).
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6298
svn path=/trunk/; revision=39233
Diffstat (limited to 'wsutil/crc32.c')
-rw-r--r-- | wsutil/crc32.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/wsutil/crc32.c b/wsutil/crc32.c index c40047dffe..5882ba9f5c 100644 --- a/wsutil/crc32.c +++ b/wsutil/crc32.c @@ -53,6 +53,8 @@ /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ /* */ /*****************************************************************/ +#define CRC32C(c,d) (c=(c>>8)^crc32c_table[(c^(d))&0xFF]) + static const guint32 crc32c_table[256] = { 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, 0x8AD958CFL, 0x78B2DBCCL, @@ -115,7 +117,7 @@ static const guint32 crc32c_table[256] = { * x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^8 + x^7 + * x^5 + x^4 + x^2 + x + 1 */ -const guint32 crc32_ccitt_table[256] = { +static const guint32 crc32_ccitt_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, @@ -193,6 +195,17 @@ crc32c_calculate(const void *buf, int len, guint32 crc) return CRC32C_SWAP(crc); } +guint32 +crc32c_calculate_no_swap(const void *buf, int len, guint32 crc) +{ + const guint8 *p = (const guint8 *)buf; + while (len-- > 0) { + CRC32C(crc, *p++); + } + + return crc; +} + guint32 crc32_ccitt(const guint8 *buf, guint len) { |