Revert "Remove Tizen specific hidden connection logic"
[platform/upstream/connman.git] / plugins / wifi.c
old mode 100644 (file)
new mode 100755 (executable)
index 42dd407..72eb64f
@@ -128,8 +128,22 @@ struct wifi_data {
        bool p2p_connecting;
        bool p2p_device;
        int servicing;
+#if defined TIZEN_EXT
+       int assoc_retry_count;
+       struct connman_network *scan_pending_network;
+#endif
 };
 
+#if defined TIZEN_EXT
+#include "connman.h"
+
+#define TIZEN_ASSOC_RETRY_COUNT                4
+
+static gboolean wifi_first_scan = false;
+static gboolean found_with_first_scan = false;
+static gboolean is_wifi_notifier_registered = false;
+#endif
+
 static GList *iface_list = NULL;
 
 static GList *pending_wifi_device = NULL;
@@ -1019,6 +1033,15 @@ static int get_hidden_connections(GSupplicantScanParams *scan_data)
                        continue;
                }
 
+#if defined TIZEN_EXT
+               value = g_key_file_get_boolean(keyfile,
+                                       services[i], "AutoConnect", NULL);
+               if (!value) {
+                       g_key_file_free(keyfile);
+                       continue;
+               }
+#endif
+
                ssid = g_key_file_get_string(keyfile,
                                        services[i], "SSID", NULL);
 
@@ -1188,6 +1211,45 @@ static void hidden_free(struct hidden_params *hidden)
        g_free(hidden);
 }
 
+#if defined TIZEN_EXT
+static void service_state_changed(struct connman_service *service,
+                                       enum connman_service_state state);
+
+static int network_connect(struct connman_network *network);
+
+static struct connman_notifier notifier = {
+       .name                   = "wifi",
+       .priority               = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
+       .service_state_changed  = service_state_changed,
+};
+
+static void service_state_changed(struct connman_service *service,
+                                       enum connman_service_state state)
+{
+       enum connman_service_type type;
+
+       type = connman_service_get_type(service);
+       if (type != CONNMAN_SERVICE_TYPE_WIFI)
+               return;
+
+       DBG("service %p state %d", service, state);
+
+       switch (state) {
+       case CONNMAN_SERVICE_STATE_READY:
+       case CONNMAN_SERVICE_STATE_ONLINE:
+       case CONNMAN_SERVICE_STATE_FAILURE:
+               connman_notifier_unregister(&notifier);
+               is_wifi_notifier_registered = FALSE;
+
+               __connman_device_request_scan(type);
+               break;
+
+       default:
+               break;
+       }
+}
+#endif
+
 static void scan_callback(int result, GSupplicantInterface *interface,
                                                void *user_data)
 {
@@ -1241,6 +1303,9 @@ static void scan_callback(int result, GSupplicantInterface *interface,
        }
 
        if (result != -ENOLINK)
+#if defined TIZEN_EXT
+       if (result != -EIO)
+#endif
                start_autoscan(device);
 
        /*
@@ -1252,6 +1317,23 @@ static void scan_callback(int result, GSupplicantInterface *interface,
 
        if (scanning)
                connman_device_unref(device);
+
+#if defined TIZEN_EXT
+       if (wifi && wifi->scan_pending_network && result != -EIO) {
+               network_connect(wifi->scan_pending_network);
+               wifi->scan_pending_network = NULL;
+               connman_network_set_connecting(wifi->network);
+       }
+
+       if (is_wifi_notifier_registered != true &&
+                       wifi_first_scan == true && found_with_first_scan == true) {
+               wifi_first_scan = false;
+               found_with_first_scan = false;
+
+               connman_notifier_register(&notifier);
+               is_wifi_notifier_registered = true;
+       }
+#endif
 }
 
 static void scan_callback_hidden(int result,
@@ -1308,7 +1390,11 @@ static gboolean autoscan_timeout(gpointer data)
        } else
                interval = autoscan->interval * autoscan->base;
 
+#if defined TIZEN_EXT
+       if (autoscan->interval >= autoscan->limit)
+#else
        if (interval > autoscan->limit)
+#endif
                interval = autoscan->limit;
 
        throw_wifi_scan(wifi->device, scan_callback_hidden);
@@ -1501,6 +1587,15 @@ static int wifi_disable(struct connman_device *device)
 
        remove_networks(device, wifi);
 
+#if defined TIZEN_EXT
+       wifi->scan_pending_network = NULL;
+
+       if (is_wifi_notifier_registered == true) {
+               connman_notifier_unregister(&notifier);
+               is_wifi_notifier_registered = false;
+       }
+#endif
+
        ret = g_supplicant_interface_remove(wifi->interface, NULL, NULL);
        if (ret < 0)
                return ret;
@@ -1837,6 +1932,7 @@ static int wifi_scan(enum connman_service_type type,
 
        ret = g_supplicant_interface_scan(wifi->interface, scan_params,
                                                scan_callback, device);
+
        if (ret == 0) {
                connman_device_set_scanning(device,
                                CONNMAN_SERVICE_TYPE_WIFI, true);
@@ -1932,15 +2028,42 @@ static void network_remove(struct connman_network *network)
                return;
 
        wifi->network = NULL;
+
+#if defined TIZEN_EXT
+       wifi->disconnecting = false;
+
+       if (wifi->pending_network == network)
+               wifi->pending_network = NULL;
+
+       if (wifi->scan_pending_network == network)
+               wifi->scan_pending_network = NULL;
+#endif
 }
 
 static void connect_callback(int result, GSupplicantInterface *interface,
                                                        void *user_data)
 {
+#if defined TIZEN_EXT
+       GList *list;
+       struct wifi_data *wifi;
+#endif
        struct connman_network *network = user_data;
 
        DBG("network %p result %d", network, result);
 
+#if defined TIZEN_EXT
+       for (list = iface_list; list; list = list->next) {
+               wifi = list->data;
+
+               if (wifi && wifi->network == network)
+                       goto found;
+       }
+
+       /* wifi_data may be invalid because wifi is already disabled */
+       return;
+
+found:
+#endif
        if (result == -ENOKEY) {
                connman_network_set_error(network,
                                        CONNMAN_NETWORK_ERROR_INVALID_KEY);
@@ -1966,6 +2089,12 @@ static GSupplicantSecurity network_security(const char *security)
                return G_SUPPLICANT_SECURITY_PSK;
        else if (g_str_equal(security, "ieee8021x"))
                return G_SUPPLICANT_SECURITY_IEEE8021X;
+#if defined TIZEN_EXT
+       else if (g_str_equal(security, "ft_psk") == TRUE)
+               return G_SUPPLICANT_SECURITY_FT_PSK;
+       else if (g_str_equal(security, "ft_ieee8021x") == TRUE)
+               return G_SUPPLICANT_SECURITY_FT_IEEE8021X;
+#endif
 
        return G_SUPPLICANT_SECURITY_UNKNOWN;
 }
@@ -2017,6 +2146,10 @@ static void ssid_init(GSupplicantSSID *ssid, struct connman_network *network)
        ssid->use_wps = connman_network_get_bool(network, "WiFi.UseWPS");
        ssid->pin_wps = connman_network_get_string(network, "WiFi.PinWPS");
 
+#if defined TIZEN_EXT
+       ssid->bssid = connman_network_get_bssid(network);
+#endif
+
        if (connman_setting_get_bool("BackgroundScanning"))
                ssid->bgscan = BGSCAN_DEFAULT;
 }
@@ -2051,6 +2184,9 @@ static int network_connect(struct connman_network *network)
        } else {
                wifi->network = connman_network_ref(network);
                wifi->retries = 0;
+#if defined TIZEN_EXT
+               wifi->scan_pending_network = NULL;
+#endif
 
                return g_supplicant_interface_connect(interface, ssid,
                                                connect_callback, network);
@@ -2062,7 +2198,30 @@ static int network_connect(struct connman_network *network)
 static void disconnect_callback(int result, GSupplicantInterface *interface,
                                                                void *user_data)
 {
+#if defined TIZEN_EXT
+       GList *list;
+       struct wifi_data *wifi;
+       struct connman_network *network = user_data;
+
+       DBG("network %p result %d", network, result);
+
+       for (list = iface_list; list; list = list->next) {
+               wifi = list->data;
+
+               if (wifi->network == NULL && wifi->disconnecting == true)
+                       wifi->disconnecting = false;
+
+               if (wifi->network == network)
+                       goto found;
+       }
+
+       /* wifi_data may be invalid because wifi is already disabled */
+       return;
+
+found:
+#else
        struct wifi_data *wifi = user_data;
+#endif
 
        DBG("result %d supplicant interface %p wifi %p",
                        result, interface, wifi);
@@ -2101,6 +2260,9 @@ static int network_disconnect(struct connman_network *network)
        struct connman_device *device = connman_network_get_device(network);
        struct wifi_data *wifi;
        int err;
+#if defined TIZEN_EXT
+       struct connman_service *service;
+#endif
 
        DBG("network %p", network);
 
@@ -2108,6 +2270,29 @@ static int network_disconnect(struct connman_network *network)
        if (!wifi || !wifi->interface)
                return -ENODEV;
 
+#if defined TIZEN_EXT
+       if (connman_network_get_associating(network) == true) {
+               connman_network_clear_associating(network);
+               connman_network_set_bool(network, "WiFi.UseWPS", false);
+       } else {
+               service = connman_service_lookup_from_network(network);
+
+               if (service != NULL &&
+                       (__connman_service_is_connected_state(service,
+                                       CONNMAN_IPCONFIG_TYPE_IPV4) == false &&
+                       __connman_service_is_connected_state(service,
+                                       CONNMAN_IPCONFIG_TYPE_IPV6) == false) &&
+                       (connman_service_get_favorite(service) == false))
+                                       __connman_service_set_passphrase(service, NULL);
+       }
+
+       if (wifi->pending_network == network)
+               wifi->pending_network = NULL;
+
+       if (wifi->scan_pending_network == network)
+               wifi->scan_pending_network = NULL;
+
+#endif
        connman_network_set_associating(network, false);
 
        if (wifi->disconnecting)
@@ -2115,8 +2300,14 @@ static int network_disconnect(struct connman_network *network)
 
        wifi->disconnecting = true;
 
+#if defined TIZEN_EXT
+       err = g_supplicant_interface_disconnect(wifi->interface,
+                                               disconnect_callback, network);
+#else
        err = g_supplicant_interface_disconnect(wifi->interface,
                                                disconnect_callback, wifi);
+#endif
+
        if (err < 0)
                wifi->disconnecting = false;
 
@@ -2238,8 +2429,16 @@ static bool handle_wps_completion(GSupplicantInterface *interface,
                if (!wps_ssid || wps_ssid_len != ssid_len ||
                                memcmp(ssid, wps_ssid, ssid_len) != 0) {
                        connman_network_set_associating(network, false);
+#if defined TIZEN_EXT
+                       g_supplicant_interface_disconnect(wifi->interface,
+                                               disconnect_callback, wifi->network);
+
+                       connman_network_set_bool(network, "WiFi.UseWPS", false);
+                       connman_network_set_string(network, "WiFi.PinWPS", NULL);
+#else
                        g_supplicant_interface_disconnect(wifi->interface,
                                                disconnect_callback, wifi);
+#endif
                        return false;
                }
 
@@ -2257,11 +2456,35 @@ static bool handle_4way_handshake_failure(GSupplicantInterface *interface,
                                        struct connman_network *network,
                                        struct wifi_data *wifi)
 {
+#if defined TIZEN_EXT
+       const char *security;
+       struct connman_service *service;
+
+       if (wifi->connected)
+               return false;
+
+       security = connman_network_get_string(network, "WiFi.Security");
+
+       if (g_str_equal(security, "ieee8021x") == true &&
+                       wifi->state == G_SUPPLICANT_STATE_ASSOCIATED) {
+               wifi->retries = 0;
+               connman_network_set_error(network, CONNMAN_NETWORK_ERROR_INVALID_KEY);
+
+               return false;
+       }
+
+       if (wifi->state != G_SUPPLICANT_STATE_4WAY_HANDSHAKE)
+               return false;
+#else
        struct connman_service *service;
 
        if (wifi->state != G_SUPPLICANT_STATE_4WAY_HANDSHAKE)
                return false;
 
+       if (wifi->connected)
+               return false;
+#endif
+
        service = connman_service_lookup_from_network(network);
        if (!service)
                return false;
@@ -2279,6 +2502,47 @@ static bool handle_4way_handshake_failure(GSupplicantInterface *interface,
        return false;
 }
 
+#if defined TIZEN_EXT
+static bool handle_wifi_assoc_retry(struct connman_network *network,
+                                       struct wifi_data *wifi)
+{
+       const char *security;
+
+       if (!wifi->network || wifi->connected || wifi->disconnecting ||
+                       connman_network_get_connecting(network) != true) {
+               wifi->assoc_retry_count = 0;
+               return false;
+       }
+
+       if (wifi->state != G_SUPPLICANT_STATE_ASSOCIATING &&
+                       wifi->state != G_SUPPLICANT_STATE_ASSOCIATED) {
+               wifi->assoc_retry_count = 0;
+               return false;
+       }
+
+       security = connman_network_get_string(network, "WiFi.Security");
+       if (g_str_equal(security, "ieee8021x") == true &&
+                       wifi->state == G_SUPPLICANT_STATE_ASSOCIATED) {
+               wifi->assoc_retry_count = 0;
+               return false;
+       }
+
+       if (++wifi->assoc_retry_count >= TIZEN_ASSOC_RETRY_COUNT) {
+               wifi->assoc_retry_count = 0;
+
+               /* Honestly it's not an invalid-key error,
+                * however QA team recommends that the invalid-key error
+                * might be better to display for user experience.
+                */
+               connman_network_set_error(network, CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
+
+               return false;
+       }
+
+       return true;
+}
+#endif
+
 static void interface_state(GSupplicantInterface *interface)
 {
        struct connman_network *network;
@@ -2314,7 +2578,11 @@ static void interface_state(GSupplicantInterface *interface)
 
        case G_SUPPLICANT_STATE_AUTHENTICATING:
        case G_SUPPLICANT_STATE_ASSOCIATING:
+#if defined TIZEN_EXT
+               reset_autoscan(device);
+#else
                stop_autoscan(device);
+#endif
 
                if (!wifi->connected)
                        connman_network_set_associating(network, true);
@@ -2322,8 +2590,17 @@ static void interface_state(GSupplicantInterface *interface)
                break;
 
        case G_SUPPLICANT_STATE_COMPLETED:
+#if defined TIZEN_EXT
+               /* though it should be already reset: */
+               reset_autoscan(device);
+
+               wifi->assoc_retry_count = 0;
+
+               wifi->scan_pending_network = NULL;
+#else
                /* though it should be already stopped: */
                stop_autoscan(device);
+#endif
 
                if (!handle_wps_completion(interface, network, device, wifi))
                        break;
@@ -2360,6 +2637,47 @@ static void interface_state(GSupplicantInterface *interface)
                                                FALSE) != 0)
                        DBG("Could not disables selected network");
 
+#if defined TIZEN_EXT
+               int err;
+               int reason_code = 0;
+
+               err = g_supplicant_interface_remove_network(wifi->interface);
+               if (err < 0)
+                       DBG("Failed to remove network(%d)", err);
+
+               reason_code = g_supplicant_interface_get_disconnect_reason(wifi->interface);
+
+               /* Some of Wi-Fi networks are not comply Wi-Fi specification.
+                * Retry association until its retry count is expired */
+               if (handle_wifi_assoc_retry(network, wifi) == true) {
+                       throw_wifi_scan(wifi->device, scan_callback);
+                       wifi->scan_pending_network = wifi->network;
+                       break;
+               }
+
+               if(reason_code > 0){
+                       DBG("Set disconnect reason code(%d)", reason_code);
+                       connman_network_set_disconnect_reason(network, reason_code);
+               }
+
+               /* To avoid unnecessary repeated association in wpa_supplicant,
+                * "RemoveNetwork" should be made when Wi-Fi is disconnected */
+               if (wps != true && wifi->network && wifi->disconnecting == false) {
+                       wifi->disconnecting = true;
+                       err = g_supplicant_interface_disconnect(wifi->interface,
+                                                       disconnect_callback, wifi->network);
+                       if (err < 0)
+                               wifi->disconnecting = false;
+
+               connman_network_set_connected(network, false);
+               connman_network_set_associating(network, false);
+
+               start_autoscan(device);
+
+               break;
+               }
+#endif
+
                connman_network_set_connected(network, false);
                connman_network_set_associating(network, false);
                wifi->disconnecting = false;
@@ -2369,6 +2687,10 @@ static void interface_state(GSupplicantInterface *interface)
                break;
 
        case G_SUPPLICANT_STATE_INACTIVE:
+#if defined TIZEN_EXT
+               if (handle_wps_completion(interface, network, device, wifi) == false)
+                       break;
+#endif
                connman_network_set_associating(network, false);
                start_autoscan(device);
 
@@ -2393,6 +2715,10 @@ static void interface_state(GSupplicantInterface *interface)
         * --> We are not connected
         * */
        switch (state) {
+#if defined TIZEN_EXT
+       case G_SUPPLICANT_STATE_SCANNING:
+               break;
+#endif
        case G_SUPPLICANT_STATE_AUTHENTICATING:
        case G_SUPPLICANT_STATE_ASSOCIATING:
        case G_SUPPLICANT_STATE_ASSOCIATED:
@@ -2497,7 +2823,38 @@ static void scan_started(GSupplicantInterface *interface)
 
 static void scan_finished(GSupplicantInterface *interface)
 {
+#if defined TIZEN_EXT
+       struct wifi_data *wifi;
+       bool is_associating = false;
+       static bool is_scanning = true;
+#endif
+
        DBG("");
+
+#if defined TIZEN_EXT
+       wifi = g_supplicant_interface_get_data(interface);
+       if (wifi && wifi->scan_pending_network) {
+               network_connect(wifi->scan_pending_network);
+               wifi->scan_pending_network = NULL;
+       }
+
+       //service state - associating
+       if(!wifi || !wifi->network)
+               return;
+
+       is_associating = connman_network_get_associating(wifi->network);
+       if(is_associating && is_scanning){
+               is_scanning = false;
+               DBG("send scan for connecting");
+               throw_wifi_scan(wifi->device, scan_callback);
+
+               return;
+       }
+       is_scanning = true;
+
+       //go scan
+
+#endif
 }
 
 static unsigned char calculate_strength(GSupplicantNetwork *supplicant_network)
@@ -2580,19 +2937,44 @@ static void network_added(GSupplicantNetwork *supplicant_network)
                /* Is AP advertizing for WPS association?
                 * If so, we decide to use WPS by default */
                if (wps_ready && wps_pbc &&
-                                               wps_advertizing)
+                                               wps_advertizing) {
+#if !defined TIZEN_EXT
                        connman_network_set_bool(network, "WiFi.UseWPS", true);
+#else
+                       DBG("wps is activating by ap but ignore it.");
+#endif
+               }
        }
 
        connman_network_set_frequency(network,
                        g_supplicant_network_get_frequency(supplicant_network));
-
+#if defined TIZEN_EXT
+       connman_network_set_bssid(network,
+                       g_supplicant_network_get_bssid(supplicant_network));
+       connman_network_set_maxrate(network,
+                       g_supplicant_network_get_maxrate(supplicant_network));
+       connman_network_set_enc_mode(network,
+                       g_supplicant_network_get_enc_mode(supplicant_network));
+       connman_network_set_rsn_mode(network,
+                       g_supplicant_network_get_rsn_mode(supplicant_network));
+       connman_network_set_keymgmt(network,
+                       g_supplicant_network_get_keymgmt(supplicant_network));
+#endif
        connman_network_set_available(network, true);
        connman_network_set_string(network, "WiFi.Mode", mode);
 
+#if defined TIZEN_EXT
+       if (group)
+#else
        if (ssid)
+#endif
                connman_network_set_group(network, group);
 
+#if defined TIZEN_EXT
+       if (wifi_first_scan == true)
+               found_with_first_scan = true;
+#endif
+
        if (wifi->hidden && ssid) {
                if (!g_strcmp0(wifi->hidden->security, security) &&
                                wifi->hidden->ssid_len == ssid_len &&
@@ -2629,6 +3011,18 @@ static void network_removed(GSupplicantNetwork *network)
        if (!connman_network)
                return;
 
+#if defined TIZEN_EXT
+       if (connman_network == wifi->scan_pending_network)
+               wifi->scan_pending_network = NULL;
+
+       if (connman_network == wifi->pending_network)
+               wifi->pending_network = NULL;
+
+       if(connman_network_get_connecting(connman_network) == true){
+               connman_network_set_connected(connman_network, false);
+       }
+#endif
+
        wifi->networks = g_slist_remove(wifi->networks, connman_network);
 
        connman_device_remove_network(wifi->device, connman_network);
@@ -2642,6 +3036,13 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
        const char *name, *identifier;
        struct connman_network *connman_network;
 
+#if defined TIZEN_EXT
+       const unsigned char *bssid;
+       unsigned int maxrate;
+       uint16_t frequency;
+       bool wps;
+#endif
+
        interface = g_supplicant_network_get_interface(network);
        wifi = g_supplicant_interface_get_data(interface);
        identifier = g_supplicant_network_get_identifier(network);
@@ -2661,6 +3062,18 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
                                        calculate_strength(network));
               connman_network_update(connman_network);
        }
+
+#if defined TIZEN_EXT
+       bssid = g_supplicant_network_get_bssid(network);
+       maxrate = g_supplicant_network_get_maxrate(network);
+       frequency = g_supplicant_network_get_frequency(network);
+       wps = g_supplicant_network_get_wps(network);
+
+       connman_network_set_bssid(connman_network, bssid);
+       connman_network_set_maxrate(connman_network, maxrate);
+       connman_network_set_frequency(connman_network, frequency);
+       connman_network_set_bool(connman_network, "WiFi.WPS", wps);
+#endif
 }
 
 static void apply_peer_services(GSupplicantPeer *peer,
@@ -2680,6 +3093,17 @@ static void apply_peer_services(GSupplicantPeer *peer,
        }
 }
 
+static void add_station(const char *mac)
+{
+       connman_technology_tethering_add_station(CONNMAN_SERVICE_TYPE_WIFI,
+                                                mac);
+}
+
+static void remove_station(const char *mac)
+{
+       connman_technology_tethering_remove_station(mac);
+}
+
 static void peer_found(GSupplicantPeer *peer)
 {
        GSupplicantInterface *iface = g_supplicant_peer_get_interface(peer);
@@ -2829,6 +3253,95 @@ static void peer_request(GSupplicantPeer *peer)
        connman_peer_request_connection(connman_peer);
 }
 
+#if defined TIZEN_EXT
+static void system_power_off(void)
+{
+       GList *list;
+       struct wifi_data *wifi;
+       struct connman_service *service;
+       struct connman_ipconfig *ipconfig_ipv4;
+
+       if (connman_setting_get_bool("WiFiDHCPRelease") == true) {
+               for (list = iface_list; list; list = list->next) {
+                       wifi = list->data;
+
+                       if (wifi->network != NULL) {
+                               service = connman_service_lookup_from_network(wifi->network);
+                               ipconfig_ipv4 = __connman_service_get_ip4config(service);
+                               __connman_dhcp_stop(ipconfig_ipv4);
+                       }
+               }
+       }
+}
+
+static void network_merged(GSupplicantNetwork *network)
+{
+       GSupplicantInterface *interface;
+       GSupplicantState state;
+       struct wifi_data *wifi;
+       const char *identifier;
+       struct connman_network *connman_network;
+       unsigned int ishs20AP = 0;
+       char *temp = NULL;
+
+       interface = g_supplicant_network_get_interface(network);
+       if (!interface)
+               return;
+
+       state = g_supplicant_interface_get_state(interface);
+       if (state < G_SUPPLICANT_STATE_AUTHENTICATING)
+               return;
+
+       wifi = g_supplicant_interface_get_data(interface);
+       if (!wifi)
+               return;
+
+       identifier = g_supplicant_network_get_identifier(network);
+
+       connman_network = connman_device_get_network(wifi->device, identifier);
+       if (!connman_network)
+               return;
+
+       DBG("merged identifier %s", identifier);
+
+       if (wifi->connected == FALSE) {
+               switch (state) {
+               case G_SUPPLICANT_STATE_AUTHENTICATING:
+               case G_SUPPLICANT_STATE_ASSOCIATING:
+               case G_SUPPLICANT_STATE_ASSOCIATED:
+               case G_SUPPLICANT_STATE_4WAY_HANDSHAKE:
+               case G_SUPPLICANT_STATE_GROUP_HANDSHAKE:
+                       connman_network_set_associating(connman_network, TRUE);
+                       break;
+               case G_SUPPLICANT_STATE_COMPLETED:
+                       connman_network_set_connected(connman_network, TRUE);
+                       break;
+               default:
+                       DBG("Not handled the state : %d", state);
+                       break;
+               }
+       }
+
+       ishs20AP = g_supplicant_network_is_hs20AP(network);
+       connman_network_set_is_hs20AP(connman_network, ishs20AP);
+
+       if (ishs20AP &&
+               g_strcmp0(g_supplicant_network_get_security(network), "ieee8021x") == 0) {
+               temp = g_ascii_strdown(g_supplicant_network_get_eap(network), -1);
+               connman_network_set_string(connman_network, "WiFi.EAP",
+                               temp);
+               connman_network_set_string(connman_network, "WiFi.Identity",
+                               g_supplicant_network_get_identity(network));
+               connman_network_set_string(connman_network, "WiFi.Phase2",
+                               g_supplicant_network_get_phase2(network));
+
+               g_free(temp);
+       }
+
+       wifi->network = connman_network;
+}
+#endif
+
 static void debug(const char *str)
 {
        if (getenv("CONNMAN_SUPPLICANT_DEBUG"))
@@ -2847,10 +3360,16 @@ static const GSupplicantCallbacks callbacks = {
        .network_added          = network_added,
        .network_removed        = network_removed,
        .network_changed        = network_changed,
+       .add_station            = add_station,
+       .remove_station         = remove_station,
        .peer_found             = peer_found,
        .peer_lost              = peer_lost,
        .peer_changed           = peer_changed,
        .peer_request           = peer_request,
+#if defined TIZEN_EXT
+       .system_power_off       = system_power_off,
+       .network_merged = network_merged,
+#endif
        .debug                  = debug,
 };
 
@@ -2874,7 +3393,8 @@ struct wifi_tethering_info {
        GSupplicantSSID *ssid;
 };
 
-static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
+static GSupplicantSSID *ssid_ap_init(const char *ssid,
+               const char *passphrase, bool hidden)
 {
        GSupplicantSSID *ap;
 
@@ -2899,6 +3419,12 @@ static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
               ap->passphrase = passphrase;
        }
 
+       if (hidden)
+               ap->ignore_broadcast_ssid =
+                               G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_CONTENTS;
+       else
+               ap->ignore_broadcast_ssid = G_SUPPLICANT_AP_NO_SSID_HIDING;
+
        return ap;
 }
 
@@ -2979,7 +3505,7 @@ static void sta_remove_callback(int result,
 
 static int tech_set_tethering(struct connman_technology *technology,
                                const char *identifier, const char *passphrase,
-                               const char *bridge, bool enabled)
+                               const char *bridge, bool enabled, bool hidden)
 {
        GList *list;
        GSupplicantInterface *interface;
@@ -3032,7 +3558,7 @@ static int tech_set_tethering(struct connman_technology *technology,
                info->wifi = wifi;
                info->technology = technology;
                info->wifi->bridge = bridge;
-               info->ssid = ssid_ap_init(identifier, passphrase);
+               info->ssid = ssid_ap_init(identifier, passphrase, hidden);
                if (!info->ssid) {
                        g_free(info);
                        continue;