1 append DRIVERS
"broadcom"
6 local adhoc sta apmode mon disabled
7 local adhoc_if sta_if ap_if mon_if
10 config_get vifs
"$device" vifs
12 config_get_bool disabled
"$vif" disabled
0
13 [ $disabled -eq 0 ] ||
continue
15 config_get mode
"$vif" mode
28 ap_if
="${ap_if:+$ap_if }$vif"
31 config_get addr
"$vif" bssid
33 addr
=$
(echo "$addr" |
tr 'A-F' 'a-f')
41 *) echo "$device($vif): Invalid mode";;
44 config_set
"$device" wds
"$wds"
47 for vif
in ${adhoc_if:-$sta_if $ap_if $mon_if}; do
48 config_set
"$vif" ifname
"${device}${_c:+.$_c}"
51 config_set
"$device" vifs
"${adhoc_if:-$sta_if $ap_if $mon_if}"
54 for vif
in 0 1 2 3; do
55 append ifdown
"vif $vif" "$N"
56 append ifdown
"enabled 0" "$N"
61 if [ "$_c" -gt 1 ]; then
69 case "$adhoc:$sta:$apmode:$mon" in
98 set_wifi_down
"$device"
99 wlc ifname
"$device" down
100 wlc ifname
"$device" bssid
`wlc ifname "$device" default_bssid`
104 # make sure the interfaces are down and removed from all bridges
105 for dev
in $device ${device}.1 ${device}.2 ${device}.3; do
106 ifconfig
"$dev" down
2>/dev
/null
>/dev
/null
&& {
117 config_get channel
"$device" channel
118 config_get country
"$device" country
119 config_get maxassoc
"$device" maxassoc
120 config_get wds
"$device" wds
121 config_get vifs
"$device" vifs
122 config_get distance
"$device" distance
123 config_get slottime
"$device" slottime
124 config_get rxantenna
"$device" rxantenna
125 config_get txantenna
"$device" txantenna
126 config_get_bool frameburst
"$device" frameburst
127 config_get macfilter
"$device" macfilter
128 config_get maclist
"$device" maclist
129 config_get macaddr
"$device" macaddr
130 config_get txpower
"$device" txpower
131 config_get frag
"$device" frag
132 config_get rts
"$device" rts
133 config_get hwmode
"$device" hwmode
134 local vif_pre_up vif_post_up vif_do_up vif_txpower
143 [ -z "$slottime" ] && {
144 [ -n "$distance" ] && {
145 # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
146 slottime
="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
149 slottime
="${slottime:--1}"
174 config_get vif_txpower
"$vif" txpower
176 config_get mode
"$vif" mode
177 append vif_pre_up
"vif $_c" "$N"
178 append vif_post_up
"vif $_c" "$N"
179 append vif_do_up
"vif $_c" "$N"
181 config_get_bool wmm
"$vif" wmm
"$wmm"
182 config_get_bool doth
"$vif" doth
"$doth"
184 [ "$mode" = "sta" ] ||
{
185 config_get_bool hidden
"$vif" hidden
0
186 append vif_pre_up
"closed $hidden" "$N"
187 config_get_bool isolate
"$vif" isolate
0
188 append vif_pre_up
"ap_isolate $isolate" "$N"
196 config_get enc
"$vif" encryption
202 config_get key
"$vif" key
204 *shared
*) append vif_do_up
"wepauth 1" "$N";;
205 *) append vif_do_up
"wepauth 0" "$N";;
210 for knr
in 1 2 3 4; do
211 config_get k
"$vif" key
$knr
212 [ -n "$k" ] ||
continue
213 [ "$defkey" = "$knr" ] && def
="=" || def
=""
214 append vif_do_up
"wepkey $def$knr,$k" "$N"
218 *) append vif_do_up
"wepkey =1,$key" "$N";;
223 config_get key
"$vif" key
225 # psk version + default cipher
227 *mixed
*|
*psk
+psk2
*) auth
=132; wsec
=6;;
228 *psk2
*) auth
=128; wsec
=4;;
234 *tkip
+aes
*|
*tkip
+ccmp
*|
*aes
+tkip
*|
*ccmp
+tkip
*) wsec
=6;;
235 *aes
*|
*ccmp
*) wsec
=4;;
239 # group rekey interval
240 config_get rekey
"$vif" wpa_group_rekey
242 eval "${vif}_key=\"\$key\""
243 nasopts
="-k \"\$${vif}_key\"${rekey:+ -g $rekey}"
248 config_get auth_server
"$vif" auth_server
249 [ -z "$auth_server" ] && config_get auth_server
"$vif" server
250 config_get auth_port
"$vif" auth_port
251 [ -z "$auth_port" ] && config_get auth_port
"$vif" port
252 config_get auth_secret
"$vif" auth_secret
253 [ -z "$auth_secret" ] && config_get auth_secret
"$vif" key
255 # wpa version + default cipher
257 *mixed
*|
*wpa
+wpa2
*) auth
=66; wsec
=6;;
258 *wpa2
*) auth
=64; wsec
=4;;
264 *tkip
+aes
*|
*tkip
+ccmp
*|
*aes
+tkip
*|
*ccmp
+tkip
*) wsec
=6;;
265 *aes
*|
*ccmp
*) wsec
=4;;
269 # group rekey interval
270 config_get rekey
"$vif" wpa_group_rekey
272 eval "${vif}_key=\"\$auth_secret\""
273 nasopts
="-r \"\$${vif}_key\" -h $auth_server -p ${auth_port:-1812}${rekey:+ -g $rekey}"
276 append vif_do_up
"wsec $wsec" "$N"
277 append vif_do_up
"wpa_auth $auth" "$N"
278 append vif_do_up
"wsec_restrict $wsec_r" "$N"
279 append vif_do_up
"eap_restrict $eap_r" "$N"
281 config_get ssid
"$vif" ssid
282 append vif_post_up
"vlan_mode 0" "$N"
283 append vif_post_up
"ssid $ssid" "$N"
284 append vif_do_up
"ssid $ssid" "$N"
286 [ "$mode" = "monitor" ] && {
287 append vif_post_up
"monitor $monitor" "$N"
290 [ "$mode" = "adhoc" ] && {
291 config_get bssid
"$vif" bssid
293 append vif_pre_up
"bssid $bssid" "$N"
294 append vif_pre_up
"ibss_merge 0" "$N"
296 append vif_pre_up
"ibss_merge 1" "$N"
300 append vif_post_up
"enabled 1" "$N"
302 config_get ifname
"$vif" ifname
303 #append if_up "ifconfig $ifname up" ";$N"
306 net_cfg
="$(find_net_config "$vif")"
307 [ -z "$net_cfg" ] ||
{
308 append if_up
"set_wifi_up '$vif' '$ifname'" ";$N"
309 append if_up
"start_net '$ifname' '$net_cfg'" ";$N"
311 [ -z "$nasopts" ] ||
{
312 eval "${vif}_ssid=\"\$ssid\""
314 [ "$mode" = "sta" ] && nas_mode
="-S"
316 nas_cmd
="${nas_cmd:+$nas_cmd$N}start-stop-daemon -S -b -p /var/run/nas.$ifname.pid -x $nas -- -P /var/run/nas.$ifname.pid -H 34954 -i $ifname $nas_mode -m $auth -w $wsec -s \"\$${vif}_ssid\" -g 3600 -F $nasopts"
321 killall
-KILL nas
>&- 2>&-
322 wlc ifname
"$device" stdin
<<EOF
328 ${mssid:+mssid $mssid}
334 rxant ${rxantenna:-3}
335 txant ${txantenna:-3}
336 fragthresh ${frag:-2346}
337 rtsthresh ${rts:-2347}
338 monitor ${monitor:-0}
341 macfilter ${macfilter:-0}
342 maclist ${maclist:-none}
345 country ${country:-US}
346 ${channel:+channel $channel}
347 maxassoc ${maxassoc:-128}
348 slottime ${slottime:--1}
349 ${frameburst:+frameburst $frameburst}
356 wlc ifname
"$device" stdin
<<EOF
360 # use vif_txpower (from last wifi-iface) instead of txpower (from
361 # wifi-device) if the latter does not exist
362 txpower
=${txpower:-$vif_txpower}
363 [ -z "$txpower" ] || iwconfig
$device txpower
${txpower}dBm
372 while grep -qs "^ *wl$((++i)):" /proc
/net
/dev
; do
373 config_get
type wl
${i} type
374 [ "$type" = broadcom
] && continue
376 config wifi-device wl${i}
380 # REMOVE THIS LINE TO ENABLE WIFI:
387 option ssid OpenWrt${i#0}
388 option encryption none