From: Neo Jou Date: Mon, 13 Jan 2020 08:31:28 +0000 (+0800) Subject: ACS: Extend acs_request_scan() to support multiple modes X-Git-Tag: hostap_2_10~1723 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=141a8815e71ba52543cead6523213880fc42ba05;p=thirdparty%2Fhostap.git ACS: Extend acs_request_scan() to support multiple modes 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 --- diff --git a/src/ap/acs.c b/src/ap/acs.c index 6554ec239..7357a4154 100644 --- a/src/ap/acs.c +++ b/src/ap/acs.c @@ -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(¶ms, 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) {