aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files/files')
-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