diff options
author | Dr. Lars Voelker <lars-github@larsvoelker.de> | 2019-04-19 15:50:49 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-04-20 06:09:53 +0000 |
commit | cf5b86721ae904601d1a501b126ab5f782f6d167 (patch) | |
tree | 324f70b6b993a5bb01c326eddf7818ff53cf16ca | |
parent | 79508114381eb2cf83cdd91aef6f4ca37eb94120 (diff) |
Adding the missing generic method to support multiple vendor-defined ext types
The current EAP dissector assumes that all vendor-defined extended types are
WPS. This does not allow for adding new vendor-defined payloads. This codes
cleans up the limitation. The Vendor-ID can be registered using a dissector
table, while the Vendor-Type is passed as data.
Change-Id: Idc75108fd42b9b2153089db503b137c6eeefe274
Signed-off-by: Dr. Lars Voelker <lars-github@larsvoelker.de>
Reviewed-on: https://code.wireshark.org/review/32888
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/dissectors/packet-eap.c | 31 | ||||
-rw-r--r-- | epan/dissectors/packet-wps.c | 27 | ||||
-rw-r--r-- | epan/dissectors/packet-wps.h | 9 |
3 files changed, 47 insertions, 20 deletions
diff --git a/epan/dissectors/packet-eap.c b/epan/dissectors/packet-eap.c index 946a7e600e..b00d0add41 100644 --- a/epan/dissectors/packet-eap.c +++ b/epan/dissectors/packet-eap.c @@ -98,6 +98,8 @@ static expert_field ei_eap_md5_value_size_overflow = EI_INIT; static expert_field ei_eap_dictionary_attacks = EI_INIT; static expert_field ei_eap_identity_invalid = EI_INIT; +static dissector_table_t eap_expanded_type_dissector_table; + static dissector_handle_t eap_handle; static dissector_handle_t tls_handle; @@ -395,10 +397,6 @@ static const fragment_items eap_tls_frag_items = { static int hf_eap_ext_vendor_id = -1; static int hf_eap_ext_vendor_type = -1; -/* Vendor-Type and Vendor-id */ -#define WFA_VENDOR_ID 0x00372A -#define WFA_SIMPLECONFIG_TYPE 0x1 - static const value_string eap_ext_vendor_id_vals[] = { { WFA_VENDOR_ID, "WFA" }, { 0, NULL } @@ -413,17 +411,28 @@ static void dissect_exteap(proto_tree *eap_tree, tvbuff_t *tvb, int offset, gint size, packet_info* pinfo) { + tvbuff_t *next_tvb; + guint32 vendor_id; + guint32 *vendor_type; - proto_tree_add_item(eap_tree, hf_eap_ext_vendor_id, tvb, offset, 3, ENC_BIG_ENDIAN); + vendor_type = (guint32 *)g_malloc(sizeof(guint32)); + + 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(eap_tree, hf_eap_ext_vendor_type, tvb, offset, 4, ENC_BIG_ENDIAN); + 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; - /* Generic method to support multiple vendor-defined extended types goes here :-) */ - dissect_exteap_wps(eap_tree, tvb, offset, size, pinfo); + 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)) { + call_data_dissector(next_tvb, pinfo, eap_tree); + } + + g_free(vendor_type); } /* ********************************************************************* ********************************************************************* */ @@ -1712,6 +1721,12 @@ proto_register_eap(void) reassembly_table_register(&eap_tls_reassembly_table, &addresses_reassembly_table_functions); + + eap_expanded_type_dissector_table = register_dissector_table("eap.ext.vendor_id", + "EAP-EXT Vendor Id", + proto_eap, FT_UINT24, + BASE_HEX); + } void diff --git a/epan/dissectors/packet-wps.c b/epan/dissectors/packet-wps.c index 26888cdcec..2231904044 100644 --- a/epan/dissectors/packet-wps.c +++ b/epan/dissectors/packet-wps.c @@ -45,6 +45,8 @@ static expert_field ei_eapwps_packet_too_short = EI_INIT; static expert_field ei_eapwps_fmt_warn_too_long = EI_INIT; static expert_field ei_eapwps_fmt_length_warn = EI_INIT; +static dissector_handle_t wps_handle; + /* OPCodes */ #define OPC_WSC_START 0x01 /* WPS OPCODE WSC_Start */ #define OPC_WSC_ACK 0x02 /* WPS OPCODE WSC_ACK */ @@ -1677,15 +1679,20 @@ dissect_wps_tlvs(proto_tree *eap_tree, tvbuff_t *tvb, int offset, /********************************************************************** */ /********************************************************************** */ -void -dissect_exteap_wps(proto_tree *eap_tree, tvbuff_t *tvb, int offset, - gint size, packet_info *pinfo) + +static int +dissect_wps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { proto_item *pi; proto_tree *pt; guint8 flags; + int offset; + gint size; + + offset = 0; + size = tvb_captured_length(tvb); - pi = proto_tree_add_item(eap_tree, hf_eapwps_opcode, tvb, offset, 1, ENC_BIG_ENDIAN); + pi = proto_tree_add_item(tree, hf_eapwps_opcode, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; size -= 1; pi = proto_item_get_parent(pi); @@ -1694,10 +1701,9 @@ dissect_exteap_wps(proto_tree *eap_tree, tvbuff_t *tvb, int offset, if (pinfo != NULL) col_append_str(pinfo->cinfo, COL_INFO, ", WPS"); - /* Flag field, if msg-len flag set, add appropriate field */ flags = tvb_get_guint8(tvb,offset); - pi = proto_tree_add_item(eap_tree, hf_eapwps_flags, tvb, offset, 1, ENC_BIG_ENDIAN); + pi = proto_tree_add_item(tree, hf_eapwps_flags, tvb, offset, 1, ENC_BIG_ENDIAN); pt = proto_item_add_subtree(pi, ett_eap_wps_flags); proto_tree_add_item(pt, hf_eapwps_flag_mf, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -1706,11 +1712,13 @@ dissect_exteap_wps(proto_tree *eap_tree, tvbuff_t *tvb, int offset, if (flags & MASK_WSC_FLAG_LF) { /* length field is present in first eap-packet when msg is fragmented */ - proto_tree_add_item(eap_tree, hf_eapwps_msglen, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_eapwps_msglen, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; size -= 2; } - dissect_wps_tlvs(eap_tree, tvb, offset, size, pinfo); + dissect_wps_tlvs(tree, tvb, offset, size, pinfo); + + return size; } /********************************************************************** */ @@ -2539,12 +2547,15 @@ proto_register_wps(void) proto_register_subtree_array(ett, array_length(ett)); expert_wps = expert_register_protocol(proto_wps); expert_register_field_array(expert_wps, ei, array_length(ei)); + + wps_handle = register_dissector("wps", dissect_wps, proto_wps); } void proto_reg_handoff_wps(void) { dissector_add_uint("wlan.ie.wifi_alliance.subtype", WFA_SUBTYPE_IEEE1905_MULTI_AP, create_dissector_handle(dissect_wps_wfa_ext_via_dt, -1)); + dissector_add_uint("eap.ext.vendor_id", WFA_VENDOR_ID, wps_handle); } /* diff --git a/epan/dissectors/packet-wps.h b/epan/dissectors/packet-wps.h index f4ef6da00f..f80ada73a6 100644 --- a/epan/dissectors/packet-wps.h +++ b/epan/dissectors/packet-wps.h @@ -23,11 +23,12 @@ #ifndef _packet_wps_h_ #define _packet_wps_h_ -void -dissect_exteap_wps(proto_tree *eap_tree, tvbuff_t *tvb, int offset, - gint size, packet_info* pinfo); + /* Vendor-Type and Vendor-id */ +#define WFA_VENDOR_ID 0x00372A +#define WFA_SIMPLECONFIG_TYPE 0x1 + void dissect_wps_tlvs(proto_tree *eap_tree, tvbuff_t *tvb, int offset, gint size, packet_info* pinfo); -#endif +#endif
\ No newline at end of file |