From 744295c8bc5aa51e55f9ae474561516fd4eff4ed Mon Sep 17 00:00:00 2001 From: Anilkumar Kolli Date: Mon, 13 Mar 2023 11:13:02 +0530 Subject: [PATCH] Add 6 GHz channel validation during channel switching The following command does not return FAIL, but it fails to update the beacon since the center frequency used in the command is not valid for 80 MHz bandwidth. hostapd_cli -i wlan0 chan_switch 5 6315 sec_channel_offset=1 \ center_freq1=6345 bandwidth=80 he Add condition check to validate the center frequency. Also, if user doesn't provide HE parameter in the hostapd_cli chan_switch command, by default HE should be enabled for 6 GHz frequency range. This is because, 6 GHz does not support legacy mode. Signed-off-by: Anilkumar Kolli Co-developed-by: Aditya Kumar Singh Signed-off-by: Aditya Kumar Singh --- hostapd/ctrl_iface.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index ca8c705ea..eb813d04a 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -2437,6 +2437,26 @@ static int hostapd_ctrl_check_freq_params(struct hostapd_freq_params *params, { u32 start_freq; + if (is_6ghz_freq(params->freq)) { + const int bw_idx[] = { 20, 40, 80, 160, 320 }; + int idx, bw; + + /* The 6 GHz band requires HE to be enabled. */ + params->he_enabled = 1; + + if (params->center_freq1) { + if (params->freq == 5935) + idx = (params->center_freq1 - 5925) / 5; + else + idx = (params->center_freq1 - 5950) / 5; + + bw = center_idx_to_bw_6ghz(idx); + if (bw < 0 || bw > (int) ARRAY_SIZE(bw_idx) || + bw_idx[bw] != params->bandwidth) + return -1; + } + } + switch (params->bandwidth) { case 0: /* bandwidth not specified: use 20 MHz by default */