]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add 6 GHz channel validation during channel switching
authorAnilkumar Kolli <quic_akolli@quicinc.com>
Mon, 13 Mar 2023 05:43:02 +0000 (11:13 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 29 Mar 2023 15:22:55 +0000 (18:22 +0300)
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 <quic_akolli@quicinc.com>
Co-developed-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
hostapd/ctrl_iface.c

index ca8c705ea15cd4f06ed15312b727b57b8cd39b1b..eb813d04ad77e008615b5ede556a7bc28dd5b156 100644 (file)
@@ -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 */