mac80211: make use of the new 'band' option
Use it to look up frequencies only in the configured band to better deal with channel number overlap Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
db072fdc9e
commit
8b8c1cb09b
@ -26,7 +26,6 @@ drv_mac80211_init_device_config() {
|
|||||||
hostapd_common_add_device_config
|
hostapd_common_add_device_config
|
||||||
|
|
||||||
config_add_string path phy 'macaddr:macaddr'
|
config_add_string path phy 'macaddr:macaddr'
|
||||||
config_add_string hwmode
|
|
||||||
config_add_string tx_burst
|
config_add_string tx_burst
|
||||||
config_add_string distance
|
config_add_string distance
|
||||||
config_add_int beacon_int chanbw frag rts
|
config_add_int beacon_int chanbw frag rts
|
||||||
@ -689,14 +688,8 @@ mac80211_prepare_iw_htmode() {
|
|||||||
case "$htmode" in
|
case "$htmode" in
|
||||||
VHT20|HT20) iw_htmode=HT20;;
|
VHT20|HT20) iw_htmode=HT20;;
|
||||||
HT40*|VHT40|VHT160)
|
HT40*|VHT40|VHT160)
|
||||||
case "$hwmode" in
|
case "$band" in
|
||||||
a)
|
2g)
|
||||||
case "$(( ($channel / 4) % 2 ))" in
|
|
||||||
1) iw_htmode="HT40+" ;;
|
|
||||||
0) iw_htmode="HT40-";;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
case "$htmode" in
|
case "$htmode" in
|
||||||
HT40+) iw_htmode="HT40+";;
|
HT40+) iw_htmode="HT40+";;
|
||||||
HT40-) iw_htmode="HT40-";;
|
HT40-) iw_htmode="HT40-";;
|
||||||
@ -709,6 +702,12 @@ mac80211_prepare_iw_htmode() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
case "$(( ($channel / 4) % 2 ))" in
|
||||||
|
1) iw_htmode="HT40+" ;;
|
||||||
|
0) iw_htmode="HT40-";;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
[ "$auto_channel" -gt 0 ] && iw_htmode="HT40+"
|
[ "$auto_channel" -gt 0 ] && iw_htmode="HT40+"
|
||||||
;;
|
;;
|
||||||
@ -818,7 +817,6 @@ mac80211_setup_vif() {
|
|||||||
mesh)
|
mesh)
|
||||||
wireless_vif_parse_encryption
|
wireless_vif_parse_encryption
|
||||||
[ -z "$htmode" ] && htmode="NOHT";
|
[ -z "$htmode" ] && htmode="NOHT";
|
||||||
freq="$(get_freq "$phy" "$channel")"
|
|
||||||
if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ] || chan_is_dfs "$phy" "$channel"; then
|
if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ] || chan_is_dfs "$phy" "$channel"; then
|
||||||
mac80211_setup_supplicant $vif_enable || failed=1
|
mac80211_setup_supplicant $vif_enable || failed=1
|
||||||
else
|
else
|
||||||
@ -832,7 +830,6 @@ mac80211_setup_vif() {
|
|||||||
adhoc)
|
adhoc)
|
||||||
wireless_vif_parse_encryption
|
wireless_vif_parse_encryption
|
||||||
if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
|
if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
|
||||||
freq="$(get_freq "$phy" "$channel")"
|
|
||||||
mac80211_setup_supplicant_noctl $vif_enable || failed=1
|
mac80211_setup_supplicant_noctl $vif_enable || failed=1
|
||||||
else
|
else
|
||||||
mac80211_setup_adhoc $vif_enable
|
mac80211_setup_adhoc $vif_enable
|
||||||
@ -849,10 +846,30 @@ mac80211_setup_vif() {
|
|||||||
|
|
||||||
get_freq() {
|
get_freq() {
|
||||||
local phy="$1"
|
local phy="$1"
|
||||||
local chan="$2"
|
local channel="$2"
|
||||||
iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
|
local band="$3"
|
||||||
|
|
||||||
|
case "$band" in
|
||||||
|
2g) band="1:";;
|
||||||
|
5g) band="2:";;
|
||||||
|
60g) band="3:";;
|
||||||
|
6g) band="4:";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
iw "$phy" info | awk -v band="$band" -v channel="[$channel]" '
|
||||||
|
|
||||||
|
$1 ~ /Band/ {
|
||||||
|
band_match = band == $2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
band_match && $3 == "MHz" && $4 == channel {
|
||||||
|
print $2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
chan_is_dfs() {
|
chan_is_dfs() {
|
||||||
local phy="$1"
|
local phy="$1"
|
||||||
local chan="$2"
|
local chan="$2"
|
||||||
@ -935,7 +952,7 @@ drv_mac80211_setup() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# convert channel to frequency
|
# convert channel to frequency
|
||||||
[ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel")"
|
[ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel" "$band")"
|
||||||
|
|
||||||
[ -n "$country" ] && {
|
[ -n "$country" ] && {
|
||||||
iw reg get | grep -q "^country $country:" || {
|
iw reg get | grep -q "^country $country:" || {
|
||||||
|
Loading…
Reference in New Issue
Block a user