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
71 config_get regdomain
"$device" regdomain
72 [ -n "$regdomain" ] && echo "$regdomain" > /proc
/sys
/dev
/$device/regdomain
74 config_get country
"$device" country
75 [ -z "$country" ] && country
="0"
76 echo "$country" > /proc
/sys
/dev
/$device/countrycode
78 config_get outdoor
"$device" outdoor
79 [ -z "$outdoor" ] && outdoor
="0"
80 echo "$outdoor" > /proc
/sys
/dev
/$device/outdoor
82 config_get channel
"$device" channel
83 config_get vifs
"$device" vifs
84 config_get txpower
"$device" txpower
86 [ auto
= "$channel" ] && channel
=0
90 local start_hostapd vif_txpower
92 config_get ifname
"$vif" ifname
93 config_get enc
"$vif" encryption
94 config_get eap_type
"$vif" eap_type
95 config_get mode
"$vif" mode
98 sta
) config_get nosbeacon
"$device" nosbeacon
;;
99 adhoc
) config_get nosbeacon
"$vif" sw_merge
;;
102 config_get ifname
"$vif" ifname
103 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
105 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
108 config_set
"$vif" ifname
"$ifname"
110 # only need to change freq band and channel on the first vif
111 config_get hwmode
"$device" hwmode
112 [ -z "$hwmode" ] && config_get hwmode
"$device" mode
118 *g
) hwmode
=11g
; pureg
=1;;
126 iwpriv
"$ifname" pureg
"$pureg"
128 [ "$first" = 1 ] && {
129 iwpriv
"$ifname" mode
"$hwmode"
130 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
133 config_get_bool hidden
"$vif" hidden
0
134 iwpriv
"$ifname" hide_ssid
"$hidden"
136 config_get ff
"$vif" ff
137 if [ -n "$ff" ]; then
138 iwpriv
"$ifname" ff
"$ff"
141 config_get wds
"$vif" wds
143 1|on|enabled
) wds
=1;;
146 iwpriv
"$ifname" wds
"$wds"
148 [ "$mode" = ap
-a "$wds" = 1 ] && {
149 config_get_bool wdssep
"$vif" wdssep
1
150 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
155 for idx
in 1 2 3 4; do
156 config_get key
"$vif" "key${idx}"
157 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
159 config_get key
"$vif" key
162 [1234]) iwconfig
"$ifname" enc
"[$key]";;
163 *) iwconfig
"$ifname" enc
"$key";;
168 config_get key
"$vif" key
174 config_get addr
"$vif" bssid
176 iwconfig
"$ifname" ap
"$addr"
180 config_get ssid
"$vif" ssid
182 config_get_bool bgscan
"$vif" bgscan
183 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
185 config_get_bool antdiv
"$device" diversity
186 config_get antrx
"$device" rxantenna
187 config_get anttx
"$device" txantenna
188 config_get_bool softled
"$device" softled
1
190 devname
="$(cat /proc/sys/dev/$device/dev_name)"
193 NanoStation2
) antgpio
=7;;
194 NanoStation5
) antgpio
=1;;
196 if [ -n "$antgpio" ]; then
198 config_get antenna
"$device" antenna
200 external
) antdiv
=0; antrx
=1; anttx
=1 ;;
201 horizontal
) antdiv
=0; antrx
=1; anttx
=1 ;;
202 vertical
) antdiv
=0; antrx
=2; anttx
=2 ;;
203 auto
) antdiv
=1; antrx
=0; anttx
=0 ;;
206 [ -x "$(which gpioctl 2>/dev/null)" ] || antenna
=
208 horizontal|vertical|auto
)
209 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
210 gpioctl
"set" "$antgpio" >/dev
/null
2>&1
213 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
214 gpioctl
"clear" "$antgpio" >/dev
/null
2>&1
219 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
220 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
221 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
222 [ -n "$softled" ] && sysctl
-w dev.
"$device".softled
="$softled" >&-
224 config_get distance
"$device" distance
225 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
227 config_get rate
"$vif" rate
228 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
230 config_get mcast_rate
"$vif" mcast_rate
231 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
233 config_get frag
"$vif" frag
234 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
236 config_get rts
"$vif" rts
237 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
239 config_get_bool comp
"$vif" compression
240 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
242 config_get_bool minrate
"$vif" minrate
243 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
245 config_get_bool maxrate
"$vif" maxrate
246 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
248 config_get_bool burst
"$vif" bursting
249 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
251 config_get_bool wmm
"$vif" wmm
252 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
254 config_get_bool xr
"$vif" xr
255 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
257 config_get_bool
ar "$vif" ar
258 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
260 config_get_bool turbo
"$vif" turbo
261 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
263 config_get_bool beacon_power
"$vif" beacon_power
264 [ -n "$beacon_power" ] && iwpriv
"$ifname" beacon_pwr
"$beacon_power"
266 config_get_bool doth
"$vif" doth
0
267 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
269 config_get_bool probereq
"$vif" probereq
270 [ -n "$probereq" ] && iwpriv
"$ifname" probereq
"$probereq"
272 config_get maclist
"$vif" maclist
273 [ -n "$maclist" ] && {
275 iwpriv
"$ifname" maccmd
3
276 for mac
in $maclist; do
277 iwpriv
"$ifname" addmac
"$mac"
281 config_get macpolicy
"$vif" macpolicy
284 iwpriv
"$ifname" maccmd
1
287 iwpriv
"$ifname" maccmd
2
290 # default deny policy if mac list exists
291 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
295 ifconfig
"$ifname" up
298 net_cfg
="$(find_net_config "$vif")"
299 [ -z "$net_cfg" ] ||
{
300 bridge
="$(bridge_interface "$net_cfg")"
301 config_set
"$vif" bridge
"$bridge"
302 start_net
"$ifname" "$net_cfg"
304 [ -n "$ssid" ] && iwconfig
"$ifname" essid on
305 iwconfig
"$ifname" essid
"$ssid"
306 set_wifi_up
"$vif" "$ifname"
308 # TXPower settings only work if device is up already
309 # while atheros hardware theoretically is capable of per-vif (even per-packet) txpower
310 # adjustment it does not work with the current atheros hal/madwifi driver
312 config_get vif_txpower
"$vif" txpower
313 # use vif_txpower (from wifi-iface) instead of txpower (from wifi-device) if
314 # the latter doesn't exist
315 txpower
="${txpower:-$vif_txpower}"
316 [ -z "$txpower" ] || iwconfig
"$ifname" txpower
"${txpower%%.*}"
320 config_get_bool isolate
"$vif" isolate
0
321 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
323 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
324 hostapd_setup_vif
"$vif" madwifi ||
{
325 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
326 # make sure this wifi interface won't accidentally stay open without encryption
327 ifconfig
"$ifname" down
328 wlanconfig
"$ifname" destroy
334 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
335 wpa_supplicant_setup_vif
"$vif" madwifi ||
{
336 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
337 ifconfig
"$ifname" down
338 wlanconfig
"$ifname" destroy
352 for dev
in $
(ls -d wifi
* 2>&-); do
353 config_get
type "$dev" type
354 devname
="$(cat /proc/sys/dev/$dev/dev_name)"
358 # Ubiquiti NanoStation features
359 option antenna auto # (auto|horizontal|vertical|external)
363 [ "$type" = atheros
] && return
365 config wifi-device $dev
369 # REMOVE THIS LINE TO ENABLE WIFI:
377 option encryption none