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 mode
"$vif" mode
86 [ "$mode" = sta
] && config_get nosbeacon
"$device" nosbeacon
88 config_get ifname
"$vif" ifname
89 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
91 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
94 config_set
"$vif" ifname
"$ifname"
97 # only need to change freq band and channel on the first vif
98 config_get agmode
"$device" agmode
99 [ -z "$agmode" ] && config_get agmode
"$device" mode
105 *g
) agmode
=11g
; pureg
=1;;
109 iwpriv
"$ifname" mode
"$agmode"
110 iwpriv
"$ifname" pureg
"$pureg"
111 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
114 config_get_bool hidden
"$vif" hidden
0
115 iwpriv
"$ifname" hide_ssid
"$hidden"
117 config_get ff
"$vif" ff
118 if [ -n "$ff" ]; then
119 iwpriv
"$ifname" ff
"$ff"
122 config_get wds
"$vif" wds
124 1|on|enabled
) wds
=1;;
127 iwpriv
"$ifname" wds
"$wds"
129 [ "$mode" = ap
-a "$wds" = 1 ] && {
130 config_get_bool wdssep
"$vif" wdssep
1
131 [ -n "$wdssep" ] && iwpriv
"$ifname" wdssep
"$wdssep"
137 for idx
in 1 2 3 4; do
138 config_get key
"$vif" "key${idx}"
139 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
141 config_get key
"$vif" key
144 [1234]) iwconfig
"$ifname" enc
"[$key]";;
145 *) iwconfig
"$ifname" enc
"$key";;
149 config_get key
"$vif" key
155 config_get addr
"$vif" bssid
157 iwconfig
"$ifname" ap
"$addr"
161 config_get ssid
"$vif" ssid
163 config_get_bool bgscan
"$vif" bgscan
164 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
166 config_get_bool antdiv
"$device" diversity
167 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
169 config_get antrx
"$device" rxantenna
170 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
172 config_get anttx
"$device" txantenna
173 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
175 config_get distance
"$device" distance
176 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
178 config_get txpwr
"$vif" txpower
179 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
181 config_get rate
"$vif" rate
182 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
184 config_get mcast_rate
"$vif" mcast_rate
185 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
187 config_get frag
"$vif" frag
188 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
190 config_get rts
"$vif" rts
191 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
193 config_get_bool comp
"$vif" compression
194 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
196 config_get_bool minrate
"$vif" minrate
197 [ -n "$minrate" ] && iwpriv
"$ifname" minrate
"$minrate"
199 config_get_bool maxrate
"$vif" maxrate
200 [ -n "$maxrate" ] && iwpriv
"$ifname" maxrate
"$maxrate"
202 config_get_bool burst
"$vif" bursting
203 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
205 config_get_bool wmm
"$vif" wmm
206 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
208 config_get_bool xr
"$vif" xr
209 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
211 config_get_bool
ar "$vif" ar
212 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
214 config_get_bool turbo
"$vif" turbo
215 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
217 config_get_bool doth
"$vif" doth
0
218 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
220 config_get maclist
"$vif" maclist
221 [ -n "$maclist" ] && {
223 iwpriv
"$ifname" maccmd
3
224 for mac
in $maclist; do
225 iwpriv
"$ifname" addmac
"$mac"
229 config_get macpolicy
"$vif" macpolicy
232 iwpriv
"$ifname" maccmd
1
235 iwpriv
"$ifname" maccmd
2
238 # default deny policy if mac list exists
239 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
243 ifconfig
"$ifname" up
245 net_cfg
="$(find_net_config "$vif")"
246 [ -z "$net_cfg" ] ||
{
247 bridge
="$(bridge_interface "$net_cfg")"
248 config_set
"$vif" bridge
"$bridge"
249 start_net
"$ifname" "$net_cfg"
251 iwconfig
"$ifname" essid
"$ssid"
252 set_wifi_up
"$vif" "$ifname"
255 config_get_bool isolate
"$vif" isolate
0
256 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
258 if eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
259 hostapd_setup_vif
"$vif" madwifi ||
{
260 echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2
261 # make sure this wifi interface won't accidentally stay open without encryption
262 ifconfig
"$ifname" down
263 wlanconfig
"$ifname" destroy
269 config_get_bool usepassphrase
"$vif" passphrase
1
275 if [ "$usepassphrase" = "1" ]; then
276 passphrase
="psk=\"${key}\""
278 passphrase
="psk=${key}"
283 if [ "$usepassphrase" = "1" ]; then
284 passphrase
="psk=\"${key}\""
286 passphrase
="psk=${key}"
290 cat > /var
/run
/wpa_supplicant-
$ifname.conf
<<EOF
301 #add wpa_supplicant calls here
304 [ -z "$proto" ] || wpa_supplicant
${bridge:+ -b $bridge} -B -D madwifi
-i "$ifname" -c /var
/run
/wpa_supplicant-
$ifname.conf
315 for dev
in $
(ls -d wifi
* 2>&-); do
316 config_get
type "$dev" type
317 [ "$type" = atheros
] && return
319 config wifi-device $dev
323 # REMOVE THIS LINE TO ENABLE WIFI:
331 option encryption none