Imported Upstream connman version 1.38
[platform/upstream/connman.git] / src / network.c
index d8756ec..870749f 100755 (executable)
 
 #define DHCP_RETRY_TIMEOUT     10
 
+#if defined TIZEN_EXT
+static unsigned char invalid_bssid[WIFI_BSSID_LEN_MAX] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+#endif
+
 static GSList *network_list = NULL;
 static GSList *driver_list = NULL;
 
@@ -131,6 +137,14 @@ struct connman_network {
                char *c_sign_key;
                char *net_access_key;
 #endif
+#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;
 
 #if defined TIZEN_EXT
@@ -721,6 +735,10 @@ static int dhcpv6_set_addresses(struct connman_network *network)
        network->connecting = false;
 
        ipconfig_ipv6 = __connman_service_get_ip6config(service);
+#if defined TIZEN_EXT
+       if (!ipconfig_ipv6)
+               goto err;
+#endif
        err = __connman_ipconfig_address_add(ipconfig_ipv6);
        if (err < 0)
                goto err;
@@ -1151,7 +1169,9 @@ static int network_probe(struct connman_network *network)
                        driver = NULL;
                        continue;
                }
-
+#if defined TIZEN_EXT
+               if (!simplified_log)
+#endif
                DBG("driver %p name %s", driver, driver->name);
 
                if (driver->probe(network) == 0)
@@ -1334,7 +1354,7 @@ static void network_destruct(struct connman_network *network)
 
 /**
  * connman_network_create:
- * @identifier: network identifier (for example an unqiue name)
+ * @identifier: network identifier (for example an unique name)
  *
  * Allocate a new network and assign the #identifier to it.
  *
@@ -1720,6 +1740,13 @@ static gboolean __connman_network_clear_associating_delayed(gpointer user_data)
 }
 #endif
 
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+bool connman_network_check_validity(struct connman_network *network)
+{
+       return (NULL == g_slist_find(network_list, network)) ? false : true;
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
+
 /**
  * connman_network_set_associating:
  * @network: network structure
@@ -2059,6 +2086,18 @@ int __connman_network_connect(struct connman_network *network)
                return err;
        }
 
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+       /*
+        * Note: If EAP on Ethernet is ON, then network will be connected
+        * after EAP Success event is recieved, from plugin/ethernet.c
+        */
+       struct connman_service *service = connman_service_lookup_from_network(network);
+       if (service && __connman_service_get_use_eapol(service)) {
+               connman_network_set_associating(network, true);
+               return 0;
+       }
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
+
        set_connected(network);
 
        return err;
@@ -2073,7 +2112,9 @@ int __connman_network_connect(struct connman_network *network)
 int __connman_network_disconnect(struct connman_network *network)
 {
        int err = 0;
-
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("network %p", network);
 
        remove_ipv4ll_timeout(network);
@@ -2304,7 +2345,9 @@ int connman_network_set_bssid(struct connman_network *network,
 
        if (bssid == NULL)
                return -EINVAL;
-
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
                        bssid[0], bssid[1], bssid[2],
                        bssid[3], bssid[4], bssid[5]);
@@ -2320,6 +2363,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)
 {
@@ -2361,6 +2439,9 @@ int connman_network_set_enc_mode(struct connman_network *network,
        if (encryption_mode == NULL)
                return -EINVAL;
 
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("network %p encryption mode %s", network, encryption_mode);
 
        g_strlcpy(network->wifi.encryption_mode, encryption_mode,
@@ -2454,6 +2535,9 @@ int connman_network_set_countrycode(struct connman_network *network,
        if (country_code == NULL)
                return -EINVAL;
 
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("network %p Country Code %02x:%02x",network,
            country_code[0],country_code[1]);
 
@@ -2480,6 +2564,9 @@ int connman_network_set_bssid_list(struct connman_network *network,
 int connman_network_set_phy_mode(struct connman_network *network,
                                    ieee80211_modes_e mode)
 {
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("network %p phy mode %d", network, mode);
        network->wifi.phy_mode = mode;
 
@@ -2509,6 +2596,45 @@ void *connman_network_get_bssid_list(struct connman_network *network)
 {
        return network->wifi.bssid_list;
 }
+
+int connman_network_set_last_connected_bssid(struct connman_network *network,
+                               const unsigned char *bssid)
+{
+       if (!bssid)
+               return -EINVAL;
+
+       if (!memcmp(bssid, invalid_bssid, WIFI_BSSID_LEN_MAX))
+               return -EINVAL;
+
+       memcpy(network->wifi.last_connected_bssid, bssid, WIFI_BSSID_LEN_MAX);
+
+       return 0;
+}
+
+unsigned char *connman_network_get_last_connected_bssid(struct connman_network *network)
+{
+       return (unsigned char *)network->wifi.last_connected_bssid;
+}
+
+void connman_network_set_assoc_reject_table(struct connman_network *network,
+               GHashTable *assoc_reject_table)
+{
+       if (!network)
+               return;
+
+       if (!assoc_reject_table)
+               return;
+
+       network->wifi.assoc_reject_table = assoc_reject_table;
+}
+
+GHashTable *connman_network_get_assoc_reject_table(struct connman_network *network)
+{
+       if (!network)
+               return NULL;
+
+       return network->wifi.assoc_reject_table;
+}
 #endif
 
 int connman_network_set_nameservers(struct connman_network *network,
@@ -2573,6 +2699,9 @@ int connman_network_set_domain(struct connman_network *network,
 int connman_network_set_name(struct connman_network *network,
                                                        const char *name)
 {
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("network %p name %s", network, name);
 
        g_free(network->name);
@@ -2817,6 +2946,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;
@@ -2845,6 +2976,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;
@@ -2896,6 +3029,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;
        }
@@ -2918,8 +3061,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;
 }