]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP: A helper function for determining whether the AP is an SP AP
authorJouni Malinen <j@w1.fi>
Fri, 22 Dec 2023 18:57:53 +0000 (20:57 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 22 Dec 2023 18:57:53 +0000 (20:57 +0200)
Get rid of unnecessary code duplication.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/beacon.c
src/ap/ieee802_11.c
src/common/ieee802_11_defs.h

index 04bfffffe5dd73dd4d3dec9ff9d58f860b9ea02d..ee1f027921fc305c30b37ac768ccd4d68fd73829 100644 (file)
@@ -580,20 +580,14 @@ static size_t he_elem_len(struct hostapd_data *hapd)
                        3 + sizeof(struct ieee80211_he_6ghz_band_cap);
                /* An additional Transmit Power Envelope element for
                 * subordinate client */
-               if (hapd->iconf->he_6ghz_reg_pwr_type ==
-                   HE_REG_INFO_6GHZ_AP_TYPE_INDOOR ||
-                   hapd->iconf->he_6ghz_reg_pwr_type ==
-                   HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP)
+               if (he_reg_is_sp(hapd->iconf->he_6ghz_reg_pwr_type))
                        len += 4;
 
                /* An additional Transmit Power Envelope element for
                 * default client with unit interpretation of regulatory
                 * client EIRP */
                if (hapd->iconf->reg_def_cli_eirp != -1 &&
-                   (hapd->iconf->he_6ghz_reg_pwr_type ==
-                    HE_REG_INFO_6GHZ_AP_TYPE_SP ||
-                    hapd->iconf->he_6ghz_reg_pwr_type ==
-                    HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP))
+                   he_reg_is_sp(hapd->iconf->he_6ghz_reg_pwr_type))
                        len += 4;
        }
 #endif /* CONFIG_IEEE80211AX */
index 8f61766a7e526754c4992a52725d10dac22e6c24..a939ad35e29a236a4e290ba3ef316e17f11154c0 100644 (file)
@@ -7077,10 +7077,7 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid)
 
                /* Indoor Access Point must include an additional TPE for
                 * subordinate devices */
-               if (iconf->he_6ghz_reg_pwr_type ==
-                   HE_REG_INFO_6GHZ_AP_TYPE_INDOOR ||
-                   iconf->he_6ghz_reg_pwr_type ==
-                   HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP) {
+               if (he_reg_is_sp(iconf->he_6ghz_reg_pwr_type)) {
                        /* TODO: Extract PSD limits from channel data */
                        if (hapd->iconf->reg_sub_cli_eirp_psd != -1)
                                tx_pwr = hapd->iconf->reg_sub_cli_eirp_psd;
@@ -7093,10 +7090,7 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid)
                }
 
                if (iconf->reg_def_cli_eirp != -1 &&
-                   (iconf->he_6ghz_reg_pwr_type ==
-                    HE_REG_INFO_6GHZ_AP_TYPE_SP ||
-                    iconf->he_6ghz_reg_pwr_type ==
-                    HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP))
+                   he_reg_is_sp(iconf->he_6ghz_reg_pwr_type))
                        eid = hostapd_add_tpe_info(
                                eid, tx_pwr_count, REGULATORY_CLIENT_EIRP,
                                REG_DEFAULT_CLIENT,
index 8ffc199aefe2f012b69ebcbc4e9506dbcbe2c2fe..2757ba7f8d81a4c1799c4fb30e02e0f5b90746e4 100644 (file)
@@ -2461,6 +2461,12 @@ enum he_reg_info_6ghz_ap_type {
        HE_REG_INFO_6GHZ_AP_TYPE_MAX = HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP,
 };
 
+static inline bool he_reg_is_sp(enum he_reg_info_6ghz_ap_type type)
+{
+       return type == HE_REG_INFO_6GHZ_AP_TYPE_SP ||
+               type == HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP;
+}
+
 /* Spatial Reuse defines */
 #define SPATIAL_REUSE_SRP_DISALLOWED           BIT(0)
 #define SPATIAL_REUSE_NON_SRG_OBSS_PD_SR_DISALLOWED    BIT(1)