DPP: Protocol testing to allow missing attributes in peer discovery

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2017-11-06 12:40:18 +02:00 committed by Jouni Malinen
parent 8c735316af
commit a306ed5a58
3 changed files with 51 additions and 0 deletions

View file

@ -938,16 +938,39 @@ static void hostapd_dpp_send_peer_disc_resp(struct hostapd_data *hapd,
if (!msg) if (!msg)
return; 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 */ /* Transaction ID */
wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID); wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID);
wpabuf_put_le16(msg, 1); wpabuf_put_le16(msg, 1);
wpabuf_put_u8(msg, trans_id); 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 */ /* DPP Status */
wpabuf_put_le16(msg, DPP_ATTR_STATUS); wpabuf_put_le16(msg, DPP_ATTR_STATUS);
wpabuf_put_le16(msg, 1); wpabuf_put_le16(msg, 1);
wpabuf_put_u8(msg, status); 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 */ /* DPP Connector */
if (status == DPP_STATUS_OK) { if (status == DPP_STATUS_OK) {
wpabuf_put_le16(msg, DPP_ATTR_CONNECTOR); 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); 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 wpa_printf(MSG_DEBUG, "DPP: Send Peer Discovery Response to " MACSTR
" status=%d", MAC2STR(src), status); " status=%d", MAC2STR(src), status);
wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR

View file

@ -278,6 +278,11 @@ enum dpp_test_behavior {
DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57, DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
DPP_TEST_INVALID_STATUS_CONF_RESP = 58, DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59, 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; extern enum dpp_test_behavior dpp_test;

View file

@ -1973,16 +1973,35 @@ int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
if (!msg) if (!msg)
return -1; 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 */ /* Transaction ID */
wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID); wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID);
wpabuf_put_le16(msg, 1); wpabuf_put_le16(msg, 1);
wpabuf_put_u8(msg, TRANSACTION_ID); 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 */ /* DPP Connector */
wpabuf_put_le16(msg, DPP_ATTR_CONNECTOR); wpabuf_put_le16(msg, DPP_ATTR_CONNECTOR);
wpabuf_put_le16(msg, os_strlen(ssid->dpp_connector)); wpabuf_put_le16(msg, os_strlen(ssid->dpp_connector));
wpabuf_put_str(msg, 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 */ /* TODO: Timeout on AP response */
wait_time = wpa_s->max_remain_on_chan; wait_time = wpa_s->max_remain_on_chan;
if (wait_time > 2000) if (wait_time > 2000)