From 3f7fe8b0c6092c489ba1f7cfec6299a78c81a1c8 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic <janusz.dziedzic@iopsys.eu> Date: Wed, 1 Feb 2023 10:12:19 +0100 Subject: [PATCH] fix scan_ex mixed opclass/channels Signed-off-by: Janusz Dziedzic <janusz.dziedzic@iopsys.eu> --- wifimngr.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/wifimngr.c b/wifimngr.c index dbc01f0..f2af462 100644 --- a/wifimngr.c +++ b/wifimngr.c @@ -1894,18 +1894,31 @@ int wl_scan_ex(struct ubus_context *ctx, struct ubus_object *obj, p = &supp_chan[sum]; } + for (i = 0; i < sum; i++) { + sp.freq[idx] = wifi_channel_to_freq_ex(supp_chan[i], oper_band); + if (sp.freq[idx] < 0) { + wifimngr_err("No freq for channel %d\n", supp_chan[i]); + continue; + } + idx++; + } + for (i = 0; i < ch_idx; i++) { /* check each channel */ for (j = 0; j < sum; j++) { - if (channels[i] == supp_chan[j]) { - sp.freq[idx] = wifi_channel_to_freq_ex(channels[i], oper_band); - if (sp.freq[idx] < 0) { - wifimngr_err("No freq for channel %d\n", channels[i]); - continue; - } - idx++; + if (channels[i] == supp_chan[j]) break; - } } + + /* We already add this channel */ + if (j != sum) + continue; + + sp.freq[idx] = wifi_channel_to_freq_ex(channels[i], oper_band); + if (sp.freq[idx] < 0) { + wifimngr_err("No freq for channel %d\n", channels[i]); + continue; + } + idx++; } sp.num_freq = idx; } -- GitLab