From d0022739c2d8ae04151a1537d960daef280ca732 Mon Sep 17 00:00:00 2001 From: Aloka Dixit Date: Tue, 15 Feb 2022 00:51:19 -0800 Subject: [PATCH 09/23] eht: add operation element in management frames Add EHT operation element in beacon, probe response and association response frames using the format described in IEEE P802.11be/D1.4, January 2022, section 9.4.2.311. Length of this field is not yet provided in this version of the specification, assume 1 byte for each field. Signed-off-by: Aloka Dixit Signed-off-by: Muna Sinada --- src/ap/beacon.c | 16 ++++++++--- src/ap/ieee802_11.c | 5 +++- src/ap/ieee802_11.h | 1 + src/ap/ieee802_11_eht.c | 51 ++++++++++++++++++++++++++++++++++++ src/common/ieee802_11_defs.h | 10 +++++++ 5 files changed, 78 insertions(+), 5 deletions(-) --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -640,8 +640,10 @@ static u8 * hostapd_gen_probe_resp(struc #endif /* CONFIG_IEEE80211AX */ #ifdef CONFIG_IEEE80211BE - if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) + if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { buflen += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); + buflen += (3 + sizeof(struct ieee80211_eht_operation)); + } #endif /* CONFIG_IEEE80211BE */ buflen += hostapd_eid_mbssid_len(hapd_probed, WLAN_FC_STYPE_PROBE_RESP, @@ -786,8 +788,10 @@ static u8 * hostapd_gen_probe_resp(struc #endif /* CONFIG_IEEE80211AX */ #ifdef CONFIG_IEEE80211BE - if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) + if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { pos = hostapd_eid_eht_capab(hapd, pos, IEEE80211_MODE_AP); + pos = hostapd_eid_eht_operation(hapd, pos, IEEE80211_MODE_AP); + } #endif /* CONFIG_IEEE80211BE */ #ifdef CONFIG_IEEE80211AC @@ -1718,8 +1722,10 @@ int ieee802_11_build_ap_params(struct ho #endif /* CONFIG_IEEE80211AX */ #ifdef CONFIG_IEEE80211BE - if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) + if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { tail_len += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); + tail_len += (3 + sizeof(struct ieee80211_eht_operation)); + } #endif /* CONFIG_IEEE80211BE */ if (hapd->iconf->ema) @@ -1873,9 +1879,12 @@ int ieee802_11_build_ap_params(struct ho #endif /* CONFIG_IEEE80211AX */ #ifdef CONFIG_IEEE80211BE - if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) + if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { tailpos = hostapd_eid_eht_capab(hapd, tailpos, IEEE80211_MODE_AP); + tailpos = hostapd_eid_eht_operation(hapd, tailpos, + IEEE80211_MODE_AP); + } #endif /* CONFIG_IEEE80211BE */ #ifdef CONFIG_IEEE80211AC --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -5084,8 +5084,10 @@ static u16 send_assoc_resp(struct hostap buflen += 5 + sta->dpp_pfs->curve->prime_len; #endif /* CONFIG_DPP2 */ #ifdef CONFIG_IEEE80211BE - if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) + if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { buflen += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); + buflen += (3 + sizeof(struct ieee80211_eht_operation)); + } #endif /* CONFIG_IEEE80211BE */ buf = os_zalloc(buflen); @@ -5203,8 +5205,10 @@ static u16 send_assoc_resp(struct hostap #endif /* CONFIG_IEEE80211AX */ #ifdef CONFIG_IEEE80211BE - if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) + if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { p = hostapd_eid_eht_capab(hapd, p, IEEE80211_MODE_AP); + p = hostapd_eid_eht_operation(hapd, p, IEEE80211_MODE_AP); + } #endif /* CONFIG_IEEE80211BE */ p = hostapd_eid_ext_capab(hapd, p); --- a/src/ap/ieee802_11.h +++ b/src/ap/ieee802_11.h @@ -219,4 +219,6 @@ size_t hostapd_eid_eht_capab_len(struct enum ieee80211_op_mode opmode); u8 * hostapd_eid_eht_capab(struct hostapd_data *hapd, u8 *eid, enum ieee80211_op_mode opmode); +u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid, + enum ieee80211_op_mode opmode); #endif /* IEEE802_11_H */ --- a/src/ap/ieee802_11_eht.c +++ b/src/ap/ieee802_11_eht.c @@ -162,3 +162,60 @@ u8 * hostapd_eid_eht_capab(struct hostap *length_pos = pos - (eid + 2); return pos; } + + +u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid, + enum ieee80211_op_mode opmode) +{ + struct hostapd_hw_modes *mode; + struct ieee80211_eht_operation *oper; + u8 *pos = eid, *length_pos, chwidth, seg0 = 0; + + mode = hapd->iface->current_mode; + if (!mode) + return eid; + + if (!mode->eht_capab[opmode].eht_supported) + return eid; + + *pos++ = WLAN_EID_EXTENSION; + length_pos = pos++; + *pos++ = WLAN_EID_EXT_EHT_OPERATION; + + oper = (struct ieee80211_eht_operation *) pos; + os_memset(oper, 0, sizeof(*oper)); + + if (is_6ghz_op_class(hapd->iconf->op_class)) + chwidth = op_class_to_ch_width(hapd->iconf->op_class); + else + chwidth = hapd->iconf->eht_oper_chwidth; + + seg0 = hostapd_get_oper_centr_freq_seg0_idx(hapd->iconf); + + switch (chwidth) { + case CHANWIDTH_320MHZ: + *pos++ = EHT_OPERATION_CHANNEL_WIDTH_320MHZ; + break; + case CHANWIDTH_160MHZ: + *pos++ = EHT_OPERATION_CHANNEL_WIDTH_160MHZ; + break; + case CHANWIDTH_80MHZ: + *pos++ = EHT_OPERATION_CHANNEL_WIDTH_80MHZ; + break; + case CHANWIDTH_USE_HT: + if (seg0) + *pos++ = EHT_OPERATION_CHANNEL_WIDTH_40MHZ; + else + pos++; + break; + default: + return eid; + } + + if (!seg0) + seg0 = hapd->iconf->channel; + *pos++ = seg0; + + *length_pos = pos - (eid + 2); + return pos; +} --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -2476,6 +2476,11 @@ struct ieee80211_eht_operation { u8 optional[]; } STRUCT_PACKED; +#define EHT_OPERATION_CHANNEL_WIDTH_40MHZ 1 +#define EHT_OPERATION_CHANNEL_WIDTH_80MHZ 2 +#define EHT_OPERATION_CHANNEL_WIDTH_160MHZ 3 +#define EHT_OPERATION_CHANNEL_WIDTH_320MHZ 4 + /* IEEE P802.11be/D1.4, January 2022, section 9.4.2.313.3 */ #define EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_IDX 0 #define EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_MASK ((u8) BIT(1)) @@ -2515,6 +2520,11 @@ struct ieee80211_eht_operation { BIT(2) | BIT(3) | \ BIT(4))) +#define EHT_OPERATION_CHANNEL_WIDTH_40MHZ 1 +#define EHT_OPERATION_CHANNEL_WIDTH_80MHZ 2 +#define EHT_OPERATION_CHANNEL_WIDTH_160MHZ 3 +#define EHT_OPERATION_CHANNEL_WIDTH_320MHZ 4 + /* IEEE P802.11ay/D4.0, 9.4.2.251 - EDMG Operation element */ #define EDMG_BSS_OPERATING_CHANNELS_OFFSET 6 #define EDMG_OPERATING_CHANNEL_WIDTH_OFFSET 7