[PATCH 3/5] DFS: consider non contiguous channels

Eliad Peller eliad
Thu Mar 19 07:41:41 PDT 2015


When looking for a new operating channel, consider
the case of non-contiguous channels when checking
all the needed channels (e.g. the driver might
support channels 36,38,40, so look for channels
36+40 explicitly, instead of failing when
encountering channel 38)

Signed-off-by: Eliad Peller <eliad at wizery.com>
---
 src/ap/dfs.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index da6fd46..b11cada 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -121,6 +121,17 @@ static int dfs_is_chan_allowed(struct hostapd_channel_data *chan, int n_chans)
 	return 0;
 }
 
+static struct hostapd_channel_data *
+dfs_get_chan_data(struct hostapd_hw_modes *mode, int freq, int first_chan_idx)
+{
+	int i;
+
+	for (i = first_chan_idx; i < mode->num_channels; i++)
+		if (mode->channels[i].freq == freq)
+			return &mode->channels[i];
+
+	return NULL;
+}
 
 static int dfs_chan_range_available(struct hostapd_hw_modes *mode,
 				    int first_chan_idx, int num_chans,
@@ -135,9 +146,10 @@ static int dfs_chan_range_available(struct hostapd_hw_modes *mode,
 	first_chan = &mode->channels[first_chan_idx];
 
 	for (i = 0; i < num_chans; i++) {
-		chan = &mode->channels[first_chan_idx + i];
-
-		if (first_chan->freq + i * 20 != chan->freq)
+		chan = dfs_get_chan_data(mode,
+					 first_chan->freq + i * 20,
+					 first_chan_idx);
+		if (!chan)
 			return 0;
 
 		if (!dfs_channel_available(chan, skip_radar))
-- 
1.8.5.2.229.g4448466.dirty




More information about the Hostap mailing list