[PATCH v1] mbssid: add bss index and max bss
Baligh Gasmi
gasmibal at gmail.com
Wed Dec 11 12:37:38 PST 2024
Configuring hostapd's BSSes with a custom BSSID via the `bssid` parameter
in the config file, can lead to a miss-configured Multiple BSSID Element
consequently leading to that stations fail to calculate the correct BSSID
for non-transmitting BSSs, as specified in IEEE Std 802.11-2020 section
9.4.2.45.
To ensure consistency, the configuration need to include criticals
parameters: `MaxBSSID Indicator` and `Multiple BSSID Index`. To customise
the MBSSID IE following the custom bssids as well.
This commit introduces:
- A new global parameter, `mbssid_max`, to set the `MaxBSSID Indicator`.
- A per-BSS parameter, `mbssid_index`, to explicitly set the
`Multiple BSSID Index`.
Signed-off-by: Baligh Gasmi <gasmibal at gmail.com>
---
hostapd/config_file.c | 4 ++++
src/ap/ap_config.h | 2 ++
src/ap/ieee802_11.c | 14 +++++++++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index e59e98d7c..0139d5bde 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -3964,6 +3964,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
return 1;
}
conf->mbssid = mbssid;
+ } else if (os_strcmp(buf, "mbssid_index") == 0) {
+ bss->mbssid_index = atoi(pos);
+ } else if (os_strcmp(buf, "mbssid_max") == 0) {
+ conf->mbssid_max = atoi(pos);
#endif /* CONFIG_IEEE80211AX */
} else if (os_strcmp(buf, "max_listen_interval") == 0) {
bss->max_listen_interval = atoi(pos);
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index b0ae71e1e..deb195162 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -995,6 +995,7 @@ struct hostapd_bss_config {
bool mld_indicate_disabled;
#endif /* CONFIG_TESTING_OPTIONS */
#endif /* CONFIG_IEEE80211BE */
+ int mbssid_index;
};
/**
@@ -1252,6 +1253,7 @@ struct hostapd_config {
bool channel_usage;
bool peer_to_peer_twt;
+ int mbssid_max;
};
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index c0da03f4c..3a908b082 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -3414,7 +3414,9 @@ static u8 hostapd_max_bssid_indicator(struct hostapd_data *hapd)
if (!hapd->iconf->mbssid || hapd->iface->num_bss <= 1)
return 0;
- num_bss_nontx = hapd->iface->num_bss - 1;
+ num_bss_nontx = (hapd->iface->conf->mbssid_max > 0) ?
+ hapd->iface->conf->mbssid_max - 1 :
+ hapd->iface->conf->num_bss - 1;
while (num_bss_nontx > 0) {
max_bssid_ind++;
num_bss_nontx >>= 1;
@@ -8322,6 +8324,7 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
const u8 *known_bss, size_t known_bss_len)
{
struct hostapd_data *tx_bss = hostapd_mbssid_get_tx_bss(hapd);
+ struct hostapd_bss_config *tx_conf = tx_bss->conf;
size_t i;
u8 *eid_len_offset, *max_bssid_indicator_offset;
@@ -8337,6 +8340,7 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
u8 ie_count = 0, non_inherit_ie[3];
size_t auth_len = 0;
u16 capab_info;
+ u8 mbssindex = i;
if (!bss || !bss->conf || !bss->started ||
mbssid_known_bss(i, known_bss, known_bss_len))
@@ -8356,11 +8360,15 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
*eid++ = conf->ssid.ssid_len;
os_memcpy(eid, conf->ssid.ssid, conf->ssid.ssid_len);
eid += conf->ssid.ssid_len;
+
+ if(conf->mbssid_index &&
+ ((conf->mbssid_index - tx_conf->mbssid_index) > 0))
+ mbssindex = (conf->mbssid_index - tx_conf->mbssid_index);
*eid++ = WLAN_EID_MULTIPLE_BSSID_INDEX;
if (frame_type == WLAN_FC_STYPE_BEACON) {
*eid++ = 3;
- *eid++ = i; /* BSSID Index */
+ *eid++ = mbssindex; /* BSSID Index */
if (hapd->iconf->mbssid == ENHANCED_MBSSID_ENABLED &&
(conf->dtim_period % elem_count))
conf->dtim_period = elem_count;
@@ -8376,7 +8384,7 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
/* Probe Request frame does not include DTIM Period and
* DTIM Count fields. */
*eid++ = 1;
- *eid++ = i; /* BSSID Index */
+ *eid++ = mbssindex; /* BSSID Index */
}
auth = wpa_auth_get_wpa_ie(bss->wpa_auth, &auth_len);
--
2.43.0
More information about the Hostap
mailing list