diff options
author | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-12-02 16:41:03 +0000 |
---|---|---|
committer | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-12-02 16:41:03 +0000 |
commit | 148b41b2f383f13a23d7a64394924c845838f986 (patch) | |
tree | 89cfa70014c554c8753782fab558317974e838ee /package/base-files | |
parent | 2fbe47ce2f32deb281025ec1663e9911f73e8664 (diff) |
netifd: add wireless configuration support and port mac80211 to the new framework
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38988 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files')
-rwxr-xr-x | package/base-files/files/sbin/wifi | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi index ef207878be..7663432bd3 100755 --- a/package/base-files/files/sbin/wifi +++ b/package/base-files/files/sbin/wifi @@ -2,15 +2,25 @@ # Copyright (C) 2006 OpenWrt.org . /lib/functions.sh +. /usr/share/libubox/jshn.sh usage() { cat <<EOF -Usage: $0 [down|detect] +Usage: $0 [down|detect|reload|status] enables (default), disables or detects a wifi configuration. EOF exit 1 } +ubus_wifi_cmd() { + local cmd="$1" + local dev="$2" + + json_init + [ -n "$2" ] && json_add_string device "$2" + ubus call network.wireless "$1" "$(json_dump)" +} + find_net_config() {( local vif="$1" local cfg @@ -95,11 +105,7 @@ wifi_fixup_hwmode() { config_set "$device" hwmode "$hwmode" } -wifi_updown() { - [ enable = "$1" ] && { - wifi_updown disable "$2" - scan_wifi - } +_wifi_updown() { for device in ${2:-$DEVICES}; do ( config_get disabled "$device" disabled [ 1 == "$disabled" ] && { @@ -110,12 +116,29 @@ wifi_updown() { if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then eval "scan_$iftype '$device'" eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed" - else + elif [ ! -f /lib/netifd/wireless/$iftype.sh ]; then echo "$device($iftype): Interface type not supported" fi ); done } +wifi_updown() { + cmd=down + [ enable = "$1" ] && { + _wifi_updown disable "$2" + scan_wifi + cmd=up + } + ubus_wifi_cmd "$cmd" "$2" + _wifi_updown "$@" +} + +wifi_reload() { + _wifi_updown "disable" "$1" + scan_wifi + _wifi_updown "enable" "$1" +} + wifi_detect() { for driver in ${2:-$DRIVERS}; do ( if eval "type detect_$driver" 2>/dev/null >/dev/null; then @@ -199,6 +222,8 @@ scan_wifi case "$1" in down) wifi_updown "disable" "$2";; detect) wifi_detect "$2";; + status) ubus_wifi_cmd "status" "$2";; + reload) wifi_reload "$2";; --help|help) usage;; *) wifi_updown "enable" "$2";; esac |