aboutsummaryrefslogtreecommitdiffstats
path: root/packet-eap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-02-06 22:45:43 +0000
committerGuy Harris <guy@alum.mit.edu>2002-02-06 22:45:43 +0000
commit672006c8f5f486a17d17e70219a0cca85c42550a (patch)
treee5c851f26308b082812ca08780cb2b5a861c6702 /packet-eap.c
parentdbf2eebd5c96e7052ea272752e94a0907b4c79c5 (diff)
Use "value_string" tables to map EAP code and type values to strings -
and fix up the table for EAP types. svn path=/trunk/; revision=4704
Diffstat (limited to 'packet-eap.c')
-rw-r--r--packet-eap.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/packet-eap.c b/packet-eap.c
index 0d9c9db0ff..58edd98c6c 100644
--- a/packet-eap.c
+++ b/packet-eap.c
@@ -1,7 +1,7 @@
/* packet-eap.c
* Routines for EAP Extensible Authentication Protocol header disassembly
*
- * $Id: packet-eap.c,v 1.5 2002/01/21 07:36:34 guy Exp $
+ * $Id: packet-eap.c,v 1.6 2002/02/06 22:45:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -58,25 +58,23 @@ typedef struct _e_eap {
guint16 eap_len;
} e_eap;
-static const char *eap_code_name[] = {
- "Undefined",
- "Request",
- "Response",
- "Success",
- "Failure",
+static const value_string eap_code_vals[] = {
+ { 1, "Request" },
+ { 2, "Response" },
+ { 3, "Success" },
+ { 4, "Failure" },
+ { 0, NULL }
};
-#define EAP_CODE_COUNT (sizeof(eap_code_name)/sizeof(eap_code_name[0]))
-
-static const char *eap_type_name[] = {
- "Undefined",
- "Identity",
- "Nak (Response only)",
- "MD5-Challenge",
- "One-Time Password",
- "Generic Token Card",
-};
-#define EAP_TYPE_COUNT (sizeof(eap_type_name)/sizeof(eap_type_name[0]))
+static const value_string eap_type_vals[] = {
+ { 1, "Identity" },
+ { 2, "Notification" },
+ { 3, "Nak (Response only)" },
+ { 4, "MD5-Challenge" },
+ { 5, "One-Time Password" },
+ { 6, "Generic Token Card" },
+ { 0, NULL }
+};
void
dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -104,9 +102,8 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
ti = proto_tree_add_item(tree, proto_eap, tvb, 0, len, FALSE);
eap_tree = proto_item_add_subtree(ti, ett_eap);
- proto_tree_add_text(eap_tree, tvb, 0, 0, "Code: %s (%u) ",
- eaph.eap_code > EAP_CODE_COUNT?
- "Unknown": eap_code_name[eaph.eap_code],
+ proto_tree_add_text(eap_tree, tvb, 0, 0, "Code: %s (%u) ",
+ val_to_str(eaph.eap_code, eap_code_vals, "Unknown"),
eaph.eap_code);
proto_tree_add_uint(eap_tree, hf_eap_identifier, tvb, 1, 1, eaph.eap_id);
@@ -115,8 +112,7 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (len > 4) {
guint8 eap_type = tvb_get_guint8(tvb, 4);
proto_tree_add_text(eap_tree, tvb, 4, 1, "Type: %s (%u)",
- eap_type > EAP_TYPE_COUNT?
- "Unknown" : eap_type_name[eap_type],
+ val_to_str(eap_type, eap_type_vals, "Unknown"),
eap_type);
}
if (len > 5)