2 append DRIVERS
"atheros"
9 config_get vifs
"$device" vifs
12 config_get ifname
"$vif" ifname
13 config_set
"$vif" ifname
"${ifname:-ath}"
15 config_get mode
"$vif" mode
17 adhoc|ahdemo|sta|ap|monitor
)
21 config_get ssid
"$vif" ssid
22 [ -z "$ssid" ] && continue
24 config_set
"$vif" wds
1
25 config_set
"$vif" mode sta
28 ${addr:+append $mode "$vif"}
30 *) echo "$device($vif): Invalid mode, ignored."; continue;;
34 case "${adhoc:+1}:${sta:+1}:${ap+1}" in
35 # valid mode combinations
38 :1:1)config_set
"$device" nosbeacon
1;; # AP+STA, can't use beacon timers for STA
42 *) echo "$device: Invalid mode combination in config"; return 1;;
45 config_set
"$device" vifs
"${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${sta:+$sta }${wds:+$wds }${monitor:+$monitor}"
52 set_wifi_down
"$device"
53 # kill all running hostapd and wpa_supplicant processes that
54 # are running on atheros vifs
55 for pid
in `pidof hostapd wpa_supplicant`; do
56 grep ath
/proc
/$pid/cmdline
>/dev
/null
&& \
63 grep "$device" "$dev/%parent" >/dev
/null
2>/dev
/null
&& {
66 wlanconfig
"$dev" destroy
74 config_get channel
"$device" channel
75 config_get vifs
"$device" vifs
77 [ auto
= "$channel" ] && channel
=0
83 config_get ifname
"$vif" ifname
84 config_get enc
"$vif" encryption
85 config_get eap_type
"$vif" eap_type
86 config_get mode
"$vif" mode
89 sta
) config_get nosbeacon
"$device" nosbeacon
;;
90 adhoc
) config_get nosbeacon
"$vif" sw_merge
;;
93 config_get ifname
"$vif" ifname
94 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
96 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
99 config_set
"$vif" ifname
"$ifname"
101 # only need to change freq band and channel on the first vif
102 config_get agmode
"$device" agmode
103 [ -z "$agmode" ] && config_get agmode
"$device" mode
109 *g
) agmode
=11g
; pureg
=1;;
117 iwpriv
"$ifname" mode
"$agmode"
118 iwpriv
"$ifname" pureg
"$pureg"
120 [ "$first" = 1 ] && {
121 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
124 config_get_bool hidden
"$vif" hidden
0
125 iwpriv
"$ifname" hide_ssid
"$hidden"
127 config_get ff
"$vif" ff
128 if [ -n "$ff" ]; then
129 iwpriv
"$ifname" ff
"$ff"
132 config_get wds
"$vif" wds
134 1|on|enabled
) wds
=1;;
137 iwpriv
"$ifname" wds
"$wds"
139 [ "$mode" = ap
-a "$wds" = 1 ] && {
140 config_get_bool wdssep
"$vif" wdssep
1
141 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
146 for idx
in 1 2 3 4; do
147 config_get key
"$vif" "key${idx}"
148 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
150 config_get key
"$vif" key
153 [1234]) iwconfig
"$ifname" enc
"[$key]";;
154 *) iwconfig
"$ifname" enc
"$key";;
159 config_get key
"$vif" key
165 config_get addr
"$vif" bssid
167 iwconfig
"$ifname" ap
"$addr"
171 config_get ssid
"$vif" ssid
173 config_get_bool bgscan
"$vif" bgscan
174 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
176 config_get_bool antdiv
"$device" diversity
177 config_get antrx
"$device" rxantenna
178 config_get anttx
"$device" txantenna
179 config_get_bool softled
"$device" softled
1
181 devname
="$(cat /proc/sys/dev/$device/dev_name)"
184 NanoStation2
) antgpio
=7;;
185 NanoStation5
) antgpio
=1;;
187 if [ -n "$antgpio" ]; then
189 config_get polarity
"$device" polarity
191 horizontal
) antdiv
=0; antrx
=1; anttx
=1 ;;
192 vertical
) antdiv
=0; antrx
=2; anttx
=2 ;;
193 auto
) antdiv
=1; antrx
=0; anttx
=0 ;;
195 config_get antenna
"$device" antenna
196 [ -x "$(which gpioctl 2>/dev/null)" ] || antenna
=
199 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
200 gpioctl
"set" "$antgpio" >/dev
/null
2>&1
203 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
204 gpioctl
"clear" "$antgpio" >/dev
/null
2>&1
212 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
213 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
214 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
215 [ -n "$softled" ] && sysctl
-w dev.
"$device".softled
="$softled" >&-
217 config_get distance
"$device" distance
218 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
220 config_get txpwr
"$vif" txpower
221 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
223 config_get rate
"$vif" rate
224 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
226 config_get mcast_rate
"$vif" mcast_rate
227 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
229 config_get frag
"$vif" frag
230 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
232 config_get rts
"$vif" rts
233 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
235 config_get_bool comp
"$vif" compression
236 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
238 config_get_bool minrate
"$vif" minrate
239 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
241 config_get_bool maxrate
"$vif" maxrate
242 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
244 config_get_bool burst
"$vif" bursting
245 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
247 config_get_bool wmm
"$vif" wmm
248 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
250 config_get_bool xr
"$vif" xr
251 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
253 config_get_bool
ar "$vif" ar
254 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
256 config_get_bool turbo
"$vif" turbo
257 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
259 config_get_bool doth
"$vif" doth
0
260 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
262 config_get maclist
"$vif" maclist
263 [ -n "$maclist" ] && {
265 iwpriv
"$ifname" maccmd
3
266 for mac
in $maclist; do
267 iwpriv
"$ifname" addmac
"$mac"
271 config_get macpolicy
"$vif" macpolicy
274 iwpriv
"$ifname" maccmd
1
277 iwpriv
"$ifname" maccmd
2
280 # default deny policy if mac list exists
281 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
285 ifconfig
"$ifname" up
287 net_cfg
="$(find_net_config "$vif")"
288 [ -z "$net_cfg" ] ||
{
289 bridge
="$(bridge_interface "$net_cfg")"
290 config_set
"$vif" bridge
"$bridge"
291 start_net
"$ifname" "$net_cfg"
293 [ -n "$ssid" ] && iwconfig
"$ifname" essid on
294 iwconfig
"$ifname" essid
"$ssid"
295 set_wifi_up
"$vif" "$ifname"
298 config_get_bool isolate
"$vif" isolate
0
299 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
301 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
302 hostapd_setup_vif
"$vif" madwifi ||
{
303 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
304 # make sure this wifi interface won't accidentally stay open without encryption
305 ifconfig
"$ifname" down
306 wlanconfig
"$ifname" destroy
312 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
313 wpa_supplicant_setup_vif
"$vif" madwifi ||
{
314 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
315 ifconfig
"$ifname" down
316 wlanconfig
"$ifname" destroy
330 for dev
in $
(ls -d wifi
* 2>&-); do
331 config_get
type "$dev" type
332 devname
="$(cat /proc/sys/dev/$dev/dev_name)"
336 # Ubiquiti NanoStation features
337 option antenna internal
338 option polarity auto # (auto|horizontal|vertical)
342 [ "$type" = atheros
] && return
344 config wifi-device $dev
348 # REMOVE THIS LINE TO ENABLE WIFI:
356 option encryption none