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

Eduardo Abinader eduardoabinader at gmail.com
Thu Apr 20 06:49:41 PDT 2017


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 at gmail.com>
---
 .../mac80211/files/lib/netifd/wireless/mac80211.sh   | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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= ;;
-- 
2.11.0




More information about the Lede-dev mailing list