From cf567e3b6cd6b596de9f8e02a8de473eddad5b13 Mon Sep 17 00:00:00 2001
From: liuzhilin <liuzhilin@uniontech.com>
Date: Mon, 15 Apr 2024 10:53:42 +0800
Subject: [PATCH] add-NM-to-support-wifi6

DESC:Support wireless networks connecting WIFI6 encryption methods,
       so this demand is achieved in NetworkManager, KF5-NetworkManager-QT,
       DDE-Network-Core software package

---
 src/core/nm-core-utils.c                      | 9 ++++++++-
 src/core/nm-core-utils.h                      | 3 ++-
 src/core/supplicant/nm-supplicant-interface.c | 7 ++++++-
 src/libnm-core-public/nm-dbus-interface.h     | 2 ++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c
index 5442efb..8e030a3 100644
--- a/src/core/nm-core-utils.c
+++ b/src/core/nm-core-utils.c
@@ -4783,13 +4783,15 @@ get_max_rate_vht(const guint8 *bytes, guint len, guint32 *out_maxrate)
 #define WLAN_EID_HT_CAPABILITY   45
 #define WLAN_EID_VHT_CAPABILITY  191
 #define WLAN_EID_VENDOR_SPECIFIC 221
+#define WLAN_EID_EXTENSION       255
 
 void
 nm_wifi_utils_parse_ies(const guint8 *bytes,
                         gsize         len,
                         guint32      *out_max_rate,
                         gboolean     *out_metered,
-                        gboolean     *out_owe_transition_mode)
+			gboolean     *out_owe_transition_mode,
+                        gboolean     *out_he_support)
 {
     guint8  id, elem_len;
     guint32 m;
@@ -4797,6 +4799,7 @@ nm_wifi_utils_parse_ies(const guint8 *bytes,
     NM_SET_OUT(out_max_rate, 0);
     NM_SET_OUT(out_metered, FALSE);
     NM_SET_OUT(out_owe_transition_mode, FALSE);
+    NM_SET_OUT(out_he_support, FALSE);
 
     while (len) {
         if (len < 2)
@@ -4835,6 +4838,10 @@ nm_wifi_utils_parse_ies(const guint8 *bytes,
                 && bytes[3] == 0x1c) /* OUI type: OWE Transition Mode */
                 NM_SET_OUT(out_owe_transition_mode, TRUE);
             break;
+        case WLAN_EID_EXTENSION:
+            if (elem_len > 0 && bytes[0] == 0x23)
+               NM_SET_OUT(out_he_support, TRUE);
+            break;
         }
 
         len -= elem_len;
diff --git a/src/core/nm-core-utils.h b/src/core/nm-core-utils.h
index 5511250..551c6fa 100644
--- a/src/core/nm-core-utils.h
+++ b/src/core/nm-core-utils.h
@@ -456,7 +456,8 @@ void nm_wifi_utils_parse_ies(const guint8 *bytes,
                              gsize         len,
                              guint32      *out_max_rate,
                              gboolean     *out_metered,
-                             gboolean     *out_owe_transition_mode);
+                             gboolean     *out_owe_transition_mode,
+                             gboolean     *out_he_support);
 
 guint8 nm_wifi_utils_level_to_quality(int val);
 
diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c
index 1852572..ddb6b2f 100644
--- a/src/core/supplicant/nm-supplicant-interface.c
+++ b/src/core/supplicant/nm-supplicant-interface.c
@@ -764,10 +764,15 @@ _bss_info_properties_changed(NMSupplicantInterface *self,
     if (v_v) {
         gboolean p_owe_transition_mode;
         gboolean p_metered;
+	gboolean p_he_support;
         guint32  rate;
 
         arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1);
-        nm_wifi_utils_parse_ies(arr_data, arr_len, &rate, &p_metered, &p_owe_transition_mode);
+        nm_wifi_utils_parse_ies(arr_data, arr_len, &rate, &p_metered, &p_owe_transition_mode, &p_he_support);
+        if (p_he_support)
+               bss_info->rsn_flags |= NM_802_11_AP_FLAGS_He;
+        else
+               bss_info->rsn_flags &= ~NM_802_11_AP_FLAGS_He;
         p_max_rate     = NM_MAX(p_max_rate, rate);
         p_max_rate_has = TRUE;
         g_variant_unref(v_v);
diff --git a/src/libnm-core-public/nm-dbus-interface.h b/src/libnm-core-public/nm-dbus-interface.h
index b490e3b..9624618 100644
--- a/src/libnm-core-public/nm-dbus-interface.h
+++ b/src/libnm-core-public/nm-dbus-interface.h
@@ -336,6 +336,7 @@ typedef enum /*< flags >*/ {
  * @NM_802_11_AP_FLAGS_WPS: access point supports some WPS method
  * @NM_802_11_AP_FLAGS_WPS_PBC: access point supports push-button WPS
  * @NM_802_11_AP_FLAGS_WPS_PIN: access point supports PIN-based WPS
+ * @NM_802_11_AP_FLAGS_He: access point support high efficiency (new feature in 802.11ax)
  *
  * 802.11 access point flags.
  **/
@@ -345,6 +346,7 @@ typedef enum /*< underscore_name=nm_802_11_ap_flags, flags >*/ {
     NM_802_11_AP_FLAGS_WPS     = 0x00000002,
     NM_802_11_AP_FLAGS_WPS_PBC = 0x00000004,
     NM_802_11_AP_FLAGS_WPS_PIN = 0x00000008,
+    NM_802_11_AP_FLAGS_He      = 0x00000010,
 } NM80211ApFlags;
 
 /**
-- 
2.39.3

