scripts/netifd-wireless.sh: add support for specifying the operating band
[project/netifd.git] / scripts / netifd-wireless.sh
index d51380d235d70ea221e42bf1ca764bbbfa069c85..b920296a9764ab61e513644c31694ab037668956 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,18 @@ _wdev_prepare_channel() {
                        fi
                ;;
        esac
+
+       case "$band" in
+               2g) hwmode=g;;
+               5g|6g|60g) hwmode=a;;
+               *)
+                       case "$hwmode" in
+                               *a) band=5g;;
+                               *ad) band=60g;;
+                               *b|*g) band=2g;;
+                       esac
+               ;;
+       esac
 }
 
 _wdev_handler() {
@@ -174,6 +174,7 @@ _wireless_add_process() {
        json_add_int pid "$1"
        json_add_string exe "$exe"
        [ -n "$3" ] && json_add_boolean required 1
+       [ -n "$4" ] && json_add_boolean keep 1
        exe2="$(readlink -f /proc/$1/exe)"
        [ "$exe" != "$exe2" ] && echo "WARNING (wireless_add_process): executable path $exe does not match process $1 path ($exe2)"
        _wdev_notify
@@ -207,7 +208,13 @@ 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";;
                *aes|*ccmp) wpa_cipher="CCMP";;
@@ -275,6 +282,12 @@ wireless_vif_parse_encryption() {
                        esac
                ;;
        esac
+
+       case "$encryption" in
+               *osen*)
+                       auth_osen=1
+               ;;
+       esac
 }
 
 _wireless_set_brsnoop_isolation() {
@@ -349,7 +362,7 @@ 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() {