From: Emmanuel Grumbach Date: Sun, 12 Jan 2025 08:30:54 +0000 (+0200) Subject: AP: Add a csa_ie_only testing option X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43c65f8a5df939105f8c0f7a77e581b050205ec5;p=thirdparty%2Fhostap.git AP: Add a csa_ie_only testing option This allows hostapd to be configured to add the CSA IE and not the ECSA IE to mimic behavior of some APs. Signed-off-by: Emmanuel Grumbach Signed-off-by: Andrei Otcheretianski --- diff --git a/hostapd/config_file.c b/hostapd/config_file.c index e9eaef7e5..a9d13f72a 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -4501,6 +4501,8 @@ static int hostapd_config_fill(struct hostapd_config *conf, PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability) } else if (os_strcmp(buf, "ecsa_ie_only") == 0) { conf->ecsa_ie_only = atoi(pos); + } else if (os_strcmp(buf, "csa_ie_only") == 0) { + conf->csa_ie_only = atoi(pos); } else if (os_strcmp(buf, "bss_load_test") == 0) { WPA_PUT_LE16(bss->bss_load_test, atoi(pos)); pos = os_strchr(pos, ':'); diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index aa56562bd..0d7310d17 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -3350,6 +3350,10 @@ own_ip_addr=127.0.0.1 # (channel switch operating class is needed) #ecsa_ie_only=0 # +# Include only CSA IE without ECSA IE +# (the operating class is not mentioned) +#csa_ie_only=0 + # Delay EAPOL-Key messages 1/4 and 3/4 by not sending the frame until the last # attempt (wpa_pairwise_update_count). This will trigger a timeout on all # previous attempts and thus delays the frame. (testing only) diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 97768f8e1..3d039d0e8 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -1154,6 +1154,7 @@ struct hostapd_config { double ignore_reassoc_probability; double corrupt_gtk_rekey_mic_probability; int ecsa_ie_only; + int csa_ie_only; bool delay_eapol_tx; #endif /* CONFIG_TESTING_OPTIONS */ diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 5d50a9d9f..95332dae2 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -516,6 +516,11 @@ static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid) if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class) return eid; +#ifdef CONFIG_TESTING_OPTIONS + if (hapd->iconf->csa_ie_only) + return eid; +#endif /* CONFIG_TESTING_OPTIONS */ + *eid++ = WLAN_EID_EXT_CHANSWITCH_ANN; *eid++ = 4; *eid++ = hapd->cs_block_tx; diff --git a/tests/hwsim/test_ap_csa.py b/tests/hwsim/test_ap_csa.py index ae1162c99..8adf77e68 100644 --- a/tests/hwsim/test_ap_csa.py +++ b/tests/hwsim/test_ap_csa.py @@ -172,6 +172,17 @@ def test_ap_csa_ecsa_only(dev, apdev): wait_channel_switch(dev[0], 2462) hwsim_utils.test_connectivity(dev[0], ap) +@remote_compatible +def test_ap_csa_csa_only(dev, apdev): + """AP Channel Switch, one switch with only CSA IE""" + csa_supported(dev[0]) + ap = connect(dev[0], apdev, csa_ie_only="1") + + hwsim_utils.test_connectivity(dev[0], ap) + switch_channel(ap, 10, 2462, extra="ht") + wait_channel_switch(dev[0], 2462) + hwsim_utils.test_connectivity(dev[0], ap) + @remote_compatible def test_ap_csa_invalid(dev, apdev): """AP Channel Switch - invalid channel"""