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 addr
"$vif" bssid
22 config_get ssid
"$vif" ssid
23 [ -z "$addr" -a -n "$ssid" ] && {
24 config_set
"$vif" wds
1
25 config_set
"$vif" mode sta
29 ${addr:+append $mode "$vif"}
31 *) echo "$device($vif): Invalid mode, ignored."; continue;;
35 case "${adhoc:+1}:${sta:+1}:${ap+1}" in
36 # valid mode combinations
39 :1:1)config_set
"$device" nosbeacon
1;; # AP+STA, can't use beacon timers for STA
43 *) echo "$device: Invalid mode combination in config"; return 1;;
46 config_set
"$device" vifs
"${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${sta:+$sta }${wds:+$wds }${monitor:+$monitor}"
53 set_wifi_down
"$device"
54 # kill all running hostapd and wpa_supplicant processes that
55 # are running on atheros vifs
56 for pid
in `pidof hostapd wpa_supplicant`; do
57 grep ath
/proc
/$pid/cmdline
>/dev
/null
&& \
64 grep "$device" "$dev/%parent" >/dev
/null
2>/dev
/null
&& {
67 wlanconfig
"$dev" destroy
75 config_get channel
"$device" channel
76 config_get vifs
"$device" vifs
78 [ auto
= "$channel" ] && channel
=0
83 config_get ifname
"$vif" ifname
84 config_get enc
"$vif" encryption
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;;
110 iwpriv
"$ifname" mode
"$agmode"
111 iwpriv
"$ifname" pureg
"$pureg"
112 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
115 config_get_bool hidden
"$vif" hidden
0
116 iwpriv
"$ifname" hide_ssid
"$hidden"
118 config_get ff
"$vif" ff
119 if [ -n "$ff" ]; then
120 iwpriv
"$ifname" ff
"$ff"
123 config_get wdssep
"$vif" wdssep
124 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
126 config_get wds
"$vif" wds
128 1|on|enabled
) wds
=1;;
131 iwpriv
"$ifname" wds
"$wds"
136 for idx
in 1 2 3 4; do
137 config_get key
"$vif" "key${idx}"
138 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
140 config_get key
"$vif" key
143 [1234]) iwconfig
"$ifname" enc
"[$key]";;
144 *) iwconfig
"$ifname" enc
"$key";;
148 config_get key
"$vif" key
154 config_get addr
"$vif" bssid
155 iwpriv
"$ifname" wds_add
"$addr"
158 config_get addr
"$vif" bssid
160 iwconfig
"$ifname" ap
"$addr"
164 config_get ssid
"$vif" ssid
166 config_get_bool bgscan
"$vif" bgscan
167 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
169 config_get_bool antdiv
"$device" diversity
170 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
172 config_get antrx
"$device" rxantenna
173 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
175 config_get anttx
"$device" txantenna
176 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
178 config_get distance
"$device" distance
179 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
181 config_get txpwr
"$vif" txpower
182 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
184 config_get rate
"$vif" rate
185 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
187 config_get mcast_rate
"$vif" mcast_rate
188 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
190 config_get frag
"$vif" frag
191 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
193 config_get rts
"$vif" rts
194 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
196 config_get_bool comp
"$vif" compression
197 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
199 config_get_bool minrate
"$vif" minrate
200 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
202 config_get_bool maxrate
"$vif" maxrate
203 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
205 config_get_bool burst
"$vif" bursting
206 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
208 config_get_bool wmm
"$vif" wmm
209 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
211 config_get_bool xr
"$vif" xr
212 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
214 config_get_bool
ar "$vif" ar
215 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
217 config_get_bool turbo
"$vif" turbo
218 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
220 config_get_bool doth
"$vif" doth
0
221 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
223 config_get maclist
"$vif" maclist
224 [ -n "$maclist" ] && {
226 iwpriv
"$ifname" maccmd
3
227 for mac
in $maclist; do
228 iwpriv
"$ifname" addmac
"$mac"
232 config_get macpolicy
"$vif" macpolicy
235 iwpriv
"$ifname" maccmd
1
238 iwpriv
"$ifname" maccmd
2
241 # default deny policy if mac list exists
242 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
246 ifconfig
"$ifname" up
248 net_cfg
="$(find_net_config "$vif")"
249 [ -z "$net_cfg" ] ||
{
250 bridge
="$(bridge_interface "$net_cfg")"
251 config_set
"$vif" bridge
"$bridge"
252 start_net
"$ifname" "$net_cfg"
254 iwconfig
"$ifname" essid
"$ssid"
255 set_wifi_up
"$vif" "$ifname"
258 config_get_bool isolate
"$vif" isolate
0
259 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
261 if eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
262 hostapd_setup_vif
"$vif" madwifi ||
{
263 echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2
264 # make sure this wifi interface won't accidentally stay open without encryption
265 ifconfig
"$ifname" down
266 wlanconfig
"$ifname" destroy
272 config_get_bool usepassphrase
"$vif" passphrase
1
278 if [ "$usepassphrase" = "1" ]; then
279 passphrase
="psk=\"${key}\""
281 passphrase
="psk=${key}"
286 if [ "$usepassphrase" = "1" ]; then
287 passphrase
="psk=\"${key}\""
289 passphrase
="psk=${key}"
293 cat > /var
/run
/wpa_supplicant-
$ifname.conf
<<EOF
304 #add wpa_supplicant calls here
307 [ -z "$proto" ] || wpa_supplicant
${bridge:+ -b $bridge} -B -D madwifi
-i "$ifname" -c /var
/run
/wpa_supplicant-
$ifname.conf
318 for dev
in $
(ls -d wifi
* 2>&-); do
319 config_get
type "$dev" type
320 [ "$type" = atheros
] && return
322 config wifi-device $dev
326 # REMOVE THIS LINE TO ENABLE WIFI:
334 option encryption none