From 0960ac4dfdbfba5a81c56a49cfc6201ecd8f48e3 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sun, 13 Dec 2015 16:54:16 -0500 Subject: Create capture dissector tables. They are modeled after dissection dissector tables, but for the moment, don't have/need the flexibility. They are intended to be much simpler/faster than full dissection. The two most used/needed are "wtap_encap" and "ethertype", so they were the basis of starting to use and test capture dissector table API. Others may be added in the future. The "capture dissector" function signature needed a bit of tweeking to handling "claiming" of a packet. The current application of this is capture functions returning TRUE if they affected a "type" of packet count. Returning FALSE ends up considering the packet an "other" type. Change-Id: I81d06a6ccb2c03665f087258a46b9d78d513d6cd Reviewed-on: https://code.wireshark.org/review/12607 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/dissectors/packet-sll.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'epan/dissectors/packet-sll.c') diff --git a/epan/dissectors/packet-sll.c b/epan/dissectors/packet-sll.c index 18205f155c..dc1253dcf9 100644 --- a/epan/dissectors/packet-sll.c +++ b/epan/dissectors/packet-sll.c @@ -137,15 +137,14 @@ static dissector_table_t sll_linux_dissector_table; static dissector_table_t gre_dissector_table; static dissector_handle_t data_handle; -static void +static gboolean capture_sll(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) { guint16 protocol; - if (!BYTES_ARE_IN_FRAME(0, len, SLL_HEADER_SIZE)) { - ld->other++; - return; - } + if (!BYTES_ARE_IN_FRAME(0, len, SLL_HEADER_SIZE)) + return FALSE; + protocol = pntoh16(&pd[14]); if (protocol <= 1536) { /* yes, 1536 - that's how Linux does it */ /* @@ -158,37 +157,31 @@ capture_sll(const guchar *pd, int offset _U_, int len, packet_counts *ld, const /* * 802.2 LLC. */ - capture_llc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header); - break; + return capture_llc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header); case LINUX_SLL_P_ETHERNET: /* * Ethernet. */ - capture_eth(pd, SLL_HEADER_SIZE, len, ld, pseudo_header); - break; + return capture_eth(pd, SLL_HEADER_SIZE, len, ld, pseudo_header); case LINUX_SLL_P_802_3: /* * Novell IPX inside 802.3 with no 802.2 LLC * header. */ - capture_ipx(pd, SLL_HEADER_SIZE, len, ld, pseudo_header); - break; + return capture_ipx(pd, SLL_HEADER_SIZE, len, ld, pseudo_header); case LINUX_SLL_P_PPPHDLC: /* * PPP HDLC. */ - capture_ppp_hdlc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header); - break; - - default: - ld->other++; - break; + return capture_ppp_hdlc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header); } - } else - capture_ethertype(protocol, pd, SLL_HEADER_SIZE, len, ld, pseudo_header); + } else { + return try_capture_dissector("ethertype", protocol, pd, SLL_HEADER_SIZE, len, ld, pseudo_header); + } + return FALSE; } static int @@ -336,8 +329,6 @@ proto_register_sll(void) proto_register_fields(proto_sll, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); - register_capture_dissector(WTAP_ENCAP_SLL, capture_sll, proto_sll); - sll_handle = create_dissector_handle(dissect_sll, proto_sll); sll_linux_dissector_table = register_dissector_table ( @@ -359,6 +350,7 @@ proto_reg_handoff_sll(void) ethertype_handle = find_dissector("ethertype"); dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_handle); + register_capture_dissector("wtap_encap", WTAP_ENCAP_SLL, capture_sll, hfi_sll->id); } /* -- cgit v1.2.3