From 716ca530e1c4515d8683c9d5be3d56b301758b66 Mon Sep 17 00:00:00 2001 From: James <> Date: Wed, 4 Nov 2015 11:49:21 +0000 Subject: trunk-47381 --- .../files/etc/hotplug.d/net/20-broadcom_wds | 61 +++ .../kernel/broadcom-wl/files/etc/init.d/wlunbind | 29 ++ .../kernel/broadcom-wl/files/lib/wifi/broadcom.sh | 477 +++++++++++++++++++++ 3 files changed, 567 insertions(+) create mode 100644 package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds create mode 100755 package/kernel/broadcom-wl/files/etc/init.d/wlunbind create mode 100644 package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh (limited to 'package/kernel/broadcom-wl/files') diff --git a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds new file mode 100644 index 0000000..35c4218 --- /dev/null +++ b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds @@ -0,0 +1,61 @@ +include /lib/wifi + +setup_broadcom_wds() { + local iface="$1" + local remote="$(wlc ifname "$iface" wdsmac)" + + [ -z "$remote" ] && return + + config_cb() { + [ -z "$CONFIG_SECTION" ] && return + + config_get type "$CONFIG_SECTION" TYPE + [ "$type" = "wifi-iface" ] || return + + config_get network "$CONFIG_SECTION" network + [ -z "$network" ] && return + + config_get addr "$CONFIG_SECTION" bssid + addr=$(echo "$addr" | tr 'A-F' 'a-f') + [ "$addr" = "$remote" ] && { + local cfg="$CONFIG_SECTION" + + include /lib/network + scan_interfaces + + for network in $network; do + setup_interface "$iface" "$network" + done + + config_get encryption "$cfg" encryption + config_get key "$cfg" key + config_get ssid "$cfg" ssid + + [ "$encryption" != "none" ] && { + sleep 5 + case "$encryption" in + psk|PSK) + nas4not "$network" "$iface" up auto tkip psk "$key" "$ssid" + ;; + psk2|PSK2) + nas4not "$network" "$iface" up auto aes psk "$key" "$ssid" + ;; + psk+psk2|psk2+psk|PSK+PSK2|PSK2+PSK) + nas4not "$network" "$iface" up auto aes+tkip psk "$key" "$ssid" + ;; + *) + nas4not lan "$iface" up auto aes "$encryption" "$key" "$ssid" + ;; + esac + } + } + } + + config_load wireless +} + +case "$ACTION" in + add|register) + [ "${INTERFACE%%[0-1]-*}" = wds ] && setup_broadcom_wds "$INTERFACE" + ;; +esac diff --git a/package/kernel/broadcom-wl/files/etc/init.d/wlunbind b/package/kernel/broadcom-wl/files/etc/init.d/wlunbind new file mode 100755 index 0000000..0a29db5 --- /dev/null +++ b/package/kernel/broadcom-wl/files/etc/init.d/wlunbind @@ -0,0 +1,29 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2010-2011 OpenWrt.org + +START=09 + +unbind_driver() { + local driver="$1" + local sysfs="/sys/bus/pci/drivers/$driver" + if [ -d "$sysfs" ]; then + local lnk + for lnk in $sysfs/*; do + [ -h "$lnk" ] || continue + case "${lnk##*/}" in + *:*:*.*) + logger "Unbinding WL PCI device ${lnk##*/} from $driver" + echo -n "${lnk##*/}" > "$sysfs/unbind" + ;; + esac + done + fi +} + +boot() { + unbind_driver b43-pci-bridge + unbind_driver bcma-pci-bridge +} + +start() { :; } +stop() { :; } 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 <