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
88 [ "$mode" = sta
] && config_get nosbeacon
"$device" nosbeacon
90 config_get ifname
"$vif" ifname
91 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
93 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
96 config_set
"$vif" ifname
"$ifname"
98 # only need to change freq band and channel on the first vif
99 config_get agmode
"$device" agmode
100 [ -z "$agmode" ] && config_get agmode
"$device" mode
106 *g
) agmode
=11g
; pureg
=1;;
114 iwpriv
"$ifname" mode
"$agmode"
115 iwpriv
"$ifname" pureg
"$pureg"
117 [ "$first" = 1 ] && {
118 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
121 config_get_bool hidden
"$vif" hidden
0
122 iwpriv
"$ifname" hide_ssid
"$hidden"
124 config_get ff
"$vif" ff
125 if [ -n "$ff" ]; then
126 iwpriv
"$ifname" ff
"$ff"
129 config_get wds
"$vif" wds
131 1|on|enabled
) wds
=1;;
134 iwpriv
"$ifname" wds
"$wds"
136 [ "$mode" = ap
-a "$wds" = 1 ] && {
137 config_get_bool wdssep
"$vif" wdssep
1
138 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
143 for idx
in 1 2 3 4; do
144 config_get key
"$vif" "key${idx}"
145 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
147 config_get key
"$vif" key
150 [1234]) iwconfig
"$ifname" enc
"[$key]";;
151 *) iwconfig
"$ifname" enc
"$key";;
156 config_get key
"$vif" key
162 config_get addr
"$vif" bssid
164 iwconfig
"$ifname" ap
"$addr"
168 config_get ssid
"$vif" ssid
170 config_get_bool bgscan
"$vif" bgscan
171 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
173 config_get_bool antdiv
"$device" diversity
174 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
176 config_get antrx
"$device" rxantenna
177 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
179 config_get anttx
"$device" txantenna
180 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
182 config_get distance
"$device" distance
183 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
185 config_get_bool softled
"$device" softled
1
186 [ -n "$softled" ] && sysctl
-w dev.
"$device".softled
="$softled" >&-
188 config_get txpwr
"$vif" txpower
189 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
191 config_get rate
"$vif" rate
192 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
194 config_get mcast_rate
"$vif" mcast_rate
195 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
197 config_get frag
"$vif" frag
198 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
200 config_get rts
"$vif" rts
201 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
203 config_get_bool comp
"$vif" compression
204 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
206 config_get_bool minrate
"$vif" minrate
207 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
209 config_get_bool maxrate
"$vif" maxrate
210 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
212 config_get_bool burst
"$vif" bursting
213 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
215 config_get_bool wmm
"$vif" wmm
216 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
218 config_get_bool xr
"$vif" xr
219 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
221 config_get_bool
ar "$vif" ar
222 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
224 config_get_bool turbo
"$vif" turbo
225 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
227 config_get_bool doth
"$vif" doth
0
228 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
230 config_get maclist
"$vif" maclist
231 [ -n "$maclist" ] && {
233 iwpriv
"$ifname" maccmd
3
234 for mac
in $maclist; do
235 iwpriv
"$ifname" addmac
"$mac"
239 config_get macpolicy
"$vif" macpolicy
242 iwpriv
"$ifname" maccmd
1
245 iwpriv
"$ifname" maccmd
2
248 # default deny policy if mac list exists
249 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
253 ifconfig
"$ifname" up
255 net_cfg
="$(find_net_config "$vif")"
256 [ -z "$net_cfg" ] ||
{
257 bridge
="$(bridge_interface "$net_cfg")"
258 config_set
"$vif" bridge
"$bridge"
259 start_net
"$ifname" "$net_cfg"
261 [ -n "$ssid" ] && iwconfig
"$ifname" essid on
262 iwconfig
"$ifname" essid
"$ssid"
263 set_wifi_up
"$vif" "$ifname"
266 config_get_bool isolate
"$vif" isolate
0
267 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
269 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
270 hostapd_setup_vif
"$vif" madwifi ||
{
271 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
272 # make sure this wifi interface won't accidentally stay open without encryption
273 ifconfig
"$ifname" down
274 wlanconfig
"$ifname" destroy
280 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
281 wpa_supplicant_setup_vif
"$vif" madwifi ||
{
282 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
283 ifconfig
"$ifname" down
284 wlanconfig
"$ifname" destroy
298 for dev
in $
(ls -d wifi
* 2>&-); do
299 config_get
type "$dev" type
300 [ "$type" = atheros
] && return
302 config wifi-device $dev
306 # REMOVE THIS LINE TO ENABLE WIFI:
314 option encryption none