1 append DRIVERS
"broadcom"
6 local adhoc sta apmode mon
7 local adhoc_if sta_if ap_if mon_if
10 config_get vifs
"$device" vifs
12 config_get mode
"$vif" mode
25 ap_if
="${ap_if:+$ap_if }$vif"
28 config_get addr
"$vif" bssid
30 addr
=$
(echo "$addr" |
tr 'A-F' 'a-f')
38 *) echo "$device($vif): Invalid mode";;
41 config_set
"$device" wds
"$wds"
44 for vif
in ${adhoc_if:-$sta_if $ap_if $mon_if}; do
45 config_set
"$vif" ifname
"${device}${_c:+.$_c}"
48 config_set
"$device" vifs
"${adhoc_if:-$sta_if $ap_if $mon_if}"
51 for vif
in 0 1 2 3; do
52 append ifdown
"vif $vif" "$N"
53 append ifdown
"enabled 0" "$N"
58 if [ "$_c" -gt 1 ]; then
66 case "$adhoc:$sta:$apmode:$mon" in
95 set_wifi_down
"$device"
96 wlc ifname
"$device" down
97 wlc ifname
"$device" bssid
`wlc ifname "$device" default_bssid`
101 # make sure the interfaces are down and removed from all bridges
102 for dev
in $device ${device}.1 ${device}.2 ${device}.3; do
103 ifconfig
"$dev" down
2>/dev
/null
>/dev
/null
&& {
114 config_get channel
"$device" channel
115 config_get country
"$device" country
116 config_get maxassoc
"$device" maxassoc
117 config_get wds
"$device" wds
118 config_get vifs
"$device" vifs
119 config_get distance
"$device" distance
120 config_get slottime
"$device" slottime
121 config_get rxantenna
"$device" rxantenna
122 config_get txantenna
"$device" txantenna
123 config_get_bool frameburst
"$device" frameburst
124 config_get macfilter
"$device" macfilter
125 config_get maclist
"$device" maclist
126 config_get macaddr
"$device" macaddr
127 config_get txpower
"$device" txpower
128 config_get frag
"$device" frag
129 config_get rts
"$device" rts
130 config_get hwmode
"$device" hwmode
131 local vif_pre_up vif_post_up vif_do_up vif_txpower
140 [ -z "$slottime" ] && {
141 [ -n "$distance" ] && {
142 # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
143 slottime
="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
146 slottime
="${slottime:--1}"
171 config_get vif_txpower
"$vif" txpower
173 config_get mode
"$vif" mode
174 append vif_pre_up
"vif $_c" "$N"
175 append vif_post_up
"vif $_c" "$N"
176 append vif_do_up
"vif $_c" "$N"
178 config_get_bool wmm
"$vif" wmm
"$wmm"
179 config_get_bool doth
"$vif" doth
"$doth"
181 [ "$mode" = "sta" ] ||
{
182 config_get_bool hidden
"$vif" hidden
0
183 append vif_pre_up
"closed $hidden" "$N"
184 config_get_bool isolate
"$vif" isolate
0
185 append vif_pre_up
"ap_isolate $isolate" "$N"
193 config_get enc
"$vif" encryption
199 config_get key
"$vif" key
201 *shared
*) append vif_do_up
"wepauth 1" "$N";;
202 *) append vif_do_up
"wepauth 0" "$N";;
207 for knr
in 1 2 3 4; do
208 config_get k
"$vif" key
$knr
209 [ -n "$k" ] ||
continue
210 [ "$defkey" = "$knr" ] && def
="=" || def
=""
211 append vif_do_up
"wepkey $def$knr,$k" "$N"
215 *) append vif_do_up
"wepkey =1,$key" "$N";;
220 config_get key
"$vif" key
222 # psk version + default cipher
224 *mixed
*|
*psk
+psk2
*) auth
=132; wsec
=6;;
225 *psk2
*) auth
=128; wsec
=4;;
231 *tkip
+aes
*|
*tkip
+ccmp
*|
*aes
+tkip
*|
*ccmp
+tkip
*) wsec
=6;;
232 *aes
*|
*ccmp
*) wsec
=4;;
236 eval "${vif}_key=\"\$key\""
237 nasopts
="-k \"\$${vif}_key\""
242 config_get key
"$vif" key
243 config_get server
"$vif" server
244 config_get port
"$vif" port
246 # wpa version + default cipher
248 *mixed
*|
*wpa
+wpa2
*) auth
=66; wsec
=6;;
249 *wpa2
*) auth
=64; wsec
=4;;
255 *tkip
+aes
*|
*tkip
+ccmp
*|
*aes
+tkip
*|
*ccmp
+tkip
*) wsec
=6;;
256 *aes
*|
*ccmp
*) wsec
=4;;
260 eval "${vif}_key=\"\$key\""
261 nasopts
="-r \"\$${vif}_key\" -h $server -p ${port:-1812}"
264 append vif_do_up
"wsec $wsec" "$N"
265 append vif_do_up
"wpa_auth $auth" "$N"
266 append vif_do_up
"wsec_restrict $wsec_r" "$N"
267 append vif_do_up
"eap_restrict $eap_r" "$N"
269 config_get ssid
"$vif" ssid
270 append vif_post_up
"vlan_mode 0" "$N"
271 append vif_post_up
"ssid $ssid" "$N"
272 append vif_do_up
"ssid $ssid" "$N"
274 [ "$mode" = "monitor" ] && {
275 append vif_post_up
"monitor $monitor" "$N"
278 [ "$mode" = "adhoc" ] && {
279 config_get bssid
"$vif" bssid
281 append vif_pre_up
"bssid $bssid" "$N"
282 append vif_pre_up
"ibss_merge 0" "$N"
284 append vif_pre_up
"ibss_merge 1" "$N"
288 append vif_post_up
"enabled 1" "$N"
290 config_get ifname
"$vif" ifname
291 #append if_up "ifconfig $ifname up" ";$N"
294 net_cfg
="$(find_net_config "$vif")"
295 [ -z "$net_cfg" ] ||
{
296 append if_up
"set_wifi_up '$vif' '$ifname'" ";$N"
297 append if_up
"start_net '$ifname' '$net_cfg'" ";$N"
299 [ -z "$nasopts" ] ||
{
300 eval "${vif}_ssid=\"\$ssid\""
302 [ "$mode" = "sta" ] && nas_mode
="-S"
304 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"
309 killall
-KILL nas
>&- 2>&-
310 wlc ifname
"$device" stdin
<<EOF
316 ${mssid:+mssid $mssid}
322 rxant ${rxantenna:-3}
323 txant ${txantenna:-3}
324 fragthresh ${frag:-2346}
325 rtsthresh ${rts:-2347}
326 monitor ${monitor:-0}
329 macfilter ${macfilter:-0}
330 maclist ${maclist:-none}
333 country ${country:-US}
334 ${channel:+channel $channel}
335 maxassoc ${maxassoc:-128}
336 slottime ${slottime:--1}
337 ${frameburst:+frameburst $frameburst}
344 wlc ifname
"$device" stdin
<<EOF
348 # use vif_txpower (from last wifi-iface) instead of txpower (from
349 # wifi-device) if the latter does not exist
350 txpower
=${txpower:-$vif_txpower}
351 [ -z "$txpower" ] || iwconfig
$device txpower
${txpower}dBm
360 while grep -qs "^ *wl$((++i)):" /proc
/net
/dev
; do
361 config_get
type wl
${i} type
362 [ "$type" = broadcom
] && continue
364 config wifi-device wl${i}
368 # REMOVE THIS LINE TO ENABLE WIFI:
375 option ssid OpenWrt${i#0}
376 option encryption none