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 "wl0${_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
101 # make sure the interfaces are down and removed from all bridges
102 for dev in wl0 wl0.1 wl0.2 wl0.3; do
103 ifconfig "$dev" down 2>/dev/null >/dev/null && {
113 config_get channel "$device" channel
114 config_get country "$device" country
115 config_get maxassoc "$device" maxassoc
116 config_get wds "$device" wds
117 config_get vifs "$device" vifs
118 config_get distance "$device" distance
119 config_get slottime "$device" slottime
120 config_get rxantenna "$device" rxantenna
121 config_get txantenna "$device" txantenna
122 config_get_bool frameburst "$device" frameburst
123 config_get macfilter "$device" macfilter
124 config_get maclist "$device" maclist
125 config_get macaddr "$device" macaddr
126 config_get txpower "$device" txpower
127 config_get frag "$device" frag
128 config_get rts "$device" rts
129 local vif_pre_up vif_post_up vif_do_up vif_txpower
135 [ -n "$nas" ] && nas="start-stop-daemon -S -b -x $nas -- "
139 [ -z "$slottime" ] && {
140 [ -n "$distance" ] && {
141 # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
142 slottime="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
145 slottime="${slottime:--1}"
161 config_get vif_txpower "$vif" txpower
163 config_get mode "$vif" mode
164 append vif_pre_up "vif $_c" "$N"
165 append vif_post_up "vif $_c" "$N"
166 append vif_do_up "vif $_c" "$N"
168 config_get_bool wmm "$vif" wmm "$wmm"
169 config_get_bool doth "$vif" doth "$doth"
171 [ "$mode" = "sta" ] || {
172 config_get_bool hidden "$vif" hidden 0
173 append vif_pre_up "closed $hidden" "$N"
174 config_get_bool isolate "$vif" isolate 0
175 append vif_pre_up "ap_isolate $isolate" "$N"
183 config_get enc "$vif" encryption
189 config_get key "$vif" key
191 *shared*) append vif_do_up "wepauth 1" "$N";;
192 *) append vif_do_up "wepauth 0" "$N";;
197 for knr in 1 2 3 4; do
198 config_get k "$vif" key$knr
199 [ -n "$k" ] || continue
200 [ "$defkey" = "$knr" ] && def="=" || def=""
201 append vif_do_up "wepkey $def$knr,$k" "$N"
205 *) append vif_do_up "wepkey =1,$key" "$N";;
210 config_get key "$vif" key
212 wpa*+wpa2*|WPA*+WPA2*|*psk+*psk2|*PSK+*PSK2) auth=132; wsec=6;;
213 wpa2*|WPA2*|*PSK2|*psk2) auth=128; wsec=4;;
214 *aes|*AES) auth=4; wsec=4;;
217 eval "${vif}_key=\"\$key\""
218 nasopts="-k \"\$${vif}_key\""
223 config_get key "$vif" key
224 config_get server "$vif" server
225 config_get port "$vif" port
227 wpa*+wpa2*|WPA*+WPA2*) auth=66; wsec=6;;
228 wpa2*|WPA2*) auth=64; wsec=4;;
231 eval "${vif}_key=\"\$key\""
232 nasopts="-r \"\$${vif}_key\" -h $server -p ${port:-1812}"
235 append vif_do_up "wsec $wsec" "$N"
236 append vif_do_up "wpa_auth $auth" "$N"
237 append vif_do_up "wsec_restrict $wsec_r" "$N"
238 append vif_do_up "eap_restrict $eap_r" "$N"
240 config_get ssid "$vif" ssid
241 append vif_post_up "vlan_mode 0" "$N"
242 append vif_post_up "ssid $ssid" "$N"
243 append vif_do_up "ssid $ssid" "$N"
245 [ "$mode" = "monitor" ] && {
246 append vif_post_up "monitor $monitor" "$N"
247 append vif_post_up "passive $passive" "$N"
250 [ "$mode" = "adhoc" ] && {
251 config_get bssid "$vif" bssid
253 append vif_pre_up "des_bssid $bssid" "$N"
254 append vif_pre_up "allow_mode 1" "$N"
256 } || append vif_pre_up "allow_mode 0" "$N"
258 append vif_post_up "enabled 1" "$N"
260 config_get ifname "$vif" ifname
261 #append if_up "ifconfig $ifname up" ";$N"
264 net_cfg="$(find_net_config "$vif")"
265 [ -z "$net_cfg" ] || {
266 bridge="$(bridge_interface "$net_cfg")"
267 append if_up "set_wifi_up '$vif' '$ifname'" ";$N"
268 append if_up "start_net '$ifname' '$net_cfg' \$(wlc ifname '$ifname' bssid)" ";$N"
270 [ -z "$nasopts" ] || {
271 eval "${vif}_ssid=\"\$ssid\""
274 [ "$mode" = "sta" ] && {
276 [ -z "$bridge" ] || {
277 append vif_post_up "supplicant 1" "$N"
278 append vif_post_up "passphrase $key" "$N"
283 [ -z "$nas" -o "$use_nas" = "0" ] || nas_cmd="${nas_cmd:+$nas_cmd$N}$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 &"
287 killall -KILL nas >&- 2>&-
293 ${mssid:+mssid $mssid}
299 rxant ${rxantenna:-3}
300 txant ${txantenna:-3}
301 fragthresh ${frag:-2346}
302 rtsthresh ${rts:-2347}
303 monitor ${monitor:-0}
304 passive ${passive:-0}
307 macfilter ${macfilter:-0}
308 maclist ${maclist:-none}
311 country ${country:-IL0}
312 ${channel:+channel $channel}
313 maxassoc ${maxassoc:-128}
314 slottime ${slottime:--1}
315 ${frameburst:+frameburst $frameburst}
326 # use vif_txpower (from last wifi-iface) instead of txpower (from
327 # wifi-device) if the latter does not exist
328 txpower=${txpower:-$vif_txpower}
329 [ -z "$txpower" ] || iwconfig $device txpower ${txpower}dBm
336 [ -f /proc/net/wl0 ] || return
337 config_get type wl0 type
338 [ "$type" = broadcom ] && return
340 config wifi-device wl0
344 # REMOVE THIS LINE TO ENABLE WIFI:
352 option encryption none