diff options
author | Balint Reczey <balint.reczey@ericsson.com> | 2010-09-12 01:13:42 +0000 |
---|---|---|
committer | Balint Reczey <balint.reczey@ericsson.com> | 2010-09-12 01:13:42 +0000 |
commit | cfbd48b7853461a1f3bd3ca3c97639762c931515 (patch) | |
tree | b1df9b5bf0c0e110dae312676a517a79798e6e91 | |
parent | 894941e532eec92ea593e6be66c0149edbb1d41c (diff) |
Decode SLL payloads using a dissector table based on sll.ltype.
The idea and the original patch came from Sebastian Reichel
<elektranox@gmail.com> in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594390
svn path=/trunk/; revision=34101
-rw-r--r-- | epan/dissectors/packet-ipx.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-llc.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ppp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-sll.c | 49 | ||||
-rw-r--r-- | epan/dissectors/packet-sll.h | 7 |
5 files changed, 23 insertions, 39 deletions
diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index 986997dab4..be7aa19765 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -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); diff --git a/epan/dissectors/packet-llc.c b/epan/dissectors/packet-llc.c index 46ea990918..9fd78245ca 100644 --- a/epan/dissectors/packet-llc.c +++ b/epan/dissectors/packet-llc.c @@ -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 */ diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c index 448814198c..4c09a283b2 100644 --- a/epan/dissectors/packet-ppp.c +++ b/epan/dissectors/packet-ppp.c @@ -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); } diff --git a/epan/dissectors/packet-sll.c b/epan/dissectors/packet-sll.c index fe49d212f7..d6c1c9c79c 100644 --- a/epan/dissectors/packet-sll.c +++ b/epan/dissectors/packet-sll.c @@ -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); diff --git a/epan/dissectors/packet-sll.h b/epan/dissectors/packet-sll.h index bac77079af..35b893cc7b 100644 --- a/epan/dissectors/packet-sll.h +++ b/epan/dissectors/packet-sll.h @@ -24,6 +24,13 @@ #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 |