CMake: bump the minimum required CMake version to 3.5
[project/netifd.git] / scripts / netifd-wireless.sh
index 73bce3d3e2b1170cbbd87f729e56cdc9a9c5752a..5b852e0937631aa0e89a410010bffe6f1d4cdad7 100644 (file)
@@ -39,13 +39,12 @@ prepare_key_wep() {
 }
 
 _wdev_prepare_channel() {
-       json_get_vars channel hwmode
+       json_get_vars channel band hwmode
 
        auto_channel=0
        enable_ht=0
        htmode=
        hwmode="${hwmode##11}"
-       hwmode_n="${hwmode##n}"
 
        case "$channel" in
                ""|0|auto)
@@ -58,17 +57,6 @@ _wdev_prepare_channel() {
                ;;
        esac
 
-       [[ "$hwmode_n" = "$hwmode" ]] || {
-               enable_ht=1
-               hwmode="$hwmode_n"
-
-               json_get_vars htmode
-               case "$htmode" in
-                       HT20|HT40+|HT40-);;
-                       *) htmode= ;;
-               esac
-       }
-
        case "$hwmode" in
                a|b|g|ad) ;;
                *)
@@ -79,6 +67,19 @@ _wdev_prepare_channel() {
                        fi
                ;;
        esac
+
+       case "$band" in
+               2g) hwmode=g;;
+               5g|6g) hwmode=a;;
+               60g) hwmode=ad;;
+               *)
+                       case "$hwmode" in
+                               *a) band=5g;;
+                               *ad) band=60g;;
+                               *b|*g) band=2g;;
+                       esac
+               ;;
+       esac
 }
 
 _wdev_handler() {
@@ -107,14 +108,16 @@ _wdev_wrapper() {
 }
 
 _wdev_notify_init() {
-       local command="$1"
-       local name="$2"
-       local value="$3"
+       local command="$1"; shift;
 
        json_init
        json_add_int "command" "$command"
        json_add_string "device" "$__netifd_device"
-       [ -n "$name" -a -n "$value" ] && json_add_string "$name" "$value"
+       while [ -n "$1" ]; do
+               local name="$1"; shift
+               local value="$1"; shift
+               json_add_string "$name" "$value"
+       done
        json_add_object "data"
 }
 
@@ -150,7 +153,7 @@ _wireless_add_vlan() {
        local name="$1"; shift
        local ifname="$1"; shift
 
-       _wdev_notify_init $CMD_SET_DATA "vlan" "$name"
+       _wdev_notify_init $CMD_SET_DATA interface "$__cur_interface" "vlan" "$name"
        json_add_string "ifname" "$ifname"
        _wdev_add_variables "$@"
        _wdev_notify
@@ -208,12 +211,21 @@ wireless_vif_parse_encryption() {
        auth_mode_open=1
        auth_mode_shared=0
        auth_type=none
-       wpa_cipher=CCMP
+
+       if [ "$hwmode" = "ad" ]; then
+               wpa_cipher="GCMP"
+       else
+               wpa_cipher="CCMP"
+       fi
+
        case "$encryption" in
                *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) wpa_cipher="CCMP TKIP";;
+               *ccmp256) wpa_cipher="CCMP-256";;
                *aes|*ccmp) wpa_cipher="CCMP";;
                *tkip) wpa_cipher="TKIP";;
+               *gcmp256) wpa_cipher="GCMP-256";;
                *gcmp) wpa_cipher="GCMP";;
+               wpa3-192*) wpa_cipher="GCMP-256";;
        esac
 
        # 802.11n requires CCMP for WPA
@@ -245,11 +257,14 @@ wireless_vif_parse_encryption() {
                owe*)
                        auth_type=owe
                ;;
+               wpa3-192*)
+                       auth_type=eap192
+               ;;
                wpa3-mixed*)
-                       auth_type=eap-eap192
+                       auth_type=eap-eap2
                ;;
                wpa3*)
-                       auth_type=eap192
+                       auth_type=eap2
                ;;
                psk3-mixed*|sae-mixed*)
                        auth_type=psk-sae
@@ -288,10 +303,10 @@ _wireless_set_brsnoop_isolation() {
        local multicast_to_unicast="$1"
        local isolate
 
-       json_get_var isolate isolate
+       json_get_vars isolate proxy_arp
 
        [ ${isolate:-0} -gt 0 -o -z "$network_bridge" ] && return
-       [ ${multicast_to_unicast:-1} -gt 0 ] && json_add_boolean isolate 1
+       [ ${multicast_to_unicast:-1} -gt 0 -o ${proxy_arp:-0} -gt 0 ] && json_add_boolean isolate 1
 }
 
 for_each_interface() {
@@ -308,6 +323,7 @@ for_each_interface() {
                json_select "$_w_iface"
                if [ -n "$_w_types" ]; then
                        json_get_var network_bridge bridge
+                       json_get_var network_ifname bridge-ifname
                        json_get_var multicast_to_unicast multicast_to_unicast
                        json_select config
                        _wireless_set_brsnoop_isolation "$multicast_to_unicast"
@@ -319,6 +335,7 @@ for_each_interface() {
                                continue
                        }
                fi
+               __cur_interface="$_w_iface"
                "$@" "$_w_iface"
                json_select ..
        done
@@ -356,15 +373,17 @@ for_each_station() {
 }
 
 _wdev_common_device_config() {
-       config_add_string channel hwmode htmode noscan
+       config_add_string channel hwmode band htmode noscan
 }
 
 _wdev_common_iface_config() {
        config_add_string mode ssid encryption 'key:wpakey'
+       config_add_boolean bridge_isolate
 }
 
 _wdev_common_vlan_config() {
        config_add_string name vid iface
+       config_add_boolean bridge_isolate
 }
 
 _wdev_common_station_config() {