aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/sbin
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-12-02 16:41:03 +0000
committerFelix Fietkau <nbd@openwrt.org>2013-12-02 16:41:03 +0000
commit498d84fc4e00ad75514c3a9dde09338552b89a8c (patch)
treec356de13fce36967a6069a2b470b070eafdc6690 /package/base-files/files/sbin
parentc9902e141e021a683e871d594ddd15a978def1d5 (diff)
downloadupstream-498d84fc4e00ad75514c3a9dde09338552b89a8c.tar.gz
upstream-498d84fc4e00ad75514c3a9dde09338552b89a8c.tar.bz2
upstream-498d84fc4e00ad75514c3a9dde09338552b89a8c.zip
netifd: add wireless configuration support and port mac80211 to the new framework
Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 38988
Diffstat (limited to 'package/base-files/files/sbin')
-rwxr-xr-xpackage/base-files/files/sbin/wifi39
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