static gboolean __connection_cb_ip_changed_cb_idle(gpointer user_data)
{
char *ip_addr;
+ char *ip6_addr;
void *data;
connection_address_changed_cb callback;
connection_handle_s *local_handle = (connection_handle_s *)user_data;
CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
"vconf_get_str(VCONFKEY_NETWORK_IP) is Failed");
+ ip6_addr = vconf_get_str(VCONFKEY_NETWORK_IP6);
+ if (ip6_addr == NULL)
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+ "vconf_get_str(VCONFKEY_NETWORK_IP6) is Failed");
+
callback = __connection_get_ip_changed_callback(local_handle);
data = __connection_get_ip_changed_userdata(local_handle);
- /* TODO: IPv6 should be supported */
+
if (callback)
- callback(ip_addr, NULL, data);
+ callback(ip_addr, ip6_addr, data);
free(ip_addr);
+ free(ip6_addr);
return FALSE;
}
local_handle = (connection_handle_s *)connection;
if (callback) {
- if (refcount == 0)
+ if (refcount == 0) {
vconf_notify_key_changed(VCONFKEY_NETWORK_IP,
__connection_cb_ip_change_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_NETWORK_IP6,
+ __connection_cb_ip_change_cb, NULL);
+ }
refcount++;
CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
CONNECTION_LOG(CONNECTION_INFO,
"Successfully de-registered(%d)", refcount);
}
+ if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP6,
+ __connection_cb_ip_change_cb) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+ "Error to de-register vconf callback(%d)", refcount);
+ } else {
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
+ }
}
}
}
}
static int __connection_set_ethernet_cable_state_changed_cb(connection_h connection,
- connection_ethernet_cable_state_chaged_cb callback, void *user_data)
+ connection_ethernet_cable_state_changed_cb callback, void *user_data)
{
connection_handle_s *local_handle = (connection_handle_s *)connection;
}
+EXPORT_API int connection_is_metered_network(connection_h connection, bool* is_metered)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (is_metered == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ int rv = _connection_libnet_get_metered_state(is_metered);
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to get metered state[%d]", rv); //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "metered state: %s", is_metered ? "true" : "false");
+ return CONNECTION_ERROR_NONE;
+}
+
+
EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
{
int rv = 0;
EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
connection_ethernet_cable_state_chaged_cb callback, void *user_data)
{
+ DEPRECATED_LOG(__FUNCTION__, "connection_set_ethernet_cable_state_changed_cb");
CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
if (callback == NULL || !(__connection_check_handle_validity(connection))) {
return CONNECTION_ERROR_INVALID_PARAMETER;
}
+ DEPRECATED_LOG("connection_ethernet_cable_state_chaged_cb",
+ "connection_ethernet_cable_state_changed_cb");
+
return __connection_set_ethernet_cable_state_changed_cb(connection,
- callback, user_data);
+ (connection_ethernet_cable_state_changed_cb)callback, user_data);
}
EXPORT_API int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection)
{
+ DEPRECATED_LOG(__FUNCTION__, "connection_unset_ethernet_cable_state_changed_cb");
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return __connection_set_ethernet_cable_state_changed_cb(connection,
+ NULL, NULL);
+}
+
+EXPORT_API int connection_set_ethernet_cable_state_changed_cb(connection_h connection,
+ connection_ethernet_cable_state_changed_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+ if (callback == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return __connection_set_ethernet_cable_state_changed_cb(connection,
+ callback, user_data);
+}
+
+EXPORT_API int connection_unset_ethernet_cable_state_changed_cb(connection_h connection)
+{
CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
if (!(__connection_check_handle_validity(connection))) {
return _connection_libnet_remove_route_ipv6(interface_name, host_address, gateway);
}
+EXPORT_API int connection_add_route_entry(connection_h connection,
+ connection_address_family_e address_family, const char *interface_name,
+ const char *host_address, const char *gateway)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
+ address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ return _connection_libnet_add_route_entry(CONNECTION_ADDRESS_FAMILY_IPV4,
+ interface_name, host_address, gateway);
+ else
+ return _connection_libnet_add_route_entry(CONNECTION_ADDRESS_FAMILY_IPV6,
+ interface_name, host_address, gateway);
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_remove_route_entry(connection_h connection,
+ connection_address_family_e address_family, const char *interface_name,
+ const char *host_address, const char *gateway)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
+ address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ return _connection_libnet_remove_route_entry(CONNECTION_ADDRESS_FAMILY_IPV4,
+ interface_name, host_address, gateway);
+ else
+ return _connection_libnet_remove_route_entry(CONNECTION_ADDRESS_FAMILY_IPV6,
+ interface_name, host_address, gateway);
+
+ return CONNECTION_ERROR_NONE;
+}
+
static int __get_cellular_statistic(connection_statistics_type_e statistics_type, long long *llsize)
{
int rv = VCONF_OK, rv1 = VCONF_OK;
return __reset_statistic(connection_type, statistics_type);
}
+EXPORT_API int connection_foreach_ipv6_address(connection_h connection,
+ connection_type_e connection_type, connection_ipv6_address_cb callback,
+ void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+ TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ GSList *ipv6_address_list = NULL;
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ int rv = CONNECTION_ERROR_NONE;
+
+ switch (connection_type) {
+ case CONNECTION_TYPE_WIFI:
+ rv = net_foreach_ipv6_address(NET_DEVICE_WIFI,
+ &ipv6_address_list);
+ break;
+ case CONNECTION_TYPE_CELLULAR:
+ rv = net_foreach_ipv6_address(NET_DEVICE_CELLULAR,
+ &ipv6_address_list);
+ break;
+ case CONNECTION_TYPE_ETHERNET:
+ rv = net_foreach_ipv6_address(NET_DEVICE_ETHERNET,
+ &ipv6_address_list);
+ break;
+ case CONNECTION_TYPE_BT:
+ rv = net_foreach_ipv6_address(NET_DEVICE_BLUETOOTH,
+ &ipv6_address_list);
+ break;
+ default:
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "net_get_multiple_id_address"
+ " Failed = %d\n", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ GSList *list;
+ for (list = ipv6_address_list; list; list = list->next) {
+ rv = callback((char *)list->data, user_data);
+ if (rv == false)
+ break;
+ }
+
+ g_slist_free_full(ipv6_address_list, g_free);
+ ipv6_address_list = NULL;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_start_tcpdump(connection_h connection)
+{
+ int ret = 0;
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _connection_libnet_start_tcpdump();
+ if (ret != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to start tcpdump (%d)", ret);
+ return ret;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_stop_tcpdump(connection_h connection)
+{
+ int ret = 0;
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _connection_libnet_stop_tcpdump();
+ if (ret != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to stop tcpdump (%d)", ret);
+ return ret;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_tcpdump_state(connection_h connection, gboolean *tcpdump_state)
+{
+ int ret = 0;
+
+ if (!(__connection_check_handle_validity(connection)) || !tcpdump_state) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _connection_libnet_get_tcpdump_state(tcpdump_state);
+ if (ret != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get the tcpdump state (%d)", ret);
+ return ret;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}