Added CAPIs for C# thread handling
[platform/core/api/connection.git] / src / connection.c
index 8c2b5b1..4ae5640 100755 (executable)
 
 #include <glib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <vconf/vconf.h>
+#include <system_info.h>
 
 #include "net_connection_private.h"
 
 static __thread GSList *conn_handle_list = NULL;
+static int tv_profile = -1; // Unknown
 
 //LCOV_EXCL_START
 static int __connection_convert_net_state(int status)
@@ -83,33 +86,13 @@ static void *__connection_get_type_changed_userdata(
        return local_handle->type_changed_user_data;
 }
 
-static gboolean __connection_cb_type_changed_cb_idle(gpointer user_data)
-{
-       int state, status;
-       void *data;
-       connection_type_changed_cb callback;
-       connection_handle_s *local_handle = (connection_handle_s *)user_data;
-
-       if (__connection_check_handle_validity((connection_h)local_handle) != true)
-               return FALSE;
-
-       if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status) != 0)
-               return FALSE;
-
-       state = __connection_convert_net_state(status);
-
-       callback = __connection_get_type_changed_callback(local_handle);
-       data = __connection_get_type_changed_userdata(local_handle);
-       if (callback)
-               callback(state, data);
-
-       return FALSE;
-}
-
-static void __connection_cb_type_change_cb(keynode_t *node, void *user_data)
+static void __connection_cb_type_change_cb(int type)
 {
        GSList *list;
        connection_h handle;
+       void *data;
+       connection_type_changed_cb callback;
+       int state;
 
        if (_connection_is_created() != true) {
                CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
@@ -117,9 +100,15 @@ static void __connection_cb_type_change_cb(keynode_t *node, void *user_data)
                return;
        }
 
+       state = __connection_convert_net_state(type);
+
        for (list = conn_handle_list; list; list = list->next) {
                handle = (connection_h)list->data;
-               _connection_callback_add(__connection_cb_type_changed_cb_idle, (gpointer)handle);
+
+               callback = __connection_get_type_changed_callback(handle);
+               data = __connection_get_type_changed_userdata(handle);
+               if (callback)
+                       callback(state, data);
        }
 }
 
@@ -160,23 +149,19 @@ static int __connection_set_type_changed_callback(connection_h connection,
 
        if (callback) {
                if (refcount == 0)
-                       vconf_notify_key_changed(VCONFKEY_NETWORK_STATUS,
-                                       __connection_cb_type_change_cb, NULL);
+                       _connection_libnet_set_type_changed_cb(
+                                                          __connection_cb_type_change_cb);
 
                refcount++;
-               CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+               CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
+                                          refcount);
        } else {
                if (refcount > 0 &&
                                __connection_get_type_changed_callback(local_handle) != NULL) {
                        if (--refcount == 0) {
-                               if (vconf_ignore_key_changed(VCONFKEY_NETWORK_STATUS,
-                                               __connection_cb_type_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);
-                               }
+                               _connection_libnet_set_type_changed_cb(NULL);
+                               CONNECTION_LOG(CONNECTION_INFO,
+                                               "Successfully de-registered(%d)", refcount);
                        }
                }
        }
@@ -199,31 +184,15 @@ static void *__connection_get_ip_changed_userdata(
        return local_handle->ip_changed_user_data;
 }
 
-static gboolean __connection_cb_ip_changed_cb_idle(gpointer user_data)
-{
-       char *ip_addr;
-       void *data;
-       connection_address_changed_cb callback;
-       connection_handle_s *local_handle = (connection_handle_s *)user_data;
-
-       if (__connection_check_handle_validity((connection_h)local_handle) != true)
-               return FALSE;
-
-       ip_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
-
-       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);
-
-       return FALSE;
-}
-
-static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data)
+static void __connection_cb_ip_change_cb(
+                        connection_address_family_e addr_family, char *ip_addr)
 {
        GSList *list;
        connection_h handle;
+       char *ip4_addr = NULL;
+       char *ip6_addr = NULL;
+       void *data;
+       connection_address_changed_cb callback;
 
        if (_connection_is_created() != true) {
                CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
@@ -231,10 +200,40 @@ static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data)
                return;
        }
 
