[TE-132] Modified comments of SE review 41/58841/2 submit/tizen/20160211.020959
authortaesub.kim <taesub.kim@samsung.com>
Thu, 4 Feb 2016 02:28:47 +0000 (11:28 +0900)
committertaesub.kim <taesub.kim@samsung.com>
Thu, 4 Feb 2016 06:07:40 +0000 (15:07 +0900)
Change-Id: I2aebaadebc66f970e6bf0d1489382ac2473b3ed5
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
daemon/include/vpn_service_daemon.h
daemon/interfaces/org.tizen.vpnsvc.xml
daemon/src/vpn_service_daemon.c
daemon/src/vpnsvc.c
framework/include/capi_vpn_service_private.h
framework/src/capi_vpn_service.c
include/vpn_service.h
include/vpn_service_internal.h
test/vpn_service_test.c

index b55e71c..211e72c 100755 (executable)
 
 #include "capi_vpn_service_private.h"
 
-int vpn_daemon_init(const char* if_name, size_t if_name_len, int fd, vpnsvc_tun_s *handle_s);
+int vpn_daemon_init(const char* iface_name, size_t iface_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 if_index, const char* local_ip, const char* remote_ip,
+int vpn_daemon_up(int iface_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 if_index);
+int vpn_daemon_down(int iface_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 8349623..4bcc50f 100755 (executable)
@@ -1,8 +1,8 @@
 <node name='/org/tizen/vpnsvc'>
        <interface name='org.tizen.vpnsvc'>
                <method name='vpn_init'>
-                       <arg type='s' name='if_name' direction='in'/>
-                       <arg type='u' name='if_name_len' direction='in'/>
+                       <arg type='s' name='iface_name' direction='in'/>
+                       <arg type='u' name='iface_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='if_index' direction='in'/>
+                       <arg type='i' name='iface_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='if_index' direction='in'/>
+                       <arg type='i' name='iface_index' direction='in'/>
                        <arg type='i' name='result' direction='out'/>
                </method>
                <method name='vpn_block_networks'>
index 94cc958..bf205b9 100755 (executable)
@@ -82,7 +82,7 @@ static in_addr_t host2net(ipv4 host)
        return net;
 }
 
-static int add_routes(char* if_name, const char* routes[], int prefix[], size_t nr_routes)
+static int add_routes(char* iface_name, const char* routes[], int prefix[], size_t nr_routes)
 {
        struct rtentry rt;
        struct sockaddr_in addr;
@@ -118,7 +118,7 @@ static int add_routes(char* if_name, const char* routes[], int prefix[], size_t
                addr.sin_addr.s_addr = host2net(make_mask(prefix[i]));
                memcpy(&rt.rt_genmask, &addr, sizeof(rt.rt_genmask));
 
-               rt.rt_dev = if_name;
+               rt.rt_dev = iface_name;
 
                if (ioctl(sk, SIOCADDRT, &rt) < 0) {
                        LOGE("ioctl SIOCADDRT failed : %s", strerror(errno));
@@ -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 *if_name)
+static int get_interface_index(const char *iface_name)
 {
        struct ifreq ifr;
        int sk = 0;
 
-       LOGD("enter get_interface_index, if_name : %s", if_name);
+       LOGD("enter get_interface_index, iface_name : %s", iface_name);
 
        sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
        if (sk < 0) {
@@ -624,8 +624,8 @@ static int get_interface_index(const char *if_name)
 
        memset(&ifr, 0, sizeof(ifr));
 
-       if (*if_name)
-       strncpy(ifr.ifr_name, if_name, strlen(if_name));
+       if (*iface_name)
+       strncpy(ifr.ifr_name, iface_name, strlen(iface_name));
 
        /* get an interface name by ifindex */
        if (ioctl(sk, SIOCGIFINDEX, &ifr) < 0) {
@@ -640,12 +640,12 @@ static int get_interface_index(const char *if_name)
 }
 
 
-int vpn_daemon_init(const char* if_name, size_t if_name_len, int fd, vpnsvc_tun_s *handle_s)
+int vpn_daemon_init(const char* iface_name, size_t iface_name_len, int fd, vpnsvc_tun_s *handle_s)
 {
        struct ifreq ifr;
        size_t len = 0;
 
-       LOGD("enter vpn_daemon_init, if_name : %s, if_name_len : %d, fd : %d\n", if_name, if_name_len, fd);
+       LOGD("enter vpn_daemon_init, iface_name : %s, iface_name_len : %d, fd : %d\n", iface_name, iface_name_len, fd);
 
        memset(&ifr, 0, sizeof(ifr));
 
@@ -657,8 +657,8 @@ int vpn_daemon_init(const char* if_name, size_t if_name_len, int fd, vpnsvc_tun_
 
        ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
 
-       if (*if_name)
-               strncpy(ifr.ifr_name, if_name, if_name_len);
+       if (*iface_name)
+               strncpy(ifr.ifr_name, iface_name, iface_name_len);
 
        LOGD("before init, ifindex : %d", ifr.ifr_ifindex);
 
@@ -681,7 +681,7 @@ int vpn_daemon_init(const char* if_name, size_t if_name_len, int fd, vpnsvc_tun_
        }
 
        handle_s->fd = 0;   /* server fd does not meaning */
-       handle_s->index = get_interface_index(if_name);
+       handle_s->index = get_interface_index(iface_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 if_index, const char* local_ip, const char* remote_ip,
+int vpn_daemon_up(int iface_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 if_index, const char* local_ip, const char* remote_ip,
 
        LOGD("enter vpn_daemon_up");
 
-       LOGD("if_index : %d", if_index);
+       LOGD("iface_index : %d", iface_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 if_index, const char* local_ip, const char* remote_ip,
        }
 
        memset(&ifr_tun, 0, sizeof(ifr_tun));
-       ifr_tun.ifr_ifindex = if_index;
+       ifr_tun.ifr_ifindex = iface_index;
 
        /* get an interface name by ifindex */
        if (ioctl(sk, SIOCGIFNAME, &ifr_tun) < 0) {
@@ -845,7 +845,7 @@ int vpn_daemon_up(int if_index, const char* local_ip, const char* remote_ip,
        return ret;
 }
 
-int vpn_daemon_down(int if_index)
+int vpn_daemon_down(int iface_index)
 {
        struct ifreq ifr, addr_ifr;
        struct sockaddr_in *addr = NULL;
@@ -858,7 +858,7 @@ int vpn_daemon_down(int if_index)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       ifr.ifr_ifindex = if_index;
+       ifr.ifr_ifindex = iface_index;
 
        if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
                LOGE("ioctl SIOCGIFNAME failed : %s", strerror(errno));
index e97d65b..4df05ae 100755 (executable)
@@ -38,8 +38,8 @@ static Vpnsvc *vpnsvc = NULL;
  ********************/
 gboolean handle_vpn_init(Vpnsvc *object,
                                                                GDBusMethodInvocation *invocation,
-                                                               const gchar *arg_if_name,
-                                                               guint arg_if_name_len)
+                                                               const gchar *arg_iface_name,
+                                                               guint arg_iface_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_if_name, arg_if_name_len);
+       LOGD("vpn_init, %s, %u\n", arg_iface_name, arg_iface_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_if_name, arg_if_name_len, *fds, &handle_s);
+       result = vpn_daemon_init(arg_iface_name, arg_iface_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_if_index,
+                                                               gint arg_iface_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("if_index : %d", arg_if_index);
+       LOGD("iface_index : %d", arg_iface_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_if_index, arg_local_ip, arg_remote_ip,
+       result = vpn_daemon_up(arg_iface_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_if_index)
+                                                                       gint arg_iface_index)
 {
        LOGD("handle_vpn_down");
        int result = VPNSVC_ERROR_NONE;
 
-       LOGD("vpn_down, %d\n", arg_if_index);
+       LOGD("vpn_down, %d\n", arg_iface_index);
 
-       result = vpn_daemon_down(arg_if_index);
+       result = vpn_daemon_down(arg_iface_index);
 
        vpnsvc_complete_vpn_down(object, invocation, result);
 
index 9b74d77..c949fca 100755 (executable)
@@ -69,8 +69,8 @@ extern "C" {
 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_VPN_IF_NAME_LEN];      /**< tun name (if.if_name) */
+       int index;                              /**< tun index (if.iface_index) */
+       char name[VPNSVC_VPN_IFACE_NAME_LEN];      /**< tun name (if.iface_name) */
        char session[VPNSVC_SESSION_STRING_LEN];/**< session name (user setting) */
        unsigned int mtu;                       /**< mtu (user setting) */
 } vpnsvc_tun_s;
index 1997a24..29002b8 100755 (executable)
@@ -103,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_VPN_IF_NAME_LEN);
+       memset(s->name, 0, VPNSVC_VPN_IFACE_NAME_LEN);
        memset(s->session, 0, VPNSVC_SESSION_STRING_LEN);
 
        if (s)
@@ -222,20 +222,20 @@ GVariant *_vpnsvc_invoke_dbus_method_with_fd(GDBusConnection *connection,
        return reply;
 }
 
-EXPORT_API int vpnsvc_init(const char* if_name, vpnsvc_h *handle)
+EXPORT_API int vpnsvc_init(const char* iface_name, vpnsvc_h *handle)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        int result = VPNSVC_ERROR_NONE;
        int dbus_result;
-       int if_fd = 0;
+       int iface_fd = 0;
 
-       LOGD("enter vpnsvc_init, if_name : %s", if_name);
+       LOGD("enter vpnsvc_init, iface_name : %s", iface_name);
        LOGD("handle : %p\n", handle);
 
        /* parameter check */
-       if (if_name == NULL || strlen(if_name) <= 0) {
-               LOGE("if_name is a NULL");
+       if (iface_name == NULL || strlen(iface_name) <= 0) {
+               LOGE("iface_name is a NULL");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        } else if (handle == NULL) {
                LOGE("handle is a NULL");
@@ -278,25 +278,25 @@ EXPORT_API int vpnsvc_init(const char* if_name, vpnsvc_h *handle)
                op = NULL;
        }
 
-       if ((if_fd = open("/dev/net/tun", O_RDWR)) < 0) {
+       if ((iface_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 if_fd : %d", if_fd);
+       LOGD("client iface_fd : %d", iface_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)", if_name, strlen(if_name)),
-                                                       if_fd,
+                                                       g_variant_new("(su)", iface_name, strlen(iface_name)),
+                                                       iface_fd,
                                                        &dbus_result);
 
        if (op == NULL) {
-               close(if_fd);
+               close(iface_fd);
                _vpnsvc_deinit_vpnsvc_tun_s(tmp_s);
                return VPNSVC_ERROR_IPC_FAILED;
        } else {
@@ -310,10 +310,10 @@ EXPORT_API int vpnsvc_init(const char* if_name, vpnsvc_h *handle)
                        result = VPNSVC_ERROR_IPC_FAILED;
                } else {
                        LOGD("vpnsvc_init() succeed");
-                       tmp_s->fd = if_fd;      /* client fd must be set */
+                       tmp_s->fd = iface_fd;   /* client fd must be set */
                        tmp_s->index = tmp_index;
-                       strncpy(tmp_s->name, tmp_name, VPNSVC_VPN_IF_NAME_LEN);
-                       tmp_s->name[VPNSVC_VPN_IF_NAME_LEN-1] = '\0';
+                       strncpy(tmp_s->name, tmp_name, VPNSVC_VPN_IFACE_NAME_LEN);
+                       tmp_s->name[VPNSVC_VPN_IFACE_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);
@@ -342,7 +342,7 @@ EXPORT_API int vpnsvc_deinit(vpnsvc_h handle)
        }
        tun_s = (vpnsvc_tun_s*)handle;
 
-       LOGD("enter vpnsvc_deinit, if_fd : %d", tun_s->fd);
+       LOGD("enter vpnsvc_deinit, iface_fd : %d", tun_s->fd);
 
        if (tun_s->fd > 0) {
                op = _vpnsvc_invoke_dbus_method(tun_s->connection,
@@ -376,7 +376,7 @@ EXPORT_API int vpnsvc_deinit(vpnsvc_h handle)
        return result;
 }
 
-EXPORT_API int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_name)
+EXPORT_API int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* iface_name)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
@@ -391,7 +391,7 @@ EXPORT_API int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_na
        }
        tun_s = (vpnsvc_tun_s*)handle;
 
-       LOGD("enter vpnsvc_protect, socket : %d, dev_name : %s", socket_fd, dev_name);
+       LOGD("enter vpnsvc_protect, socket : %d, dev_name : %s", socket_fd, iface_name);
 
        if (tun_s->connection == NULL) {
                LOGE("Connection Object is NULL");
@@ -404,7 +404,7 @@ EXPORT_API int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_na
                                                VPNSVC_DBUS_INTERFACE_OBJ_NAME,
                                                VPNSVC_DBUS_INTERFACE_NAME,
                                                "vpn_protect",
-                                               g_variant_new("(s)", dev_name),
+                                               g_variant_new("(s)", iface_name),
                                                socket_fd,
                                                &dbus_result);
 
@@ -423,8 +423,8 @@ EXPORT_API int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_na
 }
 
 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* routes_dest_add[], int routes_prefix[], size_t num_routes,
+                               const char** dns_servers, size_t num_dns_servers,
                                const char* dns_suffix)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
@@ -459,25 +459,25 @@ EXPORT_API int vpnsvc_up(vpnsvc_h handle, const char* local_ip, const char* remo
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("if_index %d", tun_s->index);
+       LOGD("iface_index %d", tun_s->index);
        LOGD("local_ip : %s, remote_ip : %s", local_ip, remote_ip);
 
        /* make a route parameter */
        g_variant_builder_init(&route_builder, G_VARIANT_TYPE("a{si}"));
-       for (i = 0 ; i < nr_routes ; i++) {
-               if (strlen(dest[i]) <= 0) {
+       for (i = 0 ; i < num_routes ; i++) {
+               if (strlen(routes_dest_add[i]) <= 0) {
                        LOGE("invalid dest[%d]", i);
                        return VPNSVC_ERROR_INVALID_PARAMETER;
                }
-               g_variant_builder_add(&route_builder, "{si}", dest[i], prefix[i]);
-               LOGD("dest[%d] : %s", i, dest[i]);
-               LOGD("prefix[i] : %d", i,  prefix[i]);
+               g_variant_builder_add(&route_builder, "{si}", routes_dest_add[i], routes_prefix[i]);
+               LOGD("dest[%d] : %s", i, routes_dest_add[i]);
+               LOGD("prefix[i] : %d", i,  routes_prefix[i]);
        }
        route_param = g_variant_builder_end(&route_builder);
 
        /* make a dns parameter */
        g_variant_builder_init(&dns_builder, G_VARIANT_TYPE("as"));
-       for (i = 0 ; i < nr_dns_servers ; i++) {
+       for (i = 0 ; i < num_dns_servers ; i++) {
                if (strlen(dns_servers[i]) <= 0) {
                        LOGE("invalid dns_servers[%d]", i);
                        return VPNSVC_ERROR_INVALID_PARAMETER;
@@ -495,7 +495,7 @@ EXPORT_API int vpnsvc_up(vpnsvc_h handle, const char* local_ip, const char* remo
                                                                VPNSVC_DBUS_INTERFACE_NAME,
                                                                "vpn_up",
                                                                g_variant_new("(issvuvusu)", tun_s->index, local_ip, \
-                                                               remote_ip, route_param, nr_routes, dns_param, nr_dns_servers, \
+                                                               remote_ip, route_param, num_routes, dns_param, num_dns_servers, \
                                                                dns_suffix, tun_s->mtu),
                                                                &dbus_result);
 
@@ -628,12 +628,12 @@ EXPORT_API int vpnsvc_write(vpnsvc_h handle, const char* data, size_t size)
 
 
 EXPORT_API int vpnsvc_block_networks(vpnsvc_h handle,
-               const char* dest_vpn[],
-               int prefix_vpn[],
-               size_t nr_allow_routes_vpn,
-               const char* dest_orig[],
-               int prefix_orig[],
-               size_t nr_allow_routes_orig)
+               const char* routes_dest_vpn_addr[],
+               int routes_vpn_prefix[],
+               size_t num_allow_routes_vpn,
+               const char* routes_dest_orig_addr[],
+               int routes_orig_prefix[],
+               size_t num_allow_routes_orig)
 
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
@@ -661,19 +661,19 @@ EXPORT_API int vpnsvc_block_networks(vpnsvc_h handle,
        }
        /* make a route parameter for allowed VPN interface routes */
        g_variant_builder_init(&nets_builder, G_VARIANT_TYPE("a{si}"));
-       for (i = 0 ; i < nr_allow_routes_vpn ; i++) {
-               g_variant_builder_add(&nets_builder, "{si}", dest_vpn[i], prefix_vpn[i]);
-               LOGD("dest_vpn[%d] : %s", i, dest_vpn[i]);
-               LOGD("prefix_vpn[%d] : %d", i,  prefix_vpn[i]);
+       for (i = 0 ; i < num_allow_routes_vpn ; i++) {
+               g_variant_builder_add(&nets_builder, "{si}", routes_dest_vpn_addr[i], routes_vpn_prefix[i]);
+               LOGD("dest_vpn[%d] : %s", i, routes_dest_vpn_addr[i]);
+               LOGD("prefix_vpn[%d] : %d", i,  routes_vpn_prefix[i]);
        }
        nets_param_vpn = g_variant_builder_end(&nets_builder);
 
        /* make a route parameter for allowed Original interface Routes */
        g_variant_builder_init(&nets_builder, G_VARIANT_TYPE("a{si}"));
-       for (i = 0 ; i < nr_allow_routes_orig ; i++) {
-               g_variant_builder_add(&nets_builder, "{si}", dest_orig[i], prefix_orig[i]);
-               LOGD("dest_orig[%d] : %s", i, dest_orig[i]);
-               LOGD("prefix_orig[%d] : %d", i,  prefix_orig[i]);
+       for (i = 0 ; i < num_allow_routes_orig ; i++) {
+               g_variant_builder_add(&nets_builder, "{si}", routes_dest_orig_addr[i], routes_orig_prefix[i]);
+               LOGD("dest_orig[%d] : %s", i, routes_dest_orig_addr[i]);
+               LOGD("prefix_orig[%d] : %d", i,  routes_orig_prefix[i]);
        }
        nets_param_orig = g_variant_builder_end(&nets_builder);
 
@@ -682,8 +682,8 @@ EXPORT_API int vpnsvc_block_networks(vpnsvc_h handle,
                                                                VPNSVC_DBUS_INTERFACE_OBJ_NAME,
                                                                VPNSVC_DBUS_INTERFACE_NAME,
                                                                "vpn_block_networks",
-                                                               g_variant_new("(vuvu)", nets_param_vpn, nr_allow_routes_vpn,
-                                                               nets_param_orig, nr_allow_routes_orig),
+                                                               g_variant_new("(vuvu)", nets_param_vpn, num_allow_routes_vpn,
+                                                               nets_param_orig, num_allow_routes_orig),
                                                                &dbus_result);
 
        if (op == NULL) {
@@ -745,14 +745,14 @@ EXPORT_API int vpnsvc_unblock_networks(vpnsvc_h handle)
        return result;
 }
 
-EXPORT_API int vpnsvc_get_if_fd(vpnsvc_h handle, int* if_fd)
+EXPORT_API int vpnsvc_get_iface_fd(vpnsvc_h handle, int* iface_fd)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        vpnsvc_tun_s *tun_s = NULL;
 
        /* parameter check */
-       if (handle == NULL || if_fd == NULL) {
+       if (handle == NULL || iface_fd == NULL) {
                LOGE("Invalid parameter");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
@@ -763,19 +763,19 @@ EXPORT_API int vpnsvc_get_if_fd(vpnsvc_h handle, int* if_fd)
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       *if_fd = (int)(tun_s->fd);
+       *iface_fd = (int)(tun_s->fd);
 
        return VPNSVC_ERROR_NONE;
 }
 
-EXPORT_API int vpnsvc_get_if_index(vpnsvc_h handle, int* if_index)
+EXPORT_API int vpnsvc_get_iface_index(vpnsvc_h handle, int* iface_index)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        vpnsvc_tun_s *tun_s = NULL;
 
        /* parameter check */
-       if (handle == NULL || if_index == NULL) {
+       if (handle == NULL || iface_index == NULL) {
                LOGE("Invalid parameter");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
@@ -787,17 +787,17 @@ EXPORT_API int vpnsvc_get_if_index(vpnsvc_h handle, int* if_index)
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       *if_index = (int)(tun_s->index);
+       *iface_index = (int)(tun_s->index);
 
        return VPNSVC_ERROR_NONE;
 }
 
-EXPORT_API int vpnsvc_get_if_name(vpnsvc_h handle, char** if_name)
+EXPORT_API int vpnsvc_get_iface_name(vpnsvc_h handle, char** iface_name)
 {
        CHECK_FEATURE_SUPPORTED(VPN_SERVICE_FEATURE);
 
        vpnsvc_tun_s *tun_s = NULL;
-       char la_if_name[VPNSVC_VPN_IF_NAME_LEN + 1] = { 0, };
+       char la_iface_name[VPNSVC_VPN_IFACE_NAME_LEN + 1] = { 0, };
 
        /* parameter check */
        if (handle == NULL) {
@@ -811,13 +811,13 @@ EXPORT_API int vpnsvc_get_if_name(vpnsvc_h handle, char** if_name)
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       if (if_name == NULL) {
+       if (iface_name == NULL) {
                LOGE("tun name string is NULL");
                return VPNSVC_ERROR_INVALID_PARAMETER;
        }
 
-       g_strlcpy(la_if_name, tun_s->name, VPNSVC_VPN_IF_NAME_LEN + 1);
-       *if_name = g_strdup(la_if_name);
+       g_strlcpy(la_iface_name, tun_s->name, VPNSVC_VPN_IFACE_NAME_LEN + 1);
+       *iface_name = g_strdup(la_iface_name);
 
        return VPNSVC_ERROR_NONE;
 }
index 31a248b..6ce3e53 100755 (executable)
@@ -42,7 +42,7 @@ extern "C" {
   * @brief VPN interface name length.
   * @since_tizen 3.0
   */
-#define VPNSVC_VPN_IF_NAME_LEN 16
+#define VPNSVC_VPN_IFACE_NAME_LEN 16
 
 /**
   * @brief Session name string length (includes end null character).
@@ -50,6 +50,10 @@ 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
@@ -79,13 +83,13 @@ typedef void* vpnsvc_h;
 
 /**
  * @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)
+ * @detail You should call vpnsvc_get_iface_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 \n
  *            %http://tizen.org/privilege/internet
  * @remarks The @a handle should be released using vpnsvc_deinit().
- * @param[in] if_name The VPN interface name
+ * @param[in] iface_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
@@ -95,15 +99,15 @@ typedef void* vpnsvc_h;
  * @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 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.
+ * @post Please call vpnsvc_get_iface_fd() if you want to know the fd(file descriptor) of VPN interface.
+ * @post Please call vpnsvc_get_iface_index() if you want to know the index of VPN interface.
+ * @post Please call vpnsvc_get_iface_name() if you want to know the name of VPN interface.
  * @see vpnsvc_deinit()
- * @see vpnsvc_get_if_fd()
- * @see vpnsvc_get_if_index()
- * @see vpnsvc_get_if_name()
+ * @see vpnsvc_get_iface_fd()
+ * @see vpnsvc_get_iface_index()
+ * @see vpnsvc_get_iface_name()
  */
-int vpnsvc_init(const char* if_name, vpnsvc_h *handle);
+int vpnsvc_init(const char* iface_name, vpnsvc_h *handle);
 
 /**
  * @brief De-Initializes VPN interface.
@@ -125,7 +129,7 @@ int vpnsvc_deinit(vpnsvc_h handle);
  * @since_tizen 3.0
  * @param[in] handle    The VPN interface handle
  * @param[in] socket_fd The opened socket file descriptor
- * @param[in] dev_name  The network interface name (e.g., interface name such as eth0, ppp0, etc) through which the VPN is working
+ * @param[in] iface_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
@@ -133,10 +137,10 @@ int vpnsvc_deinit(vpnsvc_h handle);
  * @retval #VPNSVC_ERROR_IPC_FAILED            Cannot connect to service daemon
  * @retval #VPNSVC_ERROR_NOT_SUPPORTED         Not Supported
  */
-int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* dev_name);
+int vpnsvc_protect(vpnsvc_h handle, int socket_fd, const char* iface_name);
 
 /**
- * @brief Reads the data event on VPN interface descriptor.
+ * @brief Waits for the read event on VPN interface descriptor, but no more than the indicated timeout in milliseconds.
  * @since_tizen 3.0
  * @param[in] handle      The VPN interface handle
  * @param[in] timeout_ms  The value of timeout (milliseconds)
@@ -171,12 +175,12 @@ 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 interface handle
- * @param[in] dest_vpn               Allowing networks over 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, netmask length (also called a prefix).
- * @param[in] nr_allow_routes_orig    The number of allowing networks over the original interface
+ * @param[in] routes_dest_vpn_addr    Destination address of the routes, the list of allowing networks over VPN interface (e.g., VPN interface such as tun0, etc).
+ * @param[in] routes_vpn_prefix       The prefix of VPN interface, netmask length (also called a prefix, e.g. 8, 16, 24, 32).
+ * @param[in] num_allow_routes_vpn    The number of allowing networks over VPN interface
+ * @param[in] routes_dest_orig_addr   Destination address of the routes, the list of allowing networks over the original interface (e.g., original interface such as eth0, wlan0, etc).
+ * @param[in] routes_orig_prefix      The prefix of Original interface, netmask length (also called a prefix, e.g. 8, 16, 24, 32).
+ * @param[in] num_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
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
@@ -186,12 +190,12 @@ int vpnsvc_write(vpnsvc_h handle, const char* data, size_t size);
  * @see vpnsvc_unblock_networks()
  */
 int vpnsvc_block_networks(vpnsvc_h handle,
-               const char *dest_vpn[],
-               int prefix_vpn[],
-               size_t nr_allow_routes_vpn,
-               const char *dest_orig[],
-               int prefix_orig[],
-               size_t nr_allow_routes_orig);
+               const char *routes_dest_vpn_addr[],
+               int routes_vpn_prefix[],
+               size_t num_allow_routes_vpn,
+               const char *routes_dest_orig_addr[],
+               int routes_orig_prefix[],
+               size_t num_allow_routes_orig);
 
 /**
  * @brief Removes any restrictions imposed by vpnsvc_block_networks().
@@ -209,19 +213,19 @@ int vpnsvc_unblock_networks(vpnsvc_h handle);
  * @brief Gets the fd of the VPN interface.
  * @since_tizen 3.0
  * @param[in] handle The VPN interface handle
- * @param[out] if_fd The vpn interface fd
+ * @param[out] iface_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
  */
-int vpnsvc_get_if_fd(vpnsvc_h handle, int* if_fd);
+int vpnsvc_get_iface_fd(vpnsvc_h handle, int* iface_fd);
 
 /**
  * @brief Gets the index of VPN interface.
  * @since_tizen 3.0
  * @param[in] handle The VPN interface handle
- * @param[out] if_index The VPN interface index
+ * @param[out] iface_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
@@ -229,14 +233,14 @@ int vpnsvc_get_if_fd(vpnsvc_h handle, int* if_fd);
  * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-int vpnsvc_get_if_index(vpnsvc_h handle, int* if_index);
+int vpnsvc_get_iface_index(vpnsvc_h handle, int* iface_index);
 
 /**
  * @brief Gets the name of VPN interface.
  * @since_tizen 3.0
- * @remarks The @a if_name should be released using free()
+ * @remarks The @a iface_name should be released using free()
  * @param[in] handle    The VPN interface handle
- * @param[out] if_name The name of VPN interface name
+ * @param[out] iface_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
@@ -244,7 +248,7 @@ int vpnsvc_get_if_index(vpnsvc_h handle, int* if_index);
  * @pre Before calling this function, VPN interface should be initialized already.
  * @see vpnsvc_init()
  */
-int vpnsvc_get_if_name(vpnsvc_h handle, char** if_name);
+int vpnsvc_get_iface_name(vpnsvc_h handle, char** iface_name);
 
 /**
  * @brief Sets the MTU of the VPN interface.
index 9df6386..7cbf633 100755 (executable)
@@ -34,50 +34,50 @@ extern "C" {
 
 /**
  * @internal
- * @brief Sets-up TUN interface and brings it up. Installs specified routes/DNS servers/DNS suffix.
+ * @brief Sets-up VPN 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
+ * @param[in] handle                           The VPN interface handle
+ * @param[in] local_ip                         The local(vpn client) IP address
+ * @param[in] remote_ip                                The remote(vpn server) IP address
+ * @param[in] routes_dest_addr         Destination address of the routes
+ * @param[in] routes_prefix         The prefix of routes, netmask length (also called a prefix, e.g. 8, 16, 24, 32)
+ * @param[in] num_routes                       The number of routes, Unlimitation
+ * @param[in] dns_servers                      The list of DNS server names - Optional
+ * @param[in] num_dns_servers          The number of DNS server names - Optionl, Unlimitation
+ * @param[in] dns_suffix               The DNS suffix - Optional (e.g. tizen.org)
  * @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.
+ * @pre The VPN 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 *routes_dest_addr[], int routes_prefix[], size_t num_routes,
+                               const char** dns_servers, size_t num_dns_servers,
                                const char* dns_suffix);
 
 /**
  * @internal
- * @brief Brings the TUN interface down and restores original DNS servers/domains.
+ * @brief Brings the VPN 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
+ * @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_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.
+ * @pre The VPN interface should be initialized and sets-up VPN interface already.
+ * @post Please call vpnsvc_deinit() if you want to de-initialize VPN interface.
  * @see vpnsvc_up()
  * @see vpnsvc_deinit()
  */
index ac29509..36c3396 100755 (executable)
@@ -56,19 +56,19 @@ int test_vpnsvc_init()
                char* result_name = NULL;
                printf("vpnsvc_init Succeed : %d\n", ret);
 
-               if (vpnsvc_get_if_fd(handle, &int_value) == VPNSVC_ERROR_NONE)
-                       printf("if_fd : %d\n", int_value);
+               if (vpnsvc_get_iface_fd(handle, &int_value) == VPNSVC_ERROR_NONE)
+                       printf("iface_fd : %d\n", int_value);
                else
-                       printf("Fail to get if_fd\n");
+                       printf("Fail to get iface_fd\n");
 
-               if (vpnsvc_get_if_index(handle, &int_value) == VPNSVC_ERROR_NONE)
-                       printf("if_index : %d\n", int_value);
+               if (vpnsvc_get_iface_index(handle, &int_value) == VPNSVC_ERROR_NONE)
+                       printf("iface_index : %d\n", int_value);
                else
-                       printf("Fail to get if_index\n");
+                       printf("Fail to get iface_index\n");
 
-               ret = vpnsvc_get_if_name(handle, &result_name);
+               ret = vpnsvc_get_iface_name(handle, &result_name);
                if (ret == VPNSVC_ERROR_NONE)
-                       printf("if_name : %s\n", result_name);
+                       printf("iface_name : %s\n", result_name);
        }
 
        return 0;