Merge "Removed cap for mac override and change the label for connman dir" into tizen
[platform/upstream/connman.git] / src / service.c
index 2325f64..f77f033 100755 (executable)
@@ -157,6 +157,13 @@ struct connman_service {
         */
        int user_pdn_connection_refcount;
        bool storage_reload;
+       /*
+        * Description: In case of EAP security type,
+        *                                user can select the keymgmt type for roaming(802.11r).
+        *                                - FT, CCKM, OKC, ...
+        */
+       char *keymgmt_type;
+       int disconnect_reason;
 #endif
 #if defined TIZEN_TV_EXT
        enum connman_dnsconfig_method dns_config_method;
@@ -2765,14 +2772,6 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
        const char *str;
        GSList *list;
 
-       str = __connman_service_type2string(service->type);
-       if (str)
-               connman_dbus_dict_append_basic(dict, "Type",
-                                               DBUS_TYPE_STRING, &str);
-
-       connman_dbus_dict_append_array(dict, "Security",
-                               DBUS_TYPE_STRING, append_security, service);
-
 #if defined TIZEN_EXT
        unsigned int frequency = 0U;
        if (service && service->network) {
@@ -2782,6 +2781,14 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
        }
 #endif
 
+       str = __connman_service_type2string(service->type);
+       if (str)
+               connman_dbus_dict_append_basic(dict, "Type",
+                                               DBUS_TYPE_STRING, &str);
+
+       connman_dbus_dict_append_array(dict, "Security",
+                               DBUS_TYPE_STRING, append_security, service);
+
        str = state2string(service->state);
        if (str)
                connman_dbus_dict_append_basic(dict, "State",
@@ -2845,6 +2852,10 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
 
                connman_dbus_dict_append_dict(dict, "Ethernet",
                                                append_ethernet, service);
+
+               connman_dbus_dict_append_basic(dict, "DisconnectReason",
+                               DBUS_TYPE_INT32, &service->disconnect_reason);
+
                break;
 #endif
        case CONNMAN_SERVICE_TYPE_ETHERNET:
@@ -4211,31 +4222,6 @@ void __connman_service_set_active_session(bool enable, GSList *list)
                        active_count);
 }
 
-#if defined TIZEN_CONNMAN_USE_BLACKLIST
-static connman_bool_t is_allowed(struct connman_service *service)
-{
-       connman_bool_t allowed;
-       const char *security = NULL;
-
-       if (!service)
-               return false;
-
-       security = security2string(service->security);
-       if (!security)
-               return false;
-
-       /* check if service is existed in blacklist */
-       allowed = __connman_agent_request_blacklist_check(service->name,
-                       security, service->eap);
-       if (allowed == false) {
-               DBG("service %p is not allowed", service);
-               service->autoconnect = false;
-       }
-
-       return allowed;
-}
-#endif
-
 struct preferred_tech_data {
        GList *preferred_list;
        enum connman_service_type type;
@@ -4284,6 +4270,9 @@ static GList *preferred_tech_list_get(void)
                                 */
                                if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
                                        break;
+
+                               if (service->type == CONNMAN_SERVICE_TYPE_BLUETOOTH)
+                                       break;
 #endif
                                return NULL;
                        }
@@ -4362,11 +4351,6 @@ static bool auto_connect_service(GList *services,
                                CONNMAN_SERVICE_STATE_IDLE)
                        continue;
 
-#if defined TIZEN_CONNMAN_USE_BLACKLIST
-               if (is_allowed(service) == false)
-                       continue;
-#endif
-
                if (autoconnecting && !active_sessions[service->type]) {
                        DBG("service %p type %s has no users", service,
                                __connman_service_type2string(service->type));
@@ -5946,21 +5930,6 @@ void __connman_service_set_search_domains(struct connman_service *service,
        searchdomain_add_all(service);
 }
 
-#if defined TIZEN_EXT
-void __connman_service_set_autoconnect(struct connman_service *service,
-                                               bool autoconnect)
-{
-       if (service == NULL)
-               return;
-
-       if (service->autoconnect != autoconnect) {
-               DBG("updated autoconnect flag (%d)", autoconnect);
-               service->autoconnect = autoconnect;
-               service_save(service);
-       }
-}
-#endif
-
 static void service_complete(struct connman_service *service)
 {
        reply_pending(service, EIO);
@@ -5984,7 +5953,14 @@ static void report_error_cb(void *user_context, bool retry,
                /* It is not relevant to stay on Failure state
                 * when failing is due to wrong user input */
                __connman_service_clear_error(service);
+#if defined TIZEN_EXT
+               /* Reseting the state back in case of failure state */
+               service->state_ipv4 = service->state_ipv6 =
+                               CONNMAN_SERVICE_STATE_IDLE;
 
+               if (service->error != CONNMAN_SERVICE_ERROR_AUTH_FAILED)
+                       set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
+#endif
                service_complete(service);
                __connman_connection_update_gateway();
        }
@@ -6540,6 +6516,7 @@ static int service_indicate_state(struct connman_service *service)
                reply_pending(service, ECONNABORTED);
 
                def_service = __connman_service_get_default();
+               service->disconnect_reason = connman_network_get_disconnect_reason(service->network);
 
                if (!__connman_notifier_is_connected() &&
                        def_service &&
@@ -6655,6 +6632,11 @@ int __connman_service_indicate_error(struct connman_service *service,
                                service->error == CONNMAN_SERVICE_ERROR_CONNECT_FAILED)
                        __connman_service_disconnect_default(service);
 
+               if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+                               service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY) {
+                       g_free(service->passphrase);
+                       service->passphrase = NULL;
+               }
 #endif
 
        __connman_service_ipconfig_indicate_state(service,