[ACR-472] Modified comments of ACR #3 56/57956/14
authortaesub.kim <taesub.kim@samsung.com>
Tue, 26 Jan 2016 09:29:19 +0000 (18:29 +0900)
committertaesub.kim <taesub.kim@samsung.com>
Wed, 3 Feb 2016 02:32:31 +0000 (11:32 +0900)
http://10.113.136.204/jira/browse/ACR-472

Change-Id: Ia1bf286b701f244f946f6f1215b836f82c70181c
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
12 files changed:
daemon/include/vpn_service_daemon.h
daemon/interfaces/org.tizen.vpnsvc.xml
daemon/src/vpn_service_daemon.c
daemon/src/vpnsvc.c
doc/vpn_doc.h
framework/CMakeLists.txt
framework/include/capi_vpn_service_private.h
framework/src/capi_vpn_service.c
include/tizen_vpn_error.h [deleted file]
include/vpn_service.h
include/vpn_service_internal.h [new file with mode: 0755]
test/vpn_service_test.c

index 755ce3e..b55e71c 100755 (executable)
 
 #include "capi_vpn_service_private.h"
 
-int vpn_daemon_init(const char* tun_name, size_t tun_name_len, int fd, vpnsvc_tun_s *handle_s);
+int vpn_daemon_init(const char* if_name, size_t if_name_len, int fd, vpnsvc_tun_s *handle_s);
 int vpn_daemon_deinit(const char* dev_name);
 int vpn_daemon_protect(int socket, const char* dev_name);
-int vpn_daemon_up(int tun_index, const char* local_ip, const char* remote_ip,
+int vpn_daemon_up(int if_index, const char* local_ip, const char* remote_ip,
                                                const char* routes[], int prefix[], size_t nr_routes,
                                                char** dns_servers, size_t nr_dns, size_t total_dns_string_cnt,
                                                const char* dns_suffix, const unsigned int mtu);
-int vpn_daemon_down(int tun_index);
+int vpn_daemon_down(int if_index);
 int vpn_daemon_block_networks(const char* nets_vpn[], int prefix_vpn[], size_t nr_nets_vpn,
                const char* nets_orig[], int prefix_orig[], size_t nr_nets_orig);
 int vpn_daemon_unblock_networks(void);
index 8c4d08d..8349623 100755 (executable)
@@ -1,8 +1,8 @@
 <node name='/org/tizen/vpnsvc'>
        <interface name='org.tizen.vpnsvc'>
                <method name='vpn_init'>
-                       <arg type='s' name='tun_name' direction='in'/>
-                       <arg type='u' name='tun_name_len' direction='in'/>
+                       <arg type='s' name='if_name' direction='in'/>
+                       <arg type='u' name='if_name_len' direction='in'/>
                        <arg type='i' name='result' direction='out'/>
                        <arg type='i' name='h_index' direction='out'/>
                        <arg type='s' name='h_name' direction='out'/>
@@ -16,7 +16,7 @@
                        <arg type='i' name='result' direction='out'/>
                </method>
                <method name='vpn_up'>
-                       <arg type='i' name='tun_index' direction='in'/>
+                       <arg type='i' name='if_index' direction='in'/>
                        <arg type='s' name='local_ip' direction='in'/>
                        <arg type='s' name='remote_ip' direction='in'/>
                        <arg type='v' name='routes' direction='in'/>
@@ -28,7 +28,7 @@
                        <arg type='i' name='result' direction='out'/>
                </method>
                <method name='vpn_down'>
-                       <arg type='i' name='tun_index' direction='in'/>
+                       <arg type='i' name='if_index' direction='in'/>
                        <arg type='i' name='result' direction='out'/>
                </method>
                <method name='vpn_block_networks'>
index e664124..94cc958 100755 (executable)
@@ -609,12 +609,12 @@ void iptables_delete(const char *addr, const int mask)
        iptables_rule('D', addr, mask);
 }
 
