- config_get vifs "$device" vifs
- config_get country "$device" country
-
- local first=1
- for vif in $vifs; do
- config_get ifname "$vif" ifname
- ifconfig "$ifname" down
- config_get enc "$vif" encryption
- config_get eap_type "$vif" eap_type
- config_get mode "$vif" mode
-
- config_get ifname "$vif" ifname
- [ $? -ne 0 ] && {
- echo "enable_acx($device): Failed to set up $mode vif $ifname" >&2
- continue
- }
- config_set "$vif" ifname "$ifname"
-
- [ "$first" = 1 ] && {
- # only need to change freq band and channel on the first vif
- case $country in
- us)
- iwpriv "$device" SetRegDomain 1
- ;;
- ca)
- iwpriv "$device" SetRegDomain 2
- ;;
- de|uk|be|hu|nl|pt|pl|se|dk)
- iwpriv "$device" SetRegDomain 3
- ;;
- es)
- iwpriv "$device" SetRegDomain 4
- ;;
- fr)
- iwpriv "$device" SetRegDomain 5
- ;;
- jp)
- iwpriv "$device" SetRegDomain 7
- ;;
- il)
- iwpriv "$device" SetRegDomain 8
+ [ -n "$channel" ] && iwconfig "$phy" channel "$channel" >/dev/null 2>/dev/null
+
+ config_get txpower "$device" txpower
+ [ -n "$txpower" ] && iwconfig "$phy" txpower "${txpower%%.*}"
+
+ config_get vif "$device" vifs
+
+ config_get ifname "$vif" ifname
+ config_get ssid "$vif" ssid
+ config_get mode "$vif" mode
+
+ iwconfig "$phy" essid ${ssid:+-- }"${ssid:-any}"
+
+ case "$mode" in
+ sta)
+ iwconfig "$phy" mode managed
+ config_get addr "$device" bssid
+ [ -z "$addr" ] || {
+ iwconfig "$phy" ap "$addr"
+ }
+ ;;
+ ap) iwconfig "$phy" mode master;;
+ adhoc) iwconfig "$phy" mode ad-hoc;;
+ *) iwconfig "$phy" mode "$mode";;
+ esac
+
+ config_get frag "$vif" frag
+ [ -n "$frag" ] && iwconfig "$phy" frag "${frag%%.*}"
+
+ config_get rts "$vif" rts
+ [ -n "$rts" ] && iwconfig "$phy" rts "${rts%%.*}"
+
+ config_get enc "$vif" encryption
+ case "$enc" in
+ wep)
+ for idx in 1 2 3 4; do
+ config_get key "$vif" "key${idx}"
+ iwconfig "$ifname" enc restricted "[$idx]" "${key:-off}"
+ done
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234]) iwconfig "$ifname" enc restricted "[$key]";;
+ *) iwconfig "$ifname" enc restricted "$key";;