aboutsummaryrefslogtreecommitdiffstats
path: root/packet-eapol.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-02-22 21:51:18 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-02-22 21:51:18 +0000
commit8f89638f1b9c17f10a1347d751747830cc8c640c (patch)
tree532aa1157ad315f84d07fb6c21e3360d0440babd /packet-eapol.c
parent11e927db6274a5c57786233afe8309d438c4ec62 (diff)
Get rid of an unnecessary "volatile".
Give the type field a value_string array, and use that field when putting the type into the protocol tree. Display the data under the EAPOL tree, as it's part of the EAPOL PDU. Just use "next_tvb" as the tvbuff for the data; don't create a new one that, the different fourth argument to "tvb_new_subset()" nonwithstanding, refers to the same data as "next_tvb". Call the EAP dissector through a handle. Nobody directly calls the EAP dissector any more, they all call it through handles; make it static. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4787 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-eapol.c')
-rw-r--r--packet-eapol.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/packet-eapol.c b/packet-eapol.c
index 76b5cf5a5c..1877377c4b 100644
--- a/packet-eapol.c
+++ b/packet-eapol.c
@@ -1,7 +1,7 @@
/* packet-eapol.c
* Routines for EAPOL 802.1X authentication header disassembly
*
- * $Id: packet-eapol.c,v 1.6 2002/02/17 00:51:19 guy Exp $
+ * $Id: packet-eapol.c,v 1.7 2002/02/22 21:51:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -48,6 +48,7 @@ static int hf_eapol_len = -1;
static gint ett_eapol = -1;
+static dissector_handle_t eap_handle;
static dissector_handle_t data_handle;
typedef struct _e_eapol
@@ -57,16 +58,14 @@ typedef struct _e_eapol
guint16 eapol_len;
} e_eapol;
-static const char *eapol_type_name[] = {
- "EAP",
- "Start",
- "Logoff",
- "Key",
- "Encapsulated ASF Alert"
+static const value_string eapol_type_vals[] = {
+ { 0, "EAP" },
+ { 1, "Start" },
+ { 2, "Logoff" },
+ { 3, "Key" },
+ { 4, "Encapsulated ASF Alert" },
+ { 0, NULL }
};
-#define EAPOL_TYPE_COUNT (sizeof(eapol_type_name)/sizeof(eapol_type_name[0]))
-
-extern void dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static void
dissect_eapol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -74,7 +73,7 @@ dissect_eapol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
e_eapol eapolh;
guint len;
proto_tree *ti;
- proto_tree *volatile eapol_tree;
+ proto_tree *eapol_tree;
tvbuff_t *next_tvb;
if (check_col(pinfo->cinfo, COL_PROTOCOL))
@@ -96,19 +95,16 @@ dissect_eapol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
eapol_tree = proto_item_add_subtree(ti, ett_eapol);
proto_tree_add_uint(eapol_tree, hf_eapol_version, tvb, 0, 1, eapolh.eapol_ver);
- proto_tree_add_text(eapol_tree, tvb, 1, 1, "Type: %s (%u)",
- eapolh.eapol_type > EAPOL_TYPE_COUNT?
- "Unknown" : eapol_type_name[eapolh.eapol_type],
- eapolh.eapol_type);
+ proto_tree_add_uint(eapol_tree, hf_eapol_type, tvb, 1, 1, eapolh.eapol_type);
proto_tree_add_uint(eapol_tree, hf_eapol_len, tvb, 2, 2, eapolh.eapol_len);
}
next_tvb = tvb_new_subset(tvb, 4, -1, -1);
- if (eapolh.eapol_type == 0 && next_tvb != NULL)
- dissect_eap(next_tvb, pinfo, eapol_tree);
+ if (eapolh.eapol_type == 0)
+ call_dissector(eap_handle, next_tvb, pinfo, eapol_tree);
else
- call_dissector(data_handle,tvb_new_subset(tvb, 4,-1,tvb_reported_length_remaining(tvb,4)), pinfo, tree);
+ call_dissector(data_handle, next_tvb, pinfo, eapol_tree);
}
void
@@ -120,7 +116,7 @@ proto_register_eapol(void)
NULL, 0x0, "", HFILL }},
{ &hf_eapol_type, {
"Type", "eapol.type", FT_UINT8, BASE_DEC,
- 0, 0x0, "", HFILL }},
+ VALS(eapol_type_vals), 0x0, "", HFILL }},
{ &hf_eapol_len, {
"Length", "eapol.len", FT_UINT16, BASE_DEC,
NULL, 0x0, "Length", HFILL }},
@@ -139,7 +135,12 @@ proto_reg_handoff_eapol(void)
{
dissector_handle_t eapol_handle;
+ /*
+ * Get handles for the EAP and raw data dissectors.
+ */
+ eap_handle = find_dissector("eap");
data_handle = find_dissector("data");
+
eapol_handle = create_dissector_handle(dissect_eapol, proto_eapol);
dissector_add("ethertype", ETHERTYPE_EAPOL, eapol_handle);
}