2 # Copyright (C) 2006 OpenWrt.org
11 config_get cfg
"$vif" network
17 config_get ifname
"$vif" ifname
19 cfg
="$(find_config "$ifname")"
21 [ -z "$cfg" ] && return 0
28 [ -z "$cfg" ] && return 0
33 config_get iftype
"$cfg" type
34 [ "$iftype" = bridge
] && config_get
"$cfg" ifname
41 echo -n "$key" |
grep -qE "[^a-fA-F0-9]" && hex
=0
42 [ "${#key}" -eq 10 -a $hex -eq 1 ] || \
43 [ "${#key}" -eq 26 -a $hex -eq 1 ] ||
{
44 [ "${key:0:2}" = "s:" ] && key
="${key#s:}"
45 key
="$(echo -n "$key" | hexdump -ve '1/1 "%02x
" ""')"
53 local hwmode hwmode_11n
55 config_get channel
"$device" channel
56 config_get hwmode
"$device" hwmode
63 hwmode_11n
="${hwmode##11n}"
66 default
) hwmode_11n
="$default"
68 config_set
"$device" hwmode_11n
"$hwmode_11n"
72 if [ "${channel:-0}" -gt 0 ]; then
73 if [ "${channel:-0}" -gt 14 ]; then
83 config_set
"$device" hwmode
"$hwmode"
87 [ enable = "$1" ] && {
88 wifi_updown disable
"$2"
91 for device
in ${2:-$DEVICES}; do (
92 config_get disabled
"$device" disabled
93 [ 1 == "$disabled" ] && {
94 echo "'$device' is disabled"
97 config_get iftype
"$device" type
98 if eval "type ${1}_$iftype" 2>/dev
/null
>/dev
/null
; then
99 eval "scan_$iftype '$device'"
100 eval "${1}_$iftype '$device'" ||
echo "$device($iftype): ${1} failed"
102 echo "$device($iftype): Interface type not supported"
108 for driver
in ${2:-$DRIVERS}; do (
109 if eval "type detect_$driver" 2>/dev
/null
>/dev
/null
; then
110 eval "detect_$driver" ||
echo "$driver: Detect failed" >&2
112 echo "$driver: Hardware detection not supported" >&2
122 [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev
/null
125 setup_interface
"$iface" "$config" "" "$vifmac"
131 uci_set_state wireless
"$cfg" up
1
132 uci_set_state wireless
"$cfg" ifname
"$ifname"
137 local vifs vif vifstr
139 [ -f "/var/run/wifi-${cfg}.pid" ] &&
140 kill "$(cat "/var
/run
/wifi-
${cfg}.pid
")" 2>/dev
/null
141 uci_revert_state wireless
"$cfg"
142 config_get vifs
"$cfg" vifs
144 uci_revert_state wireless
"$vif"
158 append DEVICES
"$section"
159 config_set
"$section" vifs
""
160 config_set
"$section" ht_capab
""
165 config_get TYPE
"$CONFIG_SECTION" TYPE
168 config_get device
"$CONFIG_SECTION" device
169 config_get vifs
"$device" vifs
170 append vifs
"$CONFIG_SECTION"
171 config_set
"$device" vifs
"$vifs"
175 config_load
"${cfgfile:-wireless}"
184 down
) wifi_updown
"disable" "$2";;
185 detect
) wifi_detect
"$2";;
186 *) wifi_updown
"enable" "$2";;