2 * Routines for EAP Extensible Authentication Protocol header disassembly
4 * $Id: packet-eap.c,v 1.1 2001/11/06 20:30:39 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
33 #ifdef HAVE_NETINET_IN_H
34 # include <netinet/in.h>
39 #include "packet-ieee8023.h"
40 #include "packet-ipx.h"
41 #include "packet-llc.h"
45 static int proto_eap = -1;
46 static int hf_eap_code = -1;
47 static int hf_eap_identifier = -1;
48 static int hf_eap_len = -1;
49 static int hf_eap_type = -1;
51 static gint ett_eap = -1;
53 typedef struct _e_eap {
59 static const char *eap_code_name[] = {
66 #define EAP_CODE_COUNT (sizeof(eap_code_name)/sizeof(eap_code_name[0]))
68 static const char *eap_type_name[] = {
71 "Nak (Response only)",
76 #define EAP_TYPE_COUNT (sizeof(eap_type_name)/sizeof(eap_type_name[0]))
80 dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
85 proto_tree *volatile eap_tree;
87 if (check_col(pinfo->fd, COL_PROTOCOL))
88 col_set_str(pinfo->fd, COL_PROTOCOL, "EAP");
89 if (check_col(pinfo->fd, COL_INFO))
90 col_clear(pinfo->fd, COL_INFO);
92 tvb_memcpy(tvb, (guint8 *)&eaph, 0, sizeof(eaph));
93 eaph.eap_len = ntohs(eaph.eap_len);
97 set_actual_length(tvb, pinfo, len);
102 ti = proto_tree_add_item(tree, proto_eap, tvb, 0, len, FALSE);
103 eap_tree = proto_item_add_subtree(ti, ett_eap);
105 proto_tree_add_text(eap_tree, tvb, 0, 0, "Code: %s (%u) ",
106 eaph.eap_code > EAP_CODE_COUNT?
107 "Unknown": eap_code_name[eaph.eap_code],
110 proto_tree_add_uint(eap_tree, hf_eap_identifier, tvb, 1, 1, eaph.eap_id);
111 proto_tree_add_uint(eap_tree, hf_eap_len, tvb, 2, 2, eaph.eap_len);
114 guint8 eap_type = tvb_get_guint8(tvb, 4);
115 proto_tree_add_text(eap_tree, tvb, 4, 1, "Type: %s (%u)",
116 eap_type > EAP_TYPE_COUNT?
117 "Unknown" : eap_type_name[eap_type],
121 dissect_data(tvb, 5, pinfo, tree);
126 proto_register_eap(void)
128 static hf_register_info hf[] = {
130 "Code", "eap.code", FT_UINT8, BASE_DEC,
131 NULL, 0x0, "", HFILL }},
132 { &hf_eap_identifier, {
133 "Id", "eap.id", FT_UINT8, BASE_DEC,
134 NULL, 0x0, "", HFILL }},
136 "Length", "eap.len", FT_UINT16, BASE_DEC,
137 NULL, 0x0, "", HFILL }},
139 "Type", "eap.type", FT_UINT8, BASE_DEC,
140 NULL, 0x0, "", HFILL }},
142 static gint *ett[] = {
146 proto_eap = proto_register_protocol("Extensible Authentication Protocol",
148 proto_register_field_array(proto_eap, hf, array_length(hf));
149 proto_register_subtree_array(ett, array_length(ett));
153 proto_reg_handoff_eap(void)
155 dissector_add("ppp.protocol", PPP_EAP, dissect_eap, proto_eap);