Add support for handling wifi authentication failure
[platform/upstream/connman.git] / src / network.c
index 243b502..d71b419 100755 (executable)
@@ -131,6 +131,7 @@ struct connman_network {
                char *phase1;
                unsigned char country_code[WIFI_COUNTRY_CODE_LEN];
                GSList *bssid_list;
+               GSList *sec_list;
                ieee80211_modes_e phy_mode;
                connection_mode_e connection_mode;
                char *connector;
@@ -144,6 +145,11 @@ struct connman_network {
                void *transition_mode_ssid;
                int transition_mode_ssid_len;
                unsigned char transition_mode_bssid[WIFI_BSSID_LEN_MAX];
+               bool roaming_progress;
+               char *roaming_cur_bssid;
+               char *roaming_dst_bssid;
+               __time_t roam_scan_time;
+               int snr;
 #endif
        } wifi;
 
@@ -735,6 +741,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;
@@ -1165,7 +1175,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)
@@ -1348,7 +1360,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.
  *
@@ -1781,6 +1793,22 @@ int connman_network_set_associating(struct connman_network *network,
        return 0;
 }
 
+#if defined TIZEN_EXT
+static void set_authenticate_error(struct connman_network *network)
+{
+       struct connman_service *service;
+
+       service = connman_service_lookup_from_network(network);
+
+       if (!service)
+               return;
+
+       __connman_service_indicate_error(service,
+                                       CONNMAN_SERVICE_ERROR_AUTH_FAILED);
+}
+#endif
+
+
 static void set_associate_error(struct connman_network *network)
 {
        struct connman_service *service;
@@ -1788,8 +1816,11 @@ static void set_associate_error(struct connman_network *network)
        service = connman_service_lookup_from_network(network);
 
 #if defined TIZEN_EXT
+       if (!service)
+               return;
+
        __connman_service_indicate_error(service,
-                                       CONNMAN_SERVICE_ERROR_AUTH_FAILED);
+                                       CONNMAN_SERVICE_ERROR_ASSOC_FAILED);
 #else
        __connman_service_indicate_error(service,
                                        CONNMAN_SERVICE_ERROR_CONNECT_FAILED);
@@ -1911,6 +1942,9 @@ void connman_network_set_error(struct connman_network *network,
                set_connect_error(network);
                break;
 #if defined TIZEN_EXT
+       case CONNMAN_NETWORK_ERROR_AUTHENTICATE_FAIL:
+               set_authenticate_error(network);
+               break;
        case CONNMAN_NETWORK_ERROR_DHCP_FAIL:
                set_dhcp_error(network);
                break;
@@ -2106,7 +2140,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);
@@ -2338,9 +2374,13 @@ int connman_network_set_bssid(struct connman_network *network,
        if (bssid == NULL)
                return -EINVAL;
 
-       DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
-                       bssid[0], bssid[1], bssid[2],
-                       bssid[3], bssid[4], bssid[5]);
+       if (network->connected)
+               return -EPERM;
+
+       if (!simplified_log)
+               DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
+                               bssid[0], bssid[1], bssid[2],
+                               bssid[3], bssid[4], bssid[5]);
 
        for (;i < WIFI_BSSID_LEN_MAX;i++)
                network->wifi.bssid[i] = bssid[i];
@@ -2406,6 +2446,20 @@ int connman_network_get_maxspeed(struct connman_network *network)
        return 0;
 }
 
