2 # Copyright (C) 2006 OpenWrt.org
8 Usage: $0 [down|detect]
9 enables (default), disables or detects a wifi configuration.
19 config_get cfg
"$vif" network
25 config_get ifname
"$vif" ifname
27 cfg
="$(find_config "$ifname")"
29 [ -z "$cfg" ] && return 0
36 [ -z "$cfg" ] && return 0
42 config_get iftype
"$cfg" type
43 [ "$iftype" = bridge
] && config_get
"$cfg" ifname
44 prepare_interface_bridge
"$cfg"
53 echo -n "$key" |
grep -qE "[^a-fA-F0-9]" && hex
=0
54 [ "${#key}" -eq 10 -a $hex -eq 1 ] || \
55 [ "${#key}" -eq 26 -a $hex -eq 1 ] ||
{
56 [ "${key:0:2}" = "s:" ] && key
="${key#s:}"
57 key
="$(echo -n "$key" | hexdump -ve '1/1 "%02x
" ""')"
65 local hwmode hwmode_11n
67 config_get channel
"$device" channel
68 config_get hwmode
"$device" hwmode
75 hwmode_11n
="${hwmode##11n}"
78 default
) hwmode_11n
="$default"
80 config_set
"$device" hwmode_11n
"$hwmode_11n"
84 if [ "${channel:-0}" -gt 0 ]; then
85 if [ "${channel:-0}" -gt 14 ]; then
95 config_set
"$device" hwmode
"$hwmode"
99 [ enable = "$1" ] && {
100 wifi_updown disable
"$2"
103 for device
in ${2:-$DEVICES}; do (
104 config_get disabled
"$device" disabled
105 [ 1 == "$disabled" ] && {
106 echo "'$device' is disabled"
109 config_get iftype
"$device" type
110 if eval "type ${1}_$iftype" 2>/dev
/null
>/dev
/null
; then
111 eval "scan_$iftype '$device'"
112 eval "${1}_$iftype '$device'" ||
echo "$device($iftype): ${1} failed"
114 echo "$device($iftype): Interface type not supported"
120 for driver
in ${2:-$DRIVERS}; do (
121 if eval "type detect_$driver" 2>/dev
/null
>/dev
/null
; then
122 eval "detect_$driver" ||
echo "$driver: Detect failed" >&2
124 echo "$driver: Hardware detection not supported" >&2
134 [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev
/null
135 [ -z "$config" ] ||
{
138 for config
in $config; do
139 setup_interface
"$iface" "$config" "" "$vifmac"
147 uci_set_state wireless
"$cfg" up
1
148 uci_set_state wireless
"$cfg" ifname
"$ifname"
153 local vifs vif vifstr
155 [ -f "/var/run/wifi-${cfg}.pid" ] &&
156 kill "$(cat "/var
/run
/wifi-
${cfg}.pid
")" 2>/dev
/null
157 uci_revert_state wireless
"$cfg"
158 config_get vifs
"$cfg" vifs
160 uci_revert_state wireless
"$vif"
174 append DEVICES
"$section"
175 config_set
"$section" vifs
""
176 config_set
"$section" ht_capab
""
181 config_get TYPE
"$CONFIG_SECTION" TYPE
184 config_get device
"$CONFIG_SECTION" device
185 config_get vifs
"$device" vifs
186 append vifs
"$CONFIG_SECTION"
187 config_set
"$device" vifs
"$vifs"
191 config_load
"${cfgfile:-wireless}"
200 down
) wifi_updown
"disable" "$2";;
201 detect
) wifi_detect
"$2";;
203 *) wifi_updown
"enable" "$2";;