From 716ca530e1c4515d8683c9d5be3d56b301758b66 Mon Sep 17 00:00:00 2001 From: James <> Date: Wed, 4 Nov 2015 11:49:21 +0000 Subject: trunk-47381 --- .../kernel/broadcom-wl/files/lib/wifi/broadcom.sh | 477 +++++++++++++++++++++ 1 file changed, 477 insertions(+) create mode 100644 package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh (limited to 'package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh') diff --git a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh new file mode 100644 index 0000000..a9c4de2 --- /dev/null +++ b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh @@ -0,0 +1,477 @@ +append DRIVERS "broadcom" + +scan_broadcom() { + local device="$1" + local vif vifs wds + local adhoc sta apmode mon disabled + local adhoc_if sta_if ap_if mon_if + + config_get vifs "$device" vifs + for vif in $vifs; do + config_get_bool disabled "$vif" disabled 0 + [ $disabled -eq 0 ] || continue + + local mode + config_get mode "$vif" mode + case "$mode" in + adhoc) + adhoc=1 + adhoc_if="$vif" + ;; + sta) + sta=1 + sta_if="$vif" + ;; + ap) + apmode=1 + ap_if="${ap_if:+$ap_if }$vif" + ;; + wds) + local addr + config_get addr "$vif" bssid + [ -z "$addr" ] || { + addr=$(echo "$addr" | tr 'A-F' 'a-f') + append wds "$addr" + } + ;; + monitor) + mon=1 + mon_if="$vif" + ;; + *) echo "$device($vif): Invalid mode";; + esac + done + config_set "$device" wds "$wds" + + local _c= + for vif in ${adhoc_if:-$sta_if $ap_if $mon_if}; do + config_set "$vif" ifname "${device}${_c:+-$_c}" + _c=$((${_c:-0} + 1)) + done + config_set "$device" vifs "${adhoc_if:-$sta_if $ap_if $mon_if}" + + ap=1 + infra=1 + if [ "$_c" -gt 1 ]; then + mssid=1 + else + mssid= + fi + apsta=0 + radio=1 + monitor=0 + case "$adhoc:$sta:$apmode:$mon" in + 1*) + ap=0 + mssid= + infra=0 + ;; + :1:1:) + apsta=1 + wet=1 + ;; + :1::) + wet=1 + ap=0 + mssid= + ;; + :::1) + wet=1 + ap=0 + mssid= + monitor=1 + ;; + ::) + radio=0 + ;; + esac +} + +disable_broadcom() { + local device="$1" + set_wifi_down "$device" + ( + include /lib/network + + local pid_file=/var/run/nas.$device.pid + [ -e $pid_file ] && start-stop-daemon -K -q -s SIGKILL -p $pid_file && rm $pid_file + + # make sure the interfaces are down and removed from all bridges + local dev ifname + for dev in /sys/class/net/wds${device##wl}-* /sys/class/net/${device}-* /sys/class/net/${device}; do + if [ -e "$dev" ]; then + ifname=${dev##/sys/class/net/} + ip link set dev "$ifname" down + unbridge "$ifname" + fi + done + + # make sure all of the devices are disabled in the driver + local ifdown= + local bssmax=$(wlc ifname "$device" bssmax) + local vif=$((${bssmax:-4} - 1)) + append ifdown "down" "$N" + append ifdown "wds none" "$N" + while [ $vif -ge 0 ]; do + append ifdown "vif $vif" "$N" + append ifdown "enabled 0" "$N" + vif=$(($vif - 1)) + done + + wlc ifname "$device" stdin <