-static int get_interface_index(const char *tun_name)
+static int get_interface_index(const char *if_name)
 {
        struct ifreq ifr;
        int sk = 0;
 
-       LOGD("enter get_interface_index, tun_name : %s", tun_name);
+       LOGD("enter get_interface_index, if_name : %s", if_name);
 
        sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
        if (sk < 0) {
@@ -624,8 +624,8 @@ static int get_interface_index(const char *tun_name)
 
        memset(&ifr, 0, sizeof(ifr));
 
-       if (*tun_name)
-       strncpy(ifr.ifr_name, tun_name, strlen(tun_name));
+       if (*if_name)
+       strncpy(ifr.ifr_name, if_name, strlen(if_name));
 
        /* get an interface name by ifindex */
        if (ioctl(sk, SIOCGIFINDEX, &ifr) < 0) {
@@ -640,12 +640,12 @@ static int get_interface_index(const char *tun_name)
 }
 
 
-int vpn_daemon_init(const char* tun_name, size_t tun_name_len, int fd, vpnsvc_tun_s *handle_s)
+int vpn_daemon_init(const char* if_name, size_t if_name_len, int fd, vpnsvc_tun_s *handle_s)
 {
        struct ifreq ifr;
        size_t len = 0;
 
-       LOGD("enter vpn_daemon_init, tun_name : %s, tun_name_len : %d, fd : %d\n", tun_name, tun_name_len, fd);
+       LOGD("enter vpn_daemon_init, if_name : %s, if_name_len : %d, fd : %d\n", if_name, if_name_len, fd);
 
        memset(&ifr, 0, sizeof(ifr));
 
@@ -657,8 +657,8 @@ int vpn_daemon_init(const char* tun_name, size_t tun_name_len, int fd, vpnsvc_tu
 
        ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
 
-       if (*tun_name)
-               strncpy(ifr.ifr_name, tun_name, tun_name_len);
+       if (*if_name)
+               strncpy(ifr.ifr_name, if_name, if_name_len);
 
        LOGD("before init, ifindex : %d", ifr.ifr_ifindex);
 
@@ -681,7 +681,7 @@ int vpn_daemon_init(const char* tun_name, size_t tun_name_len, int fd, vpnsvc_tu
        }
 
        handle_s->fd = 0;   /* server fd does not meaning */
-       handle_s->index = get_interface_index(tun_name);
+       handle_s->index = get_interface_index(if_name);
        len = strlen(ifr.ifr_name);
        strncpy(handle_s->name, ifr.ifr_name, len);
        handle_s->name[len] = '\0';
@@ -724,7 +724,7 @@ int vpn_daemon_protect(int socket_fd, const char* dev_name)
        return ret;
 }
 
-int vpn_daemon_up(int tun_index, const char* local_ip, const char* remote_ip,
+int vpn_daemon_up(int if_index, const char* local_ip, const char* remote_ip,
                                                const char* routes[], int prefix[], size_t nr_routes,
                                                char** dns_servers, size_t nr_dns, size_t total_dns_string_cnt,
                                                const char* dns_suffix, const unsigned int mtu) {
@@ -737,7 +737,7 @@ int vpn_daemon_up(int tun_index, const char* local_ip, const char* remote_ip,
 
        LOGD("enter vpn_daemon_up");
 
-       LOGD("tun_index : %d", tun_index);
+       LOGD("if_index : %d", if_index);
        LOGD("local ip : %s", local_ip);
        LOGD("remote ip : %s", remote_ip);
        LOGD("route pointer : %p, nr_routes : %d, dns_server pointer : %p, nr_dns : %d, dns_suffix : %s, mtu : %d", routes, nr_routes, dns_servers, nr_dns, dns_suffix, mtu);
@@ -750,7 +750,7 @@ int vpn_daemon_up(int tun_index, const char* local_ip, const char* remote_ip,
        }
 
        memset(&ifr_tun, 0, sizeof(ifr_tun));
-       ifr_tun.ifr_ifindex = tun_index;
+       ifr_tun.ifr_ifindex = if_index;
 
        /* get an interface name by ifindex */
        if (ioctl(sk, SIOCGIFNAME, &ifr_tun) < 0) {
@@ -845,7 +845,7 @@ int vpn_daemon_up(int tun_index, const char* local_ip, const char* remote_ip,
        return ret;
 }
 
-int vpn_daemon_down(int tun_index)
+int vpn_daemon_down(int if_index)
 {
        struct ifreq ifr, addr_ifr;
        struct sockaddr_in *addr = NULL;
@@ -858,7 +858,7 @@ int vpn_daemon_down(int tun_index)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       ifr.ifr_ifindex = tun_index;
+       ifr.ifr_ifindex = if_index;
 
        if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
                LOGE("ioctl SIOCGIFNAME failed : %s", strerror(errno));
index ce858da..e97d65b 100755 (executable)
@@ -38,8 +38,8 @@ static Vpnsvc *vpnsvc = NULL;
  ********************/
 gboolean handle_vpn_init(Vpnsvc *object,
                                                                GDBusMethodInvocation *invocation,
-                                                               const gchar *arg_tun_name,
-                                                               guint arg_tun_name_len)
+                                                               const gchar *arg_if_name,
+                                                               guint arg_if_name_len)
 {
        LOGD("handle_vpn_init");
 
@@ -50,7 +50,7 @@ gboolean handle_vpn_init(Vpnsvc *object,
        int fd_list_length;
        const int *fds;
 
-       LOGD("vpn_init, %s, %u\n", arg_tun_name, arg_tun_name_len);
+       LOGD("vpn_init, %s, %u\n", arg_if_name, arg_if_name_len);
 
        msg = g_dbus_method_invocation_get_message(invocation);
        fd_list = g_dbus_message_get_unix_fd_list(msg);
@@ -61,7 +61,7 @@ gboolean handle_vpn_init(Vpnsvc *object,
 
        LOGD("fd:%d\n", *fds);
 
-       result = vpn_daemon_init(arg_tun_name, arg_tun_name_len, *fds, &handle_s);
+       result = vpn_daemon_init(arg_if_name, arg_if_name_len, *fds, &handle_s);
 
        LOGD("handle_s.fd : %d, handle_s.index : %d, handle_s.name : %s",
                        handle_s.fd, handle_s.index, handle_s.name);
@@ -118,7 +118,7 @@ gboolean handle_vpn_protect(Vpnsvc *object,
 
 gboolean handle_vpn_up(Vpnsvc *object,
                                                                GDBusMethodInvocation *invocation,
-                                                               gint arg_tun_index,
+                                                               gint arg_if_index,
                                                                const gchar *arg_local_ip,
                                                                const gchar *arg_remote_ip,
                                                                GVariant *arg_routes,
@@ -144,7 +144,7 @@ gboolean handle_vpn_up(Vpnsvc *object,
        gchar* route_dest;
        gint route_prefix;
 
-       LOGD("tun_index : %d", arg_tun_index);
+       LOGD("if_index : %d", arg_if_index);
        LOGD("local ip : %s", arg_local_ip);
        LOGD("remote ip : %s", arg_remote_ip);
        LOGD("dns_suffix : %s", arg_dns_suffix);
@@ -199,7 +199,7 @@ gboolean handle_vpn_up(Vpnsvc *object,
                }
        }
 
-       result = vpn_daemon_up(arg_tun_index, arg_local_ip, arg_remote_ip,
+       result = vpn_daemon_up(arg_if_index, arg_local_ip, arg_remote_ip,
                        routes, prefix, arg_nr_routes, dns_servers, arg_nr_dns,
                        total_dns_string_cnt, arg_dns_suffix, arg_mtu);
 done:
@@ -219,14 +219,14 @@ done:
 
 gboolean handle_vpn_down(Vpnsvc *object,
                                                                        GDBusMethodInvocation *invocation,
-                                                                       gint arg_tun_index)
+                                                                       gint arg_if_index)
 {
        LOGD("handle_vpn_down");
        int result = VPNSVC_ERROR_NONE;
 
-       LOGD("vpn_down, %d\n", arg_tun_index);
+       LOGD("vpn_down, %d\n", arg_if_index);
 
-       result = vpn_daemon_down(arg_tun_index);
+       result = vpn_daemon_down(arg_if_index);
 
        vpnsvc_complete_vpn_down(object, invocation, result);
 
index 7978be8..4c8073b 100755 (executable)
  * 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.
- *
  */
 
 
-
 #ifndef __TIZEN_NETWORK_VPN_DOC_H__
 #define __TIZEN_NETWORK_VPN_DOC_H__
 
-/**
- * @defgroup CAPI_NETWORK_VPN_MODULE VPN
- * @brief The Virtual Private Network (VPN) API provides functions for managing VPN.
- * @ingroup CAPI_NETWORK_FRAMEWORK
- *
- * @section CAPI_NETWORK_VPN_MODULE_HEADER Required Header
- *   \#include <vpn_service.h>
- *
- * @section CAPI_NETWORK_VPN_MODULE_OVERVIEW Overview
- * VPN allows your application to manage VPN features.
- * The VPN Service enables your application to init and deinit a VPN device(TUN(namely netowrk TUNel) interface),
- * Routing management, DNS management and Firewall management.
- */
 
 /**
  * @defgroup CAPI_NETWORK_VPN_SERVICE_MODULE  VPN Service
- * @brief The VPN API provides functions for managing VPN.
- * @ingroup CAPI_NETWORK_VPN_MODULE
+ * @brief The Virtual Private Network (VPN) API provides functions for managing VPN.
+ * @ingroup CAPI_NETWORK_FRAMEWORK
  *
  * @section CAPI_NETWORK_VPN_SERVICE_MODULE_HEADER Required Header
  *   \#include <vpn_service.h>
  *
  * @section CAPI_NETWORK_VPN_SERVICE_MODULE_OVERVEW Overview
  * The VPN Service functions for managing VPN.
+ * There can be only one VPN connection running at the same time. The existing interface is deactivated when a new one is created.
  * Using the VPN Service, you can implement features that allow the users of your application to:
  *     - Initialize / Deinitialize the VPN device
  *     - Routing management
index 2622891..b78e4d4 100755 (executable)
@@ -41,7 +41,6 @@ TARGET_LINK_LIBRARIES(${PACKAGE_NAME} ${${PACKAGE_NAME}_LDFLAGS} -lrt -ldl)
 
 INSTALL(TARGETS ${PACKAGE_NAME} DESTINATION lib)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/vpn_service.h DESTINATION include)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/tizen_vpn_error.h DESTINATION include)
 
 SET_TARGET_PROPERTIES(${PACKAGE_NAME}
       PROPERTIES
index 0f56377..9b74d77 100755 (executable)
@@ -35,6 +35,7 @@
 #include <gio/gio.h>
 
 #include "vpn_service.h"
+#include "vpn_service_internal.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -69,7 +70,7 @@ typedef struct _vpnsvc_tun_s {
        GDBusConnection *connection;            /**< D-Bus Connection */
        int fd;                                 /**< tun socket fd */
        int index;                              /**< tun index (if.if_index) */
-       char name[VPNSVC_TUN_IF_NAME_LEN];      /**< tun name (if.if_name) */
+       char name[VPNSVC_VPN_IF_NAME_LEN];      /**< tun name (if.if_name) */
        char session[VPNSVC_SESSION_STRING_LEN];/**< session name (user setting) */
        unsigned int mtu;                       /**< mtu (user setting) */
 } vpnsvc_tun_s;
index bca72e6..1997a24 100755 (executable)
 #include <system_info.h>
 #include <gio/gunixfdlist.h>
 
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_VPNSVC"
+
 #define DBUS_REPLY_TIMEOUT (120 * 1000)
 
 GVariant *op = NULL;
@@ -98,7 +103,7 @@ static void _vpnsvc_deinit_vpnsvc_tun_s(vpnsvc_tun_s *s)
 
        s->fd = 0;
        s->index = 0;
-       memset(s->name, 0, VPNSVC_TUN_IF_NAME_LEN);
+       memset(s->name, 0, VPNSVC_VPN_IF_NAME_LEN);
        memset(s->session, 0, VPNSVC_SESSION_STRING_LEN);
 
        if (s)
@@ -217,20 +222,20 @@ GVariant *_vpnsvc_invoke_dbus_method_with_fd(GDBusConnection *connection,
        return reply;
 }
 
-int vpnsvc_init(const char* tun_name, vpnsvc_tun_h *handle)
+EXPORT_API int vpnsvc_init(const char* if_name, vpnsvc_h *handle)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        int result = VPNSVC_ERROR_NONE;
        int dbus_result;
-       int tun_fd = 0;
+       int if_fd = 0;
 
-       LOGD("enter vpnsvc_init, tun_name : %s", tun_name);
+       LOGD("enter vpnsvc_init, if_name : %s", if_name);
        LOGD("handle : %p\n", handle);
 
        /* parameter check */
-       if (tun_name == NULL || strlen(tun_name) <= 0) {
-               LOGE("tun_name is a NULL");
+       if (if_name == NULL || strlen(if_name) <= 0) {
+               LOGE("if_name is a NULL");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        } else if (handle == NULL) {
                LOGE("handle is a NULL");
@@ -273,25 +278,25 @@ int vpnsvc_init(const char* tun_name, vpnsvc_tun_h *handle)
                op = NULL;
        }
 
-       if ((tun_fd = open("/dev/net/tun", O_RDWR)) < 0) {
+       if ((if_fd = open("/dev/net/tun", O_RDWR)) < 0) {
                LOGE("tun device open fail\n");
                _vpnsvc_deinit_vpnsvc_tun_s(tmp_s);
                return VPNSVC_ERROR_IO_ERROR;
        }
 
-       LOGD("client tun_fd : %d", tun_fd);
+       LOGD("client if_fd : %d", if_fd);
 
        op = _vpnsvc_invoke_dbus_method_with_fd(tmp_s->connection,
                                                        VPNSVC_DBUS_SERVICE_NAME,
                                                        VPNSVC_DBUS_INTERFACE_OBJ_NAME,
                                                        VPNSVC_DBUS_INTERFACE_NAME,
                                                        "vpn_init",
-                                                       g_variant_new("(su)", tun_name, strlen(tun_name)),
-                                                       tun_fd,
+                                                       g_variant_new("(su)", if_name, strlen(if_name)),
+                                                       if_fd,
                                                        &dbus_result);
 
        if (op == NULL) {
-               close(tun_fd);
+               close(if_fd);
                _vpnsvc_deinit_vpnsvc_tun_s(tmp_s);
                return VPNSVC_ERROR_IPC_FAILED;
        } else {
@@ -305,10 +310,10 @@ int vpnsvc_init(const char* tun_name, vpnsvc_tun_h *handle)
                        result = VPNSVC_ERROR_IPC_FAILED;
                } else {
                        LOGD("vpnsvc_init() succeed");
-                       tmp_s->fd = tun_fd;     /* client fd must be set */
+                       tmp_s->fd = if_fd;      /* client fd must be set */
                        tmp_s->index = tmp_index;
-                       strncpy(tmp_s->name, tmp_name, VPNSVC_TUN_IF_NAME_LEN);
-                       tmp_s->name[VPNSVC_TUN_IF_NAME_LEN-1] = '\0';
+                       strncpy(tmp_s->name, tmp_name, VPNSVC_VPN_IF_NAME_LEN);
+                       tmp_s->name[VPNSVC_VPN_IF_NAME_LEN-1] = '\0';
                        *handle = tmp_s;
                        LOGD("handle : %p, handle->fd : %d, handle->index : %d, handle->name : %s",
                                (*handle), ((vpnsvc_tun_s*)*handle)->fd, ((vpnsvc_tun_s*)*handle)->index, ((vpnsvc_tun_s*)*handle)->name);
@@ -322,7 +327,7 @@ int vpnsvc_init(const char* tun_name, vpnsvc_tun_h *handle)
        return result;
 }
 
-int vpnsvc_deinit(vpnsvc_tun_h handle)
+EXPORT_API int vpnsvc_deinit(vpnsvc_h handle)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -337,7 +342,7 @@ int vpnsvc_deinit(vpnsvc_tun_h handle)
        }
        tun_s = (vpnsvc_tun_s*)handle;
 
-       LOGD("enter vpnsvc_deinit, tun_fd : %d", tun_s->fd);
+       LOGD("enter vpnsvc_deinit, if_fd : %d", tun_s->fd);
 
        if (tun_s->fd > 0) {
                op = _vpnsvc_invoke_dbus_method(tun_s->connection,
@@ -371,7 +376,7 @@ int vpnsvc_deinit(vpnsvc_tun_h handle)
        return result;
 }
 
-int vpnsvc_protect(vpnsvc_tun_h handle, int socket_fd, const char* dev_name)
+EXPORT_API int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_name)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -417,7 +422,7 @@ int vpnsvc_protect(vpnsvc_tun_h handle, int socket_fd, const char* dev_name)
        return result;
 }
 
-int vpnsvc_up(vpnsvc_tun_h handle, const char* local_ip, const char* remote_ip,
+EXPORT_API int vpnsvc_up(vpnsvc_h handle, const char* local_ip, const char* remote_ip,
                                const char* dest[], int prefix[], size_t nr_routes,
                                const char** dns_servers, size_t nr_dns_servers,
                                const char* dns_suffix)
@@ -454,7 +459,7 @@ int vpnsvc_up(vpnsvc_tun_h handle, const char* local_ip, const char* remote_ip,
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("tun_index %d", tun_s->index);
+       LOGD("if_index %d", tun_s->index);
        LOGD("local_ip : %s, remote_ip : %s", local_ip, remote_ip);
 
        /* make a route parameter */
@@ -507,7 +512,7 @@ int vpnsvc_up(vpnsvc_tun_h handle, const char* local_ip, const char* remote_ip,
        return result;
 }
 
-int vpnsvc_down(vpnsvc_tun_h handle)
+EXPORT_API int vpnsvc_down(vpnsvc_h handle)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -558,7 +563,7 @@ int vpnsvc_down(vpnsvc_tun_h handle)
 }
 
 /* this API must not be use IPC */
-int vpnsvc_read(vpnsvc_tun_h handle, int timeout_ms)
+EXPORT_API int vpnsvc_read(vpnsvc_h handle, int timeout_ms)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -600,7 +605,7 @@ int vpnsvc_read(vpnsvc_tun_h handle, int timeout_ms)
 }
 
 /* this API must not be use IPC */
-int vpnsvc_write(vpnsvc_tun_h handle, const char* data, size_t size)
+EXPORT_API int vpnsvc_write(vpnsvc_h handle, const char* data, size_t size)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -622,7 +627,7 @@ int vpnsvc_write(vpnsvc_tun_h handle, const char* data, size_t size)
 }
 
 
-int vpnsvc_block_networks(vpnsvc_tun_h handle,
+EXPORT_API int vpnsvc_block_networks(vpnsvc_h handle,
                const char* dest_vpn[],
                int prefix_vpn[],
                size_t nr_allow_routes_vpn,
@@ -694,7 +699,7 @@ int vpnsvc_block_networks(vpnsvc_tun_h handle,
        return result;
 }
 
-int vpnsvc_unblock_networks(vpnsvc_tun_h handle)
+EXPORT_API int vpnsvc_unblock_networks(vpnsvc_h handle)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -740,14 +745,14 @@ int vpnsvc_unblock_networks(vpnsvc_tun_h handle)
        return result;
 }
 
-int vpnsvc_get_tun_fd(vpnsvc_tun_h handle, int* tun_fd)
+EXPORT_API int vpnsvc_get_if_fd(vpnsvc_h handle, int* if_fd)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        vpnsvc_tun_s *tun_s = NULL;
 
        /* parameter check */
-       if (handle == NULL || tun_fd == NULL) {
+       if (handle == NULL || if_fd == NULL) {
                LOGE("Invalid parameter");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
@@ -758,19 +763,19 @@ int vpnsvc_get_tun_fd(vpnsvc_tun_h handle, int* tun_fd)
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       *tun_fd = (int)(tun_s->fd);
+       *if_fd = (int)(tun_s->fd);
 
        return VPNSVC_ERROR_NONE;
 }
 
-int vpnsvc_get_tun_index(vpnsvc_tun_h handle, int* tun_index)
+EXPORT_API int vpnsvc_get_if_index(vpnsvc_h handle, int* if_index)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        vpnsvc_tun_s *tun_s = NULL;
 
        /* parameter check */
-       if (handle == NULL || tun_index == NULL) {
+       if (handle == NULL || if_index == NULL) {
                LOGE("Invalid parameter");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
@@ -782,17 +787,17 @@ int vpnsvc_get_tun_index(vpnsvc_tun_h handle, int* tun_index)
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       *tun_index = (int)(tun_s->index);
+       *if_index = (int)(tun_s->index);
 
        return VPNSVC_ERROR_NONE;
 }
 
-int vpnsvc_get_tun_name(vpnsvc_tun_h handle, char** tun_name)
+EXPORT_API int vpnsvc_get_if_name(vpnsvc_h handle, char** if_name)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        vpnsvc_tun_s *tun_s = NULL;
-       char la_tun_name[VPNSVC_TUN_IF_NAME_LEN + 1] = { 0, };
+       char la_if_name[VPNSVC_VPN_IF_NAME_LEN + 1] = { 0, };
 
        /* parameter check */
        if (handle == NULL) {
@@ -806,18 +811,18 @@ int vpnsvc_get_tun_name(vpnsvc_tun_h handle, char** tun_name)
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       if (tun_name == NULL) {
+       if (if_name == NULL) {
                LOGE("tun name string is NULL");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       g_strlcpy(la_tun_name, tun_s->name, VPNSVC_TUN_IF_NAME_LEN + 1);
-       *tun_name = g_strdup(la_tun_name);
+       g_strlcpy(la_if_name, tun_s->name, VPNSVC_VPN_IF_NAME_LEN + 1);
+       *if_name = g_strdup(la_if_name);
 
        return VPNSVC_ERROR_NONE;
 }
 
-int vpnsvc_set_mtu(vpnsvc_tun_h handle, int mtu)
+EXPORT_API int vpnsvc_set_mtu(vpnsvc_h handle, int mtu)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -839,7 +844,7 @@ int vpnsvc_set_mtu(vpnsvc_tun_h handle, int mtu)
        return VPNSVC_ERROR_NONE;
 }
 
-int vpnsvc_set_blocking(vpnsvc_tun_h handle, bool blocking)
+EXPORT_API int vpnsvc_set_blocking(vpnsvc_h handle, bool blocking)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -877,7 +882,7 @@ int vpnsvc_set_blocking(vpnsvc_tun_h handle, bool blocking)
        return VPNSVC_ERROR_NONE;
 }
 
-int vpnsvc_set_session(vpnsvc_tun_h handle, const char* session)
+EXPORT_API int vpnsvc_set_session(vpnsvc_h handle, const char* session)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -901,7 +906,7 @@ int vpnsvc_set_session(vpnsvc_tun_h handle, const char* session)
        return VPNSVC_ERROR_NONE;
 }
 
-int vpnsvc_get_session(vpnsvc_tun_h handle, char** session)
+EXPORT_API int vpnsvc_get_session(vpnsvc_h handle, char** session)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
diff --git a/include/tizen_vpn_error.h b/include/tizen_vpn_error.h
deleted file mode 100755 (executable)
index bbd32e4..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * 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.
- */
-
-
-#ifndef __TIZEN_COMMON_VPN_ERROR_H__
-#define __TIZEN_COMMON_VPN_ERROR_H__
-
-#include <errno.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup CAPI_COMMON_VPN_ERROR Common VPN Error
- * @brief This file provides error codes that are common for the whole TIZEN VPN API.
- * @section CAPI_COMMON_VPN_ERROR_HEADER Required Header
- *   \#include <tizen_vpn_error.h>
- * @ingroup CAPI_COMMON_ERROR
- * @{
- */
-
-#define TIZEN_ERROR_MIN_VPN_ERROR (-268435456) /* = -268435455(0x0FFFFFFF) -1 */
-
-/* Check if slp error or not */
-#define TIZEN_ERROR_IS_VPN_ERROR(x) (TIZEN_ERROR_MIN_VPN_ERROR >= (x) && (x) < 0)
-
-/* Tizen VPN Service Error */
-#define TIZEN_ERROR_VPNSVC             -0x10000000
-
-/**
- * @}
- */
-#ifdef __cplusplus
-}
-#endif
-
-#endif         /**<__TIZEN_COMMON_VPN_ERROR_H__ */
index 5374e51..31a248b 100755 (executable)
 #ifndef __TIZEN_VPN_SERVICE_H__
 #define __TIZEN_VPN_SERVICE_H__
 
-/**
- * @file vpn_service.h
- */
-
-/**
-  *@defgroup VPNSVC_FRAMEWORK VPN_SERVICE
-  *@brief The VPN service APIs to manage VPN features such as VPN device (TUN interface) initialization, routing management, DNS management and firewall management.
-  *@section VPNSVC_FRAMEWORK_OVERVIEW Overview
-  * <table>
-  * <tr><th>API</th><th>Description></th></tr>
-  * <tr><td> @ref VPNSVC_FRAMEWORK</td>
-  *       <td> Provides functions to vpnsvc_init/vpnsvc_deinit/vpnsvc_protect/vpnsvc_up/vpnsvc_down/vpnsvc_read/vpnsvc_write/vpnsvc_block_networks/vpnsvc_unblock_networks.</td>
-  * </tr></table>
-  **/
-
-/**
- * @addtogroup CAPI_NETWORK_VPN_MODULE
- * @{
- */
-
 #include <tizen.h>
-#include <tizen_vpn_error.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif // __cplusplus
 
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "CAPI_VPNSVC"
+/**
+ * @file vpn_service.h
+ */
 
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
+/**
+ * @addtogroup CAPI_NETWORK_VPN_SERVICE_MODULE
+ * @{
+ */
 
 /**
   * @brief IPv4 address string length (includes end null character).
@@ -60,10 +39,10 @@ extern "C" {
 #define VPNSVC_IP4_STRING_LEN 16
 
 /**
-  * @brief TUN interface name length.
+  * @brief VPN interface name length.
   * @since_tizen 3.0
   */
-#define VPNSVC_TUN_IF_NAME_LEN 16
+#define VPNSVC_VPN_IF_NAME_LEN 16
 
 /**
   * @brief Session name string length (includes end null character).
@@ -71,10 +50,6 @@ extern "C" {
   */
 #define VPNSVC_SESSION_STRING_LEN 32
 
-#ifndef TIZEN_ERROR_VPNSVC
-#define TIZEN_ERROR_VPNSVC -0x03200000
-#endif
-
 /**
   * @brief   Enumeration for VPN service error types.
   * @details Indicate formats of error type field
@@ -94,23 +69,24 @@ typedef enum
 
 
 /**
-  * @brief   The VPN tun interface handle.
+  * @brief   The VPN interface handle.
   * @details This handle can be obtained by calling vpnsvc_init() and destroyed by calling vpnsvc_deinit().
   * @since_tizen 3.0
   * @see vpnsvc_init()
   * @see vpnsvc_deinit()
   */
-typedef void* vpnsvc_tun_h;
+typedef void* vpnsvc_h;
 
 /**
- * @brief  Initializes TUN interface.
- * @detail You should call vpnsvc_get_tun_name() for checking the actual initialized TUN interface name. (In case of duplicated interface name)
+ * @brief  Initializes VPN interface.
+ * @detail You should call vpnsvc_get_if_name() for checking the actual initialized VPN interface name. (In case of duplicated interface name)
  * @since_tizen 3.0
  * @privlevel public
- * @privilege %http://tizen.org/privilege/vpnservice
+ * @privilege %http://tizen.org/privilege/vpnservice \n
+ *            %http://tizen.org/privilege/internet
  * @remarks The @a handle should be released using vpnsvc_deinit().
- * @param[in] tun_name The interface name
- * @param[out] handle  The VPN tun interface handle
+ * @param[in] if_name The VPN interface name
+ * @param[out] handle  The VPN interface handle
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
@@ -118,38 +94,38 @@ typedef void* vpnsvc_tun_h;
  * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
  * @retval #VPNSVC_ERROR_PERMISSION_DENIED     Permission Denied
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @post Please call vpnsvc_deinit() if you want to de-initialize VPN tun interface.
- * @post Please call vpnsvc_get_tun_fd() if you want to know the fd of tun interface.
- * @post Please call vpnsvc_get_tun_index() if you want to know the fd of tun interface index.
- * @post Please call vpnsvc_get_tun_name() if you want to know the name of tun interface.
+ * @post Please call vpnsvc_deinit() if you want to de-initialize VPN interface.
+ * @post Please call vpnsvc_get_if_fd() if you want to know the fd of VPN interface.
+ * @post Please call vpnsvc_get_if_index() if you want to know the fd of VPN interface index.
+ * @post Please call vpnsvc_get_if_name() if you want to know the name of VPN interface.
  * @see vpnsvc_deinit()
- * @see vpnsvc_get_tun_fd()
- * @see vpnsvc_get_tun_index()
- * @see vpnsvc_get_tun_name()
+ * @see vpnsvc_get_if_fd()
+ * @see vpnsvc_get_if_index()
+ * @see vpnsvc_get_if_name()
  */
-API int vpnsvc_init(const char* tun_name, vpnsvc_tun_h *handle);
+int vpnsvc_init(const char* if_name, vpnsvc_h *handle);
 
 /**
- * @brief De-Initializes TUN interface.
+ * @brief De-Initializes VPN interface.
  * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
+ * @param[in] handle The VPN interface handle
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_deinit(vpnsvc_tun_h handle);
+int vpnsvc_deinit(vpnsvc_h handle);
 
 /**
  * @brief Protect a socket from VPN connections.
  * @details After protecting, data sent through this socket will go directly to the underlying network.
  * @since_tizen 3.0
- * @param[in] handle    The VPN tun interface handle
+ * @param[in] handle    The VPN interface handle
  * @param[in] socket_fd The opened socket file descriptor
- * @param[in] dev_name  The network interface name (i.e. eth0 or ppp0, not to confuse with tunXXX) through which the VPN is working
+ * @param[in] dev_name  The network interface name (e.g., interface name such as eth0, ppp0, etc) through which the VPN is working
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
@@ -157,55 +133,12 @@ API int vpnsvc_deinit(vpnsvc_tun_h handle);
  * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
  */
-API int vpnsvc_protect(vpnsvc_tun_h handle, int socket_fd, const char* dev_name);
+int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_name);
 
 /**
- * @brief Sets-up TUN interface and brings it up. Installs specified routes/DNS servers/DNS suffix.
+ * @brief Reads the data event on VPN interface descriptor.
  * @since_tizen 3.0
- * @param[in] handle         The VPN tun interface handle
- * @param[in] local_ip       The local IP address
- * @param[in] remote_ip      The remote IP address
- * @param[in] dest           Destination address of the route
- * @param[in] prefix         The prefix of route
- * @param[in] nr_routes      The number of routes
- * @param[in] dns_servers    The list of DNS server names - Optional
- * @param[in] nr_dns_servers The number of DNS server names - Optionl
- * @param[in] dns_suffix     The DNS suffix - Optional
- * @return 0 on success. otherwise, a negative error value.
- * @retval #VPNSVC_ERROR_NONE                  Success
- * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
- * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
- * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre The VPN tun interface should be initialized already.
- * @post If you want to set interface down, please call vpnsvc_down().
- * @see vpnsvc_init()
- * @see vpnsvc_down()
- */
-API int vpnsvc_up(vpnsvc_tun_h handle, const char* local_ip, const char* remote_ip,
-                               const char *dest[], int prefix[], size_t nr_routes,
-                               const char** dns_servers, size_t nr_dns_servers,
-                               const char* dns_suffix);
-
-/**
- * @brief Brings the TUN interface down and restores original DNS servers/domains.
- * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
- * @return 0 on success. otherwise, a negative error value.
- * @retval #VPNSVC_ERROR_NONE                  Success
- * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
- * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
- * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre The VPN tun interface should be initialized already.
- * @post Please call vpnsvc_deinit() if you want to de-initialize VPN tun interface.
- * @see vpnsvc_up()
- * @see vpnsvc_deinit()
- */
-API int vpnsvc_down(vpnsvc_tun_h handle);
-
-/**
- * @brief Reads the data event on TUN descriptor.
- * @since_tizen 3.0
- * @param[in] handle      The VPN tun interface handle
+ * @param[in] handle      The VPN interface handle
  * @param[in] timeout_ms  The value of timeout (milliseconds)
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
@@ -215,15 +148,14 @@ API int vpnsvc_down(vpnsvc_tun_h handle);
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
  * @pre The VPN interface should be initialized already.
  * @see vpnsvc_init()
- * @see vpnsvc_up()
  */
-API int vpnsvc_read(vpnsvc_tun_h handle, int timeout_ms);
+int vpnsvc_read(vpnsvc_h handle, int timeout_ms);
 
 /**
- * @brief Writes the data supplied into the TUN interface.
+ * @brief Writes the data supplied into the VPN interface.
  * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
- * @param[in] data   Data writing to tun interface
+ * @param[in] handle The VPN interface handle
+ * @param[in] data   Data writing to VPN interface
  * @param[in] size   The size of data
  * @return On success, the number of bytes written is returned (zero indicates nothing was written). Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
@@ -232,19 +164,18 @@ API int vpnsvc_read(vpnsvc_tun_h handle, int timeout_ms);
  * @retval In case of negative error, please refer to standard posix write API's error code.
  * @pre The VPN interface should be initialized already.
  * @see vpnsvc_init()
- * @see vpnsvc_up()
  */
-API int vpnsvc_write(vpnsvc_tun_h handle, const char* data, size_t size);
+int vpnsvc_write(vpnsvc_h handle, const char* data, size_t size);
 
 /**
  * @brief Blocks all traffics except specified allowing networks.
  * @since_tizen 3.0
- * @param[in] handle                  The VPN tun interface handle
+ * @param[in] handle                  The VPN interface handle
  * @param[in] dest_vpn               Allowing networks over VPN interface.
- * @param[in] prefix_vpn             The prefix of VPN interface
+ * @param[in] prefix_vpn              The prefix of VPN interface, netmask length (also called a prefix).
  * @param[in] nr_allow_routes_vpn     The number of allowing networks over VPN interface
  * @param[in] dest_orig              Allowing networks over the original interface.
- * @param[in] prefix_orig            The prefix of Original interface.
+ * @param[in] prefix_orig             The prefix of Original interface, netmask length (also called a prefix).
  * @param[in] nr_allow_routes_orig    The number of allowing networks over the original interface
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
@@ -254,7 +185,7 @@ API int vpnsvc_write(vpnsvc_tun_h handle, const char* data, size_t size);
  * @post Please call vpnsvc_unblock_networks() if you want to allow all traffics.
  * @see vpnsvc_unblock_networks()
  */
-API int vpnsvc_block_networks(vpnsvc_tun_h handle,
+int vpnsvc_block_networks(vpnsvc_h handle,
                const char *dest_vpn[],
                int prefix_vpn[],
                size_t nr_allow_routes_vpn,
@@ -265,120 +196,120 @@ API int vpnsvc_block_networks(vpnsvc_tun_h handle,
 /**
  * @brief Removes any restrictions imposed by vpnsvc_block_networks().
  * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
+ * @param[in] handle The VPN interface handle
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
  */
-API int vpnsvc_unblock_networks(vpnsvc_tun_h handle);
+int vpnsvc_unblock_networks(vpnsvc_h handle);
 
 /**
- * @brief Gets the fd of the VPN tun interface.
+ * @brief Gets the fd of the VPN interface.
  * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
- * @param[out] tun_fd The tun fd
- * @return The fd value of VPN tun interface. Otherwise, a negative error value.
+ * @param[in] handle The VPN interface handle
+ * @param[out] if_fd The vpn interface fd
+ * @return The fd value of VPN interface. Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
  */
-API int vpnsvc_get_tun_fd(vpnsvc_tun_h handle, int* tun_fd);
+int vpnsvc_get_if_fd(vpnsvc_h handle, int* if_fd);
 
 /**
- * @brief Gets the index of VPN tun interface.
+ * @brief Gets the index of VPN interface.
  * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
- * @param[out] tun_index The tun index
- * @return The index of the VPN tun interface. otherwise, a negative error value.
+ * @param[in] handle The VPN interface handle
+ * @param[out] if_index The VPN interface index
+ * @return The index of the VPN interface. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_get_tun_index(vpnsvc_tun_h handle, int* tun_index);
+int vpnsvc_get_if_index(vpnsvc_h handle, int* if_index);
 
 /**
- * @brief Gets the name of VPN tun interface.
+ * @brief Gets the name of VPN interface.
  * @since_tizen 3.0
- * @remarks The @a tun_name should be released using free()
- * @param[in] handle    The VPN tun interface handle
- * @param[out] tun_name The name of VPN tun interface name
+ * @remarks The @a if_name should be released using free()
+ * @param[in] handle    The VPN interface handle
+ * @param[out] if_name The name of VPN interface name
  * @return 0 on success. Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_get_tun_name(vpnsvc_tun_h handle, char** tun_name);
+int vpnsvc_get_if_name(vpnsvc_h handle, char** if_name);
 
 /**
- * @brief Sets the MTU of the VPN tun interface.
+ * @brief Sets the MTU of the VPN interface.
  * @since_tizen 3.0
- * @param[in] handle The VPN tun interface handle
- * @param[in] mtu    The MTU (Maximum Transmission Unit) value to be set for VPN tun interface. Default MTU size is 1500.
+ * @param[in] handle The VPN interface handle
+ * @param[in] mtu    The MTU (Maximum Transmission Unit) value to be set for VPN interface. Default MTU size is 1500.
  * @return 0 on success. Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_set_mtu(vpnsvc_tun_h handle, int mtu);
+int vpnsvc_set_mtu(vpnsvc_h handle, int mtu);
 
 /**
- * @brief Sets blocking mode of the file descriptor of VPN tun interface.
+ * @brief Sets blocking mode of the file descriptor of VPN interface.
  * @since_tizen 3.0
- * @param[in] handle    The VPN tun interface handle
- * @param[in] blocking  The blocking mode flag; True = BLOCKING, False = NON_BLOCKING
+ * @param[in] handle    The VPN interface handle
+ * @param[in] blocking  The blocking mode flag; True = BLOCKING, False = NON_BLOCKING (Default : BLOCKING)
  * @return 0 on success. Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_IO_ERROR              Failed to set the blocking flags
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_set_blocking(vpnsvc_tun_h handle, bool blocking);
+int vpnsvc_set_blocking(vpnsvc_h handle, bool blocking);
 
 /**
- * @brief Sets the session name for the VPN.
+ * @brief Sets the session name for the VPN. (It will be displayed in system-managed dialogs and notifications.)
  * @since_tizen 3.0
- * @param[in] handle       The VPN tun interface handle
+ * @param[in] handle       The VPN interface handle
  * @param[in] session      The Session Name
  * @return 0 on success. Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_set_session(vpnsvc_tun_h handle, const char* session);
+int vpnsvc_set_session(vpnsvc_h handle, const char* session);
 
 /**
  * @brief Gets the session name for the VPN.
  * @since_tizen 3.0
  * @remarks The @a session should be released using free()
- * @param[in] handle   The VPN tun interface handle
+ * @param[in] handle   The VPN interface handle
  * @param[out] session The Session Name returned
  * @return 0 on success. Otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
- * @pre Before calling this function, VPN tun interface should be initialized already.
+ * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-API int vpnsvc_get_session(vpnsvc_tun_h handle, char** session);
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
+int vpnsvc_get_session(vpnsvc_h handle, char** session);
 
 /**
 * @}
 */
 
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
 #endif /* __TIZEN_CAPI_VPN_SERVICE_H__ */
diff --git a/include/vpn_service_internal.h b/include/vpn_service_internal.h
new file mode 100755 (executable)
index 0000000..9df6386
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+opyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* 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.
+*/
+
+#ifndef __TIZEN_VPN_SERVICE_INTERNAL_H__
+#define __TIZEN_VPN_SERVICE_INTERNAL_H__
+
+/**
+ * @addtogroup CAPI_NETWORK_VPN_MODULE
+ * @{
+ */
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+/**
+ * @file vpn_service_internal.h
+ */
+
+/**
+ * @internal
+ * @brief Sets-up TUN interface and brings it up. Installs specified routes/DNS servers/DNS suffix.
+ * @since_tizen 3.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/vpnservice.admin
+ * @param[in] handle         The VPN tun interface handle
+ * @param[in] local_ip       The local IP address
+ * @param[in] remote_ip      The remote IP address
+ * @param[in] dest           Destination address of the route
+ * @param[in] prefix         The prefix of route
+ * @param[in] nr_routes      The number of routes
+ * @param[in] dns_servers    The list of DNS server names - Optional
+ * @param[in] nr_dns_servers The number of DNS server names - Optionl
+ * @param[in] dns_suffix     The DNS suffix - Optional
+ * @return 0 on success. otherwise, a negative error value.
+ * @retval #VPNSVC_ERROR_NONE                  Success
+ * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
+ * @retval #VPNSVC_ERROR_PERMISSION_DENIED     Permission Denied
+ * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
+ * @pre The VPN tun interface should be initialized already.
+ * @post If you want to set interface down, please call vpnsvc_down().
+ * @see vpnsvc_init()
+ * @see vpnsvc_down()
+ */
+int vpnsvc_up(vpnsvc_h handle, const char* local_ip, const char* remote_ip,
+                               const char *dest[], int prefix[], size_t nr_routes,
+                               const char** dns_servers, size_t nr_dns_servers,
+                               const char* dns_suffix);
+
+/**
+ * @internal
+ * @brief Brings the TUN interface down and restores original DNS servers/domains.
+ * @since_tizen 3.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/vpnservice.admin
+ * @param[in] handle The VPN tun interface handle
+ * @return 0 on success. otherwise, a negative error value.
+ * @retval #VPNSVC_ERROR_NONE                  Success
+ * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
+ * @retval #VPNSVC_ERROR_PERMISSION_DENIED     Permission Denied
+ * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
+ * @pre The VPN tun interface should be initialized already.
+ * @post Please call vpnsvc_deinit() if you want to de-initialize VPN tun interface.
+ * @see vpnsvc_up()
+ * @see vpnsvc_deinit()
+ */
+int vpnsvc_down(vpnsvc_h handle);
+
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+/**
+* @}
+*/
+
+#endif /* __TIZEN_CAPI_VPN_SERVICE_H__ */
+
+
+
+
+
index 10354cb..ac29509 100755 (executable)
@@ -38,7 +38,7 @@
                perror("fgets() failed!!!");\
        } while (0);
 
-vpnsvc_tun_h handle = NULL;
+vpnsvc_h handle = NULL;
 
 int test_vpnsvc_init()
 {
@@ -56,19 +56,19 @@ int test_vpnsvc_init()
                char* result_name = NULL;
                printf("vpnsvc_init Succeed : %d\n", ret);
 
-               if (vpnsvc_get_tun_fd(handle, &int_value) == VPNSVC_ERROR_NONE)
-                       printf("tun_fd : %d\n", int_value);
+               if (vpnsvc_get_if_fd(handle, &int_value) == VPNSVC_ERROR_NONE)
+                       printf("if_fd : %d\n", int_value);
                else
-                       printf("Fail to get tun_fd\n");
+                       printf("Fail to get if_fd\n");
 
-               if (vpnsvc_get_tun_index(handle, &int_value) == VPNSVC_ERROR_NONE)
-                       printf("tun_index : %d\n", int_value);
+               if (vpnsvc_get_if_index(handle, &int_value) == VPNSVC_ERROR_NONE)
+                       printf("if_index : %d\n", int_value);
                else
-                       printf("Fail to get tun_index\n");
+                       printf("Fail to get if_index\n");
 
-               ret = vpnsvc_get_tun_name(handle, &result_name);
+               ret = vpnsvc_get_if_name(handle, &result_name);
                if (ret == VPNSVC_ERROR_NONE)
-                       printf("tun_name : %s\n", result_name);
+                       printf("if_name : %s\n", result_name);
        }
 
        return 0;