[PATCH] ACS: channel selection based freqlist

[email protected] Mon, 11 May 2020 15:42:49 +0800
Newsgroups gmane.linux.drivers.hostap
Message-ID <[email protected]>
From: neo_jou <[email protected]>

When doing ACS, check freqlist also if there is the config.

Signed-off-by: neojou <[email protected]>
---
 src/ap/acs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/ap/acs.c b/src/ap/acs.c
index 5c01610..6f074db 100644
--- a/src/ap/acs.c
+++ b/src/ap/acs.c
@@ -511,6 +511,14 @@ static int is_in_chanlist(struct hostapd_iface *iface,
 	return freq_range_list_includes(&iface->conf->acs_ch_list, chan->chan);
 }
 
+static int is_in_freqlist(struct hostapd_iface *iface,
+			  struct hostapd_channel_data *chan)
+{
+	if (!iface->conf->acs_freq_list.num)
+		return 1;
+
+	return freq_range_list_includes(&iface->conf->acs_freq_list, chan->freq);
+}
 
 static void acs_survey_mode_interference_factor(
 	struct hostapd_iface *iface, struct hostapd_hw_modes *mode)
@@ -527,6 +535,9 @@ static void acs_survey_mode_interference_factor(
 		if (!is_in_chanlist(iface, chan))
 			continue;
 
+		if (!is_in_freqlist(iface, chan))
+			continue;
+
 		wpa_printf(MSG_DEBUG, "ACS: Survey analysis for channel %d (%d MHz)",
 			   chan->chan, chan->freq);
 
@@ -651,6 +662,9 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
 		if (!is_in_chanlist(iface, chan))
 			continue;
 
+		if (!is_in_freqlist(iface, chan))
+			continue;
+
 		if (!chan_bw_allowed(chan, bw, 1, 1)) {
 			wpa_printf(MSG_DEBUG,
 				   "ACS: Channel %d: BW %u is not supported",
@@ -1013,6 +1027,9 @@ static int * acs_request_scan_add_freqs(struct hostapd_iface *iface,
 		if (!is_in_chanlist(iface, chan))
 			continue;
 
+		if (!is_in_freqlist(iface, chan))
+			continue;
+
 		*freq++ = chan->freq;
 	}
 
-- 
2.7.4