]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ACS: Extend acs_request_scan() to support multiple modes
authorNeo Jou <neojou@gmail.com>
Mon, 13 Jan 2020 08:31:28 +0000 (16:31 +0800)
committerJouni Malinen <j@w1.fi>
Sat, 29 Feb 2020 09:23:03 +0000 (11:23 +0200)
Add suitable channel frequencies from all modes into the scan parameters
when a single mode is not specified for ACS. This is preparation for
being able to support hw_mode=any to select the best channel from any
supported mode.

Signed-off-by: Neo Jou <neojou@gmail.com>
src/ap/acs.c

index 6554ec239053a9ab340c6242ec7cc22000d6f042..7357a41548637837ba4f047dc6b50c982c2d88bc 100644 (file)
@@ -975,29 +975,56 @@ fail:
 }
 
 
+static int * acs_request_scan_add_freqs(struct hostapd_iface *iface,
+                                       struct hostapd_hw_modes *mode,
+                                       int *freq)
+{
+       struct hostapd_channel_data *chan;
+       int i;
+
+       for (i = 0; i < mode->num_channels; i++) {
+               chan = &mode->channels[i];
+               if (chan->flag & HOSTAPD_CHAN_DISABLED)
+                       continue;
+
+               if (!is_in_chanlist(iface, chan))
+                       continue;
+
+               *freq++ = chan->freq;
+       }
+
+       return freq;
+}
+
+
 static int acs_request_scan(struct hostapd_iface *iface)
 {
        struct wpa_driver_scan_params params;
-       struct hostapd_channel_data *chan;
        int i, *freq;
+       int num_channels;
+       struct hostapd_hw_modes *mode;
 
        os_memset(&params, 0, sizeof(params));
-       params.freqs = os_calloc(iface->current_mode->num_channels + 1,
-                                sizeof(params.freqs[0]));
+
+       num_channels = 0;
+       for (i = 0; i < iface->num_hw_features; i++) {
+               mode = &iface->hw_features[i];
+               if (!hostapd_hw_skip_mode(iface, mode))
+                       num_channels += mode->num_channels;
+       }
+
+       params.freqs = os_calloc(num_channels + 1, sizeof(params.freqs[0]));
        if (params.freqs == NULL)
                return -1;
 
        freq = params.freqs;
-       for (i = 0; i < iface->current_mode->num_channels; i++) {
-               chan = &iface->current_mode->channels[i];
-               if (chan->flag & HOSTAPD_CHAN_DISABLED)
-                       continue;
 
-               if (!is_in_chanlist(iface, chan))
-                       continue;
-
-               *freq++ = chan->freq;
+       for (i = 0; i < iface->num_hw_features; i++) {
+               mode = &iface->hw_features[i];
+               if (!hostapd_hw_skip_mode(iface, mode))
+                       freq = acs_request_scan_add_freqs(iface, mode, freq);
        }
+
        *freq = 0;
 
        if (params.freqs == freq) {