From 3904c207eebe990450593a6615f1ddd6f9c2d3c0 Mon Sep 17 00:00:00 2001 From: Hyy2001X <1804430051@qq.com> Date: Tue, 3 Aug 2021 18:40:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=20patch=20=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CustomFiles/mac80211.sh | 192 -------------------- CustomFiles/mac80211_d-team_newifi-d2.patch | 21 +++ 2 files changed, 21 insertions(+), 192 deletions(-) delete mode 100755 CustomFiles/mac80211.sh create mode 100644 CustomFiles/mac80211_d-team_newifi-d2.patch diff --git a/CustomFiles/mac80211.sh b/CustomFiles/mac80211.sh deleted file mode 100755 index c8884f4..0000000 --- a/CustomFiles/mac80211.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/sh - -append DRIVERS "mac80211" - -lookup_phy() { - [ -n "$phy" ] && { - [ -d /sys/class/ieee80211/$phy ] && return - } - - local devpath - config_get devpath "$device" path - [ -n "$devpath" ] && { - phy="$(iwinfo nl80211 phyname "path=$devpath")" - [ -n "$phy" ] && return - } - - local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')" - [ -n "$macaddr" ] && { - for _phy in /sys/class/ieee80211/*; do - [ -e "$_phy" ] || continue - - [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue - phy="${_phy##*/}" - return - done - } - phy= - return -} - -find_mac80211_phy() { - local device="$1" - - config_get phy "$device" phy - lookup_phy - [ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || { - echo "PHY for wifi device $1 not found" - return 1 - } - config_set "$device" phy "$phy" - - config_get macaddr "$device" macaddr - [ -z "$macaddr" ] && { - config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)" - } - - return 0 -} - -check_mac80211_device() { - config_get phy "$1" phy - [ -z "$phy" ] && { - find_mac80211_phy "$1" >/dev/null || return 0 - config_get phy "$1" phy - } - [ "$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 - while :; do - config_get type "radio$devidx" type - [ -n "$type" ] || break - devidx=$(($devidx + 1)) - done - - for _dev in /sys/class/ieee80211/*; do - [ -e "$_dev" ] || continue - - dev="${_dev##*/}" - - found=0 - config_foreach check_mac80211_device wifi-device - [ "$found" -gt 0 ] && continue - - mode_band="" - channel="" - htmode="" - ht_capab="" - - get_band_defaults "$dev" - - path="$(iwinfo nl80211 path "$dev")" - if [ -n "$path" ]; then - dev_id="set wireless.radio${devidx}.path='$path'" - else - dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" - fi - - uci -q batch <<-EOF - set wireless.radio${devidx}=wifi-device - set wireless.radio${devidx}.type=mac80211 - ${dev_id} - 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_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 - - devidx=$(($devidx + 1)) - done -} diff --git a/CustomFiles/mac80211_d-team_newifi-d2.patch b/CustomFiles/mac80211_d-team_newifi-d2.patch new file mode 100644 index 0000000..5627cf6 --- /dev/null +++ b/CustomFiles/mac80211_d-team_newifi-d2.patch @@ -0,0 +1,21 @@ +--- mac80211.sh1 2021-08-03 17:06:58.508824374 +0800 ++++ mac80211.sh2 2021-08-03 17:07:20.578410189 +0800 +@@ -174,14 +174,15 @@ detect_mac80211() { + 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.radio${devidx}.country=US +- ++ + set wireless.default_radio${devidx}=wifi-iface + set wireless.default_radio${devidx}.device=radio${devidx} ++ 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}.ssid=OpenWrt + set wireless.default_radio${devidx}.encryption=none + EOF + uci -q commit wireless