aboutsummaryrefslogtreecommitdiffstats
path: root/packet-eth.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-08-26 05:09:56 +0000
committerGuy Harris <guy@alum.mit.edu>2003-08-26 05:09:56 +0000
commit42fdef2ff460e460016b841b640f47bee0bb8f21 (patch)
tree7f78a504b7f603c7743906a8f72d7dfba29e2392 /packet-eth.c
parentbe83b4d48706573595974b8e09a686c3c2b96097 (diff)
Extract the CRC-32 code from the 802.11 dissector into a separate file,
and use it in the Ethernet dissector as well, to check the FCS in Ethernet frames, if present. svn path=/trunk/; revision=8265
Diffstat (limited to 'packet-eth.c')
-rw-r--r--packet-eth.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/packet-eth.c b/packet-eth.c
index 47aa625407..9bd39edb14 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.83 2003/08/26 04:34:26 guy Exp $
+ * $Id: packet-eth.c,v 1.84 2003/08/26 05:09:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,6 +36,7 @@
#include "packet-ipx.h"
#include "packet-isl.h"
#include "packet-llc.h"
+#include "crc32.h"
#include "tap.h"
/* Interpret capture file as FW1 monitor file */
@@ -340,9 +341,18 @@ add_ethernet_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
trailer_length, FALSE);
}
if (has_fcs) {
- proto_tree_add_text(fh_tree, trailer_tvb, trailer_length, 4,
- "FCS: 0x%08x",
- tvb_get_ntohl(trailer_tvb, trailer_length));
+ guint32 sent_fcs = tvb_get_ntohl(trailer_tvb, trailer_length);
+ guint32 fcs = crc32(tvb_get_ptr(tvb, 0, tvb_length(tvb) - 4),
+ 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)",
+ sent_fcs);
+ } else {
+ proto_tree_add_text(fh_tree, trailer_tvb, trailer_length, 4,
+ "Frane check sequence: 0x%08x (incorrect, should be 0x%08x)",
+ sent_fcs, fcs);
+ }
}
}
}