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 mode
"$vif" mode
45 # Only one vif is allowed on AP, station, Ad-hoc or monitor mode
46 [ -z "$mainvif" ] && {
48 config_set
"$vif" ifname
"$phy"
52 config_get ssid
"$vif" ssid
53 [ -z "$ssid" ] && continue
54 config_set
"$vif" ifname
"${phy}wds${_c}"
57 ${addr:+append wds "$vif"}
59 *) echo "$device($vif): Invalid mode, ignored."; continue;;
62 config_set
"$device" vifs
"${mainvif:+$mainvif }${wds:+$wds}"
68 find_prism2_phy
"$device" ||
return 0
69 config_get phy
"$device" phy
71 set_wifi_down
"$device"
74 while read line
< /proc
/net
/hostap
/${phy}/wds
; do
76 [ -f "/var/run/wifi-${1}.pid" ] &&
77 kill "$(cat "/var
/run
/wifi-
${1}.pid
")"
80 iwpriv
"$phy" wds_del
"$2"
89 find_prism2_phy
"$device" ||
return 0
90 config_get phy
"$device" phy
92 config_get rxantenna
"$device" rxantenna
93 config_get txantenna
"$device" txantenna
94 config_get_bool diversity
"$device" diversity
95 [ -n "$diversity" ] && {
99 [ -n "$rxantenna" ] && iwpriv
"$phy" antsel_rx
"$rxantenna"
100 [ -n "$txantenna" ] && iwpriv
"$phy" antsel_tx
"$txantenna"
102 config_get channel
"$device" channel
103 [ -n "$channel" ] && iwconfig
"$phy" channel
"$channel" >/dev
/null
2>/dev
/null
105 config_get txpower
"$device" txpower
106 [ -n "$txpower" ] && iwconfig
"$phy" txpower
"${txpower%%.*}"
108 config_get vifs
"$device" vifs
111 config_get ifname
"$vif" ifname
112 config_get ssid
"$vif" ssid
113 config_get mode
"$vif" mode
115 [ "$mode" = "wds" ] || iwconfig
"$phy" essid
${ssid:+-- }"${ssid:-any}"
119 iwconfig
"$phy" mode managed
120 config_get addr
"$device" bssid
122 iwconfig
"$phy" ap
"$addr"
125 ap
) iwconfig
"$phy" mode master
;;
126 wds
) iwpriv
"$phy" wds_add
"$ssid";;
127 adhoc
) iwconfig
"$phy" mode ad-hoc
;;
128 *) iwconfig
"$phy" mode
"$mode";;
131 [ "$first" = 1 ] && {
132 config_get rate
"$vif" rate
133 [ -n "$rate" ] && iwconfig
"$phy" rate
"${rate%%.*}"
135 config_get_bool hidden
"$vif" hidden
0
136 iwpriv
"$phy" enh_sec
"$hidden"
138 config_get frag
"$vif" frag
139 [ -n "$frag" ] && iwconfig
"$phy" frag
"${frag%%.*}"
141 config_get rts
"$vif" rts
142 [ -n "$rts" ] && iwconfig
"$phy" rts
"${rts%%.*}"
144 config_get maclist
"$vif" maclist
145 [ -n "$maclist" ] && {
147 iwpriv
"$phy" maccmd
3
148 for mac
in $maclist; do
149 iwpriv
"$phy" addmac
"$mac"
152 config_get macpolicy
"$vif" macpolicy
155 iwpriv
"$phy" maccmd
2
158 iwpriv
"$phy" maccmd
1
161 # default deny policy if mac list exists
162 [ -n "$maclist" ] && iwpriv
"$phy" maccmd
1
165 # kick all stations if we have policy explicitly set
166 [ -n "$macpolicy" ] && iwpriv
"$phy" maccmd
4
169 config_get enc
"$vif" encryption
172 for idx
in 1 2 3 4; do
173 config_get key
"$vif" "key${idx}"
174 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
176 config_get key
"$vif" key
179 [1234]) iwconfig
"$ifname" enc
"[$key]";;
180 *) iwconfig
"$ifname" enc
"$key";;
185 config_get key
"$vif" key
190 net_cfg
="$(find_net_config "$vif")"
191 [ -z "$net_cfg" ] ||
{
192 bridge
="$(bridge_interface "$net_cfg")"
193 config_set
"$vif" bridge
"$bridge"
194 start_net
"$ifname" "$net_cfg"
196 set_wifi_up
"$vif" "$ifname"
200 if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
201 hostapd_setup_vif
"$vif" hostap ||
{
202 echo "enable_prism2($device): Failed to set up hostapd for interface $ifname" >&2
203 # make sure this wifi interface won't accidentally stay open without encryption
204 ifconfig
"$ifname" down
210 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
211 wpa_supplicant_setup_vif
"$vif" hostap ||
{
212 echo "enable_prism2($device): Failed to set up wpa_supplicant for interface $ifname" >&2
213 ifconfig
"$ifname" down
224 check_prism2_device
() {
225 [ ${1%[0-9]} = "wlan" ] && config_set
"$1" phy
"$1"
226 config_get phy
"$1" phy
228 find_prism2_phy
"$1" >/dev
/null ||
return 0
229 config_get phy
"$1" phy
231 [ "$phy" = "$dev" ] && found
=1
238 config_get
type "radio$devidx" type
239 [ -n "$type" ] ||
break
240 devidx
=$
(($devidx + 1))
243 [ -d wlan
* ] ||
return
244 for dev
in $
(ls -d wlan
* 2>&-); do
246 config_foreach check_prism2_device wifi-device
247 [ "$found" -gt 0 ] && continue
249 config wifi-device radio$devidx
252 option macaddr $(cat /sys/class/net/${dev}/address)
254 # REMOVE THIS LINE TO ENABLE WIFI:
258 option device radio$devidx
262 option encryption none
265 devidx
=$
(($devidx + 1))