Embedding EAP inside wimaxasncp.

svn path=/trunk/; revision=23474
This commit is contained in:
Martin Mathieson 2007-11-16 23:03:09 +00:00
parent 6823dd10fa
commit 24d6a39eb0
9 changed files with 203 additions and 44 deletions

View File

@ -34,6 +34,8 @@
#include <epan/reassemble.h>
#include <epan/emem.h>
#include <epan/eap.h>
static int proto_eap = -1;
static int hf_eap_code = -1;
static int hf_eap_identifier = -1;
@ -45,12 +47,9 @@ static gint ett_eap = -1;
static dissector_handle_t ssl_handle;
#define EAP_REQUEST 1
#define EAP_RESPONSE 2
#define EAP_SUCCESS 3
#define EAP_FAILURE 4
static const value_string eap_code_vals[] = {
const value_string eap_code_vals[] = {
{ EAP_REQUEST, "Request" },
{ EAP_RESPONSE, "Response" },
{ EAP_SUCCESS, "Success" },
@ -68,20 +67,8 @@ References:
5) http://www.iana.org/assignments/eap-numbers EAP registry( updated 2006-10-23)
*/
#define EAP_TYPE_ID 1
#define EAP_TYPE_NOTIFY 2
#define EAP_TYPE_NAK 3
#define EAP_TYPE_MD5 4
#define EAP_TYPE_TLS 13
#define EAP_TYPE_LEAP 17
#define EAP_TYPE_SIM 18
#define EAP_TYPE_TTLS 21
#define EAP_TYPE_AKA 23
#define EAP_TYPE_PEAP 25
#define EAP_TYPE_MSCHAPV2 26
#define EAP_TYPE_FAST 43
static const value_string eap_type_vals[] = {
const value_string eap_type_vals[] = {
{EAP_TYPE_ID, "Identity [RFC3748]" },
{EAP_TYPE_NOTIFY,"Notification [RFC3748]" },
{EAP_TYPE_NAK, "Legacy Nak (Response only) [RFC3748]" },

52
epan/eap.h Normal file
View File

@ -0,0 +1,52 @@
/* sminmpec.h
* Extenal definitions for EAP Extensible Authentication Protocol dissection
* RFC 2284, RFC 3748
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2004 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __EAP_H__
#define __EAP_H__
#define EAP_REQUEST 1
#define EAP_RESPONSE 2
#define EAP_SUCCESS 3
#define EAP_FAILURE 4
WS_VAR_IMPORT const value_string eap_code_vals[];
#define EAP_TYPE_ID 1
#define EAP_TYPE_NOTIFY 2
#define EAP_TYPE_NAK 3
#define EAP_TYPE_MD5 4
#define EAP_TYPE_TLS 13
#define EAP_TYPE_LEAP 17
#define EAP_TYPE_SIM 18
#define EAP_TYPE_TTLS 21
#define EAP_TYPE_AKA 23
#define EAP_TYPE_PEAP 25
#define EAP_TYPE_MSCHAPV2 26
#define EAP_TYPE_FAST 43
WS_VAR_IMPORT const value_string eap_type_vals[];
#endif

View File

@ -266,6 +266,8 @@ dtbl_entry_get_handle
dtbl_entry_get_initial_handle
EBCDIC_to_ASCII
EBCDIC_to_ASCII1
eap_code_vals DATA
eap_type_vals DATA
emem_tree_insert32
emem_tree_insert32_array
emem_tree_insert_string

View File

@ -1,2 +1,5 @@
Author :
Authors :
Stephen Croll <croll@mobilemetrics.net>
Zhang Li <lzhang00517@cienet.com.cn>
Wu Yanping <wuyanping@cienet.com.cn>
Terry Le <tle01423@cienet.com.cn>

View File

@ -8,4 +8,8 @@
* packet-wimaxasncp.c: fixed memory leak in function
wimaxasncp_dissect_tlv_value()
2007-11-04 Zhang Li <lzhang@cienet.com.cn>
* Add EAP support. EAP payload is dessected by calling EAP dissector
* Add port preference.

View File

@ -46,6 +46,7 @@
#include <epan/expert.h>
#include <epan/filesystem.h>
#include <epan/report_err.h>
#include <epan/eap.h>
/* TODO: delete?. */
#include "packet-wimaxasncp.h"
@ -86,10 +87,15 @@ static int hf_wimaxasncp_tlv_value_bitflags32 = -1;
static int hf_wimaxasncp_tlv_value_protocol = -1;
static int hf_wimaxasncp_tlv_value_vendor_id = -1;
/* preferences */
/* Preferences */
static gboolean show_transaction_id_d_bit = FALSE;
static gboolean debug_enabled = FALSE;
/* Default WiMAX ASN control protocol port */
#define WIMAXASNCP_DEF_UDP_PORT 2231
static guint global_wimaxasncp_udp_port = WIMAXASNCP_DEF_UDP_PORT;
/* Initialize the subtree pointers */
static gint ett_wimaxasncp = -1;
static gint ett_wimaxasncp_flags = -1;
@ -100,6 +106,7 @@ static gint ett_wimaxasncp_tlv_protocol_list = -1;
static gint ett_wimaxasncp_tlv_port_range_list = -1;
static gint ett_wimaxasncp_tlv_ip_address_mask_list = -1;
static gint ett_wimaxasncp_tlv_ip_address_mask = -1;
static gint ett_wimaxasncp_tlv_eap = -1;
static gint ett_wimaxasncp_tlv_vendor_specific_information_field = -1;
/* Header size, up to, but not including, the TLV fields. */
@ -131,6 +138,8 @@ static wimaxasncp_dict_tlv_t wimaxasncp_tlv_not_found =
NULL, NULL, NULL
};
static dissector_handle_t eap_handle;
/* ------------------------------------------------------------------------- */
static const value_string wimaxasncp_flag_vals[] =
@ -1440,6 +1449,71 @@ static void wimaxasncp_dissect_tlv_value(
return;
}
case WIMAXASNCP_TLV_EAP:
{
/*
* EAP payload, call eap dissector to dissect eap payload
*/
guint8 eap_code;
guint8 eap_type = 0;
/* Get code */
eap_code = tvb_get_guint8(tvb, offset);
if (eap_code == EAP_REQUEST || eap_code == EAP_RESPONSE)
{
/* Get type */
eap_type = tvb_get_guint8(tvb, offset + 4);
}
/* Add code and type to info column */
if (check_col(pinfo->cinfo, COL_INFO))
{
col_append_fstr(pinfo->cinfo, COL_INFO, " [");
col_append_fstr(pinfo->cinfo, COL_INFO,
val_to_str(eap_code, eap_code_vals, "Unknown code (0x%02X)"));
if (eap_code == EAP_REQUEST || eap_code == EAP_RESPONSE)
{
col_append_fstr(pinfo->cinfo, COL_INFO, ", ");
col_append_fstr(pinfo->cinfo, COL_INFO,
val_to_str(eap_type, eap_type_vals, "Unknown type (0x%02X)"));
}
col_append_fstr(pinfo->cinfo, COL_INFO, "]");
}
if (tree)
{
proto_tree *eap_tree;
proto_item *item;
gboolean save_writable;
tvbuff_t *eap_tvb;
/* Create EAP subtree */
item = proto_tree_add_item(tree, tlv_info->hf_value, tvb,
offset, length, FALSE);
proto_item_set_text(item, "Value");
eap_tree = proto_item_add_subtree(item, ett_wimaxasncp_tlv_eap);
/* Extract remaining bytes into new tvb */
eap_tvb = tvb_new_subset(tvb, offset, length,
tvb_length_remaining(tvb, offset));
/* Disable writing to info column while calling eap dissector */
save_writable = col_get_writable(pinfo->cinfo);
col_set_writable(pinfo->cinfo, FALSE);
/* Call the EAP dissector. */
call_dissector(eap_handle, eap_tvb, pinfo, eap_tree);
/* Restore previous writable state of info column */
col_set_writable(pinfo->cinfo, save_writable);
}
return;
}
case WIMAXASNCP_TLV_VENDOR_SPECIFIC:
{
/* --------------------------------------------------------------------
@ -1730,6 +1804,10 @@ static guint dissect_wimaxasncp_backend(
guint16 ui16;
guint32 ui32;
const guint8 *p;
guint8 *pmsid = NULL;
guint16 tid = 0;
gboolean dbit_show;
/* ------------------------------------------------------------------------
* MSID
@ -1744,11 +1822,7 @@ static guint dissect_wimaxasncp_backend(
tree, hf_wimaxasncp_msid,
tvb, offset, 6, p);
if (check_col(pinfo->cinfo, COL_INFO))
{
col_append_fstr(
pinfo->cinfo, COL_INFO, " - MSID:%s", ether_to_str(p));
}
pmsid = ether_to_str(p);
}
offset += 6;
@ -1774,6 +1848,7 @@ static guint dissect_wimaxasncp_backend(
* ------------------------------------------------------------------------
*/
dbit_show = FALSE;
ui16 = tvb_get_ntohs(tvb, offset);
if (tree)
@ -1789,11 +1864,8 @@ static guint dissect_wimaxasncp_backend(
tvb, offset, 2, ui16,
"Transaction ID: D + 0x%04x (0x%04x)", mask & ui16, ui16);
if (check_col(pinfo->cinfo, COL_INFO))
{
col_append_fstr(
pinfo->cinfo, COL_INFO, ", TID:D+0x%04x", mask & ui16);
}
tid = ui16 & mask;
dbit_show = TRUE;
}
else
{
@ -1802,11 +1874,7 @@ static guint dissect_wimaxasncp_backend(
tvb, offset, 2, ui16,
"Transaction ID: 0x%04x", ui16);
if (check_col(pinfo->cinfo, COL_INFO))
{
col_append_fstr(
pinfo->cinfo, COL_INFO, ", TID:0x%04x", ui16);
}
tid = ui16;
}
}
else
@ -1815,11 +1883,7 @@ static guint dissect_wimaxasncp_backend(
tree, hf_wimaxasncp_transaction_id,
tvb, offset, 2, ui16);
if (check_col(pinfo->cinfo, COL_INFO))
{
col_append_fstr(
pinfo->cinfo, COL_INFO, ", TID:0x%04x", ui16);
}
tid = ui16;
}
}
@ -1858,6 +1922,19 @@ static guint dissect_wimaxasncp_backend(
offset += dissect_wimaxasncp_tlvs(tlv_tvb, pinfo, tree);
}
if (check_col(pinfo->cinfo, COL_INFO))
{
col_append_fstr(pinfo->cinfo, COL_INFO, " - MSID:%s", pmsid);
if (dbit_show)
{
col_append_fstr(pinfo->cinfo, COL_INFO, ", TID:D+0x%04x", tid);
}
else
{
col_append_fstr(pinfo->cinfo, COL_INFO, ", TID:0x%04x", tid);
}
}
return offset;
}
@ -2542,6 +2619,14 @@ static void add_tlv_reg_info(
break;
case WIMAXASNCP_TLV_EAP:
blurb = g_strdup_printf("EAP payload embedded in %s", name);
add_reg_info(
&tlv->hf_value, name, abbrev, FT_BYTES, BASE_HEX, blurb);
break;
default:
add_reg_info(
&tlv->hf_value, name, abbrev, FT_BYTES, BASE_HEX, blurb);
@ -2972,6 +3057,7 @@ proto_register_wimaxasncp(void)
&ett_wimaxasncp_tlv_port_range_list,
&ett_wimaxasncp_tlv_ip_address_mask_list,
&ett_wimaxasncp_tlv_ip_address_mask,
&ett_wimaxasncp_tlv_eap,
&ett_wimaxasncp_tlv_vendor_specific_information_field
};
@ -3141,6 +3227,14 @@ proto_register_wimaxasncp(void)
"Enable debug output",
"Print debug output to the console.",
&debug_enabled);
prefs_register_uint_preference(
wimaxasncp_module,
"udp.wimax_port",
"UDP Port for WiMAX ASN Control Plane Protocol",
"Set UDP port for WiMAX ASN Control Plane Protocol",
10, &global_wimaxasncp_udp_port);
}
/* ========================================================================= */
@ -3156,10 +3250,13 @@ void
proto_reg_handoff_wimaxasncp(void)
{
static gboolean inited = FALSE;
dissector_handle_t wimaxasncp_handle;
static int currentPort = -1;
if ( ! inited)
memset(&wimaxasncp_handle, 0, sizeof(dissector_handle_t));
if (!inited)
{
dissector_handle_t wimaxasncp_handle;
/* Use new_create_dissector_handle() to indicate that
* dissect_wimaxasncp() returns the number of bytes it dissected (or
@ -3170,8 +3267,20 @@ proto_reg_handoff_wimaxasncp(void)
dissect_wimaxasncp,
proto_wimaxasncp);
dissector_add("udp.port", 2231, wimaxasncp_handle);
inited = TRUE;
}
if (currentPort != -1)
{
/* Remove any previous registered port */
dissector_delete("udp.port", currentPort, wimaxasncp_handle);
}
/* Add the new one from preferences */
currentPort = global_wimaxasncp_udp_port;
dissector_add("udp.port", currentPort, wimaxasncp_handle);
/* Find the EAP dissector */
eap_handle = find_dissector("eap");
}

