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 "${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
89 local start_hostapd vif_txpower
91 config_get ifname "$vif" ifname
92 config_get enc "$vif" encryption
93 config_get eap_type "$vif" eap_type
94 config_get mode "$vif" mode
97 sta) config_get nosbeacon "$device" nosbeacon;;
98 adhoc) config_get nosbeacon "$vif" sw_merge;;
101 config_get ifname "$vif" ifname
102 ifname=$(wlanconfig "$ifname" create wlandev "$device" wlanmode "$mode" ${nosbeacon:+nosbeacon})
104 echo "enable_atheros($device): Failed to set up $mode vif $ifname" >&2
107 config_set "$vif" ifname "$ifname"
109 # only need to change freq band and channel on the first vif
110 config_get hwmode "$device" hwmode
111 [ -z "$hwmode" ] && config_get hwmode "$device" mode
117 *g) hwmode=11g; pureg=1;;
125 iwpriv "$ifname" pureg "$pureg"
127 [ "$first" = 1 ] && {
128 iwpriv "$ifname" mode "$hwmode"
129 iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null
132 config_get_bool hidden "$vif" hidden 0
133 iwpriv "$ifname" hide_ssid "$hidden"
135 config_get ff "$vif" ff
136 if [ -n "$ff" ]; then
137 iwpriv "$ifname" ff "$ff"
140 config_get wds "$vif" wds
142 1|on|enabled) wds=1;;
145 iwpriv "$ifname" wds "$wds"
147 [ "$mode" = ap -a "$wds" = 1 ] && {
148 config_get_bool wdssep "$vif" wdssep 1
149 [ -n "$wdssep" ] && iwpriv "$ifname" wdssep "$wdssep"
154 for idx in 1 2 3 4; do
155 config_get key "$vif" "key${idx}"
156 iwconfig "$ifname" enc "[$idx]" "${key:-off}"
158 config_get key "$vif" key
161 [1234]) iwconfig "$ifname" enc "[$key]";;
162 *) iwconfig "$ifname" enc "$key";;
167 config_get key "$vif" key
173 config_get addr "$vif" bssid
175 iwconfig "$ifname" ap "$addr"
179 config_get ssid "$vif" ssid
181 config_get_bool bgscan "$vif" bgscan
182 [ -n "$bgscan" ] && iwpriv "$ifname" bgscan "$bgscan"
184 config_get_bool antdiv "$device" diversity
185 config_get antrx "$device" rxantenna
186 config_get anttx "$device" txantenna
187 config_get_bool softled "$device" softled 1
189 devname="$(cat /proc/sys/dev/$device/dev_name)"
192 NanoStation2) antgpio=7;;
193 NanoStation5) antgpio=1;;
195 if [ -n "$antgpio" ]; then
197 config_get antenna "$device" antenna
199 external) antdiv=0; antrx=1; anttx=1 ;;
200 horizontal) antdiv=0; antrx=1; anttx=1 ;;
201 vertical) antdiv=0; antrx=2; anttx=2 ;;
202 auto) antdiv=1; antrx=0; anttx=0 ;;
205 [ -x "$(which gpioctl 2>/dev/null)" ] || antenna=
207 horizontal|vertical|auto)
208 gpioctl "dirout" "$antgpio" >/dev/null 2>&1
209 gpioctl "set" "$antgpio" >/dev/null 2>&1
212 gpioctl "dirout" "$antgpio" >/dev/null 2>&1
213 gpioctl "clear" "$antgpio" >/dev/null 2>&1
218 [ -n "$antdiv" ] && sysctl -w dev."$device".diversity="$antdiv" >&-
219 [ -n "$antrx" ] && sysctl -w dev."$device".rxantenna="$antrx" >&-
220 [ -n "$anttx" ] && sysctl -w dev."$device".txantenna="$anttx" >&-
221 [ -n "$softled" ] && sysctl -w dev."$device".softled="$softled" >&-
222 [ -n "$distance" ] && sysctl -w dev."$device".distance="$distance" >&-
224 config_get rate "$vif" rate
225 [ -n "$rate" ] && iwconfig "$ifname" rate "${rate%%.*}"
227 config_get mcast_rate "$vif" mcast_rate
228 [ -n "$mcast_rate" ] && iwpriv "$ifname" mcast_rate "${mcast_rate%%.*}"
230 config_get frag "$vif" frag
231 [ -n "$frag" ] && iwconfig "$ifname" frag "${frag%%.*}"
233 config_get rts "$vif" rts
234 [ -n "$rts" ] && iwconfig "$ifname" rts "${rts%%.*}"
236 config_get_bool comp "$vif" compression
237 [ -n "$comp" ] && iwpriv "$ifname" compression "$comp"
239 config_get_bool minrate "$vif" minrate
240 [ -n "$minrate" ] && iwpriv "$ifname" minrate "$minrate"
242 config_get_bool maxrate "$vif" maxrate
243 [ -n "$maxrate" ] && iwpriv "$ifname" maxrate "$maxrate"
245 config_get_bool burst "$vif" bursting
246 [ -n "$burst" ] && iwpriv "$ifname" burst "$burst"
248 config_get_bool wmm "$vif" wmm
249 [ -n "$wmm" ] && iwpriv "$ifname" wmm "$wmm"
251 config_get_bool xr "$vif" xr
252 [ -n "$xr" ] && iwpriv "$ifname" xr "$xr"
254 config_get_bool ar "$vif" ar
255 [ -n "$ar" ] && iwpriv "$ifname" ar "$ar"
257 config_get_bool turbo "$vif" turbo
258 [ -n "$turbo" ] && iwpriv "$ifname" turbo "$turbo"
260 config_get_bool beacon_power "$vif" beacon_power
261 [ -n "$beacon_power" ] && iwpriv "$ifname" beacon_pwr "$beacon_power"
263 config_get_bool doth "$vif" doth 0
264 [ -n "$doth" ] && iwpriv "$ifname" doth "$doth"
266 config_get_bool probereq "$vif" probereq
267 [ -n "$probereq" ] && iwpriv "$ifname" probereq "$probereq"
269 config_get maclist "$vif" maclist
270 [ -n "$maclist" ] && {
272 iwpriv "$ifname" maccmd 3
273 for mac in $maclist; do
274 iwpriv "$ifname" addmac "$mac"
278 config_get macpolicy "$vif" macpolicy
281 iwpriv "$ifname" maccmd 1
284 iwpriv "$ifname" maccmd 2
287 # default deny policy if mac list exists
288 [ -n "$maclist" ] && iwpriv "$ifname" maccmd 2
292 ifconfig "$ifname" up
295 net_cfg="$(find_net_config "$vif")"
296 [ -z "$net_cfg" ] || {
297 bridge="$(bridge_interface "$net_cfg")"
298 config_set "$vif" bridge "$bridge"
299 start_net "$ifname" "$net_cfg"
301 [ -n "$ssid" ] && iwconfig "$ifname" essid on
302 iwconfig "$ifname" essid "$ssid"
303 set_wifi_up "$vif" "$ifname"
305 # TXPower settings only work if device is up already
306 # while atheros hardware theoretically is capable of per-vif (even per-packet) txpower
307 # adjustment it does not work with the current atheros hal/madwifi driver
309 config_get vif_txpower "$vif" txpower
310 # use vif_txpower (from wifi-iface) instead of txpower (from wifi-device) if
311 # the latter doesn't exist
312 txpower="${txpower:-$vif_txpower}"
313 [ -z "$txpower" ] || iwconfig "$ifname" txpower "${txpower%%.*}"
317 config_get_bool isolate "$vif" isolate 0
318 iwpriv "$ifname" ap_bridge "$((isolate^1))"
320 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
321 hostapd_setup_vif "$vif" madwifi || {
322 echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
323 # make sure this wifi interface won't accidentally stay open without encryption
324 ifconfig "$ifname" down
325 wlanconfig "$ifname" destroy
331 if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
332 wpa_supplicant_setup_vif "$vif" madwifi || {
333 echo "enable_atheros($device): Failed to set up wpa_supplicant for interface $ifname" >&2
334 ifconfig "$ifname" down
335 wlanconfig "$ifname" destroy
349 for dev in $(ls -d wifi* 2>&-); do
350 config_get type "$dev" type
351 devname="$(cat /proc/sys/dev/$dev/dev_name)"
355 # Ubiquiti NanoStation features
356 option antenna auto # (auto|horizontal|vertical|external)
360 [ "$type" = atheros ] && return
362 config wifi-device $dev
366 # REMOVE THIS LINE TO ENABLE WIFI:
374 option encryption none