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
82 config_get ifname
"$vif" ifname
83 config_get enc
"$vif" encryption
84 config_get eap_type
"$vif" eap_type
85 config_get mode
"$vif" mode
87 [ "$mode" = sta
] && config_get nosbeacon
"$device" nosbeacon
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"
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"
116 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
119 config_get_bool hidden
"$vif" hidden
0
120 iwpriv
"$ifname" hide_ssid
"$hidden"
122 config_get ff
"$vif" ff
123 if [ -n "$ff" ]; then
124 iwpriv
"$ifname" ff
"$ff"
127 config_get wds
"$vif" wds
129 1|on|enabled
) wds
=1;;
132 iwpriv
"$ifname" wds
"$wds"
134 [ "$mode" = ap
-a "$wds" = 1 ] && {
135 config_get_bool wdssep
"$vif" wdssep
1
136 [ -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";;
154 config_get key
"$vif" key
160 config_get addr
"$vif" bssid
162 iwconfig
"$ifname" ap
"$addr"
166 config_get ssid
"$vif" ssid
168 config_get_bool bgscan
"$vif" bgscan
169 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
171 config_get_bool antdiv
"$device" diversity
172 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
174 config_get antrx
"$device" rxantenna
175 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
177 config_get anttx
"$device" txantenna
178 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
180 config_get distance
"$device" distance
181 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
183 config_get txpwr
"$vif" txpower
184 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
186 config_get rate
"$vif" rate
187 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
189 config_get mcast_rate
"$vif" mcast_rate
190 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
192 config_get frag
"$vif" frag
193 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
195 config_get rts
"$vif" rts
196 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
198 config_get_bool comp
"$vif" compression
199 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
201 config_get_bool minrate
"$vif" minrate
202 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
204 config_get_bool maxrate
"$vif" maxrate
205 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
207 config_get_bool burst
"$vif" bursting
208 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
210 config_get_bool wmm
"$vif" wmm
211 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
213 config_get_bool xr
"$vif" xr
214 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
216 config_get_bool
ar "$vif" ar
217 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
219 config_get_bool turbo
"$vif" turbo
220 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
222 config_get_bool doth
"$vif" doth
0
223 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
225 config_get maclist
"$vif" maclist
226 [ -n "$maclist" ] && {
228 iwpriv
"$ifname" maccmd
3
229 for mac
in $maclist; do
230 iwpriv
"$ifname" addmac
"$mac"
234 config_get macpolicy
"$vif" macpolicy
237 iwpriv
"$ifname" maccmd
1
240 iwpriv
"$ifname" maccmd
2
243 # default deny policy if mac list exists
244 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
248 ifconfig
"$ifname" up
250 net_cfg
="$(find_net_config "$vif")"
251 [ -z "$net_cfg" ] ||
{
252 bridge
="$(bridge_interface "$net_cfg")"
253 config_set
"$vif" bridge
"$bridge"
254 start_net
"$ifname" "$net_cfg"
256 iwconfig
"$ifname" essid
"$ssid"
257 set_wifi_up
"$vif" "$ifname"
260 config_get_bool isolate
"$vif" isolate
0
261 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
263 if eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
264 hostapd_setup_vif
"$vif" madwifi ||
{
265 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
266 # make sure this wifi interface won't accidentally stay open without encryption
267 ifconfig
"$ifname" down
268 wlanconfig
"$ifname" destroy
274 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
275 wpa_supplicant_setup_vif
"$vif" madwifi ||
{
276 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
277 ifconfig
"$ifname" down
278 wlanconfig
"$ifname" destroy
292 for dev
in $
(ls -d wifi
* 2>&-); do
293 config_get
type "$dev" type
294 [ "$type" = atheros
] && return
296 config wifi-device $dev
300 # REMOVE THIS LINE TO ENABLE WIFI:
308 option encryption none