View File

@ -55,6 +55,7 @@ enum
WIMAXASNCP_TLV_PROTOCOL_LIST,
WIMAXASNCP_TLV_PORT_RANGE_LIST,
WIMAXASNCP_TLV_IP_ADDRESS_MASK_LIST,
WIMAXASNCP_TLV_EAP,
WIMAXASNCP_TLV_VENDOR_SPECIFIC
};

View File

@ -501,6 +501,7 @@ static const value_string wimaxasncp_decode_type_vals[] =
{ WIMAXASNCP_TLV_PROTOCOL_LIST, "WIMAXASNCP_TLV_PROTOCOL_LIST"},
{ WIMAXASNCP_TLV_PORT_RANGE_LIST, "WIMAXASNCP_TLV_PORT_RANGE_LIST"},
{ WIMAXASNCP_TLV_IP_ADDRESS_MASK_LIST,"WIMAXASNCP_TLV_IP_ADDRESS_MASK_LIST"},
{ WIMAXASNCP_TLV_EAP, "WIMAXASNCP_TLV_EAP"},
{ WIMAXASNCP_TLV_VENDOR_SPECIFIC, "WIMAXASNCP_TLV_VENDOR_SPECIFIC"},
{ 0, NULL}
};

View File

@ -677,7 +677,7 @@
<tlv name="EAP Payload"
type="62"
decoder="WIMAXASNCP_TLV_TBD">
decoder="WIMAXASNCP_TLV_EAP">
</tlv>
<!-- ****************************************************************** -->