Extract the CRC-32 code from the 802.11 dissector into a separate file,
[obnox/wireshark/wip.git] / packet-eth.c
index 47aa625407e880241bc7b86b6cda051aef812c15..9bd39edb14eda8faf6b40bdfc32bc2ae9212ed13 100644 (file)
@@ -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);
+      }
     }
   }
 }