+int connman_network_set_sec_list(struct connman_network *network,
+                                       GSList *sec_list)
+{
+       g_slist_free(network->wifi.sec_list);
+       network->wifi.sec_list = sec_list;
+
+       return 0;
+}
+
+void *connman_network_get_sec_list(struct connman_network *network)
+{
+       return network->wifi.sec_list;
+}
+
 int connman_network_set_maxrate(struct connman_network *network,
                                unsigned int maxrate)
 {
@@ -2429,7 +2483,8 @@ int connman_network_set_enc_mode(struct connman_network *network,
        if (encryption_mode == NULL)
                return -EINVAL;
 
-       DBG("network %p encryption mode %s", network, encryption_mode);
+       if (!simplified_log)
+               DBG("network %p encryption mode %s", network, encryption_mode);
 
        g_strlcpy(network->wifi.encryption_mode, encryption_mode,
                                        WIFI_ENCYPTION_MODE_LEN_MAX);
@@ -2522,8 +2577,9 @@ int connman_network_set_countrycode(struct connman_network *network,
        if (country_code == NULL)
                return -EINVAL;
 
-       DBG("network %p Country Code %02x:%02x",network,
-           country_code[0],country_code[1]);
+       if (!simplified_log)
+               DBG("network %p Country Code %02x:%02x",network,
+                               country_code[0],country_code[1]);
 
        for (; i < WIFI_COUNTRY_CODE_LEN; i++)
                network->wifi.country_code[i] = country_code[i];
@@ -2548,7 +2604,8 @@ int connman_network_set_bssid_list(struct connman_network *network,
 int connman_network_set_phy_mode(struct connman_network *network,
                                    ieee80211_modes_e mode)
 {
-       DBG("network %p phy mode %d", network, mode);
+       if (!simplified_log)
+               DBG("network %p phy mode %d", network, mode);
        network->wifi.phy_mode = mode;
 
        return 0;
@@ -2616,6 +2673,27 @@ GHashTable *connman_network_get_assoc_reject_table(struct connman_network *netwo
 
        return network->wifi.assoc_reject_table;
 }
+
+__time_t connman_network_get_roam_scan_time(struct connman_network *network)
+{
+       return network->wifi.roam_scan_time;
+}
+
+void connman_network_set_roam_scan_time(struct connman_network *network,
+                                               __time_t roam_scan_time)
+{
+       network->wifi.roam_scan_time = roam_scan_time;
+}
+
+int connman_network_get_snr(struct connman_network *network)
+{
+       return network->wifi.snr;
+}
+
+void connman_network_set_snr(struct connman_network *network, int snr)
+{
+       network->wifi.snr = snr;
+}
 #endif
 
 int connman_network_set_nameservers(struct connman_network *network,
@@ -2680,6 +2758,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);
@@ -2822,6 +2903,12 @@ int connman_network_set_string(struct connman_network *network,
        } else if (g_str_equal(key, "WiFi.NetAccessKey")) {
                g_free(network->wifi.net_access_key);
                network->wifi.net_access_key = g_strdup(value);
+       } else if (g_str_equal(key, "WiFi.RoamingCurBSSID")) {
+               g_free(network->wifi.roaming_cur_bssid);
+               network->wifi.roaming_cur_bssid = g_strdup(value);
+       } else if (g_str_equal(key, "WiFi.RoamingDstBSSID")) {
+               g_free(network->wifi.roaming_dst_bssid);
+               network->wifi.roaming_dst_bssid = g_strdup(value);
 #endif
        } else {
                return -EINVAL;
@@ -2849,15 +2936,7 @@ const char *connman_network_get_string(struct connman_network *network,
        else if (g_str_equal(key, "WiFi.Mode"))
                return network->wifi.mode;
        else if (g_str_equal(key, "WiFi.Security"))
-#if defined TIZEN_EXT
-               if (network->wifi.rsn_mode != true ||
-                   g_str_equal(network->wifi.security, "ieee8021x"))
-                       return network->wifi.security;
-               else
-                       return "rsn";
-#else
                return network->wifi.security;
-#endif
        else if (g_str_equal(key, "WiFi.Passphrase"))
                return network->wifi.passphrase;
        else if (g_str_equal(key, "WiFi.EAP"))
@@ -2895,6 +2974,10 @@ const char *connman_network_get_string(struct connman_network *network,
                return network->wifi.c_sign_key;
        else if (g_str_equal(key, "WiFi.NetAccessKey"))
                return network->wifi.net_access_key;
+       else if (g_str_equal(key, "WiFi.RoamingCurBSSID"))
+               return network->wifi.roaming_cur_bssid;
+       else if (g_str_equal(key, "WiFi.RoamingDstBSSID"))
+               return network->wifi.roaming_dst_bssid;
 #endif
 
        return NULL;
@@ -2926,6 +3009,9 @@ int connman_network_set_bool(struct connman_network *network,
                network->wifi.isHS20AP = value;
        else if (g_strcmp0(key, "WiFi.TRANSITION_MODE") == 0)
                network->wifi.owe_transition_mode = value;
+       else if (g_strcmp0(key, "WiFi.Roaming") == 0) {
+               network->wifi.roaming_progress = value;
+       }
 #endif
 
        return -EINVAL;
@@ -2954,8 +3040,10 @@ 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"))
+       else if (g_str_equal(key, "WiFi.TRANSITION_MODE"))
                return network->wifi.owe_transition_mode;
+       else if (g_str_equal(key, "WiFi.Roaming"))
+               return network->wifi.roaming_progress;
 #endif
 
        return false;