diff options
author | Michael Mann <mmann78@netscape.net> | 2017-08-13 10:57:55 -0700 |
---|---|---|
committer | Richard Sharpe <realrichardsharpe@gmail.com> | 2017-08-14 04:40:04 +0000 |
commit | 3c0ff67a9ca7e9c71785fa9d97cc1c1c13908774 (patch) | |
tree | 81f89d66267303b04bc11fc5a25c996f8d7d496f /epan/dissectors/packet-wifi-p2p.c | |
parent | 329cccfc7b3adabbcd961cc328609f23058e5a12 (diff) |
ieee80211: Make a few dissector tables for vendor specific functionality
This allows vendors to more easily expand functionality.
Change-Id: Iaa6a0626f3ab3c80a3ea90ca09c90284705d0221
Reviewed-on: https://code.wireshark.org/review/23066
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-wifi-p2p.c')
-rw-r--r-- | epan/dissectors/packet-wifi-p2p.c | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/epan/dissectors/packet-wifi-p2p.c b/epan/dissectors/packet-wifi-p2p.c index ee6cdfb0e6..0a5ab5884a 100644 --- a/epan/dissectors/packet-wifi-p2p.c +++ b/epan/dissectors/packet-wifi-p2p.c @@ -421,7 +421,6 @@ static int hf_p2p_anqp_query_data = -1; static int hf_p2p_anqp_status_code = -1; static int hf_p2p_anqp_response_data = -1; -static int hf_p2p_wfa_subtype = -1; static int hf_p2p_action_subtype = -1; static int hf_p2p_action_dialog_token = -1; static int hf_p2p_public_action_subtype = -1; @@ -432,6 +431,8 @@ static expert_field ei_wifi_p2p_attr_len = EI_INIT; static expert_field ei_wifi_p2p_anqp_length = EI_INIT; static expert_field ei_wifi_p2p_anqp_unexpected_padding = EI_INIT; +dissector_handle_t wifi_display_ie_handle; + static void dissect_wifi_p2p_capability(proto_item *tlv_root, proto_item *tlv_item, tvbuff_t *tvb, int offset) @@ -1060,12 +1061,13 @@ static void dissect_persistent_group(proto_item *tlv_root, } - -void dissect_wifi_p2p_ie(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, - int offset, gint size) +static int +dissect_wifi_p2p_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { guint16 slen = 0; guint8 stype = 0; + int offset = 0; + int size = tvb_reported_length(tvb); proto_item *tlv_root, *tlv_item; while (size > 0) { @@ -1173,11 +1175,14 @@ void dissect_wifi_p2p_ie(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, offset += 3 + slen; size -= 3 + slen; } + + return tvb_captured_length(tvb); } -int dissect_wifi_p2p_public_action(packet_info *pinfo, proto_tree *tree, - tvbuff_t *tvb, int offset) +static int +dissect_wifi_p2p_public_action(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { + int offset = 0; guint8 subtype; proto_tree_add_item(tree, hf_p2p_public_action_subtype, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -1197,33 +1202,31 @@ static int dissect_wifi_p2p_action(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { int offset = 0; - guint32 subtype; - proto_tree_add_item_ret_uint(tree, hf_p2p_wfa_subtype, tvb, offset, 1, ENC_NA, &subtype); + proto_tree_add_item(tree, hf_p2p_action_subtype, tvb, offset, 1, ENC_BIG_ENDIAN); + offset++; + proto_tree_add_item(tree, hf_p2p_action_dialog_token, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; - - if (subtype == 9 /* WFA_SUBTYPE_P2P */ ) - { - proto_tree_add_item(tree, hf_p2p_action_subtype, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - proto_tree_add_item(tree, hf_p2p_action_dialog_token, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - } /* Followed by variable length IEs dissected by packet-ieee80211.c */ return offset; } -void dissect_wifi_p2p_anqp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, - int offset, gboolean request) +static int +dissect_wifi_p2p_anqp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data) { + int offset = 0; proto_item *item; + anqp_info_dissector_data_t* anqp_data = (anqp_info_dissector_data_t*)data; + tvbuff_t *next_tvb; + + DISSECTOR_ASSERT(anqp_data); item = proto_tree_add_item(tree, hf_p2p_anqp_service_update_indicator, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - while (tvb_reported_length_remaining(tvb, offset) >= (request ? 4 : 5)) { + while (tvb_reported_length_remaining(tvb, offset) >= (anqp_data->request ? 4 : 5)) { guint16 len; proto_tree *tlv; guint8 type, id, sd_proto; @@ -1231,11 +1234,11 @@ void dissect_wifi_p2p_anqp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, len = tvb_get_letohs(tvb, offset); if (len < 2) { expert_add_info_format(pinfo, item, &ei_wifi_p2p_anqp_length, "Too short Service TLV field"); - return; + return offset; } if (len > tvb_reported_length_remaining(tvb, offset + 2)) { expert_add_info_format(pinfo, item, &ei_wifi_p2p_anqp_length, "Too short frame for Service TLV field"); - return; + return offset; } type = tvb_get_guint8(tvb, offset + 2); @@ -1252,7 +1255,7 @@ void dissect_wifi_p2p_anqp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv, hf_p2p_anqp_service_transaction_id, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - if (request) { + if (anqp_data->request) { proto_tree_add_item(tlv, hf_p2p_anqp_query_data, tvb, offset + 2, len - 2, ENC_NA); } else { @@ -1260,8 +1263,10 @@ void dissect_wifi_p2p_anqp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, offset + 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv, hf_p2p_anqp_response_data, tvb, offset + 3, len - 3, ENC_NA); - if (sd_proto == 4) - dissect_wifi_display_ie(pinfo, tlv, tvb, offset + 3, len - 3); + if (sd_proto == 4) { + next_tvb = tvb_new_subset_length(tvb, offset + 3, len - 3); + call_dissector(wifi_display_ie_handle, next_tvb, pinfo, tlv); + } } offset += len; } @@ -1269,6 +1274,8 @@ void dissect_wifi_p2p_anqp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, if (tvb_reported_length_remaining(tvb, offset) > 0) { expert_add_info(pinfo, item, &ei_wifi_p2p_anqp_unexpected_padding); } + + return tvb_captured_length(tvb); } void @@ -1788,10 +1795,6 @@ proto_register_p2p(void) { "Response Data", "wifi_p2p.anqp.response_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - {&hf_p2p_wfa_subtype, - {"WFA Subtype", "wifi_p2p.wfa_subtype", - FT_UINT8, BASE_DEC, NULL, 0, - NULL, HFILL }}, { &hf_p2p_action_subtype, { "P2P Action Subtype", "wifi_p2p.action.subtype", FT_UINT8, BASE_DEC, VALS(p2p_action_subtypes), 0x0, NULL, HFILL }}, @@ -1834,7 +1837,12 @@ proto_register_p2p(void) void proto_reg_handoff_p2p(void) { - dissector_add_uint("wlan.action.vendor_specific", OUI_WFA, create_dissector_handle(dissect_wifi_p2p_action, proto_p2p)); + dissector_add_uint("wlan.action.wifi_alliance.subtype", WFA_SUBTYPE_P2P, create_dissector_handle(dissect_wifi_p2p_action, proto_p2p)); + dissector_add_uint("wlan.anqp.wifi_alliance.subtype", WFA_SUBTYPE_P2P, create_dissector_handle(dissect_wifi_p2p_anqp, proto_p2p)); + dissector_add_uint("wlan.ie.wifi_alliance.subtype", WFA_SUBTYPE_P2P, create_dissector_handle(dissect_wifi_p2p_ie, proto_p2p)); + dissector_add_uint("wlan.pa.wifi_alliance.subtype", WFA_SUBTYPE_P2P, create_dissector_handle(dissect_wifi_p2p_public_action, proto_p2p)); + + wifi_display_ie_handle = find_dissector_add_dependency("wifi_display_ie", proto_p2p); } /* |