Subject: [PATCH] hostapd: Add testing option for association_response_status_code
Raga, Gopi
gopiraga at amazon.com
Mon Oct 27 05:47:17 PDT 2025
From 654e923d8322da21fb1f925766711ff2ee1c0a6c Mon Sep 17 00:00:00 2001
From: gopiraga <mailto:gopiraga at amazon.com>
Date: Mon, 20 Oct 2025 19:37:17 +0530
Subject: [PATCH] hostapd: Add testing option for
association_response_status_code
This adds a new testing option to allow controlling the association
response status code returned by hostapd for testing purposes.
Signed-off-by: Gopi Raga <mailto:gopiraga at amazon.com>
---
hostapd/config_file.c | 14 ++++++++++++++
hostapd/hostapd.conf | 5 +++++
src/ap/ap_config.c | 1 +
src/ap/ap_config.h | 1 +
src/ap/ieee802_11.c | 9 +++++++++
5 files changed, 30 insertions(+)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 54ad77bcb..88b7a2587 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4351,6 +4351,20 @@ static int hostapd_config_fill(struct hostapd_config *conf,
bss->eapol_key_reserved_random = atoi(pos);
} else if (os_strcmp(buf, "test_assoc_comeback_type") == 0) {
bss->test_assoc_comeback_type = atoi(pos);
+ } else if (os_strcmp(buf, "association_response_status_code") == 0) {
+ int val = atoi(pos);
+ if (val < -1 || val > 65535) {
+ wpa_printf(MSG_ERROR,
+ "Line %d: Invalid association_response_status_code (expected -1 or 0-65535)",
+ line);
+ return 1;
+ }
+ bss->association_response_status_code = val;
+ if (val >= 0) {
+ wpa_printf(MSG_INFO,
+ "TESTING: association_response_status_code enabled - will override association responses with status code %d",
+ val);
+ }
} else if (os_strcmp(buf, "presp_elements") == 0) {
if (parse_wpabuf_hex(line, buf, &bss->presp_elements, pos))
return 1;
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index 2302e2abe..4752a5c43 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -3402,6 +3402,11 @@ own_ip_addr=127.0.0.1
# These elements are added after the 'vendor_elements'.
#presp_elements=
+# Send Custom Status Code in Association Response
+# Example association_response_status_code=15
+#association_response_status_code=0
+
+
##### Multiple BSSID support ##################################################
#
# Above configuration is using the default interface (wlan#, or multi-SSID VLAN
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index d1d988b5f..c45914343 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -170,6 +170,7 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
#ifdef CONFIG_TESTING_OPTIONS
bss->sae_commit_status = -1;
bss->test_assoc_comeback_type = -1;
+ bss->association_response_status_code = -1;
#endif /* CONFIG_TESTING_OPTIONS */
#ifdef CONFIG_PASN
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 44988d261..8ed0a8df9 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -700,6 +700,7 @@ struct hostapd_bss_config {
bool eapol_m3_no_encrypt;
bool eapol_key_reserved_random;
int test_assoc_comeback_type;
+ int association_response_status_code;
struct wpabuf *presp_elements;
#ifdef CONFIG_IEEE80211BE
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 45106617d..7b963b73f 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -6179,6 +6179,15 @@ static void handle_assoc(struct hostapd_data *hapd,
}
#endif /* CONFIG_FILS */
+#ifdef CONFIG_TESTING_OPTIONS
+ if (hapd->conf->association_response_status_code >= 0) {
+ wpa_printf(MSG_INFO,
+ "TESTING: Overriding association response status code from %d to %d for STA " MACSTR,
+ resp, hapd->conf->association_response_status_code, MAC2STR(mgmt->sa));
+ resp = hapd->conf->association_response_status_code;
+ }
+#endif /* CONFIG_TESTING_OPTIONS */
+
if (resp >= 0)
reply_res = send_assoc_resp(hapd,
mld_addrs_not_translated ?
--
2.34.1
More information about the Hostap
mailing list