2 append DRIVERS "atheros"
7 local adhoc ahdemo sta ap monitor
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 "${sta:+$sta }${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${wds:+$wds }${monitor:+$monitor}"
52 set_wifi_down "$device"
57 grep "$device" "$dev/%parent" >/dev/null 2>/dev/null && {
58 [ -f "/var/run/wifi-${dev}.pid" ] &&
59 kill "$(cat "/var/run/wifi-${dev}.pid")"
62 wlanconfig "$dev" destroy
71 config_get regdomain "$device" regdomain
72 [ -n "$regdomain" ] && echo "$regdomain" > /proc/sys/dev/$device/regdomain
74 config_get country "$device" country
75 [ -z "$country" ] && country="0"
76 echo "$country" > /proc/sys/dev/$device/countrycode
78 config_get_bool outdoor "$device" outdoor "0"
79 echo "$outdoor" > /proc/sys/dev/$device/outdoor
81 config_get channel "$device" channel
82 config_get vifs "$device" vifs
83 config_get txpower "$device" txpower
85 [ auto = "$channel" ] && channel=0
87 config_get_bool antdiv "$device" diversity
88 config_get antrx "$device" rxantenna
89 config_get anttx "$device" txantenna
90 config_get_bool softled "$device" softled
91 config_get antenna "$device" antenna
93 devname="$(cat /proc/sys/dev/$device/dev_name)"
97 NanoStation2) antgpio=7; invert=1;;
98 NanoStation5) antgpio=1; invert=1;;
99 "NanoStation Loco2") antgpio=2;;
102 horizontal) antdiv=0; anttx=1; antrx=1;;
103 vertical) antdiv=0; anttx=2; antrx=2;;
104 *) antdiv=1; anttx=0; antrx=0;;
108 if [ -n "$invert" ]; then
115 if [ -n "$antgpio" ]; then
123 horizontal) gpioval=0;;
129 external) antdiv=0; antrx=1; anttx=1; gpioval=1;;
130 horizontal) antdiv=0; antrx=1; anttx=1; gpioval=0;;
131 vertical) antdiv=0; antrx=2; anttx=2; gpioval=0;;
132 auto) antdiv=1; antrx=0; anttx=0; gpioval=0;;
137 [ -x "$(which gpioctl 2>/dev/null)" ] || antenna=
138 gpioctl "dirout" "$antgpio" >/dev/null 2>&1
141 gpioctl "$_clear" "$antgpio" >/dev/null 2>&1
144 gpioctl "$_set" "$antgpio" >/dev/null 2>&1
149 [ -n "$antdiv" ] && sysctl -w dev."$device".diversity="$antdiv" >&-
150 [ -n "$antrx" ] && sysctl -w dev."$device".rxantenna="$antrx" >&-
151 [ -n "$anttx" ] && sysctl -w dev."$device".txantenna="$anttx" >&-
152 [ -n "$softled" ] && sysctl -w dev."$device".softled="$softled" >&-
154 config_get distance "$device" distance
155 [ -n "$distance" ] && sysctl -w dev."$device".distance="$distance" >&-
158 local start_hostapd= vif_txpower= nosbeacon=
159 config_get ifname "$vif" ifname
160 config_get enc "$vif" encryption
161 config_get eap_type "$vif" eap_type
162 config_get mode "$vif" mode
165 sta) config_get_bool nosbeacon "$device" nosbeacon;;
166 adhoc) config_get_bool nosbeacon "$vif" sw_merge 1;;
169 [ "$nosbeacon" = 1 ] || nosbeacon=""
170 ifname=$(wlanconfig "$ifname" create wlandev "$device" wlanmode "$mode" ${nosbeacon:+nosbeacon})
172 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
175 config_set "$vif" ifname "$ifname"
177 config_get hwmode "$device" hwmode
178 [ -z "$hwmode" ] && config_get hwmode "$device" mode
184 *g) hwmode=11g; pureg=1;;
192 iwpriv "$ifname" mode "$hwmode"
193 iwpriv "$ifname" pureg "$pureg"
195 iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null
197 config_get_bool hidden "$vif" hidden 0
198 iwpriv "$ifname" hide_ssid "$hidden"
200 config_get ff "$vif" ff
201 if [ -n "$ff" ]; then
202 iwpriv "$ifname" ff "$ff"
205 config_get wds "$vif" wds
207 1|on|enabled) wds=1;;
210 iwpriv "$ifname" wds "$wds" >/dev/null 2>&1
212 [ "$mode" = ap -a "$wds" = 1 ] && {
213 config_get_bool wdssep "$vif" wdssep 1
214 [ -n "$wdssep" ] && iwpriv "$ifname" wdssep "$wdssep"
219 for idx in 1 2 3 4; do
220 config_get key "$vif" "key${idx}"
221 iwconfig "$ifname" enc "[$idx]" "${key:-off}"
223 config_get key "$vif" key
226 [1234]) iwconfig "$ifname" enc "[$key]";;
227 *) iwconfig "$ifname" enc "$key";;
232 config_get key "$vif" key
238 config_get addr "$vif" bssid
240 iwconfig "$ifname" ap "$addr"
245 config_get_bool uapsd "$vif" uapsd 0
246 iwpriv "$ifname" uapsd "$uapsd"
248 config_get_bool bgscan "$vif" bgscan
249 [ -n "$bgscan" ] && iwpriv "$ifname" bgscan "$bgscan"
251 config_get rate "$vif" rate
252 [ -n "$rate" ] && iwconfig "$ifname" rate "${rate%%.*}"
254 config_get mcast_rate "$vif" mcast_rate
255 [ -n "$mcast_rate" ] && iwpriv "$ifname" mcast_rate "${mcast_rate%%.*}"
257 config_get frag "$vif" frag
258 [ -n "$frag" ] && iwconfig "$ifname" frag "${frag%%.*}"
260 config_get rts "$vif" rts
261 [ -n "$rts" ] && iwconfig "$ifname" rts "${rts%%.*}"
263 config_get_bool comp "$vif" compression 0
264 iwpriv "$ifname" compression "$comp" >/dev/null 2>&1
266 config_get_bool minrate "$vif" minrate
267 [ -n "$minrate" ] && iwpriv "$ifname" minrate "$minrate"
269 config_get_bool maxrate "$vif" maxrate
270 [ -n "$maxrate" ] && iwpriv "$ifname" maxrate "$maxrate"
272 config_get_bool burst "$vif" bursting
273 [ -n "$burst" ] && iwpriv "$ifname" burst "$burst"
275 config_get_bool wmm "$vif" wmm
276 [ -n "$wmm" ] && iwpriv "$ifname" wmm "$wmm"
278 config_get_bool xr "$vif" xr
279 [ -n "$xr" ] && iwpriv "$ifname" xr "$xr"
281 config_get_bool ar "$vif" ar
282 [ -n "$ar" ] && iwpriv "$ifname" ar "$ar"
284 config_get_bool beacon_power "$vif" beacon_power
285 [ -n "$beacon_power" ] && iwpriv "$ifname" beacon_pwr "$beacon_power"
287 config_get_bool doth "$vif" doth 0
288 [ -n "$doth" ] && iwpriv "$ifname" doth "$doth"
290 config_get_bool probereq "$vif" probereq
291 [ -n "$probereq" ] && iwpriv "$ifname" probereq "$probereq"
293 config_get maclist "$vif" maclist
294 [ -n "$maclist" ] && {
296 iwpriv "$ifname" maccmd 3
297 for mac in $maclist; do
298 iwpriv "$ifname" addmac "$mac"
302 config_get macpolicy "$vif" macpolicy
305 iwpriv "$ifname" maccmd 1
308 iwpriv "$ifname" maccmd 2
311 # default deny policy if mac list exists
312 [ -n "$maclist" ] && iwpriv "$ifname" maccmd 2
316 ifconfig "$ifname" up
319 net_cfg="$(find_net_config "$vif")"
320 [ -z "$net_cfg" ] || {
321 bridge="$(bridge_interface "$net_cfg")"
322 config_set "$vif" bridge "$bridge"
323 start_net "$ifname" "$net_cfg"
326 config_get ssid "$vif" ssid
328 iwconfig "$ifname" essid on
329 iwconfig "$ifname" essid "$ssid"
332 set_wifi_up "$vif" "$ifname"
334 # TXPower settings only work if device is up already
335 # while atheros hardware theoretically is capable of per-vif (even per-packet) txpower
336 # adjustment it does not work with the current atheros hal/madwifi driver
338 config_get vif_txpower "$vif" txpower
339 # use vif_txpower (from wifi-iface) instead of txpower (from wifi-device) if
340 # the latter doesn't exist
341 txpower="${txpower:-$vif_txpower}"
342 [ -z "$txpower" ] || iwconfig "$ifname" txpower "${txpower%%.*}"
346 config_get_bool isolate "$vif" isolate 0
347 iwpriv "$ifname" ap_bridge "$((isolate^1))"
349 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
350 hostapd_setup_vif "$vif" madwifi || {
351 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
352 # make sure this wifi interface won't accidentally stay open without encryption
353 ifconfig "$ifname" down
354 wlanconfig "$ifname" destroy
360 if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
361 wpa_supplicant_setup_vif "$vif" madwifi || {
362 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
363 ifconfig "$ifname" down
364 wlanconfig "$ifname" destroy
377 for dev in $(ls -d wifi* 2>&-); do
378 config_get type "$dev" type
379 devname="$(cat /proc/sys/dev/$dev/dev_name)"
383 # Ubiquiti NanoStation Loco2 features
384 option antenna vertical # (horizontal|vertical)
389 # Ubiquiti NanoStation Loco5 features
390 option antenna auto # (auto|horizontal|vertical)
395 # Ubiquiti NanoStation features
396 option antenna auto # (auto|horizontal|vertical|external)
400 [ "$type" = atheros ] && continue
402 config wifi-device $dev
406 # REMOVE THIS LINE TO ENABLE WIFI:
414 option encryption none