2 * Routines for EAP Extensible Authentication Protocol header disassembly
4 * $Id: packet-eap.c,v 1.2 2001/11/26 04:52:49 hagbard 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 static dissector_handle_t data_handle;
55 typedef struct _e_eap {
61 static const char *eap_code_name[] = {
68 #define EAP_CODE_COUNT (sizeof(eap_code_name)/sizeof(eap_code_name[0]))
70 static const char *eap_type_name[] = {
73 "Nak (Response only)",
78 #define EAP_TYPE_COUNT (sizeof(eap_type_name)/sizeof(eap_type_name[0]))
82 dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
87 proto_tree *volatile eap_tree;
89 if (check_col(pinfo->fd, COL_PROTOCOL))
90 col_set_str(pinfo->fd, COL_PROTOCOL, "EAP");
91 if (check_col(pinfo->fd, COL_INFO))
92 col_clear(pinfo->fd, COL_INFO);
94 tvb_memcpy(tvb, (guint8 *)&eaph, 0, sizeof(eaph));
95 eaph.eap_len = ntohs(eaph.eap_len);
99 set_actual_length(tvb, pinfo, len);
104 ti = proto_tree_add_item(tree, proto_eap, tvb, 0, len, FALSE);
105 eap_tree = proto_item_add_subtree(ti, ett_eap);
107 proto_tree_add_text(eap_tree, tvb, 0, 0, "Code: %s (%u) ",
108 eaph.eap_code > EAP_CODE_COUNT?
109 "Unknown": eap_code_name[eaph.eap_code],
112 proto_tree_add_uint(eap_tree, hf_eap_identifier, tvb, 1, 1, eaph.eap_id);
113 proto_tree_add_uint(eap_tree, hf_eap_len, tvb, 2, 2, eaph.eap_len);
116 guint8 eap_type = tvb_get_guint8(tvb, 4);
117 proto_tree_add_text(eap_tree, tvb, 4, 1, "Type: %s (%u)",
118 eap_type > EAP_TYPE_COUNT?
119 "Unknown" : eap_type_name[eap_type],
123 call_dissector(data_handle,tvb_new_subset(tvb, 5,-1,tvb_reported_length_remaining(tvb,5)), pinfo, tree);
128 proto_register_eap(void)
130 static hf_register_info hf[] = {
132 "Code", "eap.code", FT_UINT8, BASE_DEC,
133 NULL, 0x0, "", HFILL }},
134 { &hf_eap_identifier, {
135 "Id", "eap.id", FT_UINT8, BASE_DEC,
136 NULL, 0x0, "", HFILL }},
138 "Length", "eap.len", FT_UINT16, BASE_DEC,
139 NULL, 0x0, "", HFILL }},
141 "Type", "eap.type", FT_UINT8, BASE_DEC,
142 NULL, 0x0, "", HFILL }},
144 static gint *ett[] = {
148 proto_eap = proto_register_protocol("Extensible Authentication Protocol",
150 proto_register_field_array(proto_eap, hf, array_length(hf));
151 proto_register_subtree_array(ett, array_length(ett));
155 proto_reg_handoff_eap(void)
157 data_handle = find_dissector("data");
158 dissector_add("ppp.protocol", PPP_EAP, dissect_eap, proto_eap);