From 6a3b24be292f4dc9dcf8dc3adacb1196ec67eea3 Mon Sep 17 00:00:00 2001 From: "Dr. Lars Voelker" Date: Thu, 25 Apr 2019 20:59:59 +0200 Subject: [PATCH] EAP: Passing additional context to allow for reassembly in vendor parser Currently an extended vendor parser only gets the vendor_type directly and the vendor_id indirectly. For some cases (eap fragmentation et al.) it is important to have access to the eap_code and the eap_identifier as well. This patch is adding this. Change-Id: I848cbe58dc4f8e4034382a9c9ca43d350a61bb18 Signed-off-by: Dr. Lars Voelker Reviewed-on: https://code.wireshark.org/review/32944 Reviewed-by: Jaap Keuter Petri-Dish: Jaap Keuter Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu --- epan/dissectors/packet-eap.c | 22 ++++++++++++++-------- epan/eap.h | 7 +++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/epan/dissectors/packet-eap.c b/epan/dissectors/packet-eap.c index b00d0add41..ea79dd11e3 100644 --- a/epan/dissectors/packet-eap.c +++ b/epan/dissectors/packet-eap.c @@ -409,30 +409,34 @@ static const value_string eap_ext_vendor_type_vals[] = { static void dissect_exteap(proto_tree *eap_tree, tvbuff_t *tvb, int offset, - gint size, packet_info* pinfo) + gint size, packet_info* pinfo, guint8 eap_code, guint8 eap_identifier) { tvbuff_t *next_tvb; guint32 vendor_id; - guint32 *vendor_type; + guint32 vendor_type; + eap_vendor_context *vendor_context; - vendor_type = (guint32 *)g_malloc(sizeof(guint32)); + vendor_context = wmem_new(wmem_packet_scope(), eap_vendor_context); proto_tree_add_item_ret_uint(eap_tree, hf_eap_ext_vendor_id, tvb, offset, 3, ENC_BIG_ENDIAN, &vendor_id); offset += 3; size -= 3; - proto_tree_add_item_ret_uint(eap_tree, hf_eap_ext_vendor_type, tvb, offset, 4, ENC_BIG_ENDIAN, vendor_type); + proto_tree_add_item_ret_uint(eap_tree, hf_eap_ext_vendor_type, tvb, offset, 4, ENC_BIG_ENDIAN, &vendor_type); offset += 4; size -= 4; + vendor_context->eap_code = eap_code; + vendor_context->eap_identifier = eap_identifier; + vendor_context->vendor_id = vendor_id; + vendor_context->vendor_type = vendor_type; + next_tvb = tvb_new_subset_remaining(tvb, offset); if (!dissector_try_uint_new(eap_expanded_type_dissector_table, vendor_id, next_tvb, pinfo, eap_tree, - FALSE, vendor_type)) { + FALSE, vendor_context)) { call_data_dissector(next_tvb, pinfo, eap_tree); } - - g_free(vendor_type); } /* ********************************************************************* ********************************************************************* */ @@ -786,6 +790,7 @@ static int dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { guint8 eap_code; + guint8 eap_identifier; guint16 eap_len; guint8 eap_type; gint len; @@ -803,6 +808,7 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) col_clear(pinfo->cinfo, COL_INFO); eap_code = tvb_get_guint8(tvb, 0); + eap_identifier = tvb_get_guint8(tvb, 1); col_add_str(pinfo->cinfo, COL_INFO, val_to_str(eap_code, eap_code_vals, "Unknown code (0x%02X)")); @@ -1316,7 +1322,7 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) proto_tree *exptree; exptree = proto_tree_add_subtree(eap_tree, tvb, offset, size, ett_eap_exp_attr, NULL, "Expanded Type"); - dissect_exteap(exptree, tvb, offset, size, pinfo); + dissect_exteap(exptree, tvb, offset, size, pinfo, eap_code, eap_identifier); } break; diff --git a/epan/eap.h b/epan/eap.h index ca64c0d7ac..505e0d06dc 100644 --- a/epan/eap.h +++ b/epan/eap.h @@ -68,4 +68,11 @@ WS_DLL_PUBLIC const value_string eap_aka_subtype_vals[]; WS_DLL_PUBLIC const value_string eap_ms_chap_v2_opcode_vals[]; +typedef struct _eap_vendor_context { + guint32 vendor_type; + guint32 vendor_id; + guint8 eap_code; + guint8 eap_identifier; +} eap_vendor_context; + #endif