Decode SLL payloads using a dissector table based on sll.ltype.
authorrbalint <rbalint@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 12 Sep 2010 01:13:42 +0000 (01:13 +0000)
committerrbalint <rbalint@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 12 Sep 2010 01:13:42 +0000 (01:13 +0000)
The idea and the original patch came from Sebastian Reichel
<elektranox@gmail.com> in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594390

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

epan/dissectors/packet-ipx.c
epan/dissectors/packet-llc.c
epan/dissectors/packet-ppp.c
epan/dissectors/packet-sll.c
epan/dissectors/packet-sll.h

index 986997dab49862d49e2865921cbbbb6146ec2252..be7aa197659d8f46e81f5f2f261411fbb6710151 100644 (file)
@@ -34,6 +34,7 @@
 #include <glib.h>
 #include <epan/packet.h>
 #include "packet-ipx.h"
+#include "packet-sll.h"
 #include <epan/addr_resolv.h>
 #include <epan/etypes.h>
 #include <epan/ppptypes.h>
@@ -1524,6 +1525,7 @@ proto_reg_handoff_ipx(void)
        dissector_add("ppp.protocol", PPP_IPX, ipx_handle);
        dissector_add("llc.dsap", SAP_NETWARE1, ipx_handle);
        dissector_add("llc.dsap", SAP_NETWARE2, ipx_handle);
+       dissector_add("sll.ltype", LINUX_SLL_P_802_3, ipx_handle);
        dissector_add("null.type", BSD_AF_IPX, ipx_handle);
        dissector_add("gre.proto", ETHERTYPE_IPX, ipx_handle);
        dissector_add("arcnet.protocol_id", ARCNET_PROTO_IPX, ipx_handle);
index 46ea9909183b0eff9e4884bb4666359588642c3b..9fd78245ca5936e82b7e932732f15cc8a87964fa 100644 (file)
@@ -43,6 +43,7 @@
 #include "packet-ipx.h"
 #include "packet-netbios.h"
 #include "packet-vines.h"
+#include "packet-sll.h"
 #include <epan/sna-utils.h>
 
 #include "packet-llc.h"
@@ -954,6 +955,7 @@ proto_reg_handoff_llc(void)
 
        llc_handle = find_dissector("llc");
        dissector_add("wtap_encap", WTAP_ENCAP_ATM_RFC1483, llc_handle);
+       dissector_add("sll.ltype", LINUX_SLL_P_802_2, llc_handle);
        /* RFC 2043 */
        dissector_add("ppp.protocol", PPP_LLC, llc_handle);
        /* RFC 2353 */
index 448814198c0db0196df9bc544427c8c45a5a9fbb..4c09a283b24fa63fa1633ec009688aae17cc41c8 100644 (file)
@@ -47,6 +47,7 @@
 #include <epan/crc32.h>
 #include <epan/ipproto.h>
 #include "packet-usb.h"
+#include "packet-sll.h"
 
 #define ppp_min(a, b)  (((a)<(b)) ? (a) : (b))
 
@@ -4757,6 +4758,7 @@ proto_reg_handoff_ppp(void)
   ppp_hdlc_handle = find_dissector("ppp_hdlc");
   dissector_add("wtap_encap", WTAP_ENCAP_PPP, ppp_hdlc_handle);
   dissector_add("wtap_encap", WTAP_ENCAP_PPP_WITH_PHDR, ppp_hdlc_handle);
+  dissector_add("sll.ltype", LINUX_SLL_P_PPPHDLC, ppp_hdlc_handle);
   dissector_add("osinl.excl", NLPID_PPP, ppp_handle);
   dissector_add("gre.proto", ETHERTYPE_PPP, ppp_hdlc_handle);
 }
index fe49d212f720e863351e37adbe769f6881618b7d..d6c1c9c79cde25da23d9e14957b507567f1ac327 100644 (file)
@@ -76,13 +76,6 @@ static const value_string packet_type_vals[] = {
        { 0,                    NULL }
 };
 
-/*
- * The LINUX_SLL_ values for "sll_protocol".
- */
-#define LINUX_SLL_P_802_3      0x0001  /* Novell 802.3 frames without 802.2 LLC header */
-#define LINUX_SLL_P_802_2      0x0004  /* 802.2 frames (not D/I/X Ethernet) */
-#define LINUX_SLL_P_PPPHDLC    0x0007  /* PPP HDLC frames */
-
 static const value_string ltype_vals[] = {
        { LINUX_SLL_P_802_3,    "Raw 802.3" },
        { LINUX_SLL_P_802_2,    "802.2 LLC" },
@@ -90,10 +83,8 @@ static const value_string ltype_vals[] = {
        { 0,                    NULL }
 };
 
+static dissector_table_t sll_linux_dissector_table;
 static dissector_table_t gre_dissector_table;
-static dissector_handle_t ipx_handle;
-static dissector_handle_t llc_handle;
-static dissector_handle_t ppphdlc_handle;
 static dissector_handle_t data_handle;
 
 void
@@ -237,33 +228,9 @@ dissect_sll(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                proto_tree_add_uint(fh_tree, hf_sll_ltype, tvb, 14, 2,
                    protocol);
 
-               switch (protocol) {
-
-               case LINUX_SLL_P_802_2:
-                       /*
-                        * 802.2 LLC.
-                        */
-                       call_dissector(llc_handle, next_tvb, pinfo, tree);
-                       break;
-
-               case LINUX_SLL_P_802_3:
-                       /*
-                        * Novell IPX inside 802.3 with no 802.2 LLC
-                        * header.
-                        */
-                       call_dissector(ipx_handle, next_tvb, pinfo, tree);
-                       break;
-
-               case LINUX_SLL_P_PPPHDLC:
-                       /*
-                        * PPP HDLC
-                        */
-                       call_dissector(ppphdlc_handle, next_tvb, pinfo, tree);
-                       break;
-
-               default:
+               if(!dissector_try_port(sll_linux_dissector_table, protocol,
+                       next_tvb, pinfo, tree)) {
                        call_dissector(data_handle, next_tvb, pinfo, tree);
-                       break;
                }
        } else {
                switch (hatype) {
@@ -340,6 +307,13 @@ proto_register_sll(void)
            "SLL", "sll" );
        proto_register_field_array(proto_sll, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
+
+       sll_linux_dissector_table = register_dissector_table (
+               "sll.ltype",
+               "Linux protocol type",
+               FT_UINT16,
+               BASE_HEX
+       );
 }
 
 void
@@ -351,9 +325,6 @@ proto_reg_handoff_sll(void)
         * Get handles for the IPX and LLC dissectors.
         */
        gre_dissector_table = find_dissector_table("gre.proto");
-       llc_handle = find_dissector("llc");
-       ipx_handle = find_dissector("ipx");
-       ppphdlc_handle = find_dissector("ppp_hdlc");
        data_handle = find_dissector("data");
 
        sll_handle = create_dissector_handle(dissect_sll, proto_sll);
index bac77079af5339eda9898db9901254eccd5dab69..35b893cc7bd932a9509f3d8a2261be977a786a84 100644 (file)
 #ifndef __PACKET_SLL_H__
 #define __PACKET_SLL_H__
 
+/*
+ * The LINUX_SLL_ values for "sll_protocol".
+ */
+#define LINUX_SLL_P_802_3      0x0001  /* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2      0x0004  /* 802.2 frames (not D/I/X Ethernet) */
+#define LINUX_SLL_P_PPPHDLC    0x0007  /* PPP HDLC frames */
+
 void capture_sll(const guchar *, int, packet_counts *);
 
 #endif