Big 2104 - From Benn Bollay:
authorsake <sake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 16 Dec 2007 00:35:34 +0000 (00:35 +0000)
committersake <sake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 16 Dec 2007 00:35:34 +0000 (00:35 +0000)
This patch adds a heuristic dissector to the ethernet trailer under the
keystring "eth.trailer".  This allows for other protocol plugins which coopt
the ethernet trailer for their own devices to register for trailer traffic
without requiring any further changes to the executable.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23880 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-eth.c
epan/dissectors/packet-eth.h
epan/dissectors/packet-ethertype.c
epan/dissectors/packet-ieee8023.c
epan/dissectors/packet-isl.c

index 39cb91963620c5ed53c876146fa1ba833733f3d8..743ff1a435f274156c50a6d5281849d2546f4edc 100644 (file)
@@ -59,6 +59,7 @@ static gint ett_addr = -1;
 
 static dissector_handle_t fw1_handle;
 static heur_dissector_list_t heur_subdissector_list;
+static heur_dissector_list_t eth_trailer_subdissector_list;
 
 static int eth_tap = -1;
 
@@ -376,8 +377,8 @@ static gboolean chek_is_802_2(tvbuff_t *tvb)
  * it does, maybe it doesn't"), we try to infer whether it has an FCS.
  */
 void
-add_ethernet_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
-                    tvbuff_t *trailer_tvb, int fcs_len)
+add_ethernet_trailer(packet_info *pinfo, proto_tree *fh_tree, int trailer_id,
+                    tvbuff_t *tvb, tvbuff_t *trailer_tvb, int fcs_len)
 {
   /* If there're some bytes left over, show those bytes as a trailer.
 
@@ -389,8 +390,14 @@ add_ethernet_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
     guint trailer_length, trailer_reported_length;
     gboolean has_fcs = FALSE;
 
+    if (dissector_try_heuristic(eth_trailer_subdissector_list, trailer_tvb,
+               pinfo, fh_tree)) {
+       return;
+    }
+
     trailer_length = tvb_length(trailer_tvb);
     trailer_reported_length = tvb_reported_length(trailer_tvb);
+
     if (fcs_len != 0) {
       /* If fcs_len is 4, we assume we definitely have an FCS.
          Otherwise, then, if the frame is big enough that, if we
@@ -527,6 +534,7 @@ proto_register_eth(void)
 
        /* subdissector code */
        register_heur_dissector_list("eth", &heur_subdissector_list);
+       register_heur_dissector_list("eth.trailer", &eth_trailer_subdissector_list);
 
        /* Register configuration preferences */
        eth_module = prefs_register_protocol(proto_eth, NULL);
index 35b9c252f01102a2a289402c5958b7ce52613dee..58471d6592ae1c57a58be499ac2b9df6720ed2dc 100644 (file)
@@ -32,7 +32,8 @@ typedef struct _eth_hdr {
 
 void capture_eth(const guchar *, int, int, packet_counts *);
 
-void add_ethernet_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
-                         tvbuff_t *trailer_tvb, int fcs_len);
+void add_ethernet_trailer(packet_info *pinfo, proto_tree *fh_tree,
+                         int trailer_id, tvbuff_t *tvb, tvbuff_t *trailer_tvb,
+                         int fcs_len);
 
 #endif
index 203fe6918ef3b9eb3c7c83a32eb8804c2d6cf454..a524983b9a487e5e95a3fec5b8f3e811e37ba336 100644 (file)
@@ -142,9 +142,9 @@ const value_string etype_vals[] = {
        {ETHERTYPE_PTP,         "PTPv2 over Ethernet (IEEE1588)"},
     {0,                                NULL                            } };
 
-static void add_dix_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
-    tvbuff_t *next_tvb, int offset_after_etype, guint length_before,
-    gint fcs_len);
+static void add_dix_trailer(packet_info *pinfo, proto_tree *fh_tree,
+    int trailer_id, tvbuff_t *tvb, tvbuff_t *next_tvb, int offset_after_etype,
+    guint length_before, gint fcs_len);
 
 void
 capture_ethertype(guint16 etype, const guchar *pd, int offset, int len,
@@ -268,14 +268,14 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
                }
        }
 
-       add_dix_trailer(fh_tree, trailer_id, tvb, next_tvb, offset_after_etype,
+       add_dix_trailer(pinfo, fh_tree, trailer_id, tvb, next_tvb, offset_after_etype,
            length_before, fcs_len);
 }
 
 static void
-add_dix_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
-    tvbuff_t *next_tvb, int offset_after_etype, guint length_before,
-    gint fcs_len)
+add_dix_trailer(packet_info *pinfo, proto_tree *fh_tree, int trailer_id,
+    tvbuff_t *tvb, tvbuff_t *next_tvb, int offset_after_etype,
+    guint length_before, gint fcs_len)
 {
        guint           length;
        tvbuff_t        *trailer_tvb;
@@ -311,7 +311,7 @@ add_dix_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
        } else
                trailer_tvb = NULL;     /* no trailer */
 
-       add_ethernet_trailer(fh_tree, trailer_id, tvb, trailer_tvb, fcs_len);
+       add_ethernet_trailer(pinfo, fh_tree, trailer_id, tvb, trailer_tvb, fcs_len);
 }
 
 void
index eaae439b415dbc1ef90f8c3fe5645ea9bb06be0f..fafe261b1d8d1b3cce8e7fabd50de9374af63dad 100644 (file)
@@ -100,7 +100,7 @@ dissect_802_3(int length, gboolean is_802_2, tvbuff_t *tvb,
   }
   ENDTRY;
 
-  add_ethernet_trailer(fh_tree, trailer_id, tvb, trailer_tvb, fcs_len);
+  add_ethernet_trailer(pinfo, fh_tree, trailer_id, tvb, trailer_tvb, fcs_len);
 }
 
 void
index 01189a674ad641258cae17f2303b382c5a3bd5c8..35c98be408f9b8c16ee8af63f0ba6e00fadb2bf4 100644 (file)
@@ -300,7 +300,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len)
 
       /* Now add the Ethernet trailer and FCS.
          XXX - do this only if we're encapsulated in Ethernet? */
-      add_ethernet_trailer(fh_tree, hf_isl_trailer, tvb, trailer_tvb, fcs_len);
+      add_ethernet_trailer(pinfo, fh_tree, hf_isl_trailer, tvb, trailer_tvb, fcs_len);
     }
     break;