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
"${sta:+$sta }${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${wds:+$wds }${monitor:+$monitor}"
52 set_wifi_down
"$device"
57 grep "$device" "$dev/%parent" >/dev
/null
2>/dev
/null
&& {
58 [ -f "/var/run/wifi-${dev}.pid" ] &&
59 kill "$(cat "/var
/run
/wifi-
${dev}.pid
")"
62 wlanconfig
"$dev" destroy
70 config_get channel
"$device" channel
71 config_get vifs
"$device" vifs
73 [ auto
= "$channel" ] && channel
=0
79 config_get ifname
"$vif" ifname
80 config_get enc
"$vif" encryption
81 config_get eap_type
"$vif" eap_type
82 config_get mode
"$vif" mode
85 sta
) config_get nosbeacon
"$device" nosbeacon
;;
86 adhoc
) config_get nosbeacon
"$vif" sw_merge
;;
89 config_get ifname
"$vif" ifname
90 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
92 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
95 config_set
"$vif" ifname
"$ifname"
97 # only need to change freq band and channel on the first vif
98 config_get hwmode
"$device" hwmode
99 [ -z "$hwmode" ] && config_get hwmode
"$device" mode
105 *g
) hwmode
=11g
; pureg
=1;;
113 iwpriv
"$ifname" mode
"$hwmode"
114 iwpriv
"$ifname" pureg
"$pureg"
116 [ "$first" = 1 ] && {
117 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
120 config_get_bool hidden
"$vif" hidden
0
121 iwpriv
"$ifname" hide_ssid
"$hidden"
123 config_get ff
"$vif" ff
124 if [ -n "$ff" ]; then
125 iwpriv
"$ifname" ff
"$ff"
128 config_get wds
"$vif" wds
130 1|on|enabled
) wds
=1;;
133 iwpriv
"$ifname" wds
"$wds"
135 [ "$mode" = ap
-a "$wds" = 1 ] && {
136 config_get_bool wdssep
"$vif" wdssep
1
137 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
142 for idx
in 1 2 3 4; do
143 config_get key
"$vif" "key${idx}"
144 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
146 config_get key
"$vif" key
149 [1234]) iwconfig
"$ifname" enc
"[$key]";;
150 *) iwconfig
"$ifname" enc
"$key";;
155 config_get key
"$vif" key
161 config_get addr
"$vif" bssid
163 iwconfig
"$ifname" ap
"$addr"
167 config_get ssid
"$vif" ssid
169 config_get_bool bgscan
"$vif" bgscan
170 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
172 config_get_bool antdiv
"$device" diversity
173 config_get antrx
"$device" rxantenna
174 config_get anttx
"$device" txantenna
175 config_get_bool softled
"$device" softled
1
177 devname
="$(cat /proc/sys/dev/$device/dev_name)"
180 NanoStation2
) antgpio
=7;;
181 NanoStation5
) antgpio
=1;;
183 if [ -n "$antgpio" ]; then
185 config_get antenna
"$device" antenna
187 external
) antdiv
=0; antrx
=1; anttx
=1 ;;
188 horizontal
) antdiv
=0; antrx
=1; anttx
=1 ;;
189 vertical
) antdiv
=0; antrx
=2; anttx
=2 ;;
190 auto
) antdiv
=1; antrx
=0; anttx
=0 ;;
193 [ -x "$(which gpioctl 2>/dev/null)" ] || antenna
=
195 horizontal|vertical|auto
)
196 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
197 gpioctl
"set" "$antgpio" >/dev
/null
2>&1
200 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
201 gpioctl
"clear" "$antgpio" >/dev
/null
2>&1
206 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
207 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
208 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
209 [ -n "$softled" ] && sysctl
-w dev.
"$device".softled
="$softled" >&-
211 config_get distance
"$device" distance
212 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
214 config_get rate
"$vif" rate
215 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
217 config_get mcast_rate
"$vif" mcast_rate
218 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
220 config_get frag
"$vif" frag
221 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
223 config_get rts
"$vif" rts
224 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
226 config_get_bool comp
"$vif" compression
227 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
229 config_get_bool minrate
"$vif" minrate
230 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
232 config_get_bool maxrate
"$vif" maxrate
233 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
235 config_get_bool burst
"$vif" bursting
236 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
238 config_get_bool wmm
"$vif" wmm
239 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
241 config_get_bool xr
"$vif" xr
242 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
244 config_get_bool
ar "$vif" ar
245 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
247 config_get_bool turbo
"$vif" turbo
248 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
250 config_get_bool doth
"$vif" doth
0
251 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
253 config_get maclist
"$vif" maclist
254 [ -n "$maclist" ] && {
256 iwpriv
"$ifname" maccmd
3
257 for mac
in $maclist; do
258 iwpriv
"$ifname" addmac
"$mac"
262 config_get macpolicy
"$vif" macpolicy
265 iwpriv
"$ifname" maccmd
1
268 iwpriv
"$ifname" maccmd
2
271 # default deny policy if mac list exists
272 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
276 ifconfig
"$ifname" up
278 # TXPower settings only work if device is up already
279 config_get txpwr
"$vif" txpower
280 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
283 net_cfg
="$(find_net_config "$vif")"
284 [ -z "$net_cfg" ] ||
{
285 bridge
="$(bridge_interface "$net_cfg")"
286 config_set
"$vif" bridge
"$bridge"
287 start_net
"$ifname" "$net_cfg"
289 [ -n "$ssid" ] && iwconfig
"$ifname" essid on
290 iwconfig
"$ifname" essid
"$ssid"
291 set_wifi_up
"$vif" "$ifname"
294 config_get_bool isolate
"$vif" isolate
0
295 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
297 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
298 hostapd_setup_vif
"$vif" madwifi ||
{
299 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
300 # make sure this wifi interface won't accidentally stay open without encryption
301 ifconfig
"$ifname" down
302 wlanconfig
"$ifname" destroy
308 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
309 wpa_supplicant_setup_vif
"$vif" madwifi ||
{
310 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
311 ifconfig
"$ifname" down
312 wlanconfig
"$ifname" destroy
326 for dev
in $
(ls -d wifi
* 2>&-); do
327 config_get
type "$dev" type
328 devname
="$(cat /proc/sys/dev/$dev/dev_name)"
332 # Ubiquiti NanoStation features
333 option antenna auto # (auto|horizontal|vertical|external)
337 [ "$type" = atheros
] && return
339 config wifi-device $dev
343 # REMOVE THIS LINE TO ENABLE WIFI:
351 option encryption none