合并上游改动

This commit is contained in:
Hyy2001X 2021-06-17 19:27:41 +08:00 committed by GitHub
parent 9e1b679d3d
commit 256760331a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 91 additions and 26 deletions

View File

@ -1,5 +1,4 @@
#!/bin/sh
. /lib/netifd/mac80211.sh
append DRIVERS "mac80211"
@ -11,7 +10,7 @@ lookup_phy() {
local devpath
config_get devpath "$device" path
[ -n "$devpath" ] && {
phy="$(mac80211_path_to_phy "$devpath")"
phy="$(iwinfo nl80211 phyname "path=$devpath")"
[ -n "$phy" ] && return
}
@ -57,6 +56,85 @@ check_mac80211_device() {
[ "$phy" = "$dev" ] && found=1
}
__get_band_defaults() {
local phy="$1"
( iw phy "$phy" info; echo ) | awk '
BEGIN {
bands = ""
}
($1 == "Band" || $1 == "") && band {
if (channel) {
mode="NOHT"
if (ht) mode="HT20"
if (vht && band != "1:") mode="VHT80"
if (he) mode="HE80"
if (he && band == "1:") mode="HE20"
sub("\\[", "", channel)
sub("\\]", "", channel)
bands = bands band channel ":" mode " "
}
band=""
}
$1 == "Band" {
band = $2
channel = ""
vht = ""
ht = ""
he = ""
}
$0 ~ "Capabilities:" {
ht=1
}
$0 ~ "VHT Capabilities" {
vht=1
}
$0 ~ "HE Iftypes" {
he=1
}
$1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
channel = $4
}
END {
print bands
}'
}
get_band_defaults() {
local phy="$1"
for c in $(__get_band_defaults "$phy"); do
local band="${c%%:*}"
c="${c#*:}"
local chan="${c%%:*}"
c="${c#*:}"
local mode="${c%%:*}"
case "$band" in
1) band=2g;;
2) band=5g;;
3) band=60g;;
4) band=6g;;
*) band="";;
esac
[ -n "$band" ] || continue
[ -n "$mode_band" -a "$band" = "6g" ] && return
mode_band="$band"
channel="$chan"
htmode="$mode"
done
}
detect_mac80211() {
devidx=0
config_load wireless
@ -75,28 +153,14 @@ detect_mac80211() {
config_foreach check_mac80211_device wifi-device
[ "$found" -gt 0 ] && continue
mode_band="g"
channel="11"
mode_band=""
channel=""
htmode=""
ht_capab=""
iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
get_band_defaults "$dev"
iw phy "$dev" info | grep -q '\* 5... MHz \[' && {
mode_band="a"
channel=$(iw phy "$dev" info | grep '\* 5... MHz \[' | grep '(disabled)' -v -m 1 | sed 's/[^[]*\[\|\].*//g')
iw phy "$dev" info | grep -q 'VHT Capabilities' && htmode="VHT80"
}
iw phy "$dev" info | grep -q '\* 5.... MHz \[' && {
mode_band="ad"
channel=$(iw phy "$dev" info | grep '\* 5.... MHz \[' | grep '(disabled)' -v -m 1 | sed 's/[^[]*\[\|\|\].*//g')
iw phy "$dev" info | grep -q 'Capabilities:' && htmode="HT20"
}
[ -n "$htmode" ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode"
path="$(mac80211_phy_to_path "$dev")"
path="$(iwinfo nl80211 path "$dev")"
if [ -n "$path" ]; then
dev_id="set wireless.radio${devidx}.path='$path'"
else
@ -106,18 +170,19 @@ detect_mac80211() {
uci -q batch <<-EOF
set wireless.radio${devidx}=wifi-device
set wireless.radio${devidx}.type=mac80211
set wireless.radio${devidx}.channel=${channel}
set wireless.radio${devidx}.hwmode=11${mode_band}
${dev_id}
${ht_capab}
set wireless.radio${devidx}.disabled=0
set wireless.radio${devidx}.channel=${channel}
set wireless.radio${devidx}.band=${mode_band}
set wireless.radio${devidx}.htmode=$htmode
set wireless.radio${devidx}.country=CN
set wireless.radio${devidx}.disabled=0
set wireless.default_radio${devidx}=wifi-iface
set wireless.default_radio${devidx}.device=radio${devidx}
set wireless.default_radio${devidx}.network=lan
set wireless.default_radio${devidx}.mode=ap
set wireless.default_radio0.ssid=OpenWrt_2.4G
set wireless.default_radio1.ssid=OpenWrt_5G
set wireless.default_radio${devidx}.network=lan
set wireless.default_radio${devidx}.mode=ap
set wireless.default_radio${devidx}.encryption=none
EOF
uci -q commit wireless