aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2011-10-03 04:53:17 +0000
committerAnders Broman <anders.broman@ericsson.com>2011-10-03 04:53:17 +0000
commitf08f09ecd42493885c2db0e2c97b5d4ffefc0995 (patch)
tree4d41cf36dedde631475e9d980680375b32c1dd8f /epan
parentb7bdb4a98518e64c087d8bcbd4de7b3e476f92b9 (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 'epan')
-rw-r--r--epan/dissectors/packet-sctp.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 081f5ea8c1..9f657327b7 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -446,23 +446,19 @@ sctp_adler32(const unsigned char* buf, unsigned int len)
static guint32
sctp_crc32c(const unsigned char* buf, unsigned int len)
{
- unsigned int i;
- guint32 crc32 = CRC32C_PRELOAD;
+ guint32 crc32,
+ zero = 0;
guint32 result;
- for (i = 0; i < SOURCE_PORT_LENGTH + DESTINATION_PORT_LENGTH + VERIFICATION_TAG_LENGTH; i++)
- {
- CRC32C(crc32, buf[i]);
- }
+ /* CRC for header */
+ crc32 = crc32c_calculate_no_swap(buf, SOURCE_PORT_LENGTH + DESTINATION_PORT_LENGTH + VERIFICATION_TAG_LENGTH, CRC32C_PRELOAD);
+
/* handle four 0 bytes as checksum */
- CRC32C(crc32, 0);
- CRC32C(crc32, 0);
- CRC32C(crc32, 0);
- CRC32C(crc32, 0);
- for (i = COMMON_HEADER_LENGTH; i < len; i++)
- {
- CRC32C(crc32, buf[i]);
- }
+ crc32 = crc32c_calculate_no_swap(&zero, 4, crc32);
+
+ /* CRC for the rest of the packet */
+ crc32 = crc32c_calculate_no_swap(&buf[COMMON_HEADER_LENGTH], len-COMMON_HEADER_LENGTH, crc32);
+
result = CRC32C_SWAP(crc32);
return ( ~result );