[PATCH v3 05/11] mbssid: add non-inheritance element

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: John Crispin <john@xxxxxxxxxxx>

Add data as per IEEE Std 802.11-2020 section 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: John Crispin <john@xxxxxxxxxxx>
Co-developed-by: Sowmiya Sree Elavalagan <quic_ssreeela@xxxxxxxxxxx>
Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@xxxxxxxxxxx>
Co-developed-by: Aloka Dixit <quic_alokad@xxxxxxxxxxx>
Signed-off-by: Aloka Dixit <quic_alokad@xxxxxxxxxxx>
---
 src/ap/ap_config.h           |  1 +
 src/ap/ieee802_11.c          | 41 ++++++++++++++++++++++++++++++++++--
 src/common/ieee802_11_defs.h |  1 +
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index d09b5f85990d..f0969b1cee99 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -913,6 +913,7 @@ struct hostapd_bss_config {
 	u8 ext_capa[EXT_CAPA_MAX_LEN];
 
 	u8 rnr;
+	bool xrates_supported;
 };
 
 /**
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index ce01fae2872d..41bc450dc168 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -165,6 +165,7 @@ u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
 	int i, num, count;
 	int h2e_required;
 
+	hapd->conf->xrates_supported = 0;
 	if (hapd->iface->current_rates == NULL)
 		return eid;
 
@@ -214,6 +215,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 = 1;
 	return pos;
 }
 
@@ -7567,12 +7569,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;
@@ -7600,6 +7604,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)
 			goto mbssid_too_big;
@@ -7647,6 +7661,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;
 
@@ -7658,7 +7673,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;
 
@@ -7708,6 +7724,27 @@ 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;
+			ie_count++;
+		}
+		if (!rsnx && hostapd_wpa_ie(tx_bss, WLAN_EID_RSNX)) {
+			non_inherit_ie[ie_count] = WLAN_EID_RSNX;
+			ie_count++;
+		}
+		if (hapd->conf->xrates_supported &&
+		    !bss->conf->xrates_supported) {
+			non_inherit_ie[ie_count] = WLAN_EID_EXT_SUPP_RATES;
+			ie_count++;
+		}
+		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;
 
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 8588832674a8..28c1ac526443 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -481,6 +481,7 @@
 #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
-- 
2.31.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux