]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Add support for testing Probe Response frame elements
authorJohannes Berg <johannes.berg@intel.com>
Thu, 28 Mar 2024 13:06:58 +0000 (14:06 +0100)
committerJouni Malinen <j@w1.fi>
Tue, 16 Apr 2024 07:38:00 +0000 (10:38 +0300)
Add support for additional (vendor) elements to be added
to only Probe Response frames, for testing.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.c
src/ap/ap_config.h
src/ap/ap_drv_ops.c
src/ap/beacon.c

index 20ee59081dad6197d825ca53eef437da99490390..9a8f34e0dea29fccefef22d5ed834f16b9e03dbc 100644 (file)
@@ -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) {
index e34d75c8692a5da79c427cfb4d0221a68827a878..51ca05e25740f4f4b66d9068e1234c8216a93303 100644 (file)
@@ -3216,6 +3216,13 @@ 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 ##################################################
 #
index 1a18df61771d12791c262fdf1ee0d8f123a486b3..e1910d42239b6d1ef808f0967b2ee745628c6a92 100644 (file)
@@ -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);
index 754d553311d89ae642c04739d6c7f34a948452ff..aa513be4ce4b0c8d6593392d7e56ed8bc9b11d0c 100644 (file)
@@ -709,6 +709,7 @@ struct hostapd_bss_config {
        struct wpabuf *eapol_m3_elements;
        bool eapol_m3_no_encrypt;
        int test_assoc_comeback_type;
+       struct wpabuf *presp_elements;
 
 #ifdef CONFIG_IEEE80211BE
        u16 eht_oper_puncturing_override;
index 11fe39c2599f023f7507a3838cc88a9e7bce62c1..d09d678ef672a15020b639dc7ee077d9eedf1c55 100644 (file)
@@ -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 /* CONFIG_TESTING_OPTIONS */
        add_buf(&assocresp, hapd->conf->assocresp_elements);
 
        *beacon_ret = beacon;
index 32865f667ea4e68a916b624b57e43e856ebc03b3..143b3b4b7bd26a1194a4ac577276e6625a7cc60b 100644 (file)
@@ -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 /* CONFIG_TESTING_OPTIONS */
        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 /* CONFIG_TESTING_OPTIONS */
+
        return pos;
 }