diff options
author | Richard Sharpe <realrichardsharpe@gmail.com> | 2020-08-14 21:20:32 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2020-08-15 20:46:50 +0000 |
commit | 4e8dae37ebefd048d77147df3b62a3a1f4404bb4 (patch) | |
tree | 7ffe4cc427f5291e5e3a80ca79408488d9e7e11e | |
parent | ce81473b7f05eb33adf7f5fc6acb9cc4162909c8 (diff) |
wifi-dpp: Add support for version 1.2.9 of the protocol.
Also fix packet-ieee1905.c to include packet-wifi-dpp.h for the definition
it needs.
Change-Id: Iebb290ffb3112161605d6065123cfc54b921f2eb
Reviewed-on: https://code.wireshark.org/review/38163
Petri-Dish: Richard Sharpe <realrichardsharpe@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/dissectors/packet-ieee1905.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-wifi-dpp.c | 475 | ||||
-rw-r--r-- | epan/dissectors/packet-wifi-dpp.h | 10 |
3 files changed, 426 insertions, 64 deletions
diff --git a/epan/dissectors/packet-ieee1905.c b/epan/dissectors/packet-ieee1905.c index 7c222c8914..98865aa2b1 100644 --- a/epan/dissectors/packet-ieee1905.c +++ b/epan/dissectors/packet-ieee1905.c @@ -30,6 +30,7 @@ #include <epan/address.h> #include <epan/reassemble.h> #include "packet-wps.h" +#include "packet-wifi-dpp.h" static dissector_handle_t eapol_handle; @@ -7373,10 +7374,6 @@ dissect_akm_suite_capabilities(tvbuff_t *tvb, packet_info *pinfo _U_, /* * Dissect a 1905 Encap DPP TLV: */ -int -dissect_wifi_dpp_public_action(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, void *data _U_); - guint add_ff_action(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset); diff --git a/epan/dissectors/packet-wifi-dpp.c b/epan/dissectors/packet-wifi-dpp.c index aad164959a..88fffc1a9b 100644 --- a/epan/dissectors/packet-wifi-dpp.c +++ b/epan/dissectors/packet-wifi-dpp.c @@ -2,27 +2,34 @@ * * Wi-Fi Device Provisioning Protocol (DPP) * - * Copyright 2017 Richard Sharpe <realrichardsharpe@gmail.com> - * Copyright 2017 The WiFi Alliance + * Copyright 2017-2020 Richard Sharpe <realrichardsharpe@gmail.com> + * Copyright 2017-2020 The WiFi Alliance * * SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Code and constants based on Wi-Fi_DPP_Tech_Spec_v0_1_5 + * Code and constants based on Device_Provisioning_Protocol_Specification_v1.2.9 */ #include "config.h" #include <epan/packet.h> +#include "packet-tcp.h" #include <epan/to_str.h> #include <epan/expert.h> +#include "packet-wifi-dpp.h" #include "packet-ieee80211.h" +extern const value_string wfa_subtype_vals[]; + void proto_register_wifi_dpp(void); void proto_reg_handoff_wifi_dpp(void); +#define WIFI_DPP_TCP_PORT (7871) +static guint wifi_dpp_tcp_port = WIFI_DPP_TCP_PORT; + enum { DPP_STATUS_OK = 0, DPP_STATUS_NOT_COMPATIBLE = 1, @@ -30,10 +37,31 @@ enum { DPP_STATUS_UNWRAP_FAILURE = 3, DPP_STATUS_BAD_GROUP = 4, DPP_STATUS_CONFIGURE_FAILURE = 5, - DPP_STATUS_RESPONSE_PENDING = 6 + DPP_STATUS_RESPONSE_PENDING = 6, + DPP_STATUS_INVALID_CONNECTOR = 7, + DPP_STATUS_NO_MATCH = 8, + DPP_STATUS_CONFIG_REJECTED = 9, + DPP_STATUS_NO_AP = 10, + DPP_STATUS_CONFIGURE_PENDING = 11, + DPP_STATUS_CSR_NEEDED = 12, + DPP_STATUS_CSR_BAD = 13 }; static const value_string dpp_status_codes[] = { + { DPP_STATUS_OK, "OK" }, + { DPP_STATUS_NOT_COMPATIBLE, "Not Compatible" }, + { DPP_STATUS_AUTH_FAILURE, "Auth Failure" }, + { DPP_STATUS_UNWRAP_FAILURE, "Unwrap Failure" }, + { DPP_STATUS_BAD_GROUP, "Bad Group" }, + { DPP_STATUS_CONFIGURE_FAILURE, "Configure Failure" }, + { DPP_STATUS_RESPONSE_PENDING, "Response Pending" }, + { DPP_STATUS_INVALID_CONNECTOR, "Invalid Connector" }, + { DPP_STATUS_NO_MATCH, "No Match" }, + { DPP_STATUS_CONFIG_REJECTED, "Enrollee rejected the config" }, + { DPP_STATUS_NO_AP, "Enrollee failed to discover an AP" }, + { DPP_STATUS_CONFIGURE_PENDING, "Configuration response is not ready yet. The enrollee needs to request again." }, + { DPP_STATUS_CSR_NEEDED, "Configuration requires a Certificate Signing Request. Enrollee needs to request again." }, + { DPP_STATUS_CSR_BAD, "The Certificate Signing Request was invalid." }, { DPP_STATUS_OK, "OK" }, { DPP_STATUS_NOT_COMPATIBLE, "Not Compatible" }, { DPP_STATUS_AUTH_FAILURE, "Auth Failure" }, @@ -65,7 +93,18 @@ enum { DPP_ENCRYPTED_KEY = 0x1013, DPP_ENROLLEE_NONCE = 0x1014, DPP_CODE_IDENTIFIER = 0x1015, - DPP_TRANSACTION_ID = 0x1016 + DPP_TRANSACTION_ID = 0x1016, + DPP_BOOTSTRAPPING_INFO = 0x1017, + DPP_CHANNEL = 0x1018, + DPP_PROTOCOL_VERSION = 0x1019, + DPP_ENVELOPEDATA = 0x101A, + DPP_SENDCONNSTATUS = 0x101B, + DPP_CONNSTATUS = 0x101C, + DPP_RECONFIG_FLAGS = 0x101D, + DPP_C_SIGN_KEY_HASH = 0x101E, + DPP_CSR_ATTRIBUTES_REQUEST = 0x101F, + DPP_A_NONCE = 0x1020, + DPP_E_PRIME_ID = 0x1021 }; static const value_string dpp_ie_attr_ids[] = { @@ -89,45 +128,56 @@ static const value_string dpp_ie_attr_ids[] = { { DPP_ENCRYPTED_KEY, "DPP Encrypted Key" }, { DPP_CODE_IDENTIFIER, "DPP Code Identifier" }, { DPP_TRANSACTION_ID, "DPP Transaction ID" }, + { DPP_BOOTSTRAPPING_INFO, "DPP Bootstrapping Info" }, + { DPP_CHANNEL, "DPP Channel" }, + { DPP_PROTOCOL_VERSION, "DPP Protocol Version" }, + { DPP_ENVELOPEDATA, "DPP Enveloped Data" }, + { DPP_SENDCONNSTATUS, "DPP Send Conn Status" }, + { DPP_CONNSTATUS, "DPP Conn Status" }, + { DPP_RECONFIG_FLAGS, "DPP Reconfig Flags" }, + { DPP_C_SIGN_KEY_HASH, "DPP C-sign key Hash" }, + { DPP_CSR_ATTRIBUTES_REQUEST, "DPP CSR Attributes Request" }, + { DPP_A_NONCE, "DPP A-NONCE" }, + { DPP_E_PRIME_ID, "DPP E'-id" }, { 0, NULL } }; enum { - DPP_AUTHENTICATION_REQUEST = 0, - DPP_AUTHENTICATION_RESPONSE = 1, - DPP_AUTHENTICATION_CONFIRM = 2, - DPP_PEER_DISCOVERY_REQUEST = 5, - DPP_PEER_DISCOVERY_RESPONSE = 6, - DPP_PKEX_EXCHANGE_REQUEST = 7, - DPP_PKEX_EXCHANGE_RESPONSE = 8, - DPP_PKEX_COMMIT_REVEAL_REQUEST = 9, - DPP_PKEX_COMMIT_REVEAL_RESPONSE = 10, - DPP_CONFIG_RESULT = 11, - DPP_CONNECTION_STATUS_RESULT = 12, - DPP_PRESENCE_ANNOUNCEMENT = 13, - DPP_RECONFIG_ANNOUNCEMENT = 14, - DPP_RECONFIG_AUTH_REQUEST = 15, - DPP_RECONFIG_AUTH_RESP = 16, - DPP_RECONFIG_AUTH_CONFORM = 17 + DPP_AUTHENTICATION_REQUEST = 0, + DPP_AUTHENTICATION_RESPONSE = 1, + DPP_AUTHENTICATION_CONFIRM = 2, + DPP_PEER_DISCOVERY_REQUEST = 5, + DPP_PEER_DISCOVERY_RESPONSE = 6, + DPP_PKEX_EXCHANGE_REQUEST = 7, + DPP_PKEX_EXCHANGE_RESPONSE = 8, + DPP_PKEX_COMMIT_REVEAL_REQUEST = 9, + DPP_PKEX_COMMIT_REVEAL_RESPONSE = 10, + DPP_CONFIGURATION_RESULT = 11, + DPP_CONNECTION_STATUS_RESULT = 12, + DPP_PRESENCE_ANNOUNCEMENT = 13, + DPP_RECONFIG_ANNOUNCEMENT = 14, + DPP_RECONFIG_AUTH_REQUEST = 15, + DPP_RECONFIG_AUTH_RESPONSE = 16, + DPP_RECONFIG_AUTH_CONFIRM = 17 }; static const value_string dpp_public_action_subtypes[] = { - { DPP_AUTHENTICATION_REQUEST, "Authentiation Request" }, - { DPP_AUTHENTICATION_RESPONSE, "Authentication Response" }, - { DPP_AUTHENTICATION_CONFIRM, "Authentication Confirm" }, - { DPP_PEER_DISCOVERY_REQUEST, "Peer Discovery Request" }, - { DPP_PEER_DISCOVERY_RESPONSE, "Peer Discovery Response" }, - { DPP_PKEX_EXCHANGE_REQUEST, "PKEX Exchange Request" }, - { DPP_PKEX_EXCHANGE_RESPONSE, "PKEX Exchange Response" }, - { DPP_PKEX_COMMIT_REVEAL_REQUEST, "PKEX Commit-Reveal Request" }, - { DPP_PKEX_COMMIT_REVEAL_RESPONSE, "PKEX Commit-Reveal Response" }, - { DPP_CONFIG_RESULT, "Configuration Result" }, - { DPP_CONNECTION_STATUS_RESULT, "Connection Status Result" }, - { DPP_PRESENCE_ANNOUNCEMENT, "Presence Announcement" }, - { DPP_RECONFIG_ANNOUNCEMENT, "Reconfig Announcement" }, - { DPP_RECONFIG_AUTH_REQUEST, "Reconfig Authentication Request" }, - { DPP_RECONFIG_AUTH_RESP, "Reconfig Authentication Response" }, - { DPP_RECONFIG_AUTH_CONFORM, "Reconfig Authentication Confirm" }, + { DPP_AUTHENTICATION_REQUEST, "Authentication Request" }, + { DPP_AUTHENTICATION_RESPONSE, "Authentication Response" }, + { DPP_AUTHENTICATION_CONFIRM, "Authentication Confirm" }, + { DPP_PEER_DISCOVERY_REQUEST, "Peer Discovery Request" }, + { DPP_PEER_DISCOVERY_RESPONSE, "Peer Discovery Response" }, + { DPP_PKEX_EXCHANGE_REQUEST, "PKEX Exchange Request" }, + { DPP_PKEX_EXCHANGE_RESPONSE, "PKEX Exchange Response" }, + { DPP_PKEX_COMMIT_REVEAL_REQUEST, "PKEX Commit-Reveal Request" }, + { DPP_PKEX_COMMIT_REVEAL_RESPONSE, "PKEX Commit-Reveal Response" }, + { DPP_CONFIGURATION_RESULT, "Configuration Result" }, + { DPP_CONNECTION_STATUS_RESULT, "Connection Status Result" }, + { DPP_PRESENCE_ANNOUNCEMENT, "Presence Announcement" }, + { DPP_RECONFIG_ANNOUNCEMENT, "Reconfig Announcement" }, + { DPP_RECONFIG_AUTH_REQUEST, "Reconfig Authentication Request" }, + { DPP_RECONFIG_AUTH_RESPONSE, "Reconfig Authentication Response" }, + { DPP_RECONFIG_AUTH_CONFIRM, "Reconfig Authentication Confirm" }, { 0, NULL } }; @@ -143,6 +193,13 @@ static const value_string dpp_action_subtypes[] = { { 0, NULL } }; +static const range_string dpp_protocol_version_rvals[] = { + { 0, 0, "Reserved" }, + { 1, 1, "1.0" }, + { 2, 255, "Reserved" }, + { 0, 0, NULL } +}; + static int proto_wifi_dpp = -1; static gint ett_wifi_dpp_ie_generic = -1; @@ -159,9 +216,9 @@ static int hf_wifi_dpp_action_dialog_token = -1; static int hf_wifi_dpp_action_subtype = -1; static int hf_wifi_dpp_crypto_suite = -1; static int hf_wifi_dpp_public_action_subtype = -1; -static int hf_wifi_dpp_status = -1; static int hf_wifi_dpp_init_hash = -1; static int hf_wifi_dpp_resp_hash = -1; +static int hf_wifi_dpp_status = -1; static int hf_wifi_dpp_key_x = -1; static int hf_wifi_dpp_key_y = -1; static int hf_wifi_dpp_trans_id = -1; @@ -172,8 +229,28 @@ static int hf_wifi_dpp_enc_key_attribute = -1; static int hf_wifi_dpp_primary_wrapped_data = -1; static int hf_wifi_dpp_connector_attr = -1; static int hf_wifi_dpp_initiator_nonce = -1; +static int hf_wifi_dpp_operating_class = -1; +static int hf_wifi_dpp_channel = -1; +static int hf_wifi_dpp_protocol_version = -1; +static int hf_wifi_dpp_a_nonce = -1; +static int hf_wifi_dpp_e_prime_id = -1; static int hf_wifi_dpp_unknown_anqp_item = -1; +static int hf_wifi_dpp_tcp_pdu_length = -1; +static int hf_wifi_dpp_tcp_pdu_action_field = -1; +static int hf_wifi_dpp_tcp_oui = -1; +static int hf_wifi_dpp_tcp_oui_type = -1; +static int hf_wifi_dpp_tcp_dialog_token = -1; +static int hf_wifi_dpp_tcp_adv_proto_elt = -1; +static int hf_wifi_dpp_tcp_vendor_specific = -1; +static int hf_wifi_dpp_tcp_vendor_spec_len = -1; +static int hf_wifi_dpp_tcp_config = -1; +static int hf_wifi_dpp_tcp_query_req_len = -1; +static int hf_wifi_dpp_tcp_status_code = -1; +static int hf_wifi_dpp_gas_query_resp_frag_id = -1; +static int hf_wifi_dpp_tcp_comeback_delay = -1; +static int hf_wifi_dpp_tcp_query_resp_len = -1; + static int dissect_wifi_dpp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { @@ -187,11 +264,11 @@ static int dissect_wifi_dpp_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { proto_item *ie; - int offset = 0; - gint remaining_len = tvb_reported_length(tvb); + guint remaining_len = tvb_reported_length(tvb); - ie = proto_tree_add_subtree(tree, tvb, offset, remaining_len, ett_wifi_dpp_ie_generic, NULL, "Generic DPP IE"); - proto_tree_add_item(ie, hf_wifi_dpp_ie_generic, tvb, offset, remaining_len, ENC_NA); + ie = proto_tree_add_subtree(tree, tvb, 0, remaining_len, ett_wifi_dpp_ie_generic, NULL, "Generic DPP IE"); + proto_tree_add_item(ie, hf_wifi_dpp_ie_generic, tvb, 0, remaining_len, + ENC_NA); return tvb_captured_length(tvb); } @@ -216,14 +293,17 @@ dissect_wifi_dpp_attributes(packet_info *pinfo _U_, proto_tree *tree, val_to_str(attribute_id, dpp_ie_attr_ids, "Unknown (%u)")); - attr_hdr = proto_tree_add_subtree_format(attr, tvb, offset, 4, + attr_hdr = proto_tree_add_subtree(attr, tvb, offset, 4, ett_wifi_dpp_attr_header, NULL, "Attribute Header"); - proto_tree_add_item(attr_hdr, hf_wifi_dpp_ie_attr_id, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attr_hdr, hf_wifi_dpp_ie_attr_id, tvb, offset, 2, + ENC_LITTLE_ENDIAN); offset += 2; - proto_tree_add_item(attr_hdr, hf_wifi_dpp_ie_attr_len, tvb, offset, 2, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attr_hdr, hf_wifi_dpp_ie_attr_len, tvb, offset, 2, + ENC_LITTLE_ENDIAN); offset += 2; + specific_attr = proto_tree_add_subtree(attr, tvb, offset, attribute_len, ett_wifi_dpp_attr_value, NULL, "Attribute Value"); @@ -278,13 +358,37 @@ dissect_wifi_dpp_attributes(packet_info *pinfo _U_, proto_tree *tree, break; case DPP_CONNECTOR: - proto_tree_add_item(specific_attr, hf_wifi_dpp_connector_attr, tvb, offset, attribute_len, ENC_NA); + proto_tree_add_item(specific_attr, hf_wifi_dpp_connector_attr, tvb, + offset, attribute_len, ENC_NA); break; case DPP_INITIATOR_NONCE: - proto_tree_add_item(specific_attr, hf_wifi_dpp_initiator_nonce, tvb, offset, attribute_len, ENC_NA); + proto_tree_add_item(specific_attr, hf_wifi_dpp_initiator_nonce, tvb, + offset, attribute_len, ENC_NA); + break; + + case DPP_CHANNEL: + proto_tree_add_item(specific_attr, hf_wifi_dpp_operating_class, tvb, + offset, 1, ENC_NA); + proto_tree_add_item(specific_attr, hf_wifi_dpp_channel, tvb, offset + 1, + 1, ENC_NA); + break; + + case DPP_PROTOCOL_VERSION: + proto_tree_add_item(specific_attr, hf_wifi_dpp_protocol_version, tvb, + offset, 1, ENC_NA); break; + case DPP_A_NONCE: + proto_tree_add_item(specific_attr, hf_wifi_dpp_a_nonce, tvb, offset, + attribute_len, ENC_NA); + break; + + case DPP_E_PRIME_ID: + proto_tree_add_item(specific_attr, hf_wifi_dpp_e_prime_id, tvb, offset, + attribute_len, ENC_NA); + break; + case DPP_INITIATOR_AUTHENTICATING_TAG: case DPP_RESPONDER_AUTHENTICATING_TAG: @@ -334,7 +438,8 @@ dissect_wifi_dpp_config_proto(packet_info *pinfo _U_, proto_tree *tree, } int -dissect_wifi_dpp_public_action(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_wifi_dpp_public_action(tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, void *data _U_) { guint8 subtype; guint remaining_len; @@ -345,30 +450,32 @@ dissect_wifi_dpp_public_action(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr col_set_str(pinfo->cinfo, COL_PROTOCOL, "wifi_dpp"); - /* The Crypto suite comes before the subtype */ + /* The Crypto suite comes before the DPP frame type */ subtype = tvb_get_guint8(tvb, offset + 1); col_append_fstr(pinfo->cinfo, COL_INFO, ", DPP - %s", - val_to_str(subtype, dpp_public_action_subtypes, "Unknown (%u)")); + val_to_str(subtype, dpp_public_action_subtypes, + "Unknown (%u)")); remaining_len = tvb_reported_length_remaining(tvb, offset); dpp_item = proto_tree_add_item(tree, proto_wifi_dpp, tvb, offset, -1, ENC_NA); dpp_tree = proto_item_add_subtree(dpp_item, ett_wifi_dpp_pa); proto_item_append_text(dpp_item, ": %s", val_to_str(subtype, - dpp_public_action_subtypes, - "Unknown (%u)")); - proto_tree_add_item(dpp_tree, hf_wifi_dpp_crypto_suite, tvb, offset, 1, ENC_LITTLE_ENDIAN); + dpp_public_action_subtypes, + "Unknown (%u)")); + proto_tree_add_item(dpp_tree, hf_wifi_dpp_crypto_suite, tvb, offset, 1, + ENC_LITTLE_ENDIAN); offset++; remaining_len--; - proto_tree_add_item(dpp_tree, hf_wifi_dpp_public_action_subtype, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(dpp_tree, hf_wifi_dpp_public_action_subtype, tvb, offset, + 1, ENC_LITTLE_ENDIAN); offset++; /* Skip the OUI Subtype/DPP Request type */ remaining_len--; if (remaining_len) { attr_tree = proto_tree_add_subtree_format(dpp_tree, tvb, offset, - remaining_len, - ett_wifi_dpp_attributes, NULL, - "DPP Attributes"); + remaining_len, + ett_wifi_dpp_attributes, NULL, "DPP Attributes"); attributes_len = dissect_wifi_dpp_attributes(pinfo, attr_tree, tvb, offset); offset += attributes_len; @@ -381,17 +488,168 @@ static int dissect_wifi_dpp_action(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { int offset = 0; - - proto_tree_add_item(tree, hf_wifi_dpp_action_subtype, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, hf_wifi_dpp_action_subtype, tvb, offset, 1, ENC_NA); offset++; - proto_tree_add_item(tree, hf_wifi_dpp_action_dialog_token, tvb, offset, 1, ENC_LITTLE_ENDIAN); + + proto_tree_add_item(tree, hf_wifi_dpp_action_dialog_token, tvb, offset, 1, + ENC_NA); offset++; + + return offset; +} + +static int +dissect_wifi_dpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo _U_, + proto_tree *tree, void *data _U_) +{ + int offset = 0; + guint8 action; + tvbuff_t *newtvb; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "dpp"); + + /* + * We get a length, followed by Action field, OUI, OUI type and then a + * DPP public action + */ + proto_tree_add_item(tree, hf_wifi_dpp_tcp_pdu_length, tvb, offset, 4, + ENC_BIG_ENDIAN); + offset += 4; + + action = tvb_get_guint8(tvb, offset); + proto_tree_add_item(tree, hf_wifi_dpp_tcp_pdu_action_field, tvb, offset, 1, + ENC_NA); + offset += 1; + + if (action == 0x09) { + proto_tree_add_item(tree, hf_wifi_dpp_tcp_oui, tvb, offset, 3, ENC_NA); + offset += 3; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_oui_type, tvb, offset, 1, ENC_NA); + offset += 1; + + newtvb = tvb_new_subset_remaining(tvb, offset); + + offset += dissect_wifi_dpp_public_action(newtvb, pinfo, tree, NULL); + } else if (action == 0x0a) { + col_append_str(pinfo->cinfo, COL_INFO, ", DPP - Configuration Request"); + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_dialog_token, tvb, offset, 1, + ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_adv_proto_elt, tvb, offset, 3, + ENC_NA); + offset += 3; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_vendor_specific, tvb, offset, 1, + ENC_NA); + offset += 1; + proto_tree_add_item(tree, hf_wifi_dpp_tcp_vendor_spec_len, tvb, offset, 1, + ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_oui, tvb, offset, 3, ENC_NA); + offset += 3; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_oui_type, tvb, offset, 1, ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_config, tvb, offset, 1, ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_query_req_len, tvb, offset, 2, + ENC_LITTLE_ENDIAN); + offset += 2; + + offset += dissect_wifi_dpp_config_proto(pinfo, tree, tvb, offset); + } else if (action == 0x0b || action == 0x0d) { + guint16 qr_len; + + col_append_str(pinfo->cinfo, COL_INFO, ", DPP - Configuration Response"); + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_dialog_token, tvb, offset, 1, + ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_status_code, tvb, offset, 2, + ENC_LITTLE_ENDIAN); + offset += 2; + + if (action == 0x0d) { + proto_tree_add_item(tree, hf_wifi_dpp_gas_query_resp_frag_id, tvb, offset, + 1, ENC_NA); + offset += 1; + } + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_comeback_delay, tvb, offset, 2, + ENC_LITTLE_ENDIAN); + offset += 2; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_adv_proto_elt, tvb, offset, 3, + ENC_NA); + offset += 3; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_vendor_specific, tvb, offset, 1, + ENC_NA); + offset += 1; + proto_tree_add_item(tree, hf_wifi_dpp_tcp_vendor_spec_len, tvb, offset, 1, + ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_oui, tvb, offset, 3, ENC_NA); + offset += 3; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_oui_type, tvb, offset, 1, ENC_NA); + offset += 1; + + proto_tree_add_item(tree, hf_wifi_dpp_tcp_config, tvb, offset, 1, ENC_NA); + offset += 1; + + qr_len = tvb_get_letohs(tvb, offset); + proto_tree_add_item(tree, hf_wifi_dpp_tcp_query_resp_len, tvb, offset, 2, + ENC_LITTLE_ENDIAN); + offset += 2; + + if (qr_len) { + offset += dissect_wifi_dpp_config_proto(pinfo, tree, tvb, offset); + } + } + return offset; } +static guint +get_wifi_dpp_tcp_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, + void *data _U_) +{ + guint pkt_len; + + pkt_len = tvb_get_ntohl(tvb, offset); + + return pkt_len + 4; +} + +/* + * We need 4 bytes for the length ... + */ +#define DPP_TCP_HEADER_LEN 4 +static int +dissect_wifi_dpp_tcp_pdus(tvbuff_t *tvb, packet_info *pinfo _U_, + proto_tree *tree, void *data _U_) +{ + if (!tvb_bytes_exist(tvb, 0, DPP_TCP_HEADER_LEN)) + return 0; + + tcp_dissect_pdus(tvb, pinfo, tree, TRUE, DPP_TCP_HEADER_LEN, + get_wifi_dpp_tcp_len, dissect_wifi_dpp_tcp_pdu, data); + return tvb_reported_length(tvb); +} + void proto_register_wifi_dpp(void) { + static module_t *wifi_dpp_module; static hf_register_info hf[] = { { &hf_wifi_dpp_status, { "Wi-Fi DPP Status", "dpp.status", @@ -432,6 +690,22 @@ proto_register_wifi_dpp(void) { &hf_wifi_dpp_initiator_nonce, { "Wi-Fi DPP Initiator Nonce", "dpp.initiator_nonce", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_wifi_dpp_operating_class, + { "Operating Class", "dpp.operating_class", + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_wifi_dpp_channel, + { "Channel", "dpp.channel", + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_wifi_dpp_protocol_version, + { "Protocol Version", "dpp.protocol_version", + FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(dpp_protocol_version_rvals), + 0x0, NULL, HFILL }}, + { &hf_wifi_dpp_a_nonce, + { "A-NONCE", "dpp.a_nonce", + FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_wifi_dpp_e_prime_id, + { "E'-id", "dpp.e_prime_id", + FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_wifi_dpp_ie_attr_id, { "Wi-Fi DPP IE Attribute ID", "dpp.ie.attr_id", FT_UINT16, BASE_HEX, VALS(dpp_ie_attr_ids), 0x0, NULL, HFILL }}, @@ -456,6 +730,64 @@ proto_register_wifi_dpp(void) { &hf_wifi_dpp_unknown_anqp_item, { "Wi-fi DPP Unknown ANQP Item", "dpp.unknown_anqp_item", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_pdu_length, + { "DPP TCP PDU length", "dpp.tcp.length", + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_pdu_action_field, + { "DPP TCP PDU Action type", "dpp.tcp.action_type", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_oui, + { "DPP TCP PDU OUI", "dpp.tcp.oui", + FT_UINT24, BASE_OUI, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_oui_type, + { "DPP TCP PDU OUI type", "dpp.tcp.oui_type", + FT_UINT8, BASE_DEC, VALS(wfa_subtype_vals), 0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_dialog_token, + { "DPP TCP PDU Dialog Token", "dpp.tcp.dialog_token", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_adv_proto_elt, + { "DPP TCP PDU Advertisement Protocol Element", + "dpp.tcp.adv_proto_elt", + FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_vendor_specific, + { "DPP TCP PDU Vendor Specific tag", "dpp.tcp.vendor_spec_tag", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_vendor_spec_len, + { "DPP TCP PDU Vendor Specific len", "dpp.tcp.vendor_spec_len", + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_config, + { "DPP TCP PDU Configuration", "dpp.tcp.config", + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_query_req_len, + { "DPP TCP PDU Query Req len", "dpp.tcp.query_req_len", + FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_gas_query_resp_frag_id, + { "DPP TCP PDU GAS Query Response Fragment ID", + "dpp.tp.query_resp_frag_id", + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_status_code, + { "DPP TCP PDU Status Code", "dpp.tcp.status_code", + FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_comeback_delay, + { "DPP TCP PDU Comeback Delay", "dpp.tcp.comeback_delay", + FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + + { &hf_wifi_dpp_tcp_query_resp_len, + { "DPP TCP PDU Query Resp Len", "dpp.tcp.query_resp_len", + FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, }; static gint *ett[] = { &ett_wifi_dpp_ie_generic, @@ -470,15 +802,38 @@ proto_register_wifi_dpp(void) proto_register_field_array(proto_wifi_dpp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + /* Register the preferred TCP port? Is there one? */ + wifi_dpp_module = prefs_register_protocol(proto_wifi_dpp, NULL); + prefs_register_uint_preference(wifi_dpp_module, "tcp.port", "DPP TCP Port", + "The TCP port DPP over TCP uses", + 10, &wifi_dpp_tcp_port); } void proto_reg_handoff_wifi_dpp(void) { + static gboolean initialized = FALSE; + static dissector_handle_t wifi_dpp_tcp_handle; + static int current_port; + dissector_add_uint("wlan.action.wifi_alliance.subtype", WFA_SUBTYPE_DPP, create_dissector_handle(dissect_wifi_dpp_action, proto_wifi_dpp)); dissector_add_uint("wlan.anqp.wifi_alliance.subtype", WFA_SUBTYPE_DPP, create_dissector_handle(dissect_wifi_dpp, proto_wifi_dpp)); dissector_add_uint("wlan.ie.wifi_alliance.subtype", WFA_SUBTYPE_DPP, create_dissector_handle(dissect_wifi_dpp_ie, proto_wifi_dpp)); dissector_add_uint("wlan.pa.wifi_alliance.subtype", WFA_SUBTYPE_DPP, create_dissector_handle(dissect_wifi_dpp_public_action, proto_wifi_dpp)); + + /* + * Register the TCP port + */ + if (!initialized) { + wifi_dpp_tcp_handle = create_dissector_handle(dissect_wifi_dpp_tcp_pdus, + proto_wifi_dpp); + initialized = TRUE; + } else { + dissector_delete_uint("tcp.port", current_port, wifi_dpp_tcp_handle); + } + + current_port = wifi_dpp_tcp_port; + dissector_add_uint("tcp.port", current_port, wifi_dpp_tcp_handle); } /* diff --git a/epan/dissectors/packet-wifi-dpp.h b/epan/dissectors/packet-wifi-dpp.h new file mode 100644 index 0000000000..04e87a7bd9 --- /dev/null +++ b/epan/dissectors/packet-wifi-dpp.h @@ -0,0 +1,10 @@ +/* + * packet-wifi-dpp.h + * + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +int +dissect_wifi_dpp_public_action(tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, void *data _U_); |