rdc: disable pci serial, remove bluetooth (because usb is disabled)
[openwrt.git] / package / broadcom-wl / files / lib / wifi / broadcom.sh
1 append DRIVERS "broadcom"
2
3 find_vif_config() {(
4 local vif="$1"
5 local cfg
6 local ifname
7
8 config_get cfg "$vif" network
9
10 [ -z "$cfg" ] && {
11 include /lib/network
12 scan_interfaces
13
14 config_get ifname "$vif" ifnamea
15
16 cfg="$(find_config "$ifname")"
17 }
18 [ -z "$cfg" ] && return 0
19 echo "$cfg"
20 )}
21
22 bridge_interface() {(
23 local cfg="$1"
24 [ -z "$cfg" ] && return 0
25
26 include /lib/network
27 scan_interfaces
28
29 config_get iftype "$cfg" type
30 [ "$iftype" = bridge ] && config_get "$iftype" ifname
31 )}
32
33 scan_broadcom() {
34 local device="$1"
35 local wds=
36
37 config_get vifs "$device" vifs
38 for vif in $vifs; do
39 config_get mode "$vif" mode
40 case "$mode" in
41 adhoc)
42 adhoc=1
43 adhoc_if="$vif"
44 ;;
45 sta)
46 sta=1
47 sta_if="$vif"
48 ;;
49 ap)
50 ap=1
51 ap_if="${ap_if:+$ap_if }$vif"
52 ;;
53 wds)
54 config_get addr "$vif" bssid
55 [ -z "$addr" ] || append wds "$addr"
56 ;;
57 *) echo "$device($vif): Invalid mode";;
58 esac
59 done
60 config_set "$device" wds "$wds"
61
62 local _c=
63 for vif in ${adhoc_if:-$sta_if $ap_if}; do
64 config_set "$vif" ifname "wl0${_c:+.$_c}"
65 _c=$((${_c:-0} + 1))
66 done
67
68 ifdown="down"
69 for vif in 0 1 2 3; do
70 append ifdown "vif $vif" "$N"
71 append ifdown "enabled 0" "$N"
72 done
73
74 ap=1
75 infra=1
76 mssid=1
77 apsta=0
78 radio=1
79 case "$adhoc:$sta:$ap" in
80 1*)
81 ap=0
82 mssid=0
83 infra=0
84 ;;
85 :1:1)
86 apsta=1
87 wet=1
88 ;;
89 :1:)
90 wet=1
91 ap=0
92 mssid=0
93 ;;
94 ::)
95 radio=0
96 ;;
97 esac
98 }
99
100 disable_broadcom() {
101 wlc down
102 (
103 include /lib/network
104
105 # make sure the interfaces are down and removed from all bridges
106 for dev in wl0 wl0.1 wl0.2 wl0.3; do
107 ifconfig "$dev" down 2>/dev/null >/dev/null && {
108 unbridge "$dev"
109 }
110 done
111 )
112 true
113 }
114
115 enable_broadcom() {
116 local _c
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
122 _c=0
123 nas="$(which nas)"
124 nas_cmd=
125 if_up=
126 for vif in ${adhoc_if:-$sta_if $ap_if}; do
127 append vif_pre_up "vif $_c" "$N"
128 append vif_post_up "vif $_c" "$N"
129
130 [ "$vif" = "$sta_if" ] || {
131 config_get_bool hidden "$vif" hidden 1
132 append vif_pre_up "closed $hidden" "$N"
133 config_get_bool isolate "$vif" isolate
134 append vif_pre_up "ap_isolate $hidden" "$N"
135 }
136
137 wsec_r=0
138 eap_r=0
139 wsec=0
140 auth=0
141 nasopts=
142 config_get enc "$vif" encryption
143 case "$enc" in
144 WEP|wep)
145 wsec_r=1
146 ;;
147 *psk*|*PSK*)
148 wsec_r=1
149 config_get key "$vif" key
150 case "$enc" in
151 wpa2*|WPA2*|PSK2*|psk2*) auth=128; wsec=4;;
152 *) auth=4; crypto=2;;
153 esac
154 eval "${vif}_key=\"\$key\""
155 nasopts="-k \"\$${vif}_key\""
156 ;;
157 *wpa*|*WPA*)
158 wsec_r=1
159 eap_r=1
160 config_get key "$vif" key
161 config_get server "$vif" server
162 config_get port "$vif" port
163 case "$enc" in
164 wpa2*|WPA2*) auth=64; wsec=4;;
165 *) auth=2; crypto=2;;
166 esac
167 eval "${vif}_key=\"\$key\""
168 nasopts="-r \"\$${vif}_key\" -h $server -p $port"
169 ;;
170 esac
171 append vif_post_up "wsec $wsec" "$N"
172 append vif_post_up "wpa_auth $auth" "$N"
173 append vif_post_up "wsec_restrict $wsec_r" "$N"
174 append vif_post_up "eap_restrict $eap_r" "$N"
175
176 config_get ssid "$vif" ssid
177 append vif_post_up "vlan_mode 0"
178 append vif_post_up "ssid $ssid" "$N"
179 append vif_post_up "enabled 1" "$N"
180
181 config_get ifname "$vif" ifname
182 append if_up "ifconfig $ifname up" ";$N"
183 net_cfg="$(find_vif_config "$vif")"
184 [ -z "$net_cfg" ] || {
185 bridge="$(bridge_interface "$net_cfg")"
186 append if_up "start_net '$ifname' '$net_cfg'" ";$N"
187 }
188 [ -z "$nasopts" ] || {
189 eval "${vif}_ssid=\"\$ssid\""
190 mode="-A"
191 [ "$vif" = "$sta_if" ] && mode="-S"
192 [ -z "$nas" ] || nas_cmd="${nas_cmd:+$nas_cmd$N}$nas -P /var/run/nas.$ifname.pid -H 34954 ${bridge:+ -l $bridge} -i $ifname $mode -m $auth -w $crypto -s \"\$${vif}_ssid\" -g 3600 $nasopts &"
193 }
194 _c=$(($_c + 1))
195 done
196 killall -KILL nas >&- 2>&-
197 wlc stdin <<EOF
198 $ifdown
199
200 mssid $mssid
201 ap $ap
202 apsta $apsta
203 infra $infra
204 ${wet:+wet 1}
205
206 radio ${radio:-1}
207 macfilter 0
208 maclist none
209 wds ${wds:-none}
210 channel ${channel:-0}
211 country ${country:-IL0}
212 maxassoc ${maxassoc:-128}
213
214 $vif_pre_up
215 up
216 $vif_post_up
217 EOF
218 eval "$if_up"
219 eval "$nas_cmd"
220 }
221
222
223 detect_broadcom() {
224 [ -f /proc/net/wl0 ] || return
225 config_get type wl0 type
226 [ "$type" = broadcom ] && return
227 cat <<EOF
228 config wifi-device wl0
229 option type broadcom
230 option channel 5
231
232 config wifi-iface
233 option device wl0
234 option mode ap
235 option ssid OpenWrt
236 option hidden 0
237 option encryption none
238
239 EOF
240 }
This page took 0.059261 seconds and 5 git commands to generate.