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 acx_wlan
[0-9] 2>&-); do
13 [ "$macaddr" = "$(cat /sys/class/net/${phy}/address)" ] ||
continue
14 config_set
"$device" phy
"$phy"
17 config_get phy
"$device" phy
19 [ -n "$phy" -a -f "/proc/driver/acx_$phy" ] ||
{
20 echo "phy for wifi device $1 not found"
23 [ -z "$macaddr" ] && {
24 config_set
"$device" macaddr
"$(cat /sys/class/net/${phy}/address)"
32 [ ${device%[0-9]} = "wlan" ] && config_set
"$device" phy
"$device" || find_acx_phy
"$device" ||
{
33 config_unset
"$device" vifs
36 config_get phy
"$device" phy
38 config_get vifs
"$device" vifs
40 config_get mode
"$vif" mode
43 # Only one vif is allowed
44 config_set
"$vif" ifname
"$phy"
47 *) echo "$device($vif): Invalid mode, ignored."; continue;;
50 config_set
"$device" vifs
"$vif"
56 find_acx_phy
"$device" ||
return 0
57 config_get phy
"$device" phy
59 set_wifi_down
"$device"
69 find_acx_phy
"$device" ||
return 0
70 config_get phy
"$device" phy
72 config_get regdomain
"$device" regdomain
73 [ -n "$regdomain" ] && iwpriv
"$device" SetRegDomain
"$regdomain"
75 config_get rxantenna
"$device" rxantenna
76 config_get txantenna
"$device" txantenna
77 config_get_bool diversity
"$device" diversity
78 [ -n "$diversity" ] && {
81 [ -n "$rxantenna" ] && iwpriv
"$phy" SetRxAnt
"$rxantenna"
82 [ -n "$txantenna" ] && iwpriv
"$phy" SetTxAnt
"$txantenna"
84 config_get channel
"$device" channel
85 [ -n "$channel" ] && iwconfig
"$phy" channel
"$channel" >/dev
/null
2>/dev
/null
87 config_get txpower
"$device" txpower
88 [ -n "$txpower" ] && iwconfig
"$phy" txpower
"${txpower%%.*}"
90 config_get vif
"$device" vifs
92 config_get ifname
"$vif" ifname
93 config_get ssid
"$vif" ssid
94 config_get mode
"$vif" mode
96 iwconfig
"$phy" essid
${ssid:+-- }"${ssid:-any}"
100 iwconfig
"$phy" mode managed
101 config_get addr
"$device" bssid
103 iwconfig
"$phy" ap
"$addr"
106 ap
) iwconfig
"$phy" mode master
;;
107 adhoc
) iwconfig
"$phy" mode ad-hoc
;;
108 *) iwconfig
"$phy" mode
"$mode";;
111 config_get frag
"$vif" frag
112 [ -n "$frag" ] && iwconfig
"$phy" frag
"${frag%%.*}"
114 config_get rts
"$vif" rts
115 [ -n "$rts" ] && iwconfig
"$phy" rts
"${rts%%.*}"
117 config_get enc
"$vif" encryption
120 for idx
in 1 2 3 4; do
121 config_get key
"$vif" "key${idx}"
122 iwconfig
"$ifname" enc restricted
"[$idx]" "${key:-off}"
124 config_get key
"$vif" key
127 [1234]) iwconfig
"$ifname" enc restricted
"[$key]";;
128 *) iwconfig
"$ifname" enc restricted
"$key";;
132 echo "$device($vif): WPA/WPA2 not supported by acx driver"
138 net_cfg
="$(find_net_config "$vif")"
139 [ -z "$net_cfg" ] ||
{
140 bridge
="$(bridge_interface "$net_cfg")"
141 config_set
"$vif" bridge
"$bridge"
142 start_net
"$ifname" "$net_cfg"
144 set_wifi_up
"$vif" "$ifname"
149 [ ${1%[0-9]} = "wlan" ] && config_set
"$1" phy
"$1"
150 config_get phy
"$1" phy
152 find_acx_phy
"$1" >/dev
/null ||
return 0
153 config_get phy
"$1" phy
155 [ "$phy" = "$dev" ] && found
=1
162 config_get
type "radio$devidx" type
163 [ -n "$type" ] ||
break
164 devidx
=$
(($devidx + 1))
167 for dev
in $
(ls acx_wlan
[0-9] 2>&-); do
170 config_foreach check_acx_device wifi-device
171 [ "$found" -gt 0 ] && continue
173 config wifi-device radio$devidx
176 option macaddr $(cat /sys/class/net/${dev}/address)
178 # REMOVE THIS LINE TO ENABLE WIFI:
182 option device radio$devidx
186 option encryption none
189 devidx
=$
(($devidx + 1))