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
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 }"
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
81 config_get ifname
"$vif" ifname
82 config_get enc
"$vif" encryption
83 config_get mode
"$vif" mode
85 [ "$mode" = sta
] && config_get nosbeacon
"$device" nosbeacon
87 config_get ifname
"$vif" ifname
88 ifname
=$
(wlanconfig
"$ifname" create wlandev
"$device" wlanmode
"$mode" ${nosbeacon:+nosbeacon})
90 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
93 config_set
"$vif" ifname
"$ifname"
96 # only need to change freq band and channel on the first vif
97 config_get agmode
"$device" agmode
102 *g
) agmode
=11g
; pureg
=1;;
106 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
107 ifconfig
"$ifname" up
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"
132 for idx
in 1 2 3 4; do
133 config_get key
"$vif" "key${idx}"
134 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
136 config_get key
"$vif" key
139 [1234]) iwconfig
"$ifname" enc
"[$key]";;
140 *) iwconfig
"$ifname" enc
"$key";;
144 config_get key
"$vif" key
150 config_get addr
"$vif" bssid
151 iwpriv
"$ifname" wds_add
"$addr"
154 config_get addr
"$vif" bssid
156 iwconfig
"$ifname" ap
"$addr"
160 config_get ssid
"$vif" ssid
162 config_get_bool bgscan
"$vif" bgscan
163 [ -n "$bgscan" ] && iwpriv
"$ifname" bgscan
"$bgscan"
165 config_get_bool antdiv
"$device" diversity
166 [ -n "$antdiv" ] && sysctl
-w dev.
"$device".diversity
="$antdiv" >&-
168 config_get antrx
"$device" rxantenna
169 [ -n "$antrx" ] && sysctl
-w dev.
"$device".rxantenna
="$antrx" >&-
171 config_get anttx
"$device" txantenna
172 [ -n "$anttx" ] && sysctl
-w dev.
"$device".txantenna
="$anttx" >&-
174 config_get distance
"$device" distance
175 [ -n "$distance" ] && athctrl
-i "$device" -d "$distance" >&-
177 config_get txpwr
"$vif" txpower
178 [ -n "$txpwr" ] && iwconfig
"$ifname" txpower
"${txpwr%%.*}"
180 config_get rate
"$vif" rate
181 [ -n "$rate" ] && iwconfig
"$ifname" rate
"${rate%%.*}"
183 config_get mcast_rate
"$vif" mcast_rate
184 [ -n "$mcast_rate" ] && iwpriv
"$ifname" mcast_rate
"${mcast_rate%%.*}"
186 config_get frag
"$vif" frag
187 [ -n "$frag" ] && iwconfig
"$ifname" frag
"${frag%%.*}"
189 config_get rts
"$vif" rts
190 [ -n "$rts" ] && iwconfig
"$ifname" rts
"${rts%%.*}"
192 config_get_bool doth
"$vif" 80211h
193 [ -n "$doth" ] && iwpriv
"$ifname" doth
"$doth"
195 config_get_bool comp
"$vif" compression
196 [ -n "$comp" ] && iwpriv
"$ifname" compression
"$comp"
198 config_get_bool burst
"$vif" bursting
199 [ -n "$burst" ] && iwpriv
"$ifname" burst
"$burst"
201 config_get_bool wmm
"$vif" wmm
202 [ -n "$wmm" ] && iwpriv
"$ifname" wmm
"$wmm"
204 config_get_bool xr
"$vif" xr
205 [ -n "$xr" ] && iwpriv
"$ifname" xr
"$xr"
207 config_get_bool
ar "$vif" ar
208 [ -n "$ar" ] && iwpriv
"$ifname" ar "$ar"
210 config_get_bool turbo
"$vif" turbo
211 [ -n "$turbo" ] && iwpriv
"$ifname" turbo
"$turbo"
213 config_get maclist
"$vif" maclist
214 [ -n "$maclist" ] && {
216 iwpriv
"$ifname" maccmd
3
217 for mac
in $maclist; do
218 iwpriv
"$ifname" addmac
"$mac"
222 config_get macpolicy
"$vif" macpolicy
225 iwpriv
"$ifname" maccmd
1
228 iwpriv
"$ifname" maccmd
2
231 # default deny policy if mac list exists
232 [ -n "$maclist" ] && iwpriv
"$ifname" maccmd
2
236 ifconfig
"$ifname" up
237 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
240 net_cfg
="$(find_net_config "$vif")"
241 [ -z "$net_cfg" ] ||
{
242 bridge
="$(bridge_interface "$net_cfg")"
243 config_set
"$vif" bridge
"$bridge"
244 start_net
"$ifname" "$net_cfg"
246 iwconfig
"$ifname" essid
"$ssid"
247 set_wifi_up
"$vif" "$ifname"
250 config_get_bool isolate
"$vif" isolate
0
251 iwpriv
"$ifname" ap_bridge
"$((isolate^1))"
253 if eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
254 hostapd_setup_vif
"$vif" madwifi ||
{
255 echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2
256 # make sure this wifi interface won't accidentally stay open without encryption
257 ifconfig
"$ifname" down
258 wlanconfig
"$ifname" destroy
273 passphrase
=`wpa_passphrase ${ssid} "${key}" | grep psk | grep -v \#| cut -d= -f2`
277 cat > /var
/run
/wpa_supplicant-
$ifname.conf
<<EOF
278 ctrl_interface=/var/run/wpa_supplicant
289 #add wpa_supplicant calls here
292 [ -z "$proto" ] || wpa_supplicant
${bridge:+ -b $bridge} -B -D wext
-i "$ifname" -c /var
/run
/wpa_supplicant-
$ifname.conf
303 for dev
in $
(ls -d wifi
* 2>&-); do
304 config_get
type "$dev" type
305 [ "$type" = atheros
] && return
307 config wifi-device $dev
311 # REMOVE THIS LINE TO ENABLE WIFI:
319 option encryption none