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
67 case "$adhoc:$sta:$apmode:$mon" in
97 set_wifi_down
"$device"
98 wlc ifname
"$device" down
102 # make sure the interfaces are down and removed from all bridges
103 for dev
in $device ${device}.1 ${device}.2 ${device}.3; do
104 ifconfig
"$dev" down
2>/dev
/null
>/dev
/null
&& {
115 config_get channel
"$device" channel
116 config_get country
"$device" country
117 config_get maxassoc
"$device" maxassoc
118 config_get wds
"$device" wds
119 config_get vifs
"$device" vifs
120 config_get distance
"$device" distance
121 config_get slottime
"$device" slottime
122 config_get rxantenna
"$device" rxantenna
123 config_get txantenna
"$device" txantenna
124 config_get_bool frameburst
"$device" frameburst
125 config_get macfilter
"$device" macfilter
126 config_get maclist
"$device" maclist
127 config_get macaddr
"$device" macaddr
128 config_get txpower
"$device" txpower
129 config_get frag
"$device" frag
130 config_get rts
"$device" rts
131 config_get hwmode
"$device" hwmode
132 local vif_pre_up vif_post_up vif_do_up vif_txpower
141 [ -z "$slottime" ] && {
142 [ -n "$distance" ] && {
143 # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
144 slottime
="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
147 slottime
="${slottime:--1}"
172 config_get vif_txpower
"$vif" txpower
174 config_get mode
"$vif" mode
175 append vif_pre_up
"vif $_c" "$N"
176 append vif_post_up
"vif $_c" "$N"
177 append vif_do_up
"vif $_c" "$N"
179 config_get_bool wmm
"$vif" wmm
"$wmm"
180 config_get_bool doth
"$vif" doth
"$doth"
182 [ "$mode" = "sta" ] ||
{
183 config_get_bool hidden
"$vif" hidden
0
184 append vif_pre_up
"closed $hidden" "$N"
185 config_get_bool isolate
"$vif" isolate
0
186 append vif_pre_up
"ap_isolate $isolate" "$N"
194 config_get enc
"$vif" encryption
200 config_get key
"$vif" key
202 *shared
*) append vif_do_up
"wepauth 1" "$N";;
203 *) append vif_do_up
"wepauth 0" "$N";;
208 for knr
in 1 2 3 4; do
209 config_get k
"$vif" key
$knr
210 [ -n "$k" ] ||
continue
211 [ "$defkey" = "$knr" ] && def
="=" || def
=""
212 append vif_do_up
"wepkey $def$knr,$k" "$N"
216 *) append vif_do_up
"wepkey =1,$key" "$N";;
221 config_get key
"$vif" key
223 wpa
*+wpa2
*|WPA
*+WPA2
*|
*psk
+*psk2|
*PSK
+*PSK2
) auth
=132; wsec
=6;;
224 wpa2
*|WPA2
*|
*PSK2|
*psk2
) auth
=128; wsec
=4;;
225 *aes|
*AES
) auth
=4; wsec
=4;;
228 eval "${vif}_key=\"\$key\""
229 nasopts
="-k \"\$${vif}_key\""
234 config_get key
"$vif" key
235 config_get server
"$vif" server
236 config_get port
"$vif" port
238 wpa
*+wpa2
*|WPA
*+WPA2
*) auth
=66; wsec
=6;;
239 wpa2
*|WPA2
*) auth
=64; wsec
=4;;
242 eval "${vif}_key=\"\$key\""
243 nasopts
="-r \"\$${vif}_key\" -h $server -p ${port:-1812}"
246 append vif_do_up
"wsec $wsec" "$N"
247 append vif_do_up
"wpa_auth $auth" "$N"
248 append vif_do_up
"wsec_restrict $wsec_r" "$N"
249 append vif_do_up
"eap_restrict $eap_r" "$N"
251 config_get ssid
"$vif" ssid
252 append vif_post_up
"vlan_mode 0" "$N"
253 append vif_post_up
"ssid $ssid" "$N"
254 append vif_do_up
"ssid $ssid" "$N"
256 [ "$mode" = "monitor" ] && {
257 append vif_post_up
"monitor $monitor" "$N"
258 append vif_post_up
"passive $passive" "$N"
261 [ "$mode" = "adhoc" ] && {
262 config_get bssid
"$vif" bssid
264 append vif_pre_up
"des_bssid $bssid" "$N"
265 append vif_pre_up
"allow_mode 1" "$N"
267 } || append vif_pre_up
"allow_mode 0" "$N"
269 append vif_post_up
"enabled 1" "$N"
271 config_get ifname
"$vif" ifname
272 #append if_up "ifconfig $ifname up" ";$N"
275 net_cfg
="$(find_net_config "$vif")"
276 [ -z "$net_cfg" ] ||
{
277 bridge
="$(bridge_interface "$net_cfg")"
278 append if_up
"set_wifi_up '$vif' '$ifname'" ";$N"
279 append if_up
"start_net '$ifname' '$net_cfg' \$(wlc ifname '$ifname' bssid)" ";$N"
281 [ -z "$nasopts" ] ||
{
282 eval "${vif}_ssid=\"\$ssid\""
285 [ "$mode" = "sta" ] && {
287 [ -z "$bridge" ] ||
{
288 append vif_post_up
"supplicant 1" "$N"
289 append vif_post_up
"passphrase $key" "$N"
294 [ -z "$nas" -o "$use_nas" = "0" ] ||
{
295 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 ${bridge:+ -l $bridge} -i $ifname $nas_mode -m $auth -w $wsec -s \"\$${vif}_ssid\" -g 3600 $nasopts"
300 killall
-KILL nas
>&- 2>&-
301 wlc ifname
"$device" stdin
<<EOF
307 ${mssid:+mssid $mssid}
313 rxant ${rxantenna:-3}
314 txant ${txantenna:-3}
315 fragthresh ${frag:-2346}
316 rtsthresh ${rts:-2347}
317 monitor ${monitor:-0}
318 passive ${passive:-0}
321 macfilter ${macfilter:-0}
322 maclist ${maclist:-none}
325 country ${country:-IL0}
326 ${channel:+channel $channel}
327 maxassoc ${maxassoc:-128}
328 slottime ${slottime:--1}
329 ${frameburst:+frameburst $frameburst}
336 wlc ifname
"$device" stdin
<<EOF
340 # use vif_txpower (from last wifi-iface) instead of txpower (from
341 # wifi-device) if the latter does not exist
342 txpower
=${txpower:-$vif_txpower}
343 [ -z "$txpower" ] || iwconfig
$device txpower
${txpower}dBm
352 while [ -f /proc
/net
/wl$
((++i
)) ]; do
353 config_get
type wl
${i} type
354 [ "$type" = broadcom
] && continue
356 config wifi-device wl${i}
360 # REMOVE THIS LINE TO ENABLE WIFI:
367 option ssid OpenWrt${i#0}
368 option encryption none