]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
mbssid: Add Non-Inheritance element
authorAloka Dixit <quic_alokad@quicinc.com>
Thu, 1 Dec 2022 03:18:37 +0000 (19:18 -0800)
committerJouni Malinen <j@w1.fi>
Fri, 2 Dec 2022 17:40:49 +0000 (19:40 +0200)
Add data per IEEE Std 802.11-2020, 9.4.2.240. Current implementation is
added for the security and extended supported rates only.

For the Extended rates element, add a new member 'xrates_supported'
which is set to 1 only if hostapd_eid_ext_supp_rates() returns success.
Without this change, there are cases where this function returns before
adding the element for the transmitting interface resulting in incorrect
addition of this element inside the MBSSID Non-Inheritance element.

Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
Co-developed-by: John Crispin <john@phrozen.org>
Signed-off-by: John Crispin <john@phrozen.org>
Co-developed-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
src/ap/ap_config.h
src/ap/hostapd.c
src/ap/hostapd.h
src/ap/ieee802_11.c
src/common/ieee802_11_defs.h

index 92293dc885cc94516852cd384ff5df17c4fb6268..46b7a478163cd77f723879ae41cfc0b5b168b1b7 100644 (file)
@@ -918,6 +918,7 @@ struct hostapd_bss_config {
 
        u8 rnr;
        char *config_id;
+       bool xrates_supported;
 };
 
 /**
index 20073a6c218b6455e4751b1d0cd92a558eb2d75c..a0f865a7b84675c4e56bad3b3cb4ec613a0839d3 100644 (file)
@@ -91,6 +91,29 @@ int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
 }
 
 
+struct hostapd_data * hostapd_mbssid_get_tx_bss(struct hostapd_data *hapd)
+{
+       if (hapd->iconf->mbssid)
+               return hapd->iface->bss[0];
+
+       return hapd;
+}
+
+
+int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd)
+{
+       if (hapd->iconf->mbssid) {
+               size_t i;
+
+               for (i = 1; i < hapd->iface->num_bss; i++)
+                       if (hapd->iface->bss[i] == hapd)
+                               return i;
+       }
+
+       return 0;
+}
+
+
 void hostapd_reconfig_encryption(struct hostapd_data *hapd)
 {
        if (hapd->wpa_auth)
index e945a211e2e7c1d62a719f9542875fda9a9d4ef5..ed2ff4587729785590b35914c219096745d77ec3 100644 (file)
@@ -749,5 +749,7 @@ void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
 #endif /* CONFIG_FST */
 
 int hostapd_set_acl(struct hostapd_data *hapd);
+struct hostapd_data * hostapd_mbssid_get_tx_bss(struct hostapd_data *hapd);
+int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd);
 
 #endif /* HOSTAPD_H */
index 5ed91b4f389ae2200b9c8bf3437e3bf2e8f2c264..756f3af9b5d699378167833f84b54f23160d26f2 100644 (file)
@@ -162,6 +162,7 @@ u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
        int i, num, count;
        int h2e_required;
 
+       hapd->conf->xrates_supported = false;
        if (hapd->iface->current_rates == NULL)
                return eid;
 
@@ -211,6 +212,7 @@ u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
                        *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY;
        }
 
+       hapd->conf->xrates_supported = true;
        return pos;
 }
 
@@ -6726,12 +6728,14 @@ u8 * hostapd_eid_rnr(struct hostapd_data *hapd, u8 *eid, u32 type)
 static size_t hostapd_eid_mbssid_elem_len(struct hostapd_data *hapd,
                                          u32 frame_type, size_t *bss_index)
 {
+       struct hostapd_data *tx_bss = hostapd_mbssid_get_tx_bss(hapd);
        size_t len = 3, i;
 
        for (i = *bss_index; i < hapd->iface->num_bss; i++) {
                struct hostapd_data *bss = hapd->iface->bss[i];
-               const u8 *auth, *rsn, *rsnx;
+               const u8 *auth, *rsn = NULL, *rsnx = NULL;
                size_t nontx_profile_len, auth_len;
+               u8 ie_count = 0;
 
                if (!bss || !bss->conf || !bss->started)
                        continue;
@@ -6759,6 +6763,16 @@ static size_t hostapd_eid_mbssid_elem_len(struct hostapd_data *hapd,
                        if (rsnx)
                                nontx_profile_len += 2 + rsnx[1];
                }
+               if (!rsn && hostapd_wpa_ie(tx_bss, WLAN_EID_RSN))
+                       ie_count++;
+               if (!rsnx && hostapd_wpa_ie(tx_bss, WLAN_EID_RSNX))
+                       ie_count++;
+               if (bss->conf->xrates_supported)
+                       nontx_profile_len += 8;
+               else if (hapd->conf->xrates_supported)
+                       ie_count++;
+               if (ie_count)
+                       nontx_profile_len += 4 + ie_count;
 
                if (len + nontx_profile_len > 255)
                        break;
@@ -6805,6 +6819,7 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
                                    u32 frame_type, u8 max_bssid_indicator,
                                    size_t *bss_index, u8 elem_count)
 {
+       struct hostapd_data *tx_bss = hostapd_mbssid_get_tx_bss(hapd);
        size_t i;
        u8 *eid_len_offset, *max_bssid_indicator_offset;
 
@@ -6816,7 +6831,8 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
                struct hostapd_data *bss = hapd->iface->bss[i];
                struct hostapd_bss_config *conf;
                u8 *eid_len_pos, *nontx_bss_start = eid;
-               const u8 *auth, *rsn, *rsnx;
+               const u8 *auth, *rsn = NULL, *rsnx = NULL;
+               u8 ie_count = 0, non_inherit_ie[3];
                size_t auth_len = 0;
                u16 capab_info;
 
@@ -6868,6 +6884,21 @@ static u8 * hostapd_eid_mbssid_elem(struct hostapd_data *hapd, u8 *eid, u8 *end,
                                eid += 2 + rsnx[1];
                        }
                }
+               if (!rsn && hostapd_wpa_ie(tx_bss, WLAN_EID_RSN))
+                       non_inherit_ie[ie_count++] = WLAN_EID_RSN;
+               if (!rsnx && hostapd_wpa_ie(tx_bss, WLAN_EID_RSNX))
+                       non_inherit_ie[ie_count++] = WLAN_EID_RSNX;
+               if (hapd->conf->xrates_supported &&
+                   !bss->conf->xrates_supported)
+                       non_inherit_ie[ie_count++] = WLAN_EID_EXT_SUPP_RATES;
+               if (ie_count) {
+                       *eid++ = WLAN_EID_EXTENSION;
+                       *eid++ = 2 + ie_count;
+                       *eid++ = WLAN_EID_EXT_NON_INHERITANCE;
+                       *eid++ = ie_count;
+                       os_memcpy(eid, non_inherit_ie, ie_count);
+                       eid += ie_count;
+               }
 
                *eid_len_pos = (eid - eid_len_pos) - 1;
 
index 023bbc3324aa0b6b6cd0989b8583916539f87254..ed0051e7bb02abcbd7b8a7e12e9d73797567123e 100644 (file)
 #define WLAN_EID_EXT_SPATIAL_REUSE 39
 #define WLAN_EID_EXT_COLOR_CHANGE_ANNOUNCEMENT 42
 #define WLAN_EID_EXT_OCV_OCI 54
+#define WLAN_EID_EXT_NON_INHERITANCE 56
 #define WLAN_EID_EXT_SHORT_SSID_LIST 58
 #define WLAN_EID_EXT_HE_6GHZ_BAND_CAP 59
 #define WLAN_EID_EXT_EDMG_CAPABILITIES 61