[PATCH 1/3] hostapd: add support for testing probe response elements
Johannes Berg
johannes at sipsolutions.net
Thu Mar 28 06:06:58 PDT 2024
From: Johannes Berg <johannes.berg at intel.com>
Add support for additional (vendor) elements to be added
to only probe response frames, for testing.
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
hostapd/config_file.c | 3 +++
hostapd/hostapd.conf | 8 ++++++++
src/ap/ap_config.c | 1 +
src/ap/ap_config.h | 1 +
src/ap/ap_drv_ops.c | 3 +++
src/ap/beacon.c | 12 ++++++++++++
6 files changed, 28 insertions(+)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index e9f0c5ca2344..843e31c6a367 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4516,6 +4516,9 @@ static int hostapd_config_fill(struct hostapd_config *conf,
bss->eapol_m3_no_encrypt = atoi(pos);
} else if (os_strcmp(buf, "test_assoc_comeback_type") == 0) {
bss->test_assoc_comeback_type = atoi(pos);
+ } else if (os_strcmp(buf, "presp_elements") == 0) {
+ if (parse_wpabuf_hex(line, buf, &bss->presp_elements, pos))
+ return 1;
#endif /* CONFIG_TESTING_OPTIONS */
#ifdef CONFIG_SAE
} else if (os_strcmp(buf, "sae_password") == 0) {
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index 727a87770a86..35e9ae4c629a 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -3216,6 +3216,14 @@ own_ip_addr=127.0.0.1
# attempt (wpa_pairwise_update_count). This will trigger a timeout on all
# previous attempts and thus delays the frame. (testing only)
#delay_eapol_tx=0
+#
+# Additional elements for Probe Response frames.
+# This parameter can be used to add additional element(s) to
+# the end of the Probe Response frames. The format for these
+# element(s) is a hexdump of the raw information elements (id+len+payload for
+# one or more elements)
+# These elements are added after the 'vendor_elements'.
+#presp_elements=
##### Multiple BSSID support ##################################################
#
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 1a18df61771d..e1910d42239b 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -967,6 +967,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
wpabuf_free(conf->igtk_rsc_override);
wpabuf_free(conf->eapol_m1_elements);
wpabuf_free(conf->eapol_m3_elements);
+ wpabuf_free(conf->presp_elements);
#endif /* CONFIG_TESTING_OPTIONS */
os_free(conf->no_probe_resp_if_seen_on);
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 754d553311d8..4cce662782f3 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -713,6 +713,7 @@ struct hostapd_bss_config {
#ifdef CONFIG_IEEE80211BE
u16 eht_oper_puncturing_override;
#endif /* CONFIG_IEEE80211BE */
+ struct wpabuf *presp_elements;
#endif /* CONFIG_TESTING_OPTIONS */
#define MESH_ENABLED BIT(0)
diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
index 6d910aa5aafe..1b1a9dcffa00 100644
--- a/src/ap/ap_drv_ops.c
+++ b/src/ap/ap_drv_ops.c
@@ -208,6 +208,9 @@ int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
add_buf(&beacon, hapd->conf->vendor_elements);
add_buf(&proberesp, hapd->conf->vendor_elements);
+#ifdef CONFIG_TESTING_OPTIONS
+ add_buf(&proberesp, hapd->conf->presp_elements);
+#endif
add_buf(&assocresp, hapd->conf->assocresp_elements);
*beacon_ret = beacon;
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index e339c2002fab..6bf2693bea4e 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -649,6 +649,10 @@ static size_t hostapd_probe_resp_elems_len(struct hostapd_data *hapd,
#endif /* CONFIG_FST */
if (hapd->conf->vendor_elements)
buflen += wpabuf_len(hapd->conf->vendor_elements);
+#ifdef CONFIG_TESTING_OPTIONS
+ if (hapd->conf->presp_elements)
+ buflen += wpabuf_len(hapd->conf->presp_elements);
+#endif
if (hapd->conf->vendor_vht) {
buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) +
2 + sizeof(struct ieee80211_vht_operation);
@@ -885,6 +889,14 @@ static u8 * hostapd_probe_resp_fill_elems(struct hostapd_data *hapd,
pos += wpabuf_len(hapd->conf->vendor_elements);
}
+#ifdef CONFIG_TESTING_OPTIONS
+ if (hapd->conf->presp_elements) {
+ os_memcpy(pos, wpabuf_head(hapd->conf->presp_elements),
+ wpabuf_len(hapd->conf->presp_elements));
+ pos += wpabuf_len(hapd->conf->presp_elements);
+ }
+#endif
+
return pos;
}
--
2.44.0
More information about the Hostap
mailing list