2 append DRIVERS
"prism2"
7 local macaddr
="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
8 config_get phy
"$device" phy
9 [ -z "$phy" -a -n "$macaddr" ] && {
11 for phy
in $
(ls -d wlan
* 2>&-); do
12 [ "$macaddr" = "$(cat /sys/class/net/${phy}/address)" ] ||
continue
13 config_set
"$device" phy
"$phy"
16 config_get phy
"$device" phy
18 [ -n "$phy" -a -d "/proc/net/hostap/$phy" ] ||
{
19 echo "phy for wifi device $1 not found"
22 [ -z "$macaddr" ] && {
23 config_set
"$device" macaddr
"$(cat /sys/class/net/${phy}/address)"
33 [ ${device%[0-9]} = "wlan" ] && config_set
"$device" phy
"$device" || find_prism2_phy
"$device" ||
{
34 config_unset
"$device" vifs
37 config_get phy
"$device" phy
39 config_get vifs
"$device" vifs
42 config_get_bool disabled
"$vif" disabled
0
43 [ $disabled = 0 ] ||
continue
45 config_get mode
"$vif" mode
48 # Only one vif is allowed on AP, station, Ad-hoc or monitor mode
49 [ -z "$mainvif" ] && {
51 config_set
"$vif" ifname
"$phy"
55 config_get ssid
"$vif" ssid
56 [ -z "$ssid" ] && continue
57 config_set
"$vif" ifname
"${phy}wds${_c}"
60 ${addr:+append wds "$vif"}
62 *) echo "$device($vif): Invalid mode, ignored."; continue;;
65 config_set
"$device" vifs
"${mainvif:+$mainvif }${wds:+$wds}"
71 find_prism2_phy
"$device" ||
return 0
72 config_get phy
"$device" phy
74 set_wifi_down
"$device"
77 while read line
< /proc
/net
/hostap
/${phy}/wds
; do
79 [ -f "/var/run/wifi-${1}.pid" ] &&
80 kill "$(cat "/var
/run
/wifi-
${1}.pid
")"
83 iwpriv
"$phy" wds_del
"$2"
92 find_prism2_phy
"$device" ||
return 0
93 config_get phy
"$device" phy
95 config_get rxantenna
"$device" rxantenna
96 config_get txantenna
"$device" txantenna
97 config_get_bool diversity
"$device" diversity
98 [ -n "$diversity" ] && {
102 [ -n "$rxantenna" ] && iwpriv
"$phy" antsel_rx
"$rxantenna"
103 [ -n "$txantenna" ] && iwpriv
"$phy" antsel_tx
"$txantenna"
105 config_get channel
"$device" channel
106 [ -n "$channel" ] && iwconfig
"$phy" channel
"$channel" >/dev
/null
2>/dev
/null
108 config_get txpower
"$device" txpower
109 [ -n "$txpower" ] && iwconfig
"$phy" txpower
"${txpower%%.*}"
111 config_get vifs
"$device" vifs
114 config_get ifname
"$vif" ifname
115 config_get ssid
"$vif" ssid
116 config_get mode
"$vif" mode
118 [ "$mode" = "wds" ] || iwconfig
"$phy" essid
${ssid:+-- }"${ssid:-any}"
122 iwconfig
"$phy" mode managed
123 config_get addr
"$device" bssid
125 iwconfig
"$phy" ap
"$addr"
128 ap
) iwconfig
"$phy" mode master
;;
129 wds
) iwpriv
"$phy" wds_add
"$ssid";;
130 adhoc
) iwconfig
"$phy" mode ad-hoc
;;
131 *) iwconfig
"$phy" mode
"$mode";;
134 [ "$first" = 1 ] && {
135 config_get rate
"$vif" rate
136 [ -n "$rate" ] && iwconfig
"$phy" rate
"${rate%%.*}"
138 config_get_bool hidden
"$vif" hidden
0
139 iwpriv
"$phy" enh_sec
"$hidden"
141 config_get frag
"$vif" frag
142 [ -n "$frag" ] && iwconfig
"$phy" frag
"${frag%%.*}"
144 config_get rts
"$vif" rts
145 [ -n "$rts" ] && iwconfig
"$phy" rts
"${rts%%.*}"
147 config_get maclist
"$vif" maclist
148 [ -n "$maclist" ] && {
150 iwpriv
"$phy" maccmd
3
151 for mac
in $maclist; do
152 iwpriv
"$phy" addmac
"$mac"
155 config_get macpolicy
"$vif" macpolicy
158 iwpriv
"$phy" maccmd
2
161 iwpriv
"$phy" maccmd
1
164 # default deny policy if mac list exists
165 [ -n "$maclist" ] && iwpriv
"$phy" maccmd
1
168 # kick all stations if we have policy explicitly set
169 [ -n "$macpolicy" ] && iwpriv
"$phy" maccmd
4
172 config_get enc
"$vif" encryption
175 for idx
in 1 2 3 4; do
176 config_get key
"$vif" "key${idx}"
177 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
179 config_get key
"$vif" key
182 [1234]) iwconfig
"$ifname" enc
"[$key]";;
183 *) iwconfig
"$ifname" enc
"$key";;
188 config_get key
"$vif" key
193 net_cfg
="$(find_net_config "$vif")"
194 [ -z "$net_cfg" ] ||
{
195 bridge
="$(bridge_interface "$net_cfg")"
196 config_set
"$vif" bridge
"$bridge"
197 start_net
"$ifname" "$net_cfg"
199 set_wifi_up
"$vif" "$ifname"
203 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
204 hostapd_setup_vif
"$vif" hostap ||
{
205 echo "enable_prism2($device): Failed to set up hostapd for interface $ifname" >&2
206 # make sure this wifi interface won't accidentally stay open without encryption
207 ifconfig
"$ifname" down
213 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
214 wpa_supplicant_setup_vif
"$vif" hostap ||
{
215 echo "enable_prism2($device): Failed to set up wpa_supplicant for interface $ifname" >&2
216 ifconfig
"$ifname" down
227 check_prism2_device
() {
228 [ ${1%[0-9]} = "wlan" ] && config_set
"$1" phy
"$1"
229 config_get phy
"$1" phy
231 find_prism2_phy
"$1" >/dev
/null ||
return 0
232 config_get phy
"$1" phy
234 [ "$phy" = "$dev" ] && found
=1
241 config_get
type "radio$devidx" type
242 [ -n "$type" ] ||
break
243 devidx
=$
(($devidx + 1))
246 [ -d wlan
* ] ||
return
247 for dev
in $
(ls -d wlan
* 2>&-); do
249 config_foreach check_prism2_device wifi-device
250 [ "$found" -gt 0 ] && continue
252 config wifi-device radio$devidx
255 option macaddr $(cat /sys/class/net/${dev}/address)
257 # REMOVE THIS LINE TO ENABLE WIFI:
261 option device radio$devidx
265 option encryption none
268 devidx
=$
(($devidx + 1))