From f41d55da023ab51b6197fb2c3d37afca141bdc9a Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Wed, 14 May 2014 13:11:44 +0530 Subject: [PATCH] hostapd: Check for overlapping 20 MHz BSS before starting 20/40 MHz BSS Before starting a 20/40 MHz BSS on the 2.4 GHz band, a 40-MHz-capable HT AP is required by the rules defined in IEEE Std 802.11-2012 10.15.5 to examine the channels of the current operational regulatory domain to determine whether the operation of a 20/40 MHz BSS might unfairly interfere with the operation of existing 20 MHz BSSs. The AP (or some of its associated HT STAs) is required to scan all of the channels of the current regulatory domain in order to ascertain the operating channels of any existing 20 MHz BSSs and 20/40 MHz BSSs. (IEEE 802.11-2012 S.5.2 Establishing a 20/40 MHz BSS). Add the check for an overlapping 20 MHz BSS to the initial AP scan for the P == OT_i case in 10.15.3.2. Signed-off-by: Rajkumar Manoharan --- src/ap/hw_features.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index b36183452..4e66d1b73 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -395,6 +395,36 @@ static int ieee80211n_check_40mhz_5g(struct hostapd_iface *iface, } +static int ieee80211n_check_20mhz_bss(struct wpa_scan_res *bss, int pri_freq, + int start, int end) +{ + struct ieee802_11_elems elems; + struct ieee80211_ht_operation *oper; + + if (bss->freq < start || bss->freq > end || bss->freq == pri_freq) + return 0; + + ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems, 0); + if (!elems.ht_capabilities) { + wpa_printf(MSG_DEBUG, "Found overlapping legacy BSS: " + MACSTR " freq=%d", MAC2STR(bss->bssid), bss->freq); + return 1; + } + + if (elems.ht_operation && + elems.ht_operation_len >= sizeof(*oper)) { + oper = (struct ieee80211_ht_operation *) elems.ht_operation; + if (oper->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK) + return 0; + + wpa_printf(MSG_DEBUG, "Found overlapping 20 MHz HT BSS: " + MACSTR " freq=%d", MAC2STR(bss->bssid), bss->freq); + return 1; + } + return 0; +} + + static int ieee80211n_check_40mhz_2g4(struct hostapd_iface *iface, struct wpa_scan_results *scan_res) { @@ -418,6 +448,14 @@ static int ieee80211n_check_40mhz_2g4(struct hostapd_iface *iface, int sec_chan, pri_chan; struct ieee802_11_elems elems; + /* Check for overlapping 20 MHz BSS */ + if (ieee80211n_check_20mhz_bss(bss, pri_freq, affected_start, + affected_end)) { + wpa_printf(MSG_DEBUG, + "Overlapping 20 MHz BSS is found"); + return 0; + } + ieee80211n_get_pri_sec_chan(bss, &pri_chan, &sec_chan); if (sec_chan) {