[PATCH 1/9] ap: switch pri/sec channels only if pri channel is idle

Ilan Peer ilan.peer
Wed Jun 17 06:18:13 PDT 2015


From: Eliad Peller <eliad at wizery.com>

IEEE Std 802.11-2012 (10.15.3.2) states that the secondary
channel should be a channel with no other beacons, unless
beacons are detected on both the primary and secondary
channels.

The current code doesn't check the existence of such
beacons, resulting in unnecessary switch in case
of HT20 ap on our primary channel + overlapping HT40 ap.

Add check to consider this switch only if there are
no beacons on the primary channel.

While at it, remove the redundant "match" variable
and return immediately if similar ap was found.

Signed-off-by: Eliad Peller <eliadx.peller at intel.com>
---
 src/common/hw_features_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c
index e61f824..f09ad33 100644
--- a/src/common/hw_features_common.c
+++ b/src/common/hw_features_common.c
@@ -174,7 +174,6 @@ int check_40mhz_5g(struct hostapd_hw_modes *mode,
 	int pri_freq, sec_freq, pri_bss, sec_bss;
 	int bss_pri_chan, bss_sec_chan;
 	size_t i;
-	int match;
 
 	if (!mode || !scan_res || !pri_chan || !sec_chan)
 		return 0;
@@ -208,17 +207,20 @@ int check_40mhz_5g(struct hostapd_hw_modes *mode,
 	 * channels that we are about to use (if already mixed order in
 	 * existing BSSes, use own preference).
 	 */
-	match = 0;
 	for (i = 0; i < scan_res->num; i++) {
 		struct wpa_scan_res *bss = scan_res->res[i];
 		get_pri_sec_chan(bss, &bss_pri_chan, &bss_sec_chan);
 		if (pri_chan == bss_pri_chan &&
 		    sec_chan == bss_sec_chan) {
-			match = 1;
-			break;
+			return 1;
 		}
 	}
-	if (!match) {
+
+	/*
+	 * If there are no beacons on our primary channel, switch our own
+	 * primary and secondary channel if an overlapping AP is found.
+	 */
+	if (!pri_bss) {
 		for (i = 0; i < scan_res->num; i++) {
 			struct wpa_scan_res *bss = scan_res->res[i];
 			get_pri_sec_chan(bss, &bss_pri_chan, &bss_sec_chan);
-- 
1.9.1




More information about the Hostap mailing list