2 append DRIVERS
"atheros"
7 local adhoc ahdemo sta ap monitor
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_bool outdoor
"$device" outdoor
"0"
79 echo "$outdoor" > /proc
/sys
/dev
/$device/outdoor
81 config_get channel
"$device" channel
82 config_get vifs
"$device" vifs
83 config_get txpower
"$device" txpower
85 [ auto
= "$channel" ] && channel
=0
87 config_get_bool antdiv
"$device" diversity
88 config_get antrx
"$device" rxantenna
89 config_get anttx
"$device" txantenna
90 config_get_bool softled
"$device" softled
1
92 devname
="$(cat /proc/sys/dev/$device/dev_name)"
95 NanoStation2
) antgpio
=7;;
96 NanoStation5
) antgpio
=1;;
98 if [ -n "$antgpio" ]; then
100 config_get antenna
"$device" antenna
102 external
) antdiv
=0; antrx
=1; anttx
=1 ;;
103 horizontal
) antdiv
=0; antrx
=1; anttx
=1 ;;
104 vertical
) antdiv
=0; antrx
=2; anttx
=2 ;;
105 auto
) antdiv
=1; antrx
=0; anttx
=0 ;;
108 [ -x "$(which gpioctl 2>/dev/null)" ] || antenna
=
110 horizontal|vertical|auto
)
111 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
112 gpioctl
"set" "$antgpio" >/dev
/null
2>&1
115 gpioctl
"dirout" "$antgpio" >/dev
/null
2>&1
116 gpioctl
"clear" "$antgpio" >/dev
/null
2>&1
121 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
122 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
123 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
124 [ -n "$softled" ] && sysctl
-w dev.
"$device".softled
="$softled" >&-
126 config_get distance
"$device" distance
127 [ -n "$distance" ] && sysctl
-w dev.
"$device".distance
="$distance" >&-
130 local start_hostapd
= vif_txpower
= nosbeacon
=
131 config_get ifname
"$vif" ifname
132 config_get enc
"$vif" encryption
133 config_get eap_type
"$vif" eap_type
134 config_get mode
"$vif" mode
137 sta
) config_get_bool nosbeacon
"$device" nosbeacon
;;
138 adhoc
) config_get_bool nosbeacon
"$vif" sw_merge
1;;
141 [ "$nosbeacon" = 1 ] || nosbeacon
=""
142 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
144 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
147 config_set
"$vif" ifname
"$ifname"
149 config_get hwmode
"$device" hwmode
150 [ -z "$hwmode" ] && config_get hwmode
"$device" mode
156 *g
) hwmode
=11g
; pureg
=1;;
164 iwpriv
"$ifname" mode
"$hwmode"
165 iwpriv
"$ifname" pureg
"$pureg"
167 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
169 config_get_bool hidden
"$vif" hidden
0
170 iwpriv
"$ifname" hide_ssid
"$hidden"
172 config_get ff
"$vif" ff
173 if [ -n "$ff" ]; then
174 iwpriv
"$ifname" ff
"$ff"
177 config_get wds
"$vif" wds
179 1|on|enabled
) wds
=1;;
182 iwpriv
"$ifname" wds
"$wds" >/dev
/null
2>&1
184 [ "$mode" = ap
-a "$wds" = 1 ] && {
185 config_get_bool wdssep
"$vif" wdssep
1
186 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
191 for idx
in 1 2 3 4; do
192 config_get key
"$vif" "key${idx}"
193 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
195 config_get key
"$vif" key
198 [1234]) iwconfig
"$ifname" enc
"[$key]";;
199 *) iwconfig
"$ifname" enc
"$key";;
204 config_get key
"$vif" key
210 config_get addr
"$vif" bssid
212 iwconfig
"$ifname" ap
"$addr"
217 config_get_bool uapsd
"$vif" uapsd
0
218 iwpriv
"$ifname" uapsd
"$uapsd"
220 config_get_bool bgscan
"$vif" bgscan
221 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
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
0
236 iwpriv
"$ifname" compression
"$comp" >/dev
/null
2>&1
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 beacon_power
"$vif" beacon_power
257 [ -n "$beacon_power" ] && iwpriv
"$ifname" beacon_pwr
"$beacon_power"
259 config_get_bool doth
"$vif" doth
0
260 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
262 config_get_bool probereq
"$vif" probereq
263 [ -n "$probereq" ] && iwpriv
"$ifname" probereq
"$probereq"
265 config_get maclist
"$vif" maclist
266 [ -n "$maclist" ] && {
268 iwpriv
"$ifname" maccmd
3
269 for mac
in $maclist; do
270 iwpriv
"$ifname" addmac
"$mac"
274 config_get macpolicy
"$vif" macpolicy
277 iwpriv
"$ifname" maccmd
1
280 iwpriv
"$ifname" maccmd
2
283 # default deny policy if mac list exists
284 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
288 ifconfig
"$ifname" up
291 net_cfg
="$(find_net_config "$vif")"
292 [ -z "$net_cfg" ] ||
{
293 bridge
="$(bridge_interface "$net_cfg")"
294 config_set
"$vif" bridge
"$bridge"
295 start_net
"$ifname" "$net_cfg"
298 config_get ssid
"$vif" ssid
300 iwconfig
"$ifname" essid on
301 iwconfig
"$ifname" essid
"$ssid"
304 set_wifi_up
"$vif" "$ifname"
306 # TXPower settings only work if device is up already
307 # while atheros hardware theoretically is capable of per-vif (even per-packet) txpower
308 # adjustment it does not work with the current atheros hal/madwifi driver
310 config_get vif_txpower
"$vif" txpower
311 # use vif_txpower (from wifi-iface) instead of txpower (from wifi-device) if
312 # the latter doesn't exist
313 txpower
="${txpower:-$vif_txpower}"
314 [ -z "$txpower" ] || iwconfig
"$ifname" txpower
"${txpower%%.*}"
318 config_get_bool isolate
"$vif" isolate
0
319 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
321 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
322 hostapd_setup_vif
"$vif" madwifi ||
{
323 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
324 # make sure this wifi interface won't accidentally stay open without encryption
325 ifconfig
"$ifname" down
326 wlanconfig
"$ifname" destroy
332 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
333 wpa_supplicant_setup_vif
"$vif" madwifi ||
{
334 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
335 ifconfig
"$ifname" down
336 wlanconfig
"$ifname" destroy
349 for dev
in $
(ls -d wifi
* 2>&-); do
350 config_get
type "$dev" type
351 devname
="$(cat /proc/sys/dev/$dev/dev_name)"
355 # Ubiquiti NanoStation features
356 option antenna auto # (auto|horizontal|vertical|external)
360 [ "$type" = atheros
] && continue
362 config wifi-device $dev
366 # REMOVE THIS LINE TO ENABLE WIFI:
374 option encryption none