-config_cb() {
- config_get TYPE "$CONFIG_SECTION" TYPE
- case "$TYPE" in
- wifi-device)
- append DEVICES "$CONFIG_SECTION"
- ;;
- wifi-iface)
- config_get device "$CONFIG_SECTION" device
- config_get vifs "$device" vifs
- append vifs "$CONFIG_SECTION"
- config_set "$device" vifs "$vifs"
- ;;
- esac
+set_wifi_up() {
+ local cfg="$1"
+ local ifname="$2"
+ uci_set_state wireless "$cfg" up 1
+ uci_set_state wireless "$cfg" ifname "$ifname"
+}
+
+set_wifi_down() {
+ local cfg="$1"
+ local vifs vif vifstr
+
+ [ -f "/var/run/wifi-${cfg}.pid" ] &&
+ kill "$(cat "/var/run/wifi-${cfg}.pid")"
+ uci_revert_state wireless "$cfg"
+ config_get vifs "$cfg" vifs
+ for vif in $vifs; do
+ uci_revert_state wireless "$vif"
+ done
+}
+
+scan_wifi() {
+ local cfgfile="$1"
+ config_cb() {
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ case "$TYPE" in
+ wifi-device)
+ append DEVICES "$CONFIG_SECTION"
+ ;;
+ wifi-iface)
+ config_get device "$CONFIG_SECTION" device
+ config_get vifs "$device" vifs
+ append vifs "$CONFIG_SECTION"
+ config_set "$device" vifs "$vifs"
+ ;;
+ esac
+ }
+ config_load "${cfgfile:-wireless}"