[PATCH 2/7] ap: create hostapd_chan_width_from_freq_params
Benjamin Berg
benjamin at sipsolutions.net
Thu Jul 31 06:56:58 PDT 2025
From: Benjamin Berg <benjamin.berg at intel.com>
Split out hostapd_chan_width_from_freq_params to avoid code duplication.
Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
src/ap/hostapd.c | 23 ++++-------------------
src/ap/hostapd.h | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index f2f0c29493..cb7b199366 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -4558,34 +4558,19 @@ static int hostapd_fill_csa_settings(struct hostapd_data *hapd,
struct hostapd_iface *iface = hapd->iface;
struct hostapd_freq_params old_freq;
int ret;
- u8 chan, bandwidth;
+ enum oper_chan_width chanwidth;
+ u8 chan;
os_memset(&old_freq, 0, sizeof(old_freq));
if (!iface || !iface->freq || hapd->csa_in_progress)
return -1;
- switch (settings->freq_params.bandwidth) {
- case 80:
- if (settings->freq_params.center_freq2)
- bandwidth = CONF_OPER_CHWIDTH_80P80MHZ;
- else
- bandwidth = CONF_OPER_CHWIDTH_80MHZ;
- break;
- case 160:
- bandwidth = CONF_OPER_CHWIDTH_160MHZ;
- break;
- case 320:
- bandwidth = CONF_OPER_CHWIDTH_320MHZ;
- break;
- default:
- bandwidth = CONF_OPER_CHWIDTH_USE_HT;
- break;
- }
+ chanwidth = hostapd_chan_width_from_freq_params(&settings->freq_params);
if (ieee80211_freq_to_channel_ext(
settings->freq_params.freq,
settings->freq_params.sec_channel_offset,
- bandwidth,
+ chanwidth,
&hapd->iface->cs_oper_class,
&chan) == NUM_HOSTAPD_MODES) {
wpa_printf(MSG_DEBUG,
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index f263a6cb7f..129e0b5f79 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -899,4 +899,22 @@ static inline bool ap_pmf_enabled(struct hostapd_bss_config *conf)
conf->rsn_override_mfp_2 != NO_MGMT_FRAME_PROTECTION;
}
+static inline enum oper_chan_width
+hostapd_chan_width_from_freq_params(struct hostapd_freq_params *freq_params)
+{
+ switch (freq_params->bandwidth) {
+ case 80:
+ if (freq_params->center_freq2)
+ return CONF_OPER_CHWIDTH_80P80MHZ;
+ else
+ return CONF_OPER_CHWIDTH_80MHZ;
+ case 160:
+ return CONF_OPER_CHWIDTH_160MHZ;
+ case 320:
+ return CONF_OPER_CHWIDTH_320MHZ;
+ default:
+ return CONF_OPER_CHWIDTH_USE_HT;
+ }
+}
+
#endif /* HOSTAPD_H */
--
2.50.1
More information about the Hostap
mailing list