[LEDE-DEV] mac80211.sh: adjust HT40 control channel

Submitted by Eduardo Abinader on April 20, 2017, 1:49 p.m.

Details

Message ID 20170420134941.11071-1-eduardoabinader@gmail.com
State New
Headers show

Commit Message

Eduardo Abinader April 20, 2017, 1:49 p.m.
For some channels, like FCC 165, the determination of the control
channel is being done disregarding mac80211 config, which is
HT40- (actually the channel is 20Mhz, we use here hostapd
fallback to 20MHz). Hence, this patch let the previous logic decide
for the cases where HT40+- are allowed and update ht40_capab,
if only one of these configs is allowed (+ or -).

Signed-off-by: Eduardo Abinader <eduardoabinader@gmail.com>
---
 .../mac80211/files/lib/netifd/wireless/mac80211.sh   | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Patch hide | download patch | download mbox

diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
index 9ebd76be49..8b55331dbf 100644
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -84,6 +84,23 @@  mac80211_add_capabilities() {
 	export -n -- "$__var=$__out"
 }
 
+mac80211_get_ht40_capab() {
+	phy=$1
+	channel=$2
+
+	freq=$(get_freq $phy $channel)
+	[ -z "$freq" ] && return
+
+	value=$(iw phy $phy channels|grep -vi disabled)
+
+	[ -z "$(echo "$value"|grep "$freq")" ] && return
+	value=$(echo $value|sed 's/'$freq'[^{*}]*widths:/{}/'|sed 's/.*{} //'|sed 's/ \*.*//')
+
+	[ $(echo $value|grep -o HT40|wc -l) -gt 1 ] && return
+
+	echo "$value"|sed 's/.*HT40//'|sed 's/ .*//'
+}
+
 mac80211_hostapd_setup_base() {
 	local phy="$1"
 
@@ -121,6 +138,9 @@  mac80211_hostapd_setup_base() {
 					esac
 				;;
 			esac
+			adjust_ht40=$(mac80211_get_ht40_capab $phy $channel)
+			[ -n "$adjust_ht40" ] && ht_capab="[HT40$adjust_ht40]"
+
 			[ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]"
 		;;
 		*) ieee80211n= ;;