* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
*/
+#include <glib.h>
#include <stdio.h>
+#include <stdarg.h>
#include <string.h>
-#include <glib.h>
#include <vconf/vconf.h>
+#include <system_info.h>
+#include <arpa/inet.h>
+
#include "net_connection_private.h"
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;
};
struct _profile_list_s {
- int count;
int next;
+ int count;
net_profile_info_t *profiles;
};
-struct _libnet_s {
- connection_opened_cb opened_cb;
- connection_closed_cb closed_cb;
- void *opened_user_data;
- void *closed_user_data;
- bool registered;
-};
-
static struct _profile_list_s profile_iterator = {0, 0, NULL};
-static struct _libnet_s libnet = {NULL, NULL, NULL, NULL, false};
+static bool connection_is_feature_checked[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
+static bool connection_feature_supported[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
+//LCOV_EXCL_START
static connection_error_e __libnet_convert_to_cp_error_type(net_err_t err_type)
{
switch (err_type) {
return CONNECTION_ERROR_OPERATION_ABORTED;
case NET_ERR_TIME_OUT:
return CONNECTION_ERROR_NO_REPLY;
+ case NET_ERR_ACCESS_DENIED:
+ return CONNECTION_ERROR_PERMISSION_DENIED;
default:
return CONNECTION_ERROR_OPERATION_FAILED;
}
return "INVALID_KEY";
case CONNECTION_ERROR_NO_REPLY:
return "NO_REPLY";
+ case CONNECTION_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case CONNECTION_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ case CONNECTION_ERROR_ALREADY_INITIALIZED:
+ return "ALREADY_INITIALIZED";
+ case CONNECTION_ERROR_NOT_INITIALIZED:
+ return "NOT_INITIALIZED";
}
return "UNKNOWN";
}
}
-static void __libnet_set_opened_cb(connection_opened_cb user_cb, void *user_data)
-{
- if (user_cb) {
- libnet.opened_cb = user_cb;
- libnet.opened_user_data = user_data;
- }
-}
-
-static void __libnet_opened_cb(connection_error_e result)
-{
- if (libnet.opened_cb)
- libnet.opened_cb(result, libnet.opened_user_data);
-
- libnet.opened_cb = NULL;
- libnet.opened_user_data = NULL;
-}
-
-static void __libnet_set_closed_cb(connection_closed_cb user_cb, void *user_data)
-{
- if (user_cb) {
- libnet.closed_cb = user_cb;
- libnet.closed_user_data = user_data;
- }
-}
-
-static void __libnet_closed_cb(connection_error_e result)
-{
- if (libnet.closed_cb)
- libnet.closed_cb(result, libnet.closed_user_data);
-
- libnet.closed_cb = NULL;
- libnet.closed_user_data = NULL;
-}
-
static void __libnet_state_changed_cb(char *profile_name, connection_profile_state_e state)
{
+ struct _profile_cb_s *cb_info;
+
if (profile_name == NULL)
return;
- struct _profile_cb_s *cb_info;
cb_info = g_hash_table_lookup(profile_cb_table, profile_name);
-
if (cb_info == NULL)
return;
cb_info->state = state;
- if (state >= 0 && cb_info->callback)
- cb_info->callback(state, cb_info->user_data);
+ if (state < 0 || cb_info->callback == NULL)
+ return;
+
+ cb_info->callback(cb_info->state, cb_info->user_data);
}
static void __libnet_clear_profile_list(struct _profile_list_s *profile_list)
profile_list->profiles = NULL;
}
-static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data)
+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;
+
+ if (!_connection_check_handle_validity(conn_handle)) {
+ CONNECTION_LOG(CONNECTION_INFO, "Invalid handle");
+ CONN_UNLOCK;
+ return;
+ }
- switch (event_cb->Event) {
+ switch (event_cb->event) {
case NET_EVENT_OPEN_RSP:
is_requested = true;
/* fall through */
case NET_EVENT_OPEN_IND:
result = __libnet_convert_to_cp_error_type(event_cb->Error);
- CONNECTION_LOG(CONNECTION_INFO, "Got connection open %s : %s\n",
- (is_requested) ? "RSP":"IND",
+ CONNECTION_LOG(CONNECTION_INFO, "Connection opened %s[%s]",
+ (is_requested) ? "RSP" : "IND",
__libnet_convert_cp_error_type_to_string(result));
- if (is_requested)
- __libnet_opened_cb(result);
+ if (is_requested) {
+ if (conn_handle->opened_callback) {
+ conn_handle->opened_callback(result,
+ conn_handle->opened_user_data);
+
+ conn_handle->opened_callback = NULL;
+ conn_handle->opened_user_data = NULL;
+ }
+ }
switch (event_cb->Error) {
case NET_ERR_NONE:
case NET_ERR_ACTIVE_CONNECTION_EXISTS:
- CONNECTION_LOG(CONNECTION_INFO, "'Open connection' succeeded\n");
+ 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, "'Open connection' failed!! [%s]\n",
+ 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:
/* fall through */
case NET_EVENT_CLOSE_IND:
result = __libnet_convert_to_cp_error_type(event_cb->Error);
- CONNECTION_LOG(CONNECTION_INFO, "Got connection close %s : %s\n",
- (is_requested) ? "RSP":"IND",
+ CONNECTION_LOG(CONNECTION_INFO, "Connection closed %s[%s]",
+ (is_requested) ? "RSP" : "IND",
__libnet_convert_cp_error_type_to_string(result));
- if (is_requested)
- __libnet_closed_cb(result);
+ if (is_requested) {
+ if (conn_handle->closed_callback) {
+ conn_handle->closed_callback(result,
+ conn_handle->closed_user_data);
+
+ conn_handle->closed_callback = NULL;
+ conn_handle->closed_user_data = NULL;
+ }
+ }
switch (event_cb->Error) {
case NET_ERR_NONE:
- CONNECTION_LOG(CONNECTION_INFO, "'Close connection' succeeded!\n");
+ 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, "'Close connection' failed!! [%s]\n",
- __libnet_convert_cp_error_type_to_string(result));
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to close connection[%s]",
+ __libnet_convert_cp_error_type_to_string(result));
}
break;
case NET_EVENT_NET_STATE_IND:
- CONNECTION_LOG(CONNECTION_INFO, "Got State changed IND\n");
+ 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,
- "Profile State : %s, profile name : %s\n",
- __libnet_convert_cp_state_to_string(cp_state),
- event_cb->ProfileName);
+ CONNECTION_LOG(CONNECTION_INFO, "state: %s", __libnet_convert_cp_state_to_string(cp_state));
+ 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_WIFI_SCAN_IND:
- case NET_EVENT_WIFI_SCAN_RSP:
- CONNECTION_LOG(CONNECTION_INFO, "Got wifi scan IND\n");
+ case NET_EVENT_CELLULAR_SET_DEFAULT_RSP:
+ result = __libnet_convert_to_cp_error_type(event_cb->Error);
+ CONNECTION_LOG(CONNECTION_INFO, "Got set default profile RSP %d", result);
+ if (conn_handle->set_default_callback) {
+ conn_handle->set_default_callback(result,
+ conn_handle->set_default_user_data);
+
+ conn_handle->set_default_callback = NULL;
+ conn_handle->set_default_user_data = NULL;
+ }
break;
- case NET_EVENT_WIFI_POWER_IND:
- case NET_EVENT_WIFI_POWER_RSP:
- CONNECTION_LOG(CONNECTION_INFO, "Got wifi power IND\n");
+ case NET_EVENT_CELLULAR_RESET_DEFAULT_RSP:
+ result = __libnet_convert_to_cp_error_type(event_cb->Error);
+ CONNECTION_LOG(CONNECTION_INFO, "Got reset default profile RSP %d", result);
+ if (conn_handle->reset_callback) {
+ conn_handle->reset_callback(result,
+ conn_handle->reset_user_data);
+
+ conn_handle->reset_callback = NULL;
+ conn_handle->reset_user_data = NULL;
+ }
break;
- case NET_EVENT_WIFI_WPS_RSP:
- CONNECTION_LOG(CONNECTION_INFO, "Got wifi WPS RSP\n");
- /* fall through */
- default :
- CONNECTION_LOG(CONNECTION_ERROR, "Error! Unknown Event\n\n");
+ case NET_EVENT_ETHERNET_CABLE_ATTACHED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable Attached Indication\n");
+ if (conn_handle->ethernet_cable_state_changed_callback) {
+ conn_handle->ethernet_cable_state_changed_callback(CONNECTION_ETHERNET_CABLE_ATTACHED,
+ conn_handle->ethernet_cable_state_changed_user_data);
+ }
+ break;
+ case NET_EVENT_ETHERNET_CABLE_DETACHED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable detached Indication\n");
+ if (conn_handle->ethernet_cable_state_changed_callback) {
+ conn_handle->ethernet_cable_state_changed_callback(CONNECTION_ETHERNET_CABLE_DETACHED,
+ conn_handle->ethernet_cable_state_changed_user_data);
+ }
+ break;
+ case NET_EVENT_NETWORK_TYPE_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Network Type Changed Indication");
+ int *state = (int *) event_cb->data;
+ if (conn_handle->type_changed_callback) {
+ int type = CONNECTION_TYPE_DISCONNECTED;
+
+ switch (*state) {
+ case VCONFKEY_NETWORK_CELLULAR:
+ type = CONNECTION_TYPE_CELLULAR;
+ break;
+ case VCONFKEY_NETWORK_WIFI:
+ type = CONNECTION_TYPE_WIFI;
+ break;
+ case VCONFKEY_NETWORK_ETHERNET:
+ type = CONNECTION_TYPE_ETHERNET;
+ break;
+ case VCONFKEY_NETWORK_BLUETOOTH:
+ type = CONNECTION_TYPE_BT;
+ break;
+ case VCONFKEY_NETWORK_DEFAULT_PROXY:
+ type = CONNECTION_TYPE_NET_PROXY;
+ break;
+ default:
+ type = CONNECTION_TYPE_DISCONNECTED;
+ break;
+ }
+
+ conn_handle->type_changed_callback(type,
+ conn_handle->type_changed_user_data);
+ }
+ break;
+ case NET_EVENT_IPV4_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got IPv4 Address Changed Indication");
+ if (conn_handle->ip_changed_callback) {
+ char *ipv4_addr = NULL;
+ char *ipv6_addr = NULL;
+ char *addr = (char *)event_cb->data;
+
+ ipv4_addr = g_strdup(addr);
+ ipv6_addr = vconf_get_str(VCONFKEY_NETWORK_IP6);
+ if (ipv6_addr == NULL)
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+ "vconf_get_str(VCONFKEY_NETWORK_IP6) failed");
+
+ conn_handle->ip_changed_callback(ipv4_addr, ipv6_addr,
+ conn_handle->ip_changed_user_data);
+
+ g_free(ipv4_addr);
+ g_free(ipv6_addr);
+ }
+ break;
+ case NET_EVENT_IPV6_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got IPv6 Address Changed Indication");
+ if (conn_handle->ip_changed_callback) {
+ char *ipv4_addr = NULL;
+ char *ipv6_addr = NULL;
+ char *addr = (char *)event_cb->data;
+
+ ipv6_addr = g_strdup(addr);
+ ipv4_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
+ if (ipv4_addr == NULL)
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+ "vconf_get_str(VCONFKEY_NETWORK_IP) failed");
+
+ conn_handle->ip_changed_callback(ipv4_addr, ipv6_addr,
+ conn_handle->ip_changed_user_data);
+
+ g_free(ipv4_addr);
+ g_free(ipv6_addr);
+ }
+ break;
+ case NET_EVENT_PROXY_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Proxy Changed Indication");
+ char *proxy_addr = (char *)event_cb->data;
+
+ if (conn_handle->proxy_changed_callback) {
+ conn_handle->proxy_changed_callback(proxy_addr, NULL,
+ conn_handle->proxy_changed_user_data);
+ }
+ break;
+ 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;
+
+ if (conn_handle->internet_state_changed_callback) {
+ net_profile_info_t active_profile;
+ int rv;
+
+ 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) {
+ conn_handle->internet_state_changed_callback(CONNECTION_INTERNET_STATE_OFFLINE,
+ conn_handle->internet_state_changed_user_data); //LCOV_EXCL_LINE
+ break;
+ } else if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ break;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Unable to get Default profile handle"); //LCOV_EXCL_LINE
+ break; //LCOV_EXCL_LINE
+ }
+
+ 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.profile_state != NET_STATE_TYPE_ONLINE)
+ conn_handle->internet_state_changed_callback(CONNECTION_INTERNET_STATE_OFFLINE,
+ conn_handle->internet_state_changed_user_data);
+ }
+ }
+ break;
+
+ default:
break;
}
+
+ CONN_UNLOCK;
}
+//LCOV_EXCL_STOP
-int __libnet_get_connected_count(struct _profile_list_s *profile_list)
+static int __libnet_get_connected_count(struct _profile_list_s *profile_list)
{
int count = 0;
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)
+ for (; i < profile_list->count; i++) {
+ if (profile_list->profiles[i].profile_state == NET_STATE_TYPE_ONLINE ||
+ profile_list->profiles[i].profile_state == NET_STATE_TYPE_READY)
count++;
}
return count;
}
-void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_list_s *source)
+static void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_list_s *source)
{
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) {
+ for (; i < source->count; i++) {
+ 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)++;
}
}
}
-bool _connection_libnet_init(void)
+//LCOV_EXCL_START
+static int __libnet_get_default_count(struct _profile_list_s *profile_list)
{
- int rv;
+ int count = 0;
+ int i = 0;
- if (!libnet.registered) {
- rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_DEFAULT, NULL);
- if (rv != NET_ERR_NONE)
- return false;
+ for (; i < profile_list->count; i++) {
+ if (profile_list->profiles[i].profile_type == NET_DEVICE_CELLULAR) {
+ if (profile_list->profiles[i].profile_info.pdp.default_conn == TRUE)
+ count++;
+ }
+ }
- libnet.registered = true;
+ return count;
+}
- if (profile_cb_table == NULL)
- profile_cb_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- }
+static void __libnet_copy_default_profile(net_profile_info_t **dest, struct _profile_list_s *source)
+{
+ int i = 0;
- return true;
+ for (; i < source->count; i++) {
+ if (source->profiles[i].profile_type == NET_DEVICE_CELLULAR) {
+ if (source->profiles[i].profile_info.pdp.default_conn == TRUE) {
+ memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t));
+ (*dest)++;
+ }
+ }
+ }
}
+//LCOV_EXCL_STOP
-bool _connection_libnet_deinit(void)
+int _connection_libnet_init(connection_handle_s *conn_handle)
{
- if (libnet.registered) {
- if (net_deregister_client_ext(NET_DEVICE_DEFAULT) != NET_ERR_NONE)
- return false;
+ int rv;
- libnet.registered = false;
+ rv = net_register_client(&(conn_handle->network_info_handle),
+ (net_event_cb_t)__libnet_evt_cb, conn_handle);
+ if (rv != NET_ERR_NONE)
+ return rv;
+
+ if (profile_cb_table == NULL)
+ profile_cb_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+
+ return NET_ERR_NONE;
+}
+
+bool _connection_libnet_deinit(connection_handle_s *conn_handle, bool is_empty)
+{
+ net_deregister_client(conn_handle->network_info_handle);
+ if (is_empty) {
if (profile_cb_table) {
g_hash_table_destroy(profile_cb_table);
profile_cb_table = 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);
+}
+
+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)
{
GSList *list;
int i = 0;
+ if (profile == NULL)
+ return false;
+
for (list = prof_handle_list; list; list = list->next)
if (profile == list->data) return true;
- for (;i < profile_iterator.count;i++)
+ for (; i < profile_iterator.count; i++)
if (profile == &profile_iterator.profiles[i]) return true;
return false;
}
-bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile)
+int _connection_libnet_get_metered_state(connection_handle_s *conn_handle, bool* is_metered)
{
- struct _profile_cb_s *cb_info;
- net_profile_info_t *profile_info = profile;
-
- if (profile == NULL)
- return false;
-
- cb_info = g_hash_table_lookup(profile_cb_table, profile_info->ProfileName);
- if (cb_info != NULL)
- return true;
+ int rv = 0;
+ int status = 0;
+
+ rv = net_get_metered_state(conn_handle->network_info_handle, &status);
+ if (rv == NET_ERR_ACCESS_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); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
- return false;
+ if (status == 1)
+ *is_metered = true;
+ else
+ *is_metered = false;
+ return CONNECTION_ERROR_NONE;
}
-
-bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state)
+int _connection_libnet_get_wifi_state(connection_handle_s *conn_handle, connection_wifi_state_e *state)
{
+ int rv;
net_wifi_state_t wlan_state;
- net_profile_name_t profile_name;
- if (net_get_wifi_state(&wlan_state, &profile_name) != NET_ERR_NONE) {
- CONNECTION_LOG(CONNECTION_ERROR, "Error!! net_get_wifi_state() failed.\n");
- return false;
+ rv = net_get_wifi_state(conn_handle->network_info_handle, &wlan_state);
+ if (rv == NET_ERR_ACCESS_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 Wi-Fi state[%d]", rv); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
switch (wlan_state) {
*state = CONNECTION_WIFI_STATE_DEACTIVATED;
break;
case WIFI_ON:
- case WIFI_CONNECTING:
+ case WIFI_ASSOCIATION:
+ case WIFI_CONFIGURATION:
*state = CONNECTION_WIFI_STATE_DISCONNECTED;
break;
case WIFI_CONNECTED:
case WIFI_DISCONNECTING:
*state = CONNECTION_WIFI_STATE_CONNECTED;
break;
- default :
- CONNECTION_LOG(CONNECTION_ERROR, "Error!! Unknown state\n");
- return false;
+ default:
+ CONNECTION_LOG(CONNECTION_ERROR, "Unknown Wi-Fi state"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- return true;
+ return CONNECTION_ERROR_NONE;
}
-bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state)
+//LCOV_EXCL_START
+int _connection_libnet_get_ethernet_state(connection_handle_s *conn_handle,
+ connection_ethernet_state_e *state)
{
+ int rv;
struct _profile_list_s ethernet_profiles = {0, 0, NULL};
- net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count);
+ rv = net_get_profile_list(conn_handle->network_info_handle,
+ NET_DEVICE_ETHERNET, ðernet_profiles.profiles,
+ ðernet_profiles.count);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ }
if (ethernet_profiles.count == 0) {
*state = CONNECTION_ETHERNET_STATE_DEACTIVATED;
- return true;
+ 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;
*state = CONNECTION_ETHERNET_STATE_DISCONNECTED;
break;
default:
- return false;
+ __libnet_clear_profile_list(ðernet_profiles);
+ return CONNECTION_ERROR_OPERATION_FAILED;
}
__libnet_clear_profile_list(ðernet_profiles);
- return true;
+ return CONNECTION_ERROR_NONE;
}
-bool _connection_libnet_get_bluetooth_state(connection_bt_state_e* state)
+int _connection_libnet_get_ethernet_cable_state(connection_handle_s *conn_handle,
+ connection_ethernet_cable_state_e* state)
+{
+ int rv = 0;
+ int status = 0;
+
+ rv = net_get_ethernet_cable_state(conn_handle->network_info_handle, &status);
+ 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 get ethernet cable state[%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ if (status == 1)
+ *state = CONNECTION_ETHERNET_CABLE_ATTACHED;
+ else
+ *state = CONNECTION_ETHERNET_CABLE_DETACHED;
+ return CONNECTION_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
+
+int _connection_libnet_get_bluetooth_state(connection_handle_s *conn_handle, connection_bt_state_e *state)
{
int i = 0;
+ int rv = 0;
struct _profile_list_s bluetooth_profiles = {0, 0, NULL};
- net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count);
+ rv = net_get_profile_list(conn_handle->network_info_handle,
+ NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles,
+ &bluetooth_profiles.count);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
if (bluetooth_profiles.count == 0) {
*state = CONNECTION_BT_STATE_DEACTIVATED;
- return true;
+ return CONNECTION_ERROR_NONE;
}
+ //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;
break;
default:
__libnet_clear_profile_list(&bluetooth_profiles);
- return false;
+ return CONNECTION_ERROR_OPERATION_FAILED;
}
}
+ //LCOV_EXCL_STOP
done:
__libnet_clear_profile_list(&bluetooth_profiles);
- return true;
+ return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, connection_profile_iterator_h* profile_iter_h)
+int _connection_libnet_get_profile_iterator(connection_handle_s *conn_handle,
+ connection_iterator_type_e type, connection_profile_iterator_h* profile_iter_h)
{
int count = 0;
- int rv1, rv2, rv3, rv4;
+ int rv;
net_profile_info_t *profiles = NULL;
- struct _profile_list_s wifi_profiles = {0, 0, NULL};
- struct _profile_list_s cellular_profiles = {0, 0, NULL};
- struct _profile_list_s ethernet_profiles = {0, 0, NULL};
- struct _profile_list_s bluetooth_profiles = {0, 0, NULL};
+ struct _profile_list_s profile_list = {0, 0, NULL};
__libnet_clear_profile_list(&profile_iterator);
- rv1 = net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count);
- if (rv1 != NET_ERR_NO_SERVICE && rv1 != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
-
- CONNECTION_LOG(CONNECTION_INFO, "Wifi profile count : %d\n", wifi_profiles.count);
-
- rv2 = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count);
- if (rv2 != NET_ERR_NO_SERVICE && rv2 != NET_ERR_NONE) {
- __libnet_clear_profile_list(&wifi_profiles);
- return CONNECTION_ERROR_OPERATION_FAILED;
- }
- CONNECTION_LOG(CONNECTION_INFO, "Cellular profile count : %d\n", cellular_profiles.count);
-
- rv3 = net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count);
- if (rv3 != NET_ERR_NO_SERVICE && rv3 != NET_ERR_NONE) {
- __libnet_clear_profile_list(&wifi_profiles);
- __libnet_clear_profile_list(&cellular_profiles);
- return CONNECTION_ERROR_OPERATION_FAILED;
- }
- CONNECTION_LOG(CONNECTION_INFO, "Ethernet profile count : %d\n", ethernet_profiles.count);
-
- rv4 = net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count);
- if (rv4 != NET_ERR_NO_SERVICE && rv4 != NET_ERR_NONE) {
- __libnet_clear_profile_list(&wifi_profiles);
- __libnet_clear_profile_list(&cellular_profiles);
- __libnet_clear_profile_list(ðernet_profiles);
- return CONNECTION_ERROR_OPERATION_FAILED;
- }
- CONNECTION_LOG(CONNECTION_INFO, "Bluetooth profile count : %d\n", bluetooth_profiles.count);
+ rv = net_get_all_profile_list(conn_handle->network_info_handle,
+ &profile_list.profiles, &profile_list.count);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NO_SERVICE && rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
*profile_iter_h = &profile_iterator;
switch (type) {
case CONNECTION_ITERATOR_TYPE_REGISTERED:
- count = wifi_profiles.count + cellular_profiles.count + ethernet_profiles.count + bluetooth_profiles.count;
- CONNECTION_LOG(CONNECTION_INFO, "Total profile count : %d\n", count);
+ count = profile_list.count;
+ CONNECTION_LOG(CONNECTION_INFO, "Total profile count : %d", count);
if (count == 0)
return CONNECTION_ERROR_NONE;
profiles = g_try_new0(net_profile_info_t, count);
if (profiles == NULL) {
- __libnet_clear_profile_list(&wifi_profiles);
- __libnet_clear_profile_list(&cellular_profiles);
- __libnet_clear_profile_list(ðernet_profiles);
- __libnet_clear_profile_list(&bluetooth_profiles);
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ __libnet_clear_profile_list(&profile_list); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
profile_iterator.profiles = profiles;
- if (wifi_profiles.count > 0) {
- memcpy(profiles, wifi_profiles.profiles,
- sizeof(net_profile_info_t) * wifi_profiles.count);
- profiles += wifi_profiles.count;
- }
-
- if (cellular_profiles.count > 0) {
- memcpy(profiles, cellular_profiles.profiles,
- sizeof(net_profile_info_t) * cellular_profiles.count);
- profiles += cellular_profiles.count;
- }
-
- if (ethernet_profiles.count > 0) {
- memcpy(profiles, ethernet_profiles.profiles,
- sizeof(net_profile_info_t) * ethernet_profiles.count);
- profiles += ethernet_profiles.count;
- }
-
- if (bluetooth_profiles.count > 0)
- memcpy(profiles, bluetooth_profiles.profiles,
- sizeof(net_profile_info_t) * bluetooth_profiles.count);
+ memcpy(profiles, profile_list.profiles, sizeof(net_profile_info_t) * count);
break;
case CONNECTION_ITERATOR_TYPE_CONNECTED:
- count = __libnet_get_connected_count(&wifi_profiles);
- count += __libnet_get_connected_count(&cellular_profiles);
- count += __libnet_get_connected_count(ðernet_profiles);
- count += __libnet_get_connected_count(&bluetooth_profiles);
- CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d\n", count);
+ count = __libnet_get_connected_count(&profile_list);
+ CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d", count);
if (count == 0)
return CONNECTION_ERROR_NONE;
profiles = g_try_new0(net_profile_info_t, count);
if (profiles == NULL) {
- __libnet_clear_profile_list(&wifi_profiles);
- __libnet_clear_profile_list(&cellular_profiles);
- __libnet_clear_profile_list(ðernet_profiles);
- __libnet_clear_profile_list(&bluetooth_profiles);
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ __libnet_clear_profile_list(&profile_list); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
profile_iterator.profiles = profiles;
- if (wifi_profiles.count > 0)
- __libnet_copy_connected_profile(&profiles, &wifi_profiles);
+ __libnet_copy_connected_profile(&profiles, &profile_list);
+
+ break;
+ case CONNECTION_ITERATOR_TYPE_DEFAULT:
+ count = __libnet_get_default_count(&profile_list);
+ CONNECTION_LOG(CONNECTION_INFO, "Total default profile count : %d", count); //LCOV_EXCL_LINE
+ if (count == 0)
+ return CONNECTION_ERROR_NONE;
- if (cellular_profiles.count > 0)
- __libnet_copy_connected_profile(&profiles, &cellular_profiles);
+ profiles = g_try_new0(net_profile_info_t, count);
+ if (profiles == NULL) {
+ __libnet_clear_profile_list(&profile_list);
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
- if (ethernet_profiles.count > 0)
- __libnet_copy_connected_profile(&profiles, ðernet_profiles);
+ profile_iterator.profiles = profiles;
- if (bluetooth_profiles.count > 0)
- __libnet_copy_connected_profile(&profiles, &bluetooth_profiles);
+ __libnet_copy_default_profile(&profiles, &profile_list);
break;
}
- __libnet_clear_profile_list(&wifi_profiles);
- __libnet_clear_profile_list(&cellular_profiles);
- __libnet_clear_profile_list(ðernet_profiles);
- __libnet_clear_profile_list(&bluetooth_profiles);
+ __libnet_clear_profile_list(&profile_list);
profile_iterator.count = count;
int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h)
{
if (profile_iter_h != &profile_iterator)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
__libnet_clear_profile_list(&profile_iterator);
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_get_current_profile(connection_profile_h *profile)
+int _connection_libnet_get_current_profile(connection_handle_s *conn_handle,
+ connection_profile_h *profile)
{
net_profile_info_t active_profile;
int rv;
- rv = net_get_active_net_info(&active_profile);
+ rv = net_get_active_net_info(conn_handle->network_info_handle, &active_profile);
if (rv == NET_ERR_NO_SERVICE)
- return CONNECTION_ERROR_NO_CONNECTION;
- else if (rv != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ return CONNECTION_ERROR_NO_CONNECTION; //LCOV_EXCL_LINE
+ else if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
*profile = g_try_malloc0(sizeof(net_profile_info_t));
if (*profile == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
memcpy(*profile, &active_profile, sizeof(net_profile_info_t));
prof_handle_list = g_slist_append(prof_handle_list, *profile);
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void* user_data)
+int _connection_libnet_reset_profile(connection_handle_s *conn_handle,
+ connection_reset_option_e type, connection_cellular_subscriber_id_e id)
+{
+ int rv;
+
+ rv = net_reset_profile(conn_handle->network_info_handle, type, id);
+ if (rv == NET_ERR_ACCESS_DENIED)
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_open_profile(connection_handle_s *conn_handle,
+ connection_profile_h profile)
{
+ int rv;
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
net_profile_info_t *profile_info = profile;
- if (net_open_connection_with_profile(profile_info->ProfileName) != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (profile_info->profile_type == NET_DEVICE_MESH)
+ 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->profile_name);
- __libnet_set_opened_cb(callback, user_data);
+ if (rv == NET_ERR_ACCESS_DENIED)
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile)
+int _connection_libnet_get_cellular_service_profile(connection_handle_s *conn_handle,
+ connection_cellular_service_type_e type, connection_profile_h *profile)
{
- int i = 0;
- int j = 0;
+ int i = 0, j = 0;
int rv = NET_ERR_NONE;
- net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type);
+#if defined TIZEN_DUALSIM_ENABLE
+ int default_subscriber_id = 0;
+ char subscriber_id[3];
+#endif
- struct _profile_list_s cellular_profiles = {0, 0, NULL};
+ struct _profile_list_s cellular_profiles = { 0, 0, NULL };
+ net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type);
- rv = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count);
- if (rv != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ rv = net_get_profile_list(conn_handle->network_info_handle,
+ NET_DEVICE_CELLULAR, &cellular_profiles.profiles,
+ &cellular_profiles.count);
+ if (rv == NET_ERR_ACCESS_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 profile list (%d)", rv); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
- for (;i < cellular_profiles.count;i++)
- if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type)
- break;
+#if defined TIZEN_DUALSIM_ENABLE
+ if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE,
+ &default_subscriber_id) != 0) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Failed to get VCONF_TELEPHONY_DEFAULT_DATA_SERVICE");
+ __libnet_clear_profile_list(&cellular_profiles); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
- if (i >= cellular_profiles.count)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ g_snprintf(subscriber_id, sizeof(subscriber_id), "%d", default_subscriber_id);
+#endif
+
+ for (i = 0; i < cellular_profiles.count; i++)
+ 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].profile_info.pdp.ps_modem_path,
+ subscriber_id) == TRUE)
+#endif
+ break;
+
+ if (i >= cellular_profiles.count) {
+ __libnet_clear_profile_list(&cellular_profiles); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
*profile = g_try_malloc0(sizeof(net_profile_info_t));
- if (*profile == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*profile == NULL) {
+ __libnet_clear_profile_list(&cellular_profiles); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
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
if (type != CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET &&
type != CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET)
goto done;
- for (;j < cellular_profiles.count;j++) {
+ for (j = 0; j < cellular_profiles.count; j++) {
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;
}
}
+ //LCOV_EXCL_STOP
done:
+ __libnet_clear_profile_list(&cellular_profiles);
prof_handle_list = g_slist_append(prof_handle_list, *profile);
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_set_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h profile)
+int _connection_libnet_set_cellular_service_profile_sync(connection_handle_s *conn_handle,
+ connection_cellular_service_type_e type, connection_profile_h profile)
{
+ int rv;
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
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;
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
- if (net_set_default_cellular_service_profile(profile_info->ProfileName) != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ rv = net_set_default_cellular_service_profile(conn_handle->network_info_handle,
+ 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
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data)
+int _connection_libnet_set_cellular_service_profile_async(connection_handle_s *conn_handle,
+ connection_cellular_service_type_e type, connection_profile_h profile)
{
+ int rv;
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
net_profile_info_t *profile_info = profile;
+ connection_cellular_service_type_e service_type;
- if (net_close_connection(profile_info->ProfileName) != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ 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
- __libnet_set_closed_cb(callback, user_data);
+ rv = net_set_default_cellular_service_profile_async(conn_handle->network_info_handle,
+ profile_info->profile_name);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_add_route(const char *interface_name, const char *host_address)
+int _connection_libnet_close_profile(connection_handle_s *conn_handle, connection_profile_h profile)
{
+ int rv;
+
+ if (!(_connection_libnet_check_profile_validity(profile))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ 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->profile_name); //LCOV_EXCL_LINE
+ else
+ 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
+ else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_add_route(connection_handle_s *conn_handle,
+ const char *interface_name, const char *host_address)
+{
+ int rv;
+ char *endstr = NULL;
+ int address_family = 0;
+
+ address_family = AF_INET;
+
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_add_route(conn_handle->network_info_handle,
+ host_address, interface_name, address_family);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_remove_route(connection_handle_s *conn_handle,
+ const char *interface_name, const char *host_address)
+{
+ int rv;
char *endstr = strrchr(host_address, '.');
+ int address_family = 0;
+ address_family = AF_INET;
+
+ endstr = strrchr(host_address, '.');
if (endstr == NULL ||
- strcmp(endstr, ".0") == 0 ||
- strncmp(host_address, "0.", 2) == 0 ||
- strstr(host_address, ".0.") != NULL ||
- strstr(host_address, "255") != NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, ".0.") != NULL || strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- if (net_add_route(host_address, interface_name) != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ rv = net_remove_route(conn_handle->network_info_handle,
+ host_address, interface_name, address_family);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_add_route_ipv6(connection_handle_s *conn_handle,
+ const char *interface_name, const char *host_address, const char *gateway)
+{
+ int rv;
+ int address_family = 0;
+
+ address_family = AF_INET6;
+
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_add_route_ipv6(conn_handle->network_info_handle,
+ host_address, interface_name, address_family, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_remove_route_ipv6(connection_handle_s *conn_handle,
+ const char *interface_name, const char *host_address, const char *gateway)
+{
+ int rv;
+ int address_family = 0;
+
+ address_family = AF_INET6;
+
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_remove_route_ipv6(conn_handle->network_info_handle,
+ host_address, interface_name, address_family, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_add_route_entry(connection_handle_s *conn_handle,
+ connection_address_family_e address_family, const char *interface_name,
+ const char *host_address, const char *gateway)
+{
+ int rv;
+ char *endstr = NULL;
+ int address_family_type = 0;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ address_family_type = AF_INET;
+ else
+ address_family_type = AF_INET6;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_add_route_entry(conn_handle->network_info_handle,
+ host_address, interface_name, address_family_type, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ } else {
+
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_add_route_ipv6(conn_handle->network_info_handle,
+ host_address, interface_name, address_family_type, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_remove_route_entry(connection_handle_s *conn_handle,
+ connection_address_family_e address_family, const char *interface_name,
+ const char *host_address, const char *gateway)
+{
+ int rv;
+ char *endstr = strrchr(host_address, '.');
+ int address_family_type = 0;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ address_family_type = AF_INET;
+ else
+ address_family_type = AF_INET6;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, ".0.") != NULL || strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_remove_route_entry(conn_handle->network_info_handle, host_address,
+ interface_name, address_family_type, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ } else {
+
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_remove_route_ipv6(conn_handle->network_info_handle, host_address,
+ interface_name, address_family_type, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
return CONNECTION_ERROR_NONE;
}
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) {
- g_free(profile_name);
- return false;
+ g_free(profile_name); //LCOV_EXCL_LINE
+ return false; //LCOV_EXCL_LINE
}
profile_cb_info->callback = callback;
profile_cb_info->user_data = user_data;
+ profile_cb_info->state = _profile_convert_to_cp_state(profile_info->profile_state);
- g_hash_table_insert(profile_cb_table, profile_name, profile_cb_info);
+ g_hash_table_replace(profile_cb_table, profile_name, profile_cb_info);
return true;
}
-void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile)
+bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile)
{
net_profile_info_t *profile_info = profile;
- g_hash_table_remove(profile_cb_table, profile_info->ProfileName);
+
+ if (g_hash_table_remove(profile_cb_table, profile_info->profile_name) == TRUE)
+ return true;
+
+ return false; //LCOV_EXCL_LINE
+}
+
+int _connection_libnet_set_statistics(connection_handle_s *conn_handle,
+ net_device_t device_type, net_statistics_type_e statistics_type)
+{
+ int rv;
+ rv = net_set_statistics(conn_handle->network_info_handle,
+ device_type, statistics_type);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_get_statistics(connection_handle_s *conn_handle,
+ net_statistics_type_e statistics_type, unsigned long long *size)
+{
+ int rv;
+ rv = net_get_statistics(conn_handle->network_info_handle,
+ NET_DEVICE_WIFI, statistics_type, size);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile,
+ connection_cellular_subscriber_id_e sim_id)
+{
+ char *modem_path = NULL;
+ net_profile_info_t *profile_info = (net_profile_info_t *)profile;
+
+ if (net_get_cellular_modem_object_path(&modem_path, sim_id) != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get subscriber[%d]", sim_id); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ if (!modem_path) {
+ CONNECTION_LOG(CONNECTION_ERROR, "NULL modem object path"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ 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_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type)
+int _connection_libnet_enable_ethernet_eap(bool enable, const char *profilename)
{
- if (net_set_statistics(device_type, statistics_type) != NET_ERR_NONE)
+ 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_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size)
+int _connection_libnet_ethernet_eap_enabled(const char *profilename, bool *enabled)
{
- if (net_get_statistics(NET_DEVICE_WIFI, statistics_type, size) != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ 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;
+ }
- return CONNECTION_ERROR_NONE;
+ *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;
+
+ rv = net_check_get_privilege();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_check_profile_privilege(void)
+{
+ int rv;
+
+ rv = net_check_profile_privilege();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return CONNECTION_ERROR_NONE;
+}
+
+bool __libnet_check_feature_supported(const char *key, connection_supported_feature_e feature)
+{
+ if (!connection_is_feature_checked[feature]) {
+ if (system_info_get_platform_bool(key, &connection_feature_supported[feature]) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature getting from System Info"); //LCOV_EXCL_LINE
+ set_last_result(CONNECTION_ERROR_OPERATION_FAILED); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+ connection_is_feature_checked[feature] = true;
+ }
+ return connection_feature_supported[feature];
+}
+
+int _connection_check_feature_supported(const char *feature_name, ...)
+{
+ va_list list;
+ const char *key;
+ bool value = false;
+ bool feature_supported = false;
+
+ va_start(list, feature_name);
+ key = feature_name;
+ while (1) {
+ if (strcmp(key, TELEPHONY_FEATURE) == 0)
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TELEPHONY);
+ if (strcmp(key, WIFI_FEATURE) == 0)
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_WIFI);
+ if (strcmp(key, TETHERING_BLUETOOTH_FEATURE) == 0)
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH);
+ if (strcmp(key, ETHERNET_FEATURE) == 0)
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_ETHERNET);
+
+ feature_supported |= value;
+ key = va_arg(list, const char *);
+ if (!key) break;
+ }
+ if (!feature_supported) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature is not supported");
+ set_last_result(CONNECTION_ERROR_NOT_SUPPORTED);
+ va_end(list);
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ va_end(list);
+ set_last_result(CONNECTION_ERROR_NONE);
+ return CONNECTION_ERROR_NONE;
}
+//LCOV_EXCL_START
+int _connection_libnet_start_tcpdump(connection_handle_s *conn_handle)
+{
+ connection_error_e result = CONNECTION_ERROR_NONE;
+ net_err_t ret = NET_ERR_NONE;
+
+ ret = net_start_tcpdump(conn_handle->network_info_handle);
+ result = __libnet_convert_to_cp_error_type(ret);
+
+ return result;
+}
+
+int _connection_libnet_stop_tcpdump(connection_handle_s *conn_handle)
+{
+ connection_error_e result = CONNECTION_ERROR_NONE;
+ net_err_t ret = NET_ERR_NONE;
+
+ ret = net_stop_tcpdump(conn_handle->network_info_handle);
+ result = __libnet_convert_to_cp_error_type(ret);
+
+ return result;
+}
+
+int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
+ gboolean *tcpdump_state)
+{
+ connection_error_e result = CONNECTION_ERROR_NONE;
+ net_err_t ret = NET_ERR_NONE;
+
+ ret = net_get_tcpdump_state(conn_handle->network_info_handle, tcpdump_state);
+ result = __libnet_convert_to_cp_error_type(ret);
+
+ return result;
+}
+//LCOV_EXCL_STOP
+
+void _connection_lock(void)
+{
+ if (g_conn_thread_mutex_ref == 0)
+ pthread_mutex_lock(&g_conn_thread_mutex);
+
+ g_conn_thread_mutex_ref++;
+}
+
+void _connection_unlock(void)
+{
+ 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
+}