return __connection_check_handle_validity(connection);
}
+void *_connection_get_default_handle(void)
+{
+ GSList *list = NULL;
+
+ for (list = conn_handle_list; list; list = list->next)
+ if (list->data)
+ return list->data;
+
+ return NULL;
+}
+
+void _connection_handle_ref(connection_handle_s *handle)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "%p ref %d",
+ handle, handle->refcount + 1);
+
+ __sync_fetch_and_add(&handle->refcount, 1);
+}
+
+void _connection_handle_unref(connection_handle_s *handle)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "%p ref %d",
+ handle, handle->refcount - 1);
+
+ if (__sync_fetch_and_sub(&handle->refcount, 1) != 1)
+ return;
+
+ conn_handle_list = g_slist_remove(conn_handle_list, handle);
+ _connection_libnet_deinit(handle, (conn_handle_list == NULL));
+
+ g_free(handle);
+}
+
+static void __connection_dummy_type_changed_cb(connection_type_e type, void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
+}
+
static void __connection_set_type_changed_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
conn_handle->type_changed_user_data = user_data;
- conn_handle->type_changed_callback = callback;
+ if (callback != NULL)
+ conn_handle->type_changed_callback = callback;
+ else
+ conn_handle->type_changed_callback = __connection_dummy_type_changed_cb;
+}
+
+static void __connection_dummy_address_changed_cb(const char* ipv4_address,
+ const char* ipv6_address, void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
}
static void __connection_set_ip_changed_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
conn_handle->ip_changed_user_data = user_data;
- conn_handle->ip_changed_callback = callback;
+ if (callback != NULL)
+ conn_handle->ip_changed_callback = callback;
+ else
+ conn_handle->ip_changed_callback = __connection_dummy_address_changed_cb;
}
static void __connection_set_proxy_changed_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
conn_handle->proxy_changed_user_data = user_data;
- conn_handle->proxy_changed_callback = callback;
+ if (callback != NULL)
+ conn_handle->proxy_changed_callback = callback;
+ else
+ conn_handle->proxy_changed_callback = __connection_dummy_address_changed_cb;
+}
+
+static void __connection_dummy_dhcp_state_changed_cb(connection_dhcp_state_e state,
+ const char *interface_name, connection_error_e result, void *user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
+}
+
+static void __connection_set_dhcp_state_changed_callback(connection_handle_s *conn_handle,
+ void *callback, void *user_data)
+{
+ conn_handle->dhcp_state_changed_user_data = user_data;
+ if (callback != NULL)
+ conn_handle->dhcp_state_changed_callback = callback;
+ else
+ conn_handle->dhcp_state_changed_callback = __connection_dummy_dhcp_state_changed_cb;
+}
+
+static void __connection_dummy_internet_state_changed_cb(connection_internet_state_e state,
+ void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
}
static void __connection_set_internet_state_changed_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
conn_handle->internet_state_changed_user_data = user_data;
- conn_handle->internet_state_changed_callback = callback;
+ if (callback != NULL)
+ conn_handle->internet_state_changed_callback = callback;
+ else
+ conn_handle->internet_state_changed_callback = __connection_dummy_internet_state_changed_cb;
+}
+
+static void __connection_dummy_ethernet_cable_state_changed_cb(connection_ethernet_cable_state_e state,
+ void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
}
static void __connection_set_ethernet_cable_state_changed_cb(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
- conn_handle->ethernet_cable_state_changed_callback = callback;
conn_handle->ethernet_cable_state_changed_user_data = user_data;
+ if (callback != NULL)
+ conn_handle->ethernet_cable_state_changed_callback = callback;
+ else
+ conn_handle->ethernet_cable_state_changed_callback = __connection_dummy_ethernet_cable_state_changed_cb;
+}
+
+static void __connection_dummy_set_default_cb(connection_error_e result, void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
}
static void __connection_set_default_cellular_service_profile_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
- conn_handle->set_default_callback = callback;
conn_handle->set_default_user_data = user_data;
+ if (callback != NULL)
+ conn_handle->set_default_callback = callback;
+ else
+ conn_handle->set_default_callback = __connection_dummy_set_default_cb;
+}
+
+static void __connection_dummy_opened_cb(connection_error_e result, void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
}
static void __connection_open_profile_set_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
- conn_handle->opened_callback = callback;
conn_handle->opened_user_data = user_data;
+ if (callback != NULL)
+ conn_handle->opened_callback = callback;
+ else
+ conn_handle->opened_callback = __connection_dummy_opened_cb;
+}
+
+static void __connection_dummy_closed_cb(connection_error_e result, void* user_data)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Dummy callback");
}
static void __connection_close_profile_set_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
- conn_handle->closed_callback = callback;
conn_handle->closed_user_data = user_data;
+ if (callback != NULL)
+ conn_handle->closed_callback = callback;
+ else
+ conn_handle->closed_callback = __connection_dummy_closed_cb;
}
static void __connection_reset_profile_set_callback(connection_handle_s *conn_handle,
void *callback, void *user_data)
{
- conn_handle->reset_callback = callback;
conn_handle->reset_user_data = user_data;
+ if (callback != NULL)
+ conn_handle->reset_callback = callback;
+ else
+ conn_handle->reset_callback = __connection_dummy_opened_cb;
}
//LCOV_EXCL_STOP
}
conn_handle_list = g_slist_prepend(conn_handle_list, *connection);
+ _connection_handle_ref(*connection);
CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
__connection_set_proxy_changed_callback(connection, NULL, NULL);
__connection_set_internet_state_changed_callback(connection, NULL, NULL);
__connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
+ __connection_set_dhcp_state_changed_callback(connection, NULL, NULL);
- conn_handle_list = g_slist_remove(conn_handle_list, connection);
- _connection_libnet_deinit(connection, (conn_handle_list == NULL));
-
- g_free(connection);
- connection = NULL;
+ _connection_handle_unref(connection);
CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
//LCOV_EXCL_STOP
-EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type)
+EXPORT_API int connection_get_type(connection_h connection, connection_type_e *type)
{
int rv = 0;
int status = 0;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- rv = vconf_get_int(VCONFKEY_NETWORK_STATUS, &status);
+ rv = _connection_vconf_get_int(connection, VCONFKEY_NETWORK_STATUS, &status);
if (rv != VCONF_OK) {
CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d", status); //LCOV_EXCL_LINE
CONN_UNLOCK; //LCOV_EXCL_LINE
switch (address_family) {
case CONNECTION_ADDRESS_FAMILY_IPV4:
- *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
+ *ip_address = _connection_vconf_get_str(connection, VCONFKEY_NETWORK_IP);
break;
case CONNECTION_ADDRESS_FAMILY_IPV6:
- *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP6);
+ *ip_address = _connection_vconf_get_str(connection, VCONFKEY_NETWORK_IP6);
break;
default:
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
switch (address_family) {
case CONNECTION_ADDRESS_FAMILY_IPV4:
case CONNECTION_ADDRESS_FAMILY_IPV6:
- *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+ *proxy = _connection_vconf_get_str(connection, VCONFKEY_NETWORK_PROXY);
break;
default:
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
if (fp) {
if (fgets(buf, sizeof(buf), fp) == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE);
- fclose(fp);
- CONN_UNLOCK;
- return CONNECTION_ERROR_OPERATION_FAILED;
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
- CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
+ CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf); //LCOV_EXCL_LINE
- *mac_addr = g_strdup(buf);
- fclose(fp);
+ *mac_addr = g_strdup(buf); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
} else {
- *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+ *mac_addr = _connection_vconf_get_str(connection, VCONFKEY_WIFI_BSSID_ADDRESS);
if (*mac_addr == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
}
if (strlen(*mac_addr) == 0) {
- CONNECTION_LOG(CONNECTION_ERROR, "Mac address is invalid"
+ CONNECTION_LOG(CONNECTION_ERROR, "Mac address is invalid" //LCOV_EXCL_LINE
" from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
g_free(*mac_addr); //LCOV_EXCL_LINE
*mac_addr = NULL; //LCOV_EXCL_LINE
}
/* Checking Invalid MAC Address */
- if ((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
+ if (*mac_addr == NULL || (strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
(strcmp(*mac_addr, "ff:ff:ff:ff:ff:ff") == 0)) {
CONNECTION_LOG(CONNECTION_ERROR, "MAC Address(%s) is invalid", *mac_addr); //LCOV_EXCL_LINE
CONN_UNLOCK; //LCOV_EXCL_LINE
}
-EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
+EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e *state)
{
int rv = 0;
int status = 0;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (state == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
- CONN_UNLOCK;
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status);
+ rv = _connection_vconf_get_int(connection, VCONFKEY_NETWORK_CELLULAR_STATE, &status);
if (rv != VCONF_OK) {
CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); //LCOV_EXCL_LINE
CONN_UNLOCK; //LCOV_EXCL_LINE
if (*state == CONNECTION_CELLULAR_STATE_AVAILABLE) {
#if defined TIZEN_DUALSIM_ENABLE
- rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
+ rv = _connection_vconf_get_int(connection, VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
if (rv != VCONF_OK) {
CONNECTION_LOG(CONNECTION_ERROR,
"Failed to get default subscriber id", sim_id);
switch (sim_id) {
case CONNECTION_CELLULAR_SUBSCRIBER_1:
#endif
- rv = vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state);
+ rv = _connection_vconf_get_int(connection, VCONFKEY_DNET_STATE, &cellular_state);
#if defined TIZEN_DUALSIM_ENABLE
break;
case CONNECTION_CELLULAR_SUBSCRIBER_2:
- rv = vconf_get_int(VCONFKEY_DNET_STATE2, &cellular_state);
+ rv = _connection_vconf_get_int(connection, VCONFKEY_DNET_STATE2, &cellular_state);
break;
default:
return CONNECTION_ERROR_NONE;
}
-EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state)
+EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e *state)
{
CONN_LOCK;
return CONNECTION_ERROR_NONE;
}
+EXPORT_API int connection_get_dhcp_state(connection_h connection,
+ const char *interface_name, connection_dhcp_state_e *state)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (interface_name == NULL || state == NULL ||
+ !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ int rv = _connection_libnet_get_dhcp_state(connection, interface_name, state);
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to get DHCP state[%d]", rv); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_NONE; //LCOV_EXCL_LINE
+}
+
EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
connection_ethernet_cable_state_chaged_cb callback, void *user_data)
{
CHECK_FEATURE_SUPPORTED(TETHERING_BLUETOOTH_FEATURE);
if (state == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
- CONN_UNLOCK;
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
int rv = _connection_libnet_get_bluetooth_state(connection, state);
return CONNECTION_ERROR_NONE;
}
+//LCOV_EXCL_START
EXPORT_API int connection_set_type_changed_cb(connection_h connection,
connection_type_changed_cb callback, void* user_data)
{
CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
+//LCOV_EXCL_STOP
EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection,
connection_address_changed_cb callback, void* user_data)
return CONNECTION_ERROR_NONE;
}
+EXPORT_API int connection_set_dhcp_state_changed_cb(connection_h connection,
+ connection_dhcp_state_changed_cb callback, void *user_data)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (callback == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ __connection_set_dhcp_state_changed_callback(connection, callback, user_data);
+
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_unset_dhcp_state_changed_cb(connection_h connection)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ __connection_set_dhcp_state_changed_callback(connection, NULL, NULL);
+
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_NONE;
+}
+
EXPORT_API int connection_set_internet_state_changed_cb(connection_h connection,
connection_internet_state_changed_cb callback, void *user_data)
{
if (!(__connection_check_handle_validity(connection)) ||
!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
- CONN_UNLOCK;
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- if (profile_info->ProfileInfo.Pdp.PSModemPath[0] != '/' ||
- strlen(profile_info->ProfileInfo.Pdp.PSModemPath) < 2) {
+ if (profile_info->profile_info.pdp.ps_modem_path[0] != '/' ||
+ strlen(profile_info->profile_info.pdp.ps_modem_path) < 2) {
CONNECTION_LOG(CONNECTION_ERROR, "Modem object path is NULL"); //LCOV_EXCL_LINE
CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
rv = net_add_profile(conn_handle->network_info_handle,
- profile_info->ProfileInfo.Pdp.ServiceType, profile_info);
+ profile_info->profile_info.pdp.service_type, profile_info);
if (rv == NET_ERR_ACCESS_DENIED) {
CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = net_delete_profile(conn_handle->network_info_handle, profile_info->ProfileName);
+ rv = net_delete_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
CONN_UNLOCK; //LCOV_EXCL_LINE
}
rv = net_modify_profile(conn_handle->network_info_handle,
- profile_info->ProfileName, (net_profile_info_t*)profile);
+ profile_info->profile_name, (net_profile_info_t*)profile);
if (rv == NET_ERR_ACCESS_DENIED) {
CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
CONN_UNLOCK; //LCOV_EXCL_LINE
}
EXPORT_API int connection_get_profile_iterator(connection_h connection,
- connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator)
+ connection_iterator_type_e type, connection_profile_iterator_h *profile_iterator)
{
CONN_LOCK;
}
EXPORT_API int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator,
- connection_profile_h* profile)
+ connection_profile_h *profile)
{
CONN_LOCK;
return rv;
}
-EXPORT_API int connection_get_current_profile(connection_h connection, connection_profile_h* profile)
+EXPORT_API int connection_get_current_profile(connection_h connection, connection_profile_h *profile)
{
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
- CONN_UNLOCK;
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
int rv = _connection_libnet_get_cellular_service_profile(connection, type, profile);
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
- CONN_UNLOCK;
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
int rv = _connection_libnet_set_cellular_service_profile_sync(connection, type, profile);
int rv;
if (!(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed");
- CONN_UNLOCK;
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
if (id < 0 || id > 1) {
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+ CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
interface_name == NULL || host_address == NULL) {
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+ CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
interface_name == NULL || host_address == NULL) {
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+ CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
interface_name == NULL || host_address == NULL) {
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+ CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
interface_name == NULL || host_address == NULL) {
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+ CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
CONN_LOCK;
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+ CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
}
}
-static int __get_cellular_statistic(connection_statistics_type_e statistics_type, long long *llsize)
+static int __get_cellular_statistic(connection_handle_s *conn_handle,
+ connection_statistics_type_e statistics_type, long long *llsize)
{
int rv = VCONF_OK, rv1 = VCONF_OK;
int last_size = 0, size = 0;
}
#if defined TIZEN_DUALSIM_ENABLE
- rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
+ rv = _connection_vconf_get_int(conn_handle, VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
if (rv != VCONF_OK) {
CONNECTION_LOG(CONNECTION_ERROR, "Failed to get default subscriber id");
*llsize = 0;
#endif
switch (statistics_type) {
case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
break;
case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
break;
case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
- rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, &size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
+ rv1 = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, &size);
break;
case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
- rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, &size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
+ rv1 = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, &size);
break;
}
#if defined TIZEN_DUALSIM_ENABLE
case 1:
switch (statistics_type) {
case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
break;
case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
break;
case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
- rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2, &size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
+ rv1 = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2, &size);
break;
case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
- rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
- rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2, &size);
+ rv = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
+ rv1 = _connection_vconf_get_int(conn_handle, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2, &size);
break;
}
break;
}
if (connection_type == CONNECTION_TYPE_CELLULAR)
- return __get_cellular_statistic(statistics_type, llsize);
+ return __get_cellular_statistic(conn_handle, statistics_type, llsize);
else if (connection_type == CONNECTION_TYPE_WIFI) {
switch (statistics_type) {
case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
+
+//LCOV_EXCL_START
+EXPORT_API int connection_clock_is_updated(connection_h connection, bool *updated)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(_connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER;//LCOV_EXCL_LINE
+ }
+
+ int rv = _connection_libnet_get_clock_updated(connection, updated);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to get clock update information[%d]", rv); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "Clock updated: %s", *updated ? "true" : "false");
+ CONN_UNLOCK;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_get_ntp_server(connection_h connection, char **ntp_server)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (ntp_server == NULL || !(_connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER;//LCOV_EXCL_LINE
+ }
+
+ char *server = NULL;
+
+ int rv = _connection_libnet_get_ntp_server(connection, &server);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to get ntp server [%d]", rv); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ if (server) {
+ *ntp_server = strdup(server);
+ g_free(server);
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "NTP SERVER: %s", *ntp_server);
+ CONN_UNLOCK;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_set_ntp_server(connection_h connection, const char *ntp_server)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) || ntp_server == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ int rv = _connection_libnet_set_ntp_server(connection, ntp_server);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to set NTP server[%d]", rv); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ CONN_UNLOCK;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_clear_ntp_server(connection_h connection)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ int rv = _connection_libnet_clear_ntp_server(connection);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to clear NTP server[%d]", rv); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ CONN_UNLOCK;
+
+ return CONNECTION_ERROR_NONE;
+}
+//LCOV_EXCL_STOP