]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Protocol testing to allow missing attributes in peer discovery
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 6 Nov 2017 10:40:18 +0000 (12:40 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 6 Nov 2017 10:40:18 +0000 (12:40 +0200)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/dpp_hostapd.c
src/common/dpp.h
wpa_supplicant/dpp_supplicant.c

index f715e1578c266f0996ca281ef08dd9242316d6e9..c00da40f2f557fff4183178f883735a94cc56243 100644 (file)
@@ -938,16 +938,39 @@ static void hostapd_dpp_send_peer_disc_resp(struct hostapd_data *hapd,
        if (!msg)
                return;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP) {
+               wpa_printf(MSG_INFO, "DPP: TESTING - no Transaction ID");
+               goto skip_trans_id;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        /* Transaction ID */
        wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID);
        wpabuf_put_le16(msg, 1);
        wpabuf_put_u8(msg, trans_id);
 
+#ifdef CONFIG_TESTING_OPTIONS
+skip_trans_id:
+       if (dpp_test == DPP_TEST_NO_STATUS_PEER_DISC_RESP) {
+               wpa_printf(MSG_INFO, "DPP: TESTING - no Status");
+               goto skip_status;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        /* DPP Status */
        wpabuf_put_le16(msg, DPP_ATTR_STATUS);
        wpabuf_put_le16(msg, 1);
        wpabuf_put_u8(msg, status);
 
+#ifdef CONFIG_TESTING_OPTIONS
+skip_status:
+       if (dpp_test == DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP) {
+               wpa_printf(MSG_INFO, "DPP: TESTING - no Connector");
+               goto skip_connector;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        /* DPP Connector */
        if (status == DPP_STATUS_OK) {
                wpabuf_put_le16(msg, DPP_ATTR_CONNECTOR);
@@ -955,6 +978,10 @@ static void hostapd_dpp_send_peer_disc_resp(struct hostapd_data *hapd,
                wpabuf_put_str(msg, hapd->conf->dpp_connector);
        }
 
+#ifdef CONFIG_TESTING_OPTIONS
+skip_connector:
+#endif /* CONFIG_TESTING_OPTIONS */
+
        wpa_printf(MSG_DEBUG, "DPP: Send Peer Discovery Response to " MACSTR
                   " status=%d", MAC2STR(src), status);
        wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
index a17404537e28f4bc1d55c876760b3274d97512ef..d921dfbe242d7e80a5ed0a74a2a665e2d951462b 100644 (file)
@@ -278,6 +278,11 @@ enum dpp_test_behavior {
        DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
        DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
        DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
+       DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
+       DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
+       DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
+       DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
+       DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
 };
 
 extern enum dpp_test_behavior dpp_test;
index 74dbb9311328ec7d2db4948cf945787482ede3bb..f4fd5ef82359b7db733a942f6966460f1ab8ee70 100644 (file)
@@ -1973,16 +1973,35 @@ int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
        if (!msg)
                return -1;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ) {
+               wpa_printf(MSG_INFO, "DPP: TESTING - no Transaction ID");
+               goto skip_trans_id;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        /* Transaction ID */
        wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID);
        wpabuf_put_le16(msg, 1);
        wpabuf_put_u8(msg, TRANSACTION_ID);
 
+#ifdef CONFIG_TESTING_OPTIONS
+skip_trans_id:
+       if (dpp_test == DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ) {
+               wpa_printf(MSG_INFO, "DPP: TESTING - no Connector");
+               goto skip_connector;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        /* DPP Connector */
        wpabuf_put_le16(msg, DPP_ATTR_CONNECTOR);
        wpabuf_put_le16(msg, os_strlen(ssid->dpp_connector));
        wpabuf_put_str(msg, ssid->dpp_connector);
 
+#ifdef CONFIG_TESTING_OPTIONS
+skip_connector:
+#endif /* CONFIG_TESTING_OPTIONS */
+
        /* TODO: Timeout on AP response */
        wait_time = wpa_s->max_remain_on_chan;
        if (wait_time > 2000)