#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);
<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'/>
<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'/>
<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'>
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;
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));
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) {
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) {
}
-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));
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);
}
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';
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) {
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);
}
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) {
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;
}
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));
********************/
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");
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);
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);
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,
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);
}
}
- 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:
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);
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;
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)
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");
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 {
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);
}
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,
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);
}
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");
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);
}
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);
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;
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);
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);
}
/* 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);
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) {
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;
}
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;
}
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) {
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;
}
* @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).
*/
#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
/**
* @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
* @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.
* @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
* @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)
* @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
* @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().
* @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
* @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
* @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.
/**
* @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()
*/
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;