From 47dad1ed1607fd1dfc5e40ff7eb6601e292d170f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 8 Mar 2024 10:00:35 +0200 Subject: [PATCH] EHT: Move puncturing bitmap determination into a helper function Avoid duplicated implementation for this by using a shared helper function. Signed-off-by: Jouni Malinen --- src/ap/hostapd.c | 16 ++++++++++++++++ src/ap/hostapd.h | 2 ++ src/ap/ieee802_11_eht.c | 10 +--------- src/ap/ieee802_11_vht.c | 6 +----- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 0def1b918a..0b805ba107 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -4425,3 +4425,19 @@ struct hostapd_data * hostapd_mld_get_link_bss(struct hostapd_data *hapd, return NULL; } #endif /* CONFIG_IEEE80211BE */ + + +u16 hostapd_get_punct_bitmap(struct hostapd_data *hapd) +{ + u16 punct_bitmap = 0; + +#ifdef CONFIG_IEEE80211BE + punct_bitmap = hapd->iconf->punct_bitmap; +#ifdef CONFIG_TESTING_OPTIONS + if (!punct_bitmap) + punct_bitmap = hapd->conf->eht_oper_puncturing_override; +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_IEEE80211BE */ + + return punct_bitmap; +} diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 22540bb371..9be762c244 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -801,4 +801,6 @@ int hostapd_link_remove(struct hostapd_data *hapd, u32 count); if (false) #endif /* CONFIG_IEEE80211BE */ +u16 hostapd_get_punct_bitmap(struct hostapd_data *hapd); + #endif /* HOSTAPD_H */ diff --git a/src/ap/ieee802_11_eht.c b/src/ap/ieee802_11_eht.c index b599e10433..e4590b9ff7 100644 --- a/src/ap/ieee802_11_eht.c +++ b/src/ap/ieee802_11_eht.c @@ -206,19 +206,11 @@ u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid) enum oper_chan_width chwidth; size_t elen = 1 + 4; bool eht_oper_info_present; - u16 punct_bitmap = conf->punct_bitmap; + u16 punct_bitmap = hostapd_get_punct_bitmap(hapd); if (!hapd->iface->current_mode) return eid; -#ifdef CONFIG_TESTING_OPTIONS - if (!punct_bitmap && hapd->conf->eht_oper_puncturing_override) { - wpa_printf(MSG_DEBUG, "EHT: Puncturing mask override=0x%x", - hapd->conf->eht_oper_puncturing_override); - punct_bitmap = hapd->conf->eht_oper_puncturing_override; - } -#endif /* CONFIG_TESTING_OPTIONS */ - if (is_6ghz_op_class(conf->op_class)) chwidth = op_class_to_ch_width(conf->op_class); else diff --git a/src/ap/ieee802_11_vht.c b/src/ap/ieee802_11_vht.c index f942aa78c3..e92851af98 100644 --- a/src/ap/ieee802_11_vht.c +++ b/src/ap/ieee802_11_vht.c @@ -80,7 +80,7 @@ u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid) u8 seg0 = hapd->iconf->vht_oper_centr_freq_seg0_idx; u8 seg1 = hapd->iconf->vht_oper_centr_freq_seg1_idx; #ifdef CONFIG_IEEE80211BE - u16 punct_bitmap = hapd->iconf->punct_bitmap; + u16 punct_bitmap = hostapd_get_punct_bitmap(hapd); #endif /* CONFIG_IEEE80211BE */ if (is_6ghz_op_class(hapd->iconf->op_class)) @@ -93,10 +93,6 @@ u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid) os_memset(oper, 0, sizeof(*oper)); #ifdef CONFIG_IEEE80211BE -#ifdef CONFIG_TESTING_OPTIONS - if (!punct_bitmap && hapd->conf->eht_oper_puncturing_override) - punct_bitmap = hapd->conf->eht_oper_puncturing_override; -#endif /* CONFIG_TESTING_OPTIONS */ if (punct_bitmap) { punct_update_legacy_bw(punct_bitmap, hapd->iconf->channel, -- 2.47.2