From 24d6a39eb09534179a523613b0b431578608af75 Mon Sep 17 00:00:00 2001 From: Martin Mathieson Date: Fri, 16 Nov 2007 23:03:09 +0000 Subject: Embedding EAP inside wimaxasncp. svn path=/trunk/; revision=23474 --- epan/dissectors/packet-eap.c | 25 ++---- epan/eap.h | 52 +++++++++++ epan/libwireshark.def | 2 + plugins/wimaxasncp/AUTHORS | 5 +- plugins/wimaxasncp/ChangeLog | 4 + plugins/wimaxasncp/packet-wimaxasncp.c | 157 ++++++++++++++++++++++++++++----- plugins/wimaxasncp/wimaxasncp_dict.h | 1 + plugins/wimaxasncp/wimaxasncp_dict.l | 1 + wimaxasncp/dictionary.xml | 2 +- 9 files changed, 204 insertions(+), 45 deletions(-) create mode 100644 epan/eap.h diff --git a/epan/dissectors/packet-eap.c b/epan/dissectors/packet-eap.c index 4332234bf4..c5a8f67cae 100644 --- a/epan/dissectors/packet-eap.c +++ b/epan/dissectors/packet-eap.c @@ -34,6 +34,8 @@ #include #include +#include + 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]" }, diff --git a/epan/eap.h b/epan/eap.h new file mode 100644 index 0000000000..333e9ebb59 --- /dev/null +++ b/epan/eap.h @@ -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 + * 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 diff --git a/epan/libwireshark.def b/epan/libwireshark.def index f29c4d2cf0..74bb1b4ab9 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -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 diff --git a/plugins/wimaxasncp/AUTHORS b/plugins/wimaxasncp/AUTHORS index ff18ca32fb..4a80a5841b 100644 --- a/plugins/wimaxasncp/AUTHORS +++ b/plugins/wimaxasncp/AUTHORS @@ -1,2 +1,5 @@ -Author : +Authors : Stephen Croll +Zhang Li +Wu Yanping +Terry Le diff --git a/plugins/wimaxasncp/ChangeLog b/plugins/wimaxasncp/ChangeLog index 264fad1fe8..7b0cc4e3ed 100644 --- a/plugins/wimaxasncp/ChangeLog +++ b/plugins/wimaxasncp/ChangeLog @@ -8,4 +8,8 @@ * packet-wimaxasncp.c: fixed memory leak in function wimaxasncp_dissect_tlv_value() +2007-11-04 Zhang Li + + * Add EAP support. EAP payload is dessected by calling EAP dissector + * Add port preference. diff --git a/plugins/wimaxasncp/packet-wimaxasncp.c b/plugins/wimaxasncp/packet-wimaxasncp.c index 40b55c64b4..451f171c64 100644 --- a/plugins/wimaxasncp/packet-wimaxasncp.c +++ b/plugins/wimaxasncp/packet-wimaxasncp.c @@ -46,6 +46,7 @@ #include #include #include +#include /* 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"); } diff --git a/plugins/wimaxasncp/wimaxasncp_dict.h b/plugins/wimaxasncp/wimaxasncp_dict.h index bb7edcee12..a4747362c6 100644 --- a/plugins/wimaxasncp/wimaxasncp_dict.h +++ b/plugins/wimaxasncp/wimaxasncp_dict.h @@ -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 }; diff --git a/plugins/wimaxasncp/wimaxasncp_dict.l b/plugins/wimaxasncp/wimaxasncp_dict.l index 1bec0f685d..9571a15f6f 100644 --- a/plugins/wimaxasncp/wimaxasncp_dict.l +++ b/plugins/wimaxasncp/wimaxasncp_dict.l @@ -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} }; diff --git a/wimaxasncp/dictionary.xml b/wimaxasncp/dictionary.xml index 470eb78d20..14a360937f 100644 --- a/wimaxasncp/dictionary.xml +++ b/wimaxasncp/dictionary.xml @@ -677,7 +677,7 @@ + decoder="WIMAXASNCP_TLV_EAP"> -- cgit v1.2.3