aboutsummaryrefslogtreecommitdiffstats
path: root/packet-eth.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-08-21 21:05:30 +0000
committerGuy Harris <guy@alum.mit.edu>2003-08-21 21:05:30 +0000
commit8b22117e4c08e7a77e2bae5216619a3755f0ac33 (patch)
tree03b7a126984ab3bcf7d7f3ff6189176d3aefe560 /packet-eth.c
parentf695468fa2ca54a888d11bf61865f74d9c444cc8 (diff)
Sometimes Ethernet captures include an FCS at the end of the packet.
An Ethernet trailer is only needed to pad the packet to 60 bytes of Ethernet header plus payload; if the packet has what appears to be a trailer, and it's 4 or more bytes (i.e., long enough to include an FCS), and the Ethernet frame was claimed to have 64 or more bytes (i.e., it has at least an FCS worth of data more than the minimum 60 bytes), assume that the last 4 bytes of the frame were an FCS. svn path=/trunk/; revision=8207
Diffstat (limited to 'packet-eth.c')
-rw-r--r--packet-eth.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/packet-eth.c b/packet-eth.c
index c13e88ea8d..02532499c9 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.79 2003/01/22 06:26:33 guy Exp $
+ * $Id: packet-eth.c,v 1.80 2003/08/21 21:05:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -274,6 +274,41 @@ end_of_eth:
return;
}
+/*
+ * Add an Ethernet trailer - which, for some captures, might be the FCS
+ * rather than a pad-to-60-bytes trailer.
+ */
+void
+add_ethernet_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
+ tvbuff_t *trailer_tvb)
+{
+ /* If there're some bytes left over, show those bytes as a trailer.
+
+ However, if the Ethernet frame was claimed to have had 64 or more
+ bytes - i.e., it was at least an FCS worth of data longer than
+ the minimum payload size - assume the last 4 bytes of the trailer
+ are an FCS. */
+ if (trailer_tvb && fh_tree) {
+ guint trailer_length;
+ gboolean has_fcs = FALSE;
+
+ trailer_length = tvb_length(trailer_tvb);
+ if (tvb_reported_length(tvb) >= 64 && trailer_length >= 4) {
+ trailer_length -= 4;
+ has_fcs = TRUE;
+ }
+ if (trailer_length != 0) {
+ proto_tree_add_item(fh_tree, trailer_id, trailer_tvb, 0,
+ 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));
+ }
+ }
+}
+
void
proto_register_eth(void)
{