>From 2436296d96e656aafe8561134e5d14db879f7d04 Mon Sep 17 00:00:00 2001 From: Mikael Kanstrup Date: Wed, 25 Jan 2017 10:57:25 +0100 Subject: [PATCH] hostapd: Add skip_auth_reply and skip_assoc_reply test commands Add skip_auth_reply and skip_assoc_reply commands for testing purpuses. By enabling skip with the new command either authentication reply and/or association reply frames are skipped from being sent by AP. These commands can be used to simulate dropped reply frames. Signed-off-by: Mikael Kanstrup --- hostapd/ctrl_iface.c | 4 ++++ src/ap/hostapd.h | 2 ++ src/ap/ieee802_11.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 9bfead0..34a1768 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -1278,6 +1278,10 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd) hapd->ext_mgmt_frame_handling = atoi(value); } else if (os_strcasecmp(cmd, "ext_eapol_frame_io") == 0) { hapd->ext_eapol_frame_io = atoi(value); + } else if (os_strcasecmp(cmd, "skip_auth_reply") == 0) { + hapd->skip_auth_reply = !!atoi(value); + } else if (os_strcasecmp(cmd, "skip_assoc_reply") == 0) { + hapd->skip_assoc_reply = !!atoi(value); #endif /* CONFIG_TESTING_OPTIONS */ #ifdef CONFIG_MBO } else if (os_strcasecmp(cmd, "mbo_assoc_disallow") == 0) { diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index e7c65f7..96ccbb1 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -302,6 +302,8 @@ struct hostapd_data { #ifdef CONFIG_TESTING_OPTIONS unsigned int ext_mgmt_frame_handling:1; unsigned int ext_eapol_frame_io:1; + unsigned int skip_auth_reply:1; + unsigned int skip_assoc_reply:1; struct l2_packet_data *l2_test; #endif /* CONFIG_TESTING_OPTIONS */ diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index d15a70c..5532d81 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -280,6 +280,14 @@ static int send_auth_reply(struct hostapd_data *hapd, size_t rlen; int reply_res = WLAN_STATUS_UNSPECIFIED_FAILURE; +#ifdef CONFIG_TESTING_OPTIONS + if (hapd->skip_auth_reply) { + wpa_printf(MSG_INFO, "skip_auth_reply active: STA=" MACSTR, + MAC2STR(dst)); + return WLAN_STATUS_SUCCESS; + } +#endif /* CONFIG_TESTING_OPTIONS */ + rlen = IEEE80211_HDRLEN + sizeof(reply->u.auth) + ies_len; buf = os_zalloc(rlen); if (buf == NULL) @@ -2740,6 +2748,15 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta, } #endif /* CONFIG_FILS */ +#ifdef CONFIG_TESTING_OPTIONS + if (hapd->skip_assoc_reply) { + wpa_printf(MSG_INFO, "skip_assoc_reply active: STA=" MACSTR, + MAC2STR(sta->addr)); + return WLAN_STATUS_SUCCESS; + } +#endif /* CONFIG_TESTING_OPTIONS */ + + #ifdef CONFIG_OWE if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) && sta && sta->owe_ecdh && -- 2.10.1.502.g6598894