aboutsummaryrefslogtreecommitdiffstats
path: root/packet-eth.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-08-21 21:05:30 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-08-21 21:05:30 +0000
commitd1935d7e72cd74730274b3fb65575b3913c52e0e (patch)
tree03b7a126984ab3bcf7d7f3ff6189176d3aefe560 /packet-eth.c
parenta19457e30034cd139a03b26da94722be6d5c4062 (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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@8207 f5534014-38df-0310-8fa8-9805f1628bb7
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)
{