supported OWE Transition mode 06/234106/2
authorJinwon Kim <jinwon0325.kim@samsung.com>
Wed, 20 May 2020 04:28:12 +0000 (13:28 +0900)
committerYu <jiung.yu@samsung.com>
Fri, 22 May 2020 06:32:00 +0000 (15:32 +0900)
Change-Id: I6dd1cb437ac16c0428df4d5bc812fefb36543c6d
Signed-off-by: Jinwon Kim <jinwon0325.kim@samsung.com>
gsupplicant/gsupplicant.h
gsupplicant/supplicant.c
include/network.h
packaging/connman.spec
plugins/wifi.c
src/network.c

index 6cf85f3..d748ff6 100755 (executable)
@@ -225,6 +225,7 @@ struct _GSupplicantSSID {
        const char *phase1;
        const char *pac_file;
        uint16_t ieee80211w;
+       unsigned int keymgmt;
        const char *connector;
        const char *c_sign_key;
        const char *net_access_key;
@@ -476,6 +477,11 @@ const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork
                                                          *network);
 void *g_supplicant_network_get_bssid_list(GSupplicantNetwork *network);
 GSupplicantPhy_mode g_supplicant_network_get_phy_mode(GSupplicantNetwork *network);
+dbus_bool_t g_supplicant_network_get_transition_mode(GSupplicantNetwork *network);
+const unsigned char *g_supplicant_network_get_transition_mode_bssid(GSupplicantNetwork *network);
+const void *g_supplicant_network_get_transition_mode_ssid(GSupplicantNetwork *network,
+                                                       unsigned int *transition_mode_ssid_len);
+
 #endif
 #if defined TIZEN_EXT
 void g_supplicant_network_set_last_connected_bssid(GSupplicantNetwork *network, const unsigned char *bssid);
index 2dccc95..fd0e509 100755 (executable)
@@ -306,6 +306,10 @@ struct g_supplicant_bss {
        dbus_bool_t sae;
        dbus_bool_t owe;
        dbus_bool_t dpp;
+       dbus_bool_t owe_transition_mode;
+       unsigned int transition_mode_ssid_len;
+       unsigned char transition_mode_bssid[6];
+       unsigned char transition_mode_ssid[32];
 #endif
 };
 
@@ -334,8 +338,10 @@ struct _GSupplicantNetwork {
        GSList *vsie_list;
        unsigned char country_code[COUNTRY_CODE_LENGTH];
        GSupplicantPhy_mode phy_mode;
-#endif
-#if defined TIZEN_EXT
+       dbus_bool_t owe_transition_mode;
+       unsigned int transition_mode_ssid_len;
+       unsigned char transition_mode_bssid[6];
+       unsigned char transition_mode_ssid[32];
        unsigned char last_connected_bssid[WIFI_BSSID_LEN_MAX];
        GHashTable *assoc_reject_table;
 #endif
@@ -1815,6 +1821,34 @@ const unsigned char *g_supplicant_network_get_bssid(GSupplicantNetwork *network)
 
        return (const unsigned char *)network->best_bss->bssid;
 }
+dbus_bool_t g_supplicant_network_get_transition_mode(GSupplicantNetwork *network)
+{
+       if (network == NULL)
+               return FALSE;
+
+       return network->owe_transition_mode;
+}
+
+
+const unsigned char *g_supplicant_network_get_transition_mode_bssid(GSupplicantNetwork *network)
+{
+       if (network == NULL)
+               return NULL;
+
+       return (const unsigned char *)network->transition_mode_bssid;
+}
+
+const void *g_supplicant_network_get_transition_mode_ssid(GSupplicantNetwork *network,
+                                               unsigned int *transition_mode_ssid_len)
+{
+       if (!network) {
+               *transition_mode_ssid_len = 0;
+               return NULL;
+       }
+
+       *transition_mode_ssid_len = network->transition_mode_ssid_len;
+       return network->transition_mode_ssid;
+}
 
 unsigned int g_supplicant_network_get_maxrate(GSupplicantNetwork *network)
 {
@@ -2548,6 +2582,10 @@ static int add_or_replace_bss_to_network(struct g_supplicant_bss *bss)
        }
 
 #if defined TIZEN_EXT
+       network->owe_transition_mode = bss->owe_transition_mode;
+       memcpy(network->transition_mode_ssid, bss->transition_mode_ssid, bss->transition_mode_ssid_len);
+       memcpy(network->transition_mode_bssid, bss->transition_mode_bssid, WIFI_BSSID_LEN_MAX);
+
        network->keymgmt = bss->keymgmt;
 
        if (g_slist_length(bss->vsie_list) > 0) {
@@ -2818,6 +2856,7 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data)
        unsigned int value;
        int ie_len;
 #if defined TIZEN_EXT
+       const unsigned char OWE_WFA_OUI[] = { 0x50, 0x6f, 0x9a, 0x1c };
        int r_len, j;
        unsigned char *rates = NULL;
        unsigned char *ext_rates = NULL;
@@ -2856,6 +2895,37 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data)
 #if defined TIZEN_EXT
                unsigned char *vsie;
                int vsie_len = 0;
+
+               if(ie[0] == VENDOR_SPECIFIC_INFO && memcmp(ie+2, OWE_WFA_OUI, sizeof(OWE_WFA_OUI)) == 0) {
+                       SUPPLICANT_DBG("IE: match vendor specific data : OWE Transition Mode");
+
+/*
+               Tag: Vendor Specific: Wi-Fi Alliance: OWE Transition Mode
+                       Tag Number: Vendor Specific (221)    -> ie[0]
+                       Tag length: 26                       -> ie[1]
+                       OUI: 50:6f:9a (Wi-Fi Alliance)       -> ie[2]
+                       Vendor Specific OUI Type: 28         -> ie[5]
+                       BSSID: 92:fd:f0:20:2b:09             -> ie[6]
+                       SSID length: 15                      -> ie[12]
+                       SSID: Wi-Fi-5.2.3-owe                -> ie[13]
+
+0000   dd 1a 50 6f 9a 1c 92 fd f0 20 2b 09 0f 57 69 2d   ..Po..... +..Wi-
+0010   46 69 2d 35 2e 32 2e 33 2d 6f 77 65               Fi-5.2.3-owe
+
+*/
+                       bss->owe_transition_mode = TRUE;
+                       if (ie[1] >= 11) { // Tag length is at least up to ssid length position.
+                               memcpy(bss->transition_mode_bssid, ie+6, WIFI_BSSID_LEN_MAX);
+                               if (ie[12] > 0 && ie[12] < 32) {
+                                       memcpy(bss->transition_mode_ssid, ie+13, ie[12]);
+                                       bss->transition_mode_ssid_len = ie[12];
+                               } else
+                                       bss->transition_mode_ssid_len = 0;
+                       } else
+                               bss->owe_transition_mode = FALSE;
+                       continue;
+               }
+
                if(ie[0] == VENDOR_SPECIFIC_INFO && memcmp(ie+2, WPS_OUI, sizeof(WPS_OUI)) != 0) {
                        SUPPLICANT_DBG("IE: match vendor specific data");
 
@@ -3023,7 +3093,7 @@ static void bss_compute_security(struct g_supplicant_bss *bss)
                bss->security = G_SUPPLICANT_SECURITY_IEEE8021X;
        else if (bss->sae)
                bss->security = G_SUPPLICANT_SECURITY_SAE;
-       else if (bss->owe)
+       else if (bss->owe || bss->owe_transition_mode)
                bss->security = G_SUPPLICANT_SECURITY_OWE;
        else if (bss->dpp)
                bss->security = G_SUPPLICANT_SECURITY_DPP;
@@ -7043,7 +7113,10 @@ static void add_network_security(DBusMessageIter *dict, GSupplicantSSID *ssid)
                add_network_security_proto(dict, ssid);
                break;
        case G_SUPPLICANT_SECURITY_SAE:
-               key_mgmt = "SAE";
+               if (ssid->keymgmt & G_SUPPLICANT_KEYMGMT_WPA_PSK)
+                       key_mgmt = "SAE WPA-PSK"; // WFA (WPA3 & WPA2 Mixed -> WPA2 only)
+               else
+                       key_mgmt = "SAE";
                add_network_security_psk(dict, ssid);
                break;
        case G_SUPPLICANT_SECURITY_OWE:
@@ -7126,7 +7199,11 @@ static void interface_add_network_params(DBusMessageIter *iter, void *user_data)
                                                ssid->ssid_len);
 
 #if defined TIZEN_EXT
-       if (ssid->bssid) {
+       bool owe_transition_mode = FALSE;
+       if ((ssid->security == G_SUPPLICANT_SECURITY_OWE) && !(ssid->keymgmt & G_SUPPLICANT_KEYMGMT_OWE))
+               owe_transition_mode = TRUE;
+
+       if (ssid->bssid && !owe_transition_mode) {
                char *bssid = NULL;
                bssid = g_try_malloc0(18);
                if (bssid == NULL) {
index a9f4f01..c5b1055 100755 (executable)
@@ -186,6 +186,13 @@ int connman_network_set_bssid(struct connman_network *network,
                                const unsigned char *bssid);
 unsigned char *connman_network_get_bssid(struct connman_network *network);
 
+int connman_network_set_transition_mode_bssid(struct connman_network *network,
+                               const unsigned char *transition_mode_bssid);
+
+unsigned char *connman_network_get_transition_mode_bssid(struct connman_network *network);
+
+bool connman_network_check_transition_mode(struct connman_network *network1, struct connman_network *network2);
+
 int connman_network_set_maxrate(struct connman_network *network,
                                unsigned int maxrate);
 
index 4a6815e..f1385ed 100644 (file)
@@ -5,7 +5,7 @@
 
 Name:           connman
 Version:        1.37
-Release:        41
+Release:        42
 License:        GPL-2.0+
 Summary:        Connection Manager
 Url:            http://connman.net
index cbc6b15..0b75c77 100755 (executable)
@@ -3601,6 +3601,8 @@ done:
 
        if(g_strcmp0(ssid->eap, "fast") == 0)
                ssid->pac_file = g_strdup(WIFI_EAP_FAST_PAC_FILE);
+
+       ssid->keymgmt = connman_network_get_keymgmt(network);
 #endif
 
        if (connman_setting_get_bool("BackgroundScanning"))
@@ -4784,6 +4786,10 @@ static void network_added(GSupplicantNetwork *supplicant_network)
        bool wps_advertizing;
 
 #if defined TIZEN_EXT
+       bool owe_transition_mode;
+       const unsigned char *transition_mode_ssid;
+       const unsigned char *transition_mode_bssid;
+       unsigned int transition_mode_ssid_len;
        GSList *vsie_list = NULL;
        const unsigned char *country_code;
        ieee80211_modes_e phy_mode;
@@ -4888,6 +4894,15 @@ static void network_added(GSupplicantNetwork *supplicant_network)
 #if defined TIZEN_EXT
        connman_network_set_bssid(network,
                        g_supplicant_network_get_bssid(supplicant_network));
+       owe_transition_mode = (bool)g_supplicant_network_get_transition_mode(supplicant_network);
+       connman_network_set_bool(network, "WiFi.TRANSITION_MODE", owe_transition_mode);
+       if (owe_transition_mode) {
+               transition_mode_ssid = (unsigned char *)g_supplicant_network_get_transition_mode_ssid(supplicant_network, &transition_mode_ssid_len);
+               connman_network_set_blob(network, "WiFi.TRANSITION_MODE_SSID",
+                                                       transition_mode_ssid, transition_mode_ssid_len);
+               transition_mode_bssid = g_supplicant_network_get_transition_mode_bssid(supplicant_network);
+               connman_network_set_transition_mode_bssid(network, transition_mode_bssid);
+       }
        connman_network_set_maxrate(network,
                        g_supplicant_network_get_maxrate(supplicant_network));
        connman_network_set_enc_mode(network,
@@ -5174,7 +5189,22 @@ static void network_associated(GSupplicantNetwork *network)
        if (wifi->network) {
                if (wifi->network == connman_network)
                        return;
-
+#if TIZEN_EXT
+               unsigned int ssid_len;
+               DBG("network1 ssid[%s] , OWE[%d],ssid[%s]",
+                       (char *)connman_network_get_blob(wifi->network,"WiFi.SSID", &ssid_len),
+                       connman_network_get_bool(wifi->network,"WiFi.TRANSITION_MODE"),
+                       (char *)connman_network_get_blob(wifi->network,"WiFi.TRANSITION_MODE_SSID", &ssid_len));
+
+               DBG("network1 ssid[%s], OWE[%d], ssid[%s]",
+                       (char *)connman_network_get_blob(connman_network,"WiFi.SSID",&ssid_len),
+                       connman_network_get_bool(connman_network,"WiFi.TRANSITION_MODE"),
+                       (char *)connman_network_get_blob(connman_network,"WiFi.TRANSITION_MODE_SSID", &ssid_len));
+               if (connman_network_check_transition_mode(wifi->network, connman_network)) {//OWE trasition mode check
+                       DBG("OWE transition mode is TRUE");
+                       return;
+               }
+#endif
                /*
                 * This should never happen, we got associated with
                 * a network different than the one we were expecting.
index 334202c..243b502 100755 (executable)
@@ -140,6 +140,10 @@ struct connman_network {
 #if defined TIZEN_EXT
                unsigned char last_connected_bssid[WIFI_BSSID_LEN_MAX];
                GHashTable *assoc_reject_table;
+               bool owe_transition_mode;
+               void *transition_mode_ssid;
+               int transition_mode_ssid_len;
+               unsigned char transition_mode_bssid[WIFI_BSSID_LEN_MAX];
 #endif
        } wifi;
 
@@ -2349,6 +2353,41 @@ unsigned char *connman_network_get_bssid(struct connman_network *network)
        return (unsigned char *)network->wifi.bssid;
 }
 
+int connman_network_set_transition_mode_bssid(struct connman_network *network,
+                               const unsigned char *transition_mode_bssid)
+{
+       int i = 0;
+
+       if (transition_mode_bssid == NULL)
+               return -EINVAL;
+
+       for (;i < WIFI_BSSID_LEN_MAX;i++)
+               network->wifi.transition_mode_bssid[i] = transition_mode_bssid[i];
+
+       return 0;
+}
+
+unsigned char *connman_network_get_transition_mode_bssid(struct connman_network *network)
+{
+       return (unsigned char *)network->wifi.transition_mode_bssid;
+}
+
+bool connman_network_check_transition_mode(struct connman_network *network1, struct connman_network *network2)
+{
+
+       if (network1 == NULL || network2 == NULL)
+               return FALSE;
+
+       if (network1->wifi.owe_transition_mode == FALSE || network2->wifi.owe_transition_mode == FALSE)
+               return FALSE;
+
+       if ((memcmp(network1->wifi.bssid, network2->wifi.transition_mode_bssid, WIFI_BSSID_LEN_MAX) == 0)
+               && (memcmp(network1->wifi.transition_mode_bssid, network2->wifi.bssid, WIFI_BSSID_LEN_MAX) == 0))
+               return TRUE;
+       else
+               return FALSE;
+}
+
 int connman_network_set_maxspeed(struct connman_network *network,
                                 int maxspeed)
 {
@@ -2885,6 +2924,8 @@ int connman_network_set_bool(struct connman_network *network,
                network->default_internet = value;
        else if (g_strcmp0(key, "WiFi.HS20AP") == 0)
                network->wifi.isHS20AP = value;
+       else if (g_strcmp0(key, "WiFi.TRANSITION_MODE") == 0)
+               network->wifi.owe_transition_mode = value;
 #endif
 
        return -EINVAL;
@@ -2913,6 +2954,8 @@ bool connman_network_get_bool(struct connman_network *network,
                return network->default_internet;
        else if (g_str_equal(key, "WiFi.HS20AP"))
                return network->wifi.isHS20AP;
+       else if (g_strcmp0(key, "WiFi.TRANSITION_MODE"))
+               return network->wifi.owe_transition_mode;
 #endif
 
        return false;
@@ -2964,6 +3007,16 @@ int connman_network_set_blob(struct connman_network *network,
                        network->wifi.ssid_len = size;
                } else
                        network->wifi.ssid_len = 0;
+#ifdef TIZEN_EXT
+       } else if (g_str_equal(key, "WiFi.TRANSITION_MODE_SSID")) {
+               g_free(network->wifi.transition_mode_ssid);
+               network->wifi.transition_mode_ssid = g_try_malloc(size);
+               if (network->wifi.transition_mode_ssid) {
+                       memcpy(network->wifi.transition_mode_ssid, data, size);
+                       network->wifi.transition_mode_ssid_len = size;
+               } else
+                       network->wifi.transition_mode_ssid_len = 0;
+#endif
        } else {
                return -EINVAL;
        }
@@ -2986,8 +3039,13 @@ const void *connman_network_get_blob(struct connman_network *network,
                if (size)
                        *size = network->wifi.ssid_len;
                return network->wifi.ssid;
+#ifdef TIZEN_EXT
+       } else if (g_str_equal(key, "WiFi.TRANSITION_MODE_SSID")) {
+               if (size)
+                       *size = network->wifi.transition_mode_ssid_len;
+               return network->wifi.transition_mode_ssid;
+#endif
        }
-
        return NULL;
 }