aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-01-19 20:58:06 -0800
committerGuy Harris <guy@alum.mit.edu>2016-01-20 04:58:39 +0000
commitaeeb2a99420f90121ffccaab817a51096e078c70 (patch)
treeddfd0f74d2953c540df4f46ffc449196f9509112 /epan/dissectors
parentf55bb2e27cd13e2b0574e86916cac94b7ff08714 (diff)
Call the dissectors for types in TZSP packets individually.
That way, we know we're passing them the dissector data they expect. Change-Id: I43aa1b751705eae77e082c537e8ffd6a4edc1a5f Reviewed-on: https://code.wireshark.org/review/13430 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-ieee80211-prism.c7
-rw-r--r--epan/dissectors/packet-tzsp.c171
2 files changed, 99 insertions, 79 deletions
diff --git a/epan/dissectors/packet-ieee80211-prism.c b/epan/dissectors/packet-ieee80211-prism.c
index 1122081b04..d40a14f19e 100644
--- a/epan/dissectors/packet-ieee80211-prism.c
+++ b/epan/dissectors/packet-ieee80211-prism.c
@@ -65,6 +65,8 @@ static int hf_ieee80211_prism_did_unknown = -1;
static gint ett_prism = -1;
static gint ett_prism_did = -1;
+static dissector_handle_t prism_handle;
+
/*
* Prism II-based wlan devices have a monitoring mode that sticks
* a proprietary header on each packet with lots of good
@@ -554,13 +556,12 @@ 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));
+
+ prism_handle = register_dissector("prism", dissect_prism, proto_prism);
}
void proto_reg_handoff_ieee80211_prism(void)
{
- dissector_handle_t prism_handle;
-
- prism_handle = create_dissector_handle(dissect_prism, proto_prism);
dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_PRISM, prism_handle);
ieee80211_handle = find_dissector("wlan");
ieee80211_radio_handle = find_dissector("wlan_radio");
diff --git a/epan/dissectors/packet-tzsp.c b/epan/dissectors/packet-tzsp.c
index abbe275a29..e3f10c743d 100644
--- a/epan/dissectors/packet-tzsp.c
+++ b/epan/dissectors/packet-tzsp.c
@@ -67,11 +67,49 @@ static const value_string tzsp_type[] = {
{0, NULL}
};
+/* ************************************************************************* */
+/* Encapsulation type values */
+/* Note that these are not all the same as DLT_ values */
+/* ************************************************************************* */
+
+#define TZSP_ENCAP_ETHERNET 1
+#define TZSP_ENCAP_TOKEN_RING 2
+#define TZSP_ENCAP_SLIP 3
+#define TZSP_ENCAP_PPP 4
+#define TZSP_ENCAP_FDDI 5
+#define TZSP_ENCAP_RAW 7 /* "Raw UO", presumably meaning "Raw IP" */
+#define TZSP_ENCAP_IEEE_802_11 18
+#define TZSP_ENCAP_IEEE_802_11_PRISM 119
+#define TZSP_ENCAP_IEEE_802_11_AVS 127
+
+/*
+ * Packet encapsulations.
+ */
+static const value_string tzsp_encapsulation[] = {
+ {TZSP_ENCAP_ETHERNET, "Ethernet"},
+ {TZSP_ENCAP_TOKEN_RING, "Token Ring"},
+ {TZSP_ENCAP_SLIP, "SLIP"},
+ {TZSP_ENCAP_PPP, "PPP"},
+ {TZSP_ENCAP_FDDI, "FDDI"},
+ {TZSP_ENCAP_RAW, "Raw IP"},
+ {TZSP_ENCAP_IEEE_802_11, "IEEE 802.11"},
+ {TZSP_ENCAP_IEEE_802_11_PRISM, "IEEE 802.11 with Prism headers"},
+ {TZSP_ENCAP_IEEE_802_11_AVS, "IEEE 802.11 with AVS headers"},
+ {0, NULL}
+};
+
static gint ett_tzsp = -1;
static gint ett_tag = -1;
+static dissector_handle_t eth_handle;
+static dissector_handle_t tr_handle;
+static dissector_handle_t ppp_handle;
+static dissector_handle_t fddi_handle;
+static dissector_handle_t raw_ip_handle;
+static dissector_handle_t ieee_802_11_handle;
+static dissector_handle_t ieee_802_11_prism_handle;
+static dissector_handle_t ieee_802_11_avs_handle;
static dissector_handle_t data_handle;
-static dissector_table_t encap_dissector_table;
/* ************************************************************************* */
/* WLAN radio header fields */
@@ -96,21 +134,6 @@ static int hf_original_length = -1;
static int hf_sensormac = -1;
/* ************************************************************************* */
-/* Encapsulation type values */
-/* Note that these are not all the same as DLT_ values */
-/* ************************************************************************* */
-
-#define TZSP_ENCAP_ETHERNET 1
-#define TZSP_ENCAP_TOKEN_RING 2
-#define TZSP_ENCAP_SLIP 3
-#define TZSP_ENCAP_PPP 4
-#define TZSP_ENCAP_FDDI 5
-#define TZSP_ENCAP_RAW 7 /* "Raw UO", presumably meaning "Raw IP" */
-#define TZSP_ENCAP_IEEE_802_11 18
-#define TZSP_ENCAP_IEEE_802_11_PRISM 119
-#define TZSP_ENCAP_IEEE_802_11_AVS 127
-
-/* ************************************************************************* */
/* Generic header options */
/* ************************************************************************* */
@@ -253,34 +276,6 @@ add_option_info(tvbuff_t *tvb, int pos, proto_tree *tree, proto_item *ti)
}
/* ************************************************************************* */
-/* Map TZSP encapsulation types to Wiretap encapsulation types */
-/* ************************************************************************* */
-struct encap_map {
- guint16 tzsp_encap;
- int wtap_encap;
-};
-
-static const struct encap_map map_table[] = {
- { TZSP_ENCAP_ETHERNET, WTAP_ENCAP_ETHERNET },
- { TZSP_ENCAP_IEEE_802_11_PRISM, WTAP_ENCAP_IEEE_802_11_PRISM },
- { TZSP_ENCAP_IEEE_802_11_AVS, WTAP_ENCAP_IEEE_802_11_AVS },
- { TZSP_ENCAP_IEEE_802_11, WTAP_ENCAP_IEEE_802_11 },
- { 0, -1 }
-};
-
-static int
-tzsp_encap_to_wtap_encap(guint16 encap)
-{
- int i;
-
- for (i = 0; map_table[i].wtap_encap != -1; i++) {
- if (map_table[i].tzsp_encap == encap)
- return map_table[i].wtap_encap;
- }
- return -1;
-}
-
-/* ************************************************************************* */
/* Dissect a TZSP packet */
/* ************************************************************************* */
@@ -292,51 +287,33 @@ dissect_tzsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
int pos = 0;
tvbuff_t *next_tvb;
guint16 encapsulation = 0;
- int wtap_encap;
- dissector_handle_t encap_dissector;
- const char *encap_name;
const char *info;
guint8 type;
+ struct eth_phdr eth;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "TZSP");
col_clear(pinfo->cinfo, COL_INFO);
type = tvb_get_guint8(tvb, 1);
- /* Find the dissector. */
+ /* Find the encapsulation. */
encapsulation = tvb_get_ntohs(tvb, 2);
- if (encapsulation != 0) {
- wtap_encap = tzsp_encap_to_wtap_encap(encapsulation);
- if ((wtap_encap != -1) &&
- (encap_dissector = dissector_get_uint_handle(encap_dissector_table, wtap_encap))) {
- encap_name = dissector_handle_get_short_name(encap_dissector);
- }
- else {
- encap_name = "Unknown";
- }
- info = encap_name;
- }
- else {
- wtap_encap = -1;
- encap_name = "Nothing";
- info = val_to_str(type, tzsp_type, "Unknown (%u)");
- }
+ info = val_to_str(encapsulation, tzsp_encapsulation, "Unknown (%u)");
col_add_str(pinfo->cinfo, COL_INFO, info);
if (tree) {
/* Adding TZSP item and subtree */
ti = proto_tree_add_protocol_format(tree, proto_tzsp, tvb, 0,
- -1, "TZSP: %s: ", info);
+ -1, "TZSP: %s ", info);
tzsp_tree = proto_item_add_subtree(ti, ett_tzsp);
proto_tree_add_item (tzsp_tree, hf_tzsp_version, tvb, 0, 1,
ENC_BIG_ENDIAN);
proto_tree_add_uint (tzsp_tree, hf_tzsp_type, tvb, 1, 1,
type);
- proto_tree_add_uint_format (tzsp_tree, hf_tzsp_encap, tvb, 2, 2,
- encapsulation, "Encapsulates: %s (%d)",
- encap_name, encapsulation);
+ proto_tree_add_uint (tzsp_tree, hf_tzsp_encap, tvb, 2, 2,
+ encapsulation);
}
/*
@@ -360,11 +337,47 @@ dissect_tzsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
if (tree)
proto_item_set_end(ti, tvb, pos);
next_tvb = tvb_new_subset_remaining(tvb, pos);
- if ((encapsulation != 0)
- && ((wtap_encap == -1)
- || !dissector_try_uint(encap_dissector_table, wtap_encap,
- next_tvb, pinfo, tree))) {
+ switch (encapsulation) {
+
+ case TZSP_ENCAP_ETHERNET:
+ eth.fcs_len = -1; /* not known */
+ call_dissector_with_data(eth_handle, next_tvb, pinfo, tree, &eth);
+ break;
+ case TZSP_ENCAP_TOKEN_RING:
+ call_dissector(tr_handle, next_tvb, pinfo, tree);
+ break;
+
+ case TZSP_ENCAP_PPP:
+ call_dissector(ppp_handle, next_tvb, pinfo, tree);
+ break;
+
+ case TZSP_ENCAP_FDDI:
+ call_dissector(fddi_handle, next_tvb, pinfo, tree);
+ break;
+
+ case TZSP_ENCAP_RAW:
+ call_dissector(raw_ip_handle, next_tvb, pinfo, tree);
+ break;
+
+ case TZSP_ENCAP_IEEE_802_11:
+ /*
+ * XXX - get some of the information from the TLVs
+ * and turn it into a radio metadata header to
+ * hand to the radio dissector, and call it?
+ */
+ call_dissector(ieee_802_11_handle, next_tvb, pinfo, tree);
+ break;
+
+ case TZSP_ENCAP_IEEE_802_11_PRISM:
+ call_dissector(ieee_802_11_prism_handle, next_tvb, pinfo, tree);
+ break;
+
+ case TZSP_ENCAP_IEEE_802_11_AVS:
+ call_dissector(ieee_802_11_avs_handle, next_tvb, pinfo, tree);
+ break;
+
+ default:
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
col_add_fstr(pinfo->cinfo, COL_INFO, "TZSP_ENCAP = %u",
encapsulation);
@@ -468,7 +481,7 @@ proto_register_tzsp(void)
VALS(tzsp_type), 0, NULL, HFILL }},
{ &hf_tzsp_encap, {
"Encapsulation", "tzsp.encap", FT_UINT16, BASE_DEC,
- NULL, 0, NULL, HFILL }},
+ VALS(tzsp_encapsulation), 0, NULL, HFILL }},
{ &hf_option_tag, {
"Option Tag", "tzsp.option_tag", FT_UINT8, BASE_DEC,
@@ -542,13 +555,19 @@ proto_reg_handoff_tzsp(void)
{
dissector_add_uint("udp.port", UDP_PORT_TZSP, tzsp_handle);
- /* Get the data dissector for handling unknown encapsulation types. */
+ /* Get the data dissector for handling various encapsulation types. */
+ eth_handle = find_dissector("eth");
+ tr_handle = find_dissector("tr");
+ ppp_handle = find_dissector("ppp_hdlc");
+ fddi_handle = find_dissector("fddi");
+ raw_ip_handle = find_dissector("raw_ip");
+ ieee_802_11_handle = find_dissector("wlan");
+ ieee_802_11_prism_handle = find_dissector("prism");
+ ieee_802_11_avs_handle = find_dissector("wlancap");
data_handle = find_dissector("data");
/* Register this protocol as an encapsulation type. */
dissector_add_uint("wtap_encap", WTAP_ENCAP_TZSP, tzsp_handle);
-
- encap_dissector_table = find_dissector_table("wtap_encap");
}
/*