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 key "$vif" key
249 config_get server "$vif" server
250 config_get port "$vif" port
252 # wpa version + default cipher
254 *mixed*|*wpa+wpa2*) auth=66; wsec=6;;
255 *wpa2*) auth=64; wsec=4;;
261 *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
262 *aes*|*ccmp*) wsec=4;;
266 # group rekey interval
267 config_get rekey "$vif" wpa_group_rekey
269 eval "${vif}_key=\"\$key\""
270 nasopts="-r \"\$${vif}_key\" -h $server -p ${port:-1812}${rekey:+ -g $rekey}"
273 append vif_do_up "wsec $wsec" "$N"
274 append vif_do_up "wpa_auth $auth" "$N"
275 append vif_do_up "wsec_restrict $wsec_r" "$N"
276 append vif_do_up "eap_restrict $eap_r" "$N"
278 config_get ssid "$vif" ssid
279 append vif_post_up "vlan_mode 0" "$N"
280 append vif_post_up "ssid $ssid" "$N"
281 append vif_do_up "ssid $ssid" "$N"
283 [ "$mode" = "monitor" ] && {
284 append vif_post_up "monitor $monitor" "$N"
287 [ "$mode" = "adhoc" ] && {
288 config_get bssid "$vif" bssid
290 append vif_pre_up "bssid $bssid" "$N"
291 append vif_pre_up "ibss_merge 0" "$N"
293 append vif_pre_up "ibss_merge 1" "$N"
297 append vif_post_up "enabled 1" "$N"
299 config_get ifname "$vif" ifname
300 #append if_up "ifconfig $ifname up" ";$N"
303 net_cfg="$(find_net_config "$vif")"
304 [ -z "$net_cfg" ] || {
305 append if_up "set_wifi_up '$vif' '$ifname'" ";$N"
306 append if_up "start_net '$ifname' '$net_cfg'" ";$N"
308 [ -z "$nasopts" ] || {
309 eval "${vif}_ssid=\"\$ssid\""
311 [ "$mode" = "sta" ] && nas_mode="-S"
313 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"
318 killall -KILL nas >&- 2>&-
319 wlc ifname "$device" stdin <<EOF
325 ${mssid:+mssid $mssid}
331 rxant ${rxantenna:-3}
332 txant ${txantenna:-3}
333 fragthresh ${frag:-2346}
334 rtsthresh ${rts:-2347}
335 monitor ${monitor:-0}
338 macfilter ${macfilter:-0}
339 maclist ${maclist:-none}
342 country ${country:-US}
343 ${channel:+channel $channel}
344 maxassoc ${maxassoc:-128}
345 slottime ${slottime:--1}
346 ${frameburst:+frameburst $frameburst}
353 wlc ifname "$device" stdin <<EOF
357 # use vif_txpower (from last wifi-iface) instead of txpower (from
358 # wifi-device) if the latter does not exist
359 txpower=${txpower:-$vif_txpower}
360 [ -z "$txpower" ] || iwconfig $device txpower ${txpower}dBm
369 while grep -qs "^ *wl$((++i)):" /proc/net/dev; do
370 config_get type wl${i} type
371 [ "$type" = broadcom ] && continue
373 config wifi-device wl${i}
377 # REMOVE THIS LINE TO ENABLE WIFI:
384 option ssid OpenWrt${i#0}
385 option encryption none