Fix build issue
[platform/core/api/connection.git] / src / libnetwork.c
index 2d60d7c..4788660 100755 (executable)
@@ -27,6 +27,7 @@
 static GSList *prof_handle_list = NULL;
 static GHashTable *profile_cb_table = NULL;
 static pthread_mutex_t g_conn_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __thread int g_conn_thread_mutex_ref = 0;
 
 struct _profile_cb_s {
        connection_profile_state_changed_cb callback;
@@ -169,11 +170,18 @@ static void __libnet_clear_profile_list(struct _profile_list_s *profile_list)
 
 static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
 {
+       CONN_LOCK;
        bool is_requested = false;
        connection_error_e result = CONNECTION_ERROR_NONE;
        connection_handle_s *conn_handle = (connection_handle_s *)user_data;
 
-       switch (event_cb->Event) {
+       if (!_connection_check_handle_validity(conn_handle)) {
+               CONNECTION_LOG(CONNECTION_INFO, "Invalid handle");
+               CONN_UNLOCK;
+               return;
+       }
+
+       switch (event_cb->event) {
        case NET_EVENT_OPEN_RSP:
                is_requested = true;
                /* fall through */
@@ -198,14 +206,15 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                case NET_ERR_ACTIVE_CONNECTION_EXISTS:
                        CONNECTION_LOG(CONNECTION_INFO, "Successfully open connection");
 
-                       __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_CONNECTED);
+                       __libnet_state_changed_cb(event_cb->profile_name, CONNECTION_PROFILE_STATE_CONNECTED);
+                       CONN_UNLOCK;
                        return;
                default:
                        CONNECTION_LOG(CONNECTION_ERROR, "Failed to open connection[%s]",
                                                __libnet_convert_cp_error_type_to_string(result));
                }
 
-               __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED);
+               __libnet_state_changed_cb(event_cb->profile_name, CONNECTION_PROFILE_STATE_DISCONNECTED);
 
                break;
        case NET_EVENT_CLOSE_RSP:
@@ -231,7 +240,8 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                case NET_ERR_NONE:
                        CONNECTION_LOG(CONNECTION_INFO, "Successfully closed connection");
 
-                       __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED);
+                       __libnet_state_changed_cb(event_cb->profile_name, CONNECTION_PROFILE_STATE_DISCONNECTED);
+                       CONN_UNLOCK;
                        return;
                default:
                        CONNECTION_LOG(CONNECTION_ERROR, "Failed to close connection[%s]",
@@ -242,16 +252,18 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
        case NET_EVENT_NET_STATE_IND:
                CONNECTION_LOG(CONNECTION_INFO, "State changed IND");
 
-               if (event_cb->Datalength != sizeof(net_state_type_t))
+               if (event_cb->datalength != sizeof(net_state_type_t)) {
+                       CONN_UNLOCK;
                        return;
+               }
 
-               net_state_type_t *profile_state = (net_state_type_t *)event_cb->Data;
+               net_state_type_t *profile_state = (net_state_type_t *)event_cb->data;
                connection_profile_state_e cp_state = _profile_convert_to_cp_state(*profile_state);
 
                CONNECTION_LOG(CONNECTION_INFO, "state: %s", __libnet_convert_cp_state_to_string(cp_state));
-               SECURE_CONNECTION_LOG(CONNECTION_INFO, "profile name: %s", event_cb->ProfileName);
+               SECURE_CONNECTION_LOG(CONNECTION_INFO, "profile name: %s", event_cb->profile_name);
 
-               __libnet_state_changed_cb(event_cb->ProfileName, cp_state);
+               __libnet_state_changed_cb(event_cb->profile_name, cp_state);
 
                break;
        case NET_EVENT_CELLULAR_SET_DEFAULT_RSP:
@@ -292,7 +304,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                break;
        case NET_EVENT_NETWORK_TYPE_CHANGED:
                CONNECTION_LOG(CONNECTION_INFO, "Got Network Type Changed Indication");
-               int *state = (int *) event_cb->Data;
+               int *state = (int *) event_cb->data;
                if (conn_handle->type_changed_callback) {
                        int type = CONNECTION_TYPE_DISCONNECTED;
 
@@ -326,7 +338,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                if (conn_handle->ip_changed_callback) {
                        char *ipv4_addr = NULL;
                        char *ipv6_addr = NULL;
-                       char *addr = (char *)event_cb->Data;
+                       char *addr = (char *)event_cb->data;
 
                        ipv4_addr = g_strdup(addr);
                        ipv6_addr = vconf_get_str(VCONFKEY_NETWORK_IP6);
@@ -346,7 +358,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                if (conn_handle->ip_changed_callback) {
                        char *ipv4_addr = NULL;
                        char *ipv6_addr = NULL;
-                       char *addr = (char *)event_cb->Data;
+                       char *addr = (char *)event_cb->data;
 
                        ipv6_addr = g_strdup(addr);
                        ipv4_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
@@ -363,7 +375,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                break;
        case NET_EVENT_PROXY_ADDRESS_CHANGED:
                CONNECTION_LOG(CONNECTION_INFO, "Got Proxy Changed Indication");
-               char *proxy_addr = (char *)event_cb->Data;
+               char *proxy_addr = (char *)event_cb->data;
 
                if (conn_handle->proxy_changed_callback) {
                        conn_handle->proxy_changed_callback(proxy_addr, NULL,
@@ -373,8 +385,8 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
        case NET_EVENT_INTERNET_ONLINE_IND:
        case NET_EVENT_INTERNET_OFFLINE_IND:
                CONNECTION_LOG(CONNECTION_INFO, "Got Internet State Changed Indication: %s",
-                               event_cb->Event == NET_EVENT_INTERNET_ONLINE_IND ? "Online" : "Offline");
-               net_device_t *device_type = (net_device_t *) event_cb->Data;
+                               event_cb->event == NET_EVENT_INTERNET_ONLINE_IND ? "Online" : "Offline");
+               net_device_t *device_type = (net_device_t *) event_cb->data;
 
                if (conn_handle->internet_state_changed_callback) {
                        net_profile_info_t active_profile;
@@ -382,7 +394,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
 
                        rv = net_get_active_net_info(conn_handle->network_info_handle, &active_profile);
 
-                       if (rv == NET_ERR_NO_SERVICE && event_cb->Event == NET_EVENT_INTERNET_OFFLINE_IND) {
+                       if (rv == NET_ERR_NO_SERVICE && event_cb->event == NET_EVENT_INTERNET_OFFLINE_IND) {
                                conn_handle->internet_state_changed_callback(CONNECTION_INTERNET_STATE_OFFLINE,
                                        conn_handle->internet_state_changed_user_data); //LCOV_EXCL_LINE
                                break;
@@ -394,13 +406,13 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                                break; //LCOV_EXCL_LINE
                        }
 
-                       if (event_cb->Event == NET_EVENT_INTERNET_ONLINE_IND) {
-                               if (active_profile.ProfileState == NET_STATE_TYPE_ONLINE &&
+                       if (event_cb->event == NET_EVENT_INTERNET_ONLINE_IND) {
+                               if (active_profile.profile_state == NET_STATE_TYPE_ONLINE &&
                                                active_profile.profile_type == *device_type)
                                        conn_handle->internet_state_changed_callback(CONNECTION_INTERNET_STATE_ONLINE,
                                                        conn_handle->internet_state_changed_user_data);
                        } else {
-                               if (active_profile.ProfileState != NET_STATE_TYPE_ONLINE)
+                               if (active_profile.profile_state != NET_STATE_TYPE_ONLINE)
                                        conn_handle->internet_state_changed_callback(CONNECTION_INTERNET_STATE_OFFLINE,
                                                        conn_handle->internet_state_changed_user_data);
                        }
@@ -410,6 +422,8 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
        default:
                break;
        }
+
+       CONN_UNLOCK;
 }
 //LCOV_EXCL_STOP
 
@@ -419,8 +433,8 @@ static int __libnet_get_connected_count(struct _profile_list_s *profile_list)
        int i = 0;
 
        for (; i < profile_list->count; i++) {
-               if (profile_list->profiles[i].ProfileState == NET_STATE_TYPE_ONLINE ||
-                   profile_list->profiles[i].ProfileState == NET_STATE_TYPE_READY)
+               if (profile_list->profiles[i].profile_state == NET_STATE_TYPE_ONLINE ||
+                   profile_list->profiles[i].profile_state == NET_STATE_TYPE_READY)
                        count++;
        }
 
@@ -432,8 +446,8 @@ static void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _p
        int i = 0;
 
        for (; i < source->count; i++) {
-               if (source->profiles[i].ProfileState == NET_STATE_TYPE_ONLINE ||
-                   source->profiles[i].ProfileState == NET_STATE_TYPE_READY) {
+               if (source->profiles[i].profile_state == NET_STATE_TYPE_ONLINE ||
+                   source->profiles[i].profile_state == NET_STATE_TYPE_READY) {
                        memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t));
                        (*dest)++;
                }
@@ -448,7 +462,7 @@ static int __libnet_get_default_count(struct _profile_list_s *profile_list)
 
        for (; i < profile_list->count; i++) {
                if (profile_list->profiles[i].profile_type == NET_DEVICE_CELLULAR) {
-                       if (profile_list->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE)
+                       if (profile_list->profiles[i].profile_info.pdp.default_conn == TRUE)
                                count++;
                }
        }
@@ -462,7 +476,7 @@ static void __libnet_copy_default_profile(net_profile_info_t **dest, struct _pro
 
        for (; i < source->count; i++) {
                if (source->profiles[i].profile_type == NET_DEVICE_CELLULAR) {
-                       if (source->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE) {
+                       if (source->profiles[i].profile_info.pdp.default_conn == TRUE) {
                                memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t));
                                (*dest)++;
                        }
@@ -486,25 +500,28 @@ int _connection_libnet_init(connection_handle_s *conn_handle)
        return NET_ERR_NONE;
 }
 
-bool _connection_libnet_deinit(connection_handle_s *conn_handle)
+bool _connection_libnet_deinit(connection_handle_s *conn_handle, bool is_empty)
 {
        net_deregister_client(conn_handle->network_info_handle);
 
-       if (profile_cb_table) {
-               g_hash_table_destroy(profile_cb_table);
-               profile_cb_table = NULL;
-       }
+       if (is_empty) {
+               if (profile_cb_table) {
+                       g_hash_table_destroy(profile_cb_table);
+                       profile_cb_table = NULL;
+               }
 
-       __libnet_clear_profile_list(&profile_iterator);
+               __libnet_clear_profile_list(&profile_iterator);
 
-       if (prof_handle_list) {
-               g_slist_free_full(prof_handle_list, g_free);
-               prof_handle_list = NULL;
+               if (prof_handle_list) {
+                       g_slist_free_full(prof_handle_list, g_free);
+                       prof_handle_list = NULL;
+               }
        }
 
        return true;
 }
 
+//LCOV_EXCL_START
 void _connection_set_cs_tid(int tid, connection_handle_s *conn_handle)
 {
        net_set_cs_tid(tid, conn_handle->network_info_handle);
@@ -514,6 +531,7 @@ void _connection_unset_cs_tid(int tid, connection_handle_s *conn_handle)
 {
        net_unset_cs_tid(tid, conn_handle->network_info_handle);
 }
+//LCOV_EXCL_STOP
 
 bool _connection_libnet_check_profile_validity(connection_profile_h profile)
 {
@@ -539,11 +557,11 @@ int _connection_libnet_get_metered_state(connection_handle_s *conn_handle, bool*
 
        rv = net_get_metered_state(conn_handle->network_info_handle, &status);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get metered state[%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get metered state[%d]", rv); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        if (status == 1)
@@ -607,7 +625,7 @@ int _connection_libnet_get_ethernet_state(connection_handle_s *conn_handle,
                return CONNECTION_ERROR_NONE;
        }
 
-       switch (ethernet_profiles.profiles->ProfileState) {
+       switch (ethernet_profiles.profiles->profile_state) {
        case NET_STATE_TYPE_ONLINE:
        case NET_STATE_TYPE_READY:
                *state = CONNECTION_ETHERNET_STATE_CONNECTED;
@@ -672,7 +690,7 @@ int _connection_libnet_get_bluetooth_state(connection_handle_s *conn_handle, con
 
        //LCOV_EXCL_START
        for (; i < bluetooth_profiles.count; i++) {
-               switch (bluetooth_profiles.profiles[i].ProfileState) {
+               switch (bluetooth_profiles.profiles[i].profile_state) {
                case NET_STATE_TYPE_ONLINE:
                case NET_STATE_TYPE_READY:
                        *state = CONNECTION_BT_STATE_CONNECTED;
@@ -727,7 +745,7 @@ int _connection_libnet_get_profile_iterator(connection_handle_s *conn_handle,
 
                profiles = g_try_new0(net_profile_info_t, count);
                if (profiles == NULL) {
-                       __libnet_clear_profile_list(&profile_list);
+                       __libnet_clear_profile_list(&profile_list); //LCOV_EXCL_LINE
                        return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
                }
 
@@ -744,7 +762,7 @@ int _connection_libnet_get_profile_iterator(connection_handle_s *conn_handle,
 
                profiles = g_try_new0(net_profile_info_t, count);
                if (profiles == NULL) {
-                       __libnet_clear_profile_list(&profile_list);
+                       __libnet_clear_profile_list(&profile_list); //LCOV_EXCL_LINE
                        return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
                }
 
@@ -866,11 +884,11 @@ int _connection_libnet_open_profile(connection_handle_s *conn_handle,
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type == NET_DEVICE_MESH)
-               rv = net_open_mesh_connection_with_profile(conn_handle->network_info_handle,
-                               profile_info->ProfileName);
+               rv = net_open_mesh_connection_with_profile(conn_handle->network_info_handle, //LCOV_EXCL_LINE
+                               profile_info->profile_name);
        else
                rv = net_open_connection_with_profile(conn_handle->network_info_handle,
-                               profile_info->ProfileName);
+                               profile_info->profile_name);
 
        if (rv == NET_ERR_ACCESS_DENIED)
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
@@ -917,10 +935,10 @@ int _connection_libnet_get_cellular_service_profile(connection_handle_s *conn_ha
 #endif
 
        for (i = 0; i < cellular_profiles.count; i++)
-               if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type)
+               if (cellular_profiles.profiles[i].profile_info.pdp.service_type == service_type)
 #if defined TIZEN_DUALSIM_ENABLE
                        if (g_str_has_suffix(
-                                       cellular_profiles.profiles[i].ProfileInfo.Pdp.PSModemPath,
+                                       cellular_profiles.profiles[i].profile_info.pdp.ps_modem_path,
                                        subscriber_id) == TRUE)
 #endif
                                break;
@@ -938,7 +956,7 @@ int _connection_libnet_get_cellular_service_profile(connection_handle_s *conn_ha
 
        memcpy(*profile, &cellular_profiles.profiles[i], sizeof(net_profile_info_t));
 
-       if (cellular_profiles.profiles[i].ProfileInfo.Pdp.DefaultConn)
+       if (cellular_profiles.profiles[i].profile_info.pdp.default_conn)
                goto done;
 
        //LCOV_EXCL_START
@@ -950,10 +968,10 @@ int _connection_libnet_get_cellular_service_profile(connection_handle_s *conn_ha
                if (i == j)
                        continue;
 
-               if (cellular_profiles.profiles[j].ProfileInfo.Pdp.ServiceType != service_type)
+               if (cellular_profiles.profiles[j].profile_info.pdp.service_type != service_type)
                        continue;
 
-               if (cellular_profiles.profiles[j].ProfileInfo.Pdp.DefaultConn) {
+               if (cellular_profiles.profiles[j].profile_info.pdp.default_conn) {
                        memcpy(*profile, &cellular_profiles.profiles[j], sizeof(net_profile_info_t));
                        goto done;
                }
@@ -980,13 +998,13 @@ int _connection_libnet_set_cellular_service_profile_sync(connection_handle_s *co
        net_profile_info_t *profile_info = profile;
        connection_cellular_service_type_e service_type;
 
-       service_type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType);
+       service_type = _profile_convert_to_connection_cellular_service_type(profile_info->profile_info.pdp.service_type);
 
        if (service_type != type)
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
 
        rv = net_set_default_cellular_service_profile(conn_handle->network_info_handle,
-                               profile_info->ProfileName);
+                               profile_info->profile_name);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
@@ -1009,13 +1027,13 @@ int _connection_libnet_set_cellular_service_profile_async(connection_handle_s *c
        net_profile_info_t *profile_info = profile;
        connection_cellular_service_type_e service_type;
 
-       service_type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType);
+       service_type = _profile_convert_to_connection_cellular_service_type(profile_info->profile_info.pdp.service_type);
 
        if (service_type != type)
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
 
        rv = net_set_default_cellular_service_profile_async(conn_handle->network_info_handle,
-                               profile_info->ProfileName);
+                               profile_info->profile_name);
        if (rv == NET_ERR_ACCESS_DENIED) {
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE)
@@ -1036,9 +1054,9 @@ int _connection_libnet_close_profile(connection_handle_s *conn_handle, connectio
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type == NET_DEVICE_MESH)
-               rv = net_close_mesh_connection(conn_handle->network_info_handle, profile_info->ProfileName);
+               rv = net_close_mesh_connection(conn_handle->network_info_handle, profile_info->profile_name); //LCOV_EXCL_LINE
        else
-               rv = net_close_connection(conn_handle->network_info_handle, profile_info->ProfileName);
+               rv = net_close_connection(conn_handle->network_info_handle, profile_info->profile_name);
 
        if (rv == NET_ERR_ACCESS_DENIED)
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
@@ -1278,7 +1296,7 @@ bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
                connection_profile_state_changed_cb callback, void *user_data)
 {
        net_profile_info_t *profile_info = profile;
-       char *profile_name = g_strdup(profile_info->ProfileName);
+       char *profile_name = g_strdup(profile_info->profile_name);
 
        struct _profile_cb_s *profile_cb_info = g_try_malloc0(sizeof(struct _profile_cb_s));
        if (profile_cb_info == NULL) {
@@ -1288,7 +1306,7 @@ bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
 
        profile_cb_info->callback = callback;
        profile_cb_info->user_data = user_data;
-       profile_cb_info->state = _profile_convert_to_cp_state(profile_info->ProfileState);
+       profile_cb_info->state = _profile_convert_to_cp_state(profile_info->profile_state);
 
        g_hash_table_replace(profile_cb_table, profile_name, profile_cb_info);
 
@@ -1299,7 +1317,7 @@ bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile
 {
        net_profile_info_t *profile_info = profile;
 
-       if (g_hash_table_remove(profile_cb_table, profile_info->ProfileName) == TRUE)
+       if (g_hash_table_remove(profile_cb_table, profile_info->profile_name) == TRUE)
                return true;
 
        return false; //LCOV_EXCL_LINE
@@ -1351,13 +1369,68 @@ int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile,
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
-       g_strlcpy(profile_info->ProfileInfo.Pdp.PSModemPath, modem_path,
+       g_strlcpy(profile_info->profile_info.pdp.ps_modem_path, modem_path,
                                NET_PROFILE_NAME_LEN_MAX);
        g_free(modem_path);
 
        return CONNECTION_ERROR_NONE;
 }
 
+int _connection_libnet_enable_ethernet_eap(bool enable, const char *profilename)
+{
+       int rv = 0;
+
+       rv = net_ethernet_eap_enable(enable, profilename);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_ethernet_eap_enabled(const char *profilename, bool *enabled)
+{
+       int rv = 0;
+       gboolean eap_enabled = false;
+
+       rv = net_ethernet_eap_enabled(profilename, &eap_enabled);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       *enabled = eap_enabled;
+       return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_profile_save_ethernet_eap_config(connection_handle_s *conn_handle,
+                       connection_profile_h profile)
+{
+       int rv;
+
+       net_profile_info_t *profile_info = profile;
+
+       rv = net_save_ethernet_eap_config(conn_handle->network_info_handle,
+                       &profile_info->profile_info.ethernet.net_info);
+
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to save eap config[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       return CONNECTION_ERROR_NONE;
+}
+
 int _connection_libnet_check_get_privilege(void)
 {
        int rv;
@@ -1434,6 +1507,7 @@ int _connection_check_feature_supported(const char *feature_name, ...)
        return CONNECTION_ERROR_NONE;
 }
 
+//LCOV_EXCL_START
 int _connection_libnet_start_tcpdump(connection_handle_s *conn_handle)
 {
        connection_error_e result = CONNECTION_ERROR_NONE;
@@ -1467,13 +1541,28 @@ int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
 
        return result;
 }
+//LCOV_EXCL_STOP
 
 void _connection_lock(void)
 {
-       pthread_mutex_lock(&g_conn_thread_mutex);
+       if (g_conn_thread_mutex_ref == 0)
+               pthread_mutex_lock(&g_conn_thread_mutex);
+
+       g_conn_thread_mutex_ref++;
 }
 
 void _connection_unlock(void)
 {
-       pthread_mutex_unlock(&g_conn_thread_mutex);
+       if (g_conn_thread_mutex_ref == 1)
+               pthread_mutex_unlock(&g_conn_thread_mutex);
+
+       g_conn_thread_mutex_ref--;
+
+//LCOV_EXCL_START
+       if (g_conn_thread_mutex_ref < 0) {
+               CONNECTION_LOG(CONNECTION_ERROR,
+                               "Error scenario, thread specific mutex ref is negative !!!");
+               g_conn_thread_mutex_ref = 0;
+       }
+//LCOV_EXCL_STOP
 }