mac80211: restricted automatic channel selection
[openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index 4f680a4..43c01d3 100644 (file)
@@ -21,8 +21,9 @@ drv_mac80211_init_device_config() {
        config_add_string hwmode
        config_add_int beacon_int chanbw frag rts
        config_add_int rxantenna txantenna antenna_gain txpower distance
-       config_add_boolean noscan
+       config_add_boolean noscan ht_coex
        config_add_array ht_capab
+       config_add_array channels
        config_add_boolean \
                rxldpc \
                short_gi_80 \
@@ -89,8 +90,9 @@ mac80211_hostapd_setup_base() {
        json_select config
 
        [ "$auto_channel" -gt 0 ] && channel=acs_survey
+       [ "$auto_channel" -gt 0 ] && json_get_values channel_list channels
 
-       json_get_vars noscan
+       json_get_vars noscan ht_coex
        json_get_values ht_capab_list ht_capab
 
        ieee80211n=1
@@ -127,6 +129,9 @@ mac80211_hostapd_setup_base() {
        [ -n "$ieee80211n" ] && {
                append base_cfg "ieee80211n=1" "$N"
 
+               set_default ht_coex 0
+               append base_cfg "ht_coex=$ht_coex" "$N"
+
                json_get_vars \
                        ldpc:1 \
                        greenfield:0 \
@@ -298,6 +303,7 @@ mac80211_hostapd_setup_base() {
        hostapd_prepare_device_config "$hostapd_conf_file" nl80211
        cat >> "$hostapd_conf_file" <<EOF
 ${channel:+channel=$channel}
+${channel_list:+chanlist=$channel_list}
 ${noscan:+noscan=$noscan}
 $base_cfg
 
@@ -452,12 +458,7 @@ mac80211_prepare_vif() {
                        }
                ;;
                mesh)
-                       json_get_vars key mesh_id
-                       if [ -n "$key" ]; then
-                               iw phy "$phy" interface add "$ifname" type mp
-                       else
-                               iw phy "$phy" interface add "$ifname" type mp mesh_id "$mesh_id"
-                       fi
+                       iw phy "$phy" interface add "$ifname" type mp
                ;;
                monitor)
                        iw phy "$phy" interface add "$ifname" type monitor
@@ -483,7 +484,7 @@ mac80211_prepare_vif() {
                # All interfaces must have unique mac addresses
                # which can either be explicitly set in the device
                # section, or automatically generated
-               ifconfig "$ifname" hw ether "$macaddr"
+               ip link set dev "$ifname" address "$macaddr"
        fi
 
        json_select ..
@@ -579,7 +580,7 @@ mac80211_setup_vif() {
        json_get_vars mode
        json_get_var vif_txpower txpower
 
-       ifconfig "$ifname" up || {
+       ip link set dev "$ifname" up || {
                wireless_setup_vif_failed IFUP_ERROR
                json_select ..
                return
@@ -600,6 +601,13 @@ mac80211_setup_vif() {
                                        wireless_vif_parse_encryption
                                        mac80211_setup_supplicant || failed=1
                                fi
+                       else
+                               json_get_vars mesh_id mcast_rate
+
+                               mcval=
+                               [ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate"
+
+                               iw dev "$ifname" mesh join "$mesh_id" ${mcval:+mcast-rate $mcval}
                        fi
 
                        for var in $MP_CONFIG_INT $MP_CONFIG_BOOL $MP_CONFIG_STRING; do
@@ -635,7 +643,7 @@ mac80211_interface_cleanup() {
        local phy="$1"
 
        for wdev in $(list_phy_interfaces "$phy"); do
-               ifconfig "$wdev" down 2>/dev/null
+               ip link set dev "$wdev" down 2>/dev/null
                iw dev "$wdev" del
        done
 }