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
41 config_get iftype
"$cfg" type
42 [ "$iftype" = bridge
] && config_get
"$cfg" ifname
43 prepare_interface_bridge
"$cfg"
50 echo -n "$key" |
grep -qE "[^a-fA-F0-9]" && hex
=0
51 [ "${#key}" -eq 10 -a $hex -eq 1 ] || \
52 [ "${#key}" -eq 26 -a $hex -eq 1 ] ||
{
53 [ "${key:0:2}" = "s:" ] && key
="${key#s:}"
54 key
="$(echo -n "$key" | hexdump -ve '1/1 "%02x
" ""')"
62 local hwmode hwmode_11n
64 config_get channel
"$device" channel
65 config_get hwmode
"$device" hwmode
72 hwmode_11n
="${hwmode##11n}"
75 default
) hwmode_11n
="$default"
77 config_set
"$device" hwmode_11n
"$hwmode_11n"
81 if [ "${channel:-0}" -gt 0 ]; then
82 if [ "${channel:-0}" -gt 14 ]; then
92 config_set
"$device" hwmode
"$hwmode"
96 [ enable = "$1" ] && {
97 wifi_updown disable
"$2"
100 for device
in ${2:-$DEVICES}; do (
101 config_get disabled
"$device" disabled
102 [ 1 == "$disabled" ] && {
103 echo "'$device' is disabled"
106 config_get iftype
"$device" type
107 if eval "type ${1}_$iftype" 2>/dev
/null
>/dev
/null
; then
108 eval "scan_$iftype '$device'"
109 eval "${1}_$iftype '$device'" ||
echo "$device($iftype): ${1} failed"
111 echo "$device($iftype): Interface type not supported"
117 for driver
in ${2:-$DRIVERS}; do (
118 if eval "type detect_$driver" 2>/dev
/null
>/dev
/null
; then
119 eval "detect_$driver" ||
echo "$driver: Detect failed" >&2
121 echo "$driver: Hardware detection not supported" >&2
131 [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev
/null
132 [ -z "$config" ] ||
{
135 setup_interface
"$iface" "$config" "" "$vifmac"
142 uci_set_state wireless
"$cfg" up
1
143 uci_set_state wireless
"$cfg" ifname
"$ifname"
148 local vifs vif vifstr
150 [ -f "/var/run/wifi-${cfg}.pid" ] &&
151 kill "$(cat "/var
/run
/wifi-
${cfg}.pid
")" 2>/dev
/null
152 uci_revert_state wireless
"$cfg"
153 config_get vifs
"$cfg" vifs
155 uci_revert_state wireless
"$vif"
169 append DEVICES
"$section"
170 config_set
"$section" vifs
""
171 config_set
"$section" ht_capab
""
176 config_get TYPE
"$CONFIG_SECTION" TYPE
179 config_get device
"$CONFIG_SECTION" device
180 config_get vifs
"$device" vifs
181 append vifs
"$CONFIG_SECTION"
182 config_set
"$device" vifs
"$vifs"
186 config_load
"${cfgfile:-wireless}"
195 down
) wifi_updown
"disable" "$2";;
196 detect
) wifi_detect
"$2";;
198 *) wifi_updown
"enable" "$2";;