diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-08-26 06:18:18 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-08-26 06:18:18 +0000 |
commit | b73e8138a8456cdc0e3b40fb6d0ac25a47eb6602 (patch) | |
tree | 19dbd5781994835a4360c76337d44eb96bb9d12f | |
parent | cdd8b24d5c8d9e2cd685a2491d14d3fce7c13fc0 (diff) | |
download | wireshark-b73e8138a8456cdc0e3b40fb6d0ac25a47eb6602.tar.gz wireshark-b73e8138a8456cdc0e3b40fb6d0ac25a47eb6602.tar.bz2 wireshark-b73e8138a8456cdc0e3b40fb6d0ac25a47eb6602.zip |
Make the CRC-32 routines take a tvbuff and a length as arguments.
Rename "crc32()" so as not to collide with the one in zlib; rename
"crc32_802()" to match.
svn path=/trunk/; revision=8268
-rw-r--r-- | crc32.c | 10 | ||||
-rw-r--r-- | crc32.h | 6 | ||||
-rw-r--r-- | packet-eth.c | 5 | ||||
-rw-r--r-- | packet-ieee80211.c | 4 | ||||
-rw-r--r-- | packet-ppp.c | 4 |
5 files changed, 15 insertions, 14 deletions
@@ -1,7 +1,7 @@ /* crc32.c * CRC-32 routine * - * $Id: crc32.c,v 1.2 2003/08/26 05:52:43 guy Exp $ + * $Id: crc32.c,v 1.3 2003/08/26 06:18:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -30,6 +30,7 @@ */ #include <glib.h> +#include <epan/tvbuff.h> #include "crc32.h" /* @@ -96,9 +97,10 @@ const guint32 crc32_table[256] = { }; guint32 -crc32(const unsigned char* buf, unsigned int len) +crc32_tvb(tvbuff_t *tvb, unsigned int len) { unsigned int i; + const unsigned char* buf = tvb_get_ptr(tvb, 0, len); guint32 crc32 = 0xFFFFFFFF; for (i = 0; i < len; i++) @@ -117,11 +119,11 @@ crc32(const unsigned char* buf, unsigned int len) * to cope with 802.x sending stuff out in reverse bit order? */ guint32 -crc32_802(const unsigned char* buf, unsigned int len) +crc32_tvb_802(tvbuff_t *tvb, unsigned int len) { guint32 c_crc; - c_crc = crc32(buf, len); + c_crc = crc32_tvb(tvb, len); /* Byte reverse. */ c_crc = ((unsigned char)(c_crc>>0)<<24) | @@ -1,7 +1,7 @@ /* crc32.h * Declaration of CRC-32 routine and table * - * $Id: crc32.h,v 1.2 2003/08/26 05:52:43 guy Exp $ + * $Id: crc32.h,v 1.3 2003/08/26 06:18:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -26,6 +26,6 @@ extern const guint32 crc32_table[256]; -extern guint32 crc32(const unsigned char* buf, unsigned int len); -extern guint32 crc32_802(const unsigned char* buf, unsigned int len); +extern guint32 crc32_tvb(tvbuff_t *tvb, unsigned int len); +extern guint32 crc32_tvb_802(tvbuff_t *tvb, unsigned int len); diff --git a/packet-eth.c b/packet-eth.c index 75e469a911..4728f2b568 100644 --- a/packet-eth.c +++ b/packet-eth.c @@ -1,7 +1,7 @@ /* packet-eth.c * Routines for ethernet packet disassembly * - * $Id: packet-eth.c,v 1.85 2003/08/26 05:52:44 guy Exp $ + * $Id: packet-eth.c,v 1.86 2003/08/26 06:18:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -342,8 +342,7 @@ add_ethernet_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb, } if (has_fcs) { guint32 sent_fcs = tvb_get_ntohl(trailer_tvb, trailer_length); - guint32 fcs = crc32_802(tvb_get_ptr(tvb, 0, tvb_length(tvb) - 4), - tvb_length(tvb) - 4); + guint32 fcs = crc32_tvb_802(tvb, tvb_length(tvb) - 4); if (fcs == sent_fcs) { proto_tree_add_text(fh_tree, trailer_tvb, trailer_length, 4, "Frane check sequence: 0x%08x (correct)", diff --git a/packet-ieee80211.c b/packet-ieee80211.c index 97dfb7bd1e..d44b232c77 100644 --- a/packet-ieee80211.c +++ b/packet-ieee80211.c @@ -3,7 +3,7 @@ * Copyright 2000, Axis Communications AB * Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com * - * $Id: packet-ieee80211.c,v 1.94 2003/08/26 05:52:48 guy Exp $ + * $Id: packet-ieee80211.c,v 1.95 2003/08/26 06:18:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1686,7 +1686,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo, reported_len -= 4; if (tree) { - guint32 fcs = crc32_802(tvb_get_ptr(tvb, 0, hdr_len + len), hdr_len + len); + guint32 fcs = crc32_tvb_802(tvb, hdr_len + len); guint32 sent_fcs = tvb_get_ntohl(tvb, hdr_len + len); if (fcs == sent_fcs) proto_tree_add_uint_format(hdr_tree, hf_fcs, tvb, diff --git a/packet-ppp.c b/packet-ppp.c index 8e643316b3..d77ef8a92b 100644 --- a/packet-ppp.c +++ b/packet-ppp.c @@ -2,7 +2,7 @@ * Routines for ppp packet disassembly * RFC 1661, RFC 1662 * - * $Id: packet-ppp.c,v 1.115 2003/08/26 05:52:50 guy Exp $ + * $Id: packet-ppp.c,v 1.116 2003/08/26 06:18:18 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1404,7 +1404,7 @@ fcs32(tvbuff_t * tvbuff) /* Check for invalid Length */ if (len == 0) return (0x00000000); - return crc32(tvb_get_ptr(tvbuff, 0, len), len); + return crc32_tvb(tvbuff, len); } tvbuff_t * |