+       switch (addr_family) {
+       case CONNECTION_ADDRESS_FAMILY_IPV4:
+               ip4_addr = g_strdup(ip_addr);
+
+               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) failed");
+               break;
+       case CONNECTION_ADDRESS_FAMILY_IPV6:
+               ip6_addr = g_strdup(ip_addr);
+
+               ip4_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
+               if (ip4_addr == NULL)
+                       CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+                                                  "vconf_get_str(VCONFKEY_NETWORK_IP) failed");
+               break;
+       default:
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid Address Type");
+               return;
+       }
+
        for (list = conn_handle_list; list; list = list->next) {
                handle = (connection_h)list->data;
-               _connection_callback_add(__connection_cb_ip_changed_cb_idle, (gpointer)handle);
+
+               callback = __connection_get_ip_changed_callback(handle);
+               data = __connection_get_ip_changed_userdata(handle);
+
+               if (callback)
+                       callback(ip4_addr, ip6_addr, data);
        }
+
+       g_free(ip4_addr);
+       g_free(ip6_addr);
 }
 
 static int __connection_set_ip_changed_callback(connection_h connection,
@@ -247,23 +246,19 @@ static int __connection_set_ip_changed_callback(connection_h connection,
 
        if (callback) {
                if (refcount == 0)
-                       vconf_notify_key_changed(VCONFKEY_NETWORK_IP,
-                                       __connection_cb_ip_change_cb, NULL);
+                       _connection_libnet_set_ip_changed_cb(
+                                                          __connection_cb_ip_change_cb);
 
                refcount++;
-               CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+               CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
+                                          refcount);
        } else {
                if (refcount > 0 &&
                                __connection_get_ip_changed_callback(local_handle) != NULL) {
                        if (--refcount == 0) {
-                               if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP,
-                                               __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);
-                               }
+                               _connection_libnet_set_ip_changed_cb(NULL);
+                               CONNECTION_LOG(CONNECTION_INFO,
+                                                          "Successfully de-registered(%d)", refcount);
                        }
                }
        }
@@ -286,31 +281,12 @@ static void *__connection_get_proxy_changed_userdata(
        return local_handle->proxy_changed_user_data;
 }
 
-static gboolean __connection_cb_proxy_changed_cb_idle(gpointer user_data)
-{
-       char *proxy;
-       void *data;
-       connection_address_changed_cb callback;
-       connection_handle_s *local_handle = (connection_handle_s *)user_data;
-
-       if (__connection_check_handle_validity((connection_h)local_handle) != true)
-               return FALSE;
-
-       proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
-
-       callback = __connection_get_proxy_changed_callback(local_handle);
-       data = __connection_get_proxy_changed_userdata(local_handle);
-       /* TODO: IPv6 should be supported */
-       if (callback)
-               callback(proxy, NULL, data);
-
-       return FALSE;
-}
-
-static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data)
+static void __connection_cb_proxy_change_cb(char *proxy_addr)
 {
        GSList *list;
        connection_h handle;
+       void *data;
+       connection_address_changed_cb callback;
 
        if (_connection_is_created() != true) {
                CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
@@ -320,7 +296,12 @@ static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data)
 
        for (list = conn_handle_list; list; list = list->next) {
                handle = (connection_h)list->data;
-               _connection_callback_add(__connection_cb_proxy_changed_cb_idle, (gpointer)handle);
+
+               callback = __connection_get_proxy_changed_callback(handle);
+               data = __connection_get_proxy_changed_userdata(handle);
+               /* TODO: IPv6 should be supported */
+               if (callback)
+                       callback(proxy_addr, NULL, data);
        }
 }
 
@@ -334,23 +315,19 @@ static int __connection_set_proxy_changed_callback(connection_h connection,
 
        if (callback) {
                if (refcount == 0)
-                       vconf_notify_key_changed(VCONFKEY_NETWORK_PROXY,
-                                       __connection_cb_proxy_change_cb, NULL);
+                       _connection_libnet_set_proxy_changed_cb(
+                               __connection_cb_proxy_change_cb);
 
                refcount++;
-               CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+               CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
+                                          refcount);
        } else {
                if (refcount > 0 &&
                                __connection_get_proxy_changed_callback(local_handle) != NULL) {
                        if (--refcount == 0) {
-                               if (vconf_ignore_key_changed(VCONFKEY_NETWORK_PROXY,
-                                               __connection_cb_proxy_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);
-                               }
+                               _connection_libnet_set_proxy_changed_cb(NULL);
+                               CONNECTION_LOG(CONNECTION_INFO,
+                                               "Successfully de-registered(%d)", refcount);
                        }
                }
        }
@@ -362,7 +339,7 @@ static int __connection_set_proxy_changed_callback(connection_h connection,
 }
 
 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;
 
@@ -372,7 +349,8 @@ static int __connection_set_ethernet_cable_state_changed_cb(connection_h connect
                                        __connection_cb_ethernet_cable_state_changed_cb);
 
        } else {
-               if (__connection_get_ethernet_cable_state_changed_callback_count() == 1)
+               if (__connection_get_ethernet_cable_state_changed_callback_count() == 1 &&
+                                 local_handle->ethernet_cable_state_changed_callback)
                        _connection_libnet_set_ethernet_cable_state_changed_cb(NULL);
        }
 
@@ -446,6 +424,28 @@ EXPORT_API int connection_destroy(connection_h connection)
        return CONNECTION_ERROR_NONE;
 }
 
+EXPORT_API int connection_create_cs(int tid, connection_h *connection)
+{
+       int rv;
+
+       rv = connection_create(connection);
+
+       if (rv == CONNECTION_ERROR_NONE)
+               _connection_set_cs_tid(tid);
+
+       return rv;
+}
+
+EXPORT_API int connection_destroy_cs(int tid, connection_h connection)
+{
+       int rv;
+
+       _connection_unset_cs_tid(tid);
+       rv = connection_destroy(connection);
+
+       return rv;
+}
+
 EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type)
 {
        int rv = 0;
@@ -483,9 +483,11 @@ EXPORT_API int connection_get_ip_address(connection_h connection,
 
        switch (address_family) {
        case CONNECTION_ADDRESS_FAMILY_IPV4:
-       case CONNECTION_ADDRESS_FAMILY_IPV6:
                *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
                break;
+       case CONNECTION_ADDRESS_FAMILY_IPV6:
+               *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP6);
+               break;
        default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
                return CONNECTION_ERROR_INVALID_PARAMETER;
@@ -546,37 +548,46 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 
        switch (type) {
        case CONNECTION_TYPE_WIFI:
-#if defined TIZEN_TV
-               fp = fopen(WIFI_MAC_INFO_FILE, "r");
-               if (fp == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+               if (__builtin_expect(tv_profile == -1, 0)) {
+                       char *profileName;
+                       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+                       if (*profileName == 't' || *profileName == 'T')
+                               tv_profile = 1;
+                       else
+                               tv_profile = 0;
+                       free(profileName);
                }
+               if (tv_profile == 1) {
+                       fp = fopen(WIFI_MAC_INFO_FILE, "r");
+                       if (fp == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+                       }
 
-               if (fgets(buf, sizeof(buf), fp) == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
-                       fclose(fp); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OPERATION_FAILED;
-               }
+                       if (fgets(buf, sizeof(buf), fp) == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+                               fclose(fp); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OPERATION_FAILED;
+                       }
 
-               CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
+                       CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
 
-               *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
-               if (*mac_addr == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
-                       fclose(fp); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
-               }
-               g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
-               fclose(fp);
-#else
-               *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+                       *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
+                       if (*mac_addr == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
+                               fclose(fp); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+                       }
+                       g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
+                       fclose(fp);
+               } else {
+                       *mac_addr = vconf_get_str(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
-                       return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+                       if (*mac_addr == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+                       }
                }
-#endif
                break;
        //LCOV_EXCL_START
        case CONNECTION_TYPE_ETHERNET:
@@ -606,7 +617,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 
                break;
        //LCOV_EXCL_STOP
-       default :
+       default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
@@ -624,6 +635,26 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 }
 
 
+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;
@@ -738,6 +769,7 @@ EXPORT_API int connection_get_ethernet_cable_state(connection_h connection, conn
 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))) {
@@ -745,12 +777,43 @@ EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connec
                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))) {
@@ -1133,6 +1196,54 @@ EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char
        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;
@@ -1355,3 +1466,113 @@ EXPORT_API int connection_reset_statistics(connection_h connection,
        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;
+}