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 <quic_akolli@quicinc.com>
Co-developed-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
This commit is contained in:
Anilkumar Kolli 2023-03-13 11:13:02 +05:30 committed by Jouni Malinen
parent 5349a45d32
commit 744295c8bc

View file

@ -2437,6 +2437,26 @@ static int hostapd_ctrl_check_freq_params(struct hostapd_freq_params *params,
{ {
u32 start_freq; 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) { switch (params->bandwidth) {
case 0: case 0:
/* bandwidth not specified: use 20 MHz by default */ /* bandwidth not specified: use 20 MHz by default */