Patchwork [1/4] hostapd: DFS VHT80 fix available channels list

login
register
mail settings
Submitter Janusz.Dziedzic@tieto.com
Date Oct. 24, 2013, 3:40 p.m.
Message ID <1382629228-8895-1-git-send-email-janusz.dziedzic@tieto.com>
Download mbox | patch
Permalink /patch/285951/
State Accepted
Commit 1dc17db34ac47a4528024a5a0f75893b99928f19
Headers show

Comments

Janusz.Dziedzic@tieto.com - Oct. 24, 2013, 3:40 p.m.
Add VHT80 available channels table. This table
contains first available channel. We will choose
also first channel as a control one.

Signed-hostap: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 src/ap/dfs.c |   30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
Jouni Malinen - Oct. 26, 2013, 2:55 p.m.
On Thu, Oct 24, 2013 at 05:40:25PM +0200, Janusz Dziedzic wrote:
> Add VHT80 available channels table. This table
> contains first available channel. We will choose
> also first channel as a control one.

Thanks, all four patches applied.

Patch

diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index 37bbd20..70696cd 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -55,13 +55,33 @@  static int dfs_channel_available(struct hostapd_channel_data *chan)
 }
 
 
-static int dfs_is_ht40_allowed(struct hostapd_channel_data *chan)
+static int dfs_is_chan_allowed(struct hostapd_channel_data *chan, int n_chans)
 {
-	int allowed[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157,
-			  184, 192 };
+	/* Tables contains first valid channel number base on width.
+	 * We will also choose this first channel as a control one. */
+	int allowed_40[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157,
+			     184, 192 };
+	/* VHT80, valid channels base on central freq: 42, 58, 106, 122, 138, 155 */
+	int allowed_80[] = { 36, 52, 100, 116, 132, 149 };
+	int *allowed = allowed_40;
+	int allowed_no = 0;
 	unsigned int i;
 
-	for (i = 0; i < sizeof(allowed) / sizeof(allowed[0]); i++) {
+	switch (n_chans) {
+	case 2:
+		allowed = allowed_40;
+		allowed_no = sizeof(allowed_40) / sizeof(allowed_40[0]);
+		break;
+	case 4:
+		allowed = allowed_80;
+		allowed_no = sizeof(allowed_80) / sizeof(allowed_80[0]);
+		break;
+	default:
+		wpa_printf(MSG_DEBUG, "Unknown width for %d channels", n_chans);
+		break;
+	}
+
+	for (i = 0; i < allowed_no; i++) {
 		if (chan->chan == allowed[i])
 			return 1;
 	}
@@ -92,7 +112,7 @@  static int dfs_find_channel(struct hostapd_data *hapd,
 		/* Skip HT40/VHT uncompatible channels */
 		if (hapd->iconf->ieee80211n &&
 		    hapd->iconf->secondary_channel) {
-			if (!dfs_is_ht40_allowed(chan))
+			if (!dfs_is_chan_allowed(chan, n_chans))
 				continue;
 
 			for (j = 1; j < n_chans; j++) {