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-ieee80211-prism.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'epan/dissectors/packet-ieee80211-prism.c') diff --git a/epan/dissectors/packet-ieee80211-prism.c b/epan/dissectors/packet-ieee80211-prism.c index 6d223d8dee..50b69a9567 100644 --- a/epan/dissectors/packet-ieee80211-prism.c +++ b/epan/dissectors/packet-ieee80211-prism.c @@ -237,33 +237,29 @@ prism_rate_return(guint32 rate) } -static void +static gboolean capture_prism(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) { guint32 cookie; - if (!BYTES_ARE_IN_FRAME(offset, len, 4)) { - ld->other++; - return; - } + if (!BYTES_ARE_IN_FRAME(offset, len, 4)) + return FALSE; /* Some captures with DLT_PRISM have the AVS WLAN header */ cookie = pntoh32(pd); if ((cookie == WLANCAP_MAGIC_COOKIE_V1) || (cookie == WLANCAP_MAGIC_COOKIE_V2)) { - capture_wlancap(pd, offset, len, ld, pseudo_header); - return; + return capture_wlancap(pd, offset, len, ld, pseudo_header); } /* Prism header */ - if (!BYTES_ARE_IN_FRAME(offset, len, PRISM_HEADER_LENGTH)) { - ld->other++; - return; - } + if (!BYTES_ARE_IN_FRAME(offset, len, PRISM_HEADER_LENGTH)) + return FALSE; + offset += PRISM_HEADER_LENGTH; /* 802.11 header follows */ - capture_ieee80211(pd, offset, len, ld, pseudo_header); + return capture_ieee80211(pd, offset, len, ld, pseudo_header); } static int @@ -558,8 +554,6 @@ void proto_register_ieee80211_prism(void) "prism"); proto_register_field_array(proto_prism, hf_prism, array_length(hf_prism)); proto_register_subtree_array(tree_array, array_length(tree_array)); - - register_capture_dissector(WTAP_ENCAP_IEEE_802_11_PRISM, capture_prism, proto_prism); } void proto_reg_handoff_ieee80211_prism(void) @@ -571,6 +565,8 @@ void proto_reg_handoff_ieee80211_prism(void) ieee80211_handle = find_dissector("wlan"); ieee80211_radio_handle = find_dissector("wlan_radio"); wlancap_handle = find_dissector("wlancap"); + + register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_PRISM, capture_prism, proto_prism); } /* -- cgit v1.2.3