* </tr></table>
**/
+/**
+ * @addtogroup CAPI_NETWORK_VPN_MODULE
+ * @{
+ */
+
#include <tizen.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <tizen_error.h>
#include <tizen_vpn_error.h>
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "CAPI_VPNSVC"
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
#ifndef API
#define API __attribute__ ((visibility("default")))
/**
* @brief IPv4 address string length (includes end null character)
+ * @since_tizen 3.0
*/
#define VPNSVC_IP4_STRING_LEN 16
/**
- * @brief TUN interface name length (IFNAMSIZ)
+ * @brief TUN interface name length
+ * @since_tizen 3.0
*/
#define VPNSVC_TUN_IF_NAME_LEN 16
/**
* @brief Session name string length (includes end null character)
+ * @since_tizen 3.0
*/
#define VPNSVC_SESSION_STRING_LEN 32
VPNSVC_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< IO error */
VPNSVC_ERROR_TIMEOUT = TIZEN_ERROR_TIMED_OUT, /**< Time out error or no answer */
VPNSVC_ERROR_IPC_FAILED = TIZEN_ERROR_VPNSVC | 0x02, /**< Failed to communicate with server */
- VPNSVC_ERROR_LICENSE_FAILED = TIZEN_ERROR_VPNSVC | 0x03, /**< Failed to verify license */
VPNSVC_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */
} vpnsvc_error_e;
/**
* @brief The structure containing the route information
* @details This structure can be used for both vpnsvc_up() and vpnsvc_block_networks() functions.
- *
* @since_tizen 3.0
* @see vpnsvc_up()
* @see vpnsvc_block_networks()
/**
* @brief The VPN tun interface handle
- * @details This handle can be obtained by calling vpnsvc_init() and destroyed(NULL) by calling vpnsvc_deinit().
+ * @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()
/**
- * @brief Initializes TUN interface (/dev/net/tun)
+ * @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)
- *
* @since_tizen 3.0
* @privlevel public
- * @privilege %http://tizen.org/privilege/vpnservicea
- * @remarks The license needed if you want to use this VPN API
- *
+ * @privilege %http://tizen.org/privilege/vpnservice
+ * @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
- *
* @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 I/O Error (e.g. socket I/O error)
* @retval #VPNSVC_ERROR_IPC_FAILED Cannot connect to service daemon
* @retval #VPNSVC_ERROR_PERMISSION_DENIED Permission Denied
- * @retval #VPNSVC_ERROR_LICENSE_FAILED Failed to verify license
* @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.
/**
* @brief De-Initializes TUN interface
- *
* @since_tizen 3.0
- * @remarks The license needed if you want to use this VPN API
- *
* @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_LICENSE_FAILED Failed to verify license
* @retval #VPNSVC_ERROR_NOT_SUPPORTED Not Supported
- *
* @pre Before calling this function, VPN tun interface should be initialized already.
* @see vpnsvc_init()
*/
/**
* @brief Prevents the underlying VPN traffic to be routed to the VPN itself
* @details The specific socket will be bound to the network interface using by this function.
- *
* @since_tizen 3.0
- * @remarks The license needed if you want to use this VPN API
- *
* @param[in] handle The VPN tun 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
- *
* @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 I/O Error (e.g. socket I/O error)
* @retval #VPNSVC_ERROR_IPC_FAILED Cannot connect to service daemon
- * @retval #VPNSVC_ERROR_LICENSE_FAILED Failed to verify license
* @retval #VPNSVC_ERROR_NOT_SUPPORTED Not Supported
*/
API int vpnsvc_protect(vpnsvc_tun_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
- *
* @since_tizen 3.0
- * @remarks The license needed if you want to use this VPN API
- *
* @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] dns_servers The list of DNS server names - Optional
* @param[in] nr_dns_servers The number of DNS server names - Optional
* @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_LICENSE_FAILED Failed to verify license
* @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_route
/**
* @brief Brings the TUN interface down and restores original DNS servers/domains
- *
* @since_tizen 3.0
- * @remarks The license needed if you want to use this VPN API.
- *
* @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_LICENSE_FAILED Failed to verify license
* @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()
/**
* @brief Waits for the read event on TUN descriptor, but no more than the indicated timeout in milliseconds
- *
* @since_tizen 3.0
- *
* @param[in] handle The VPN tun 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
* @retval #VPNSVC_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #VPNSVC_ERROR_IO_ERROR I/O Error (e.g. socket I/O error)
* @retval #VPNSVC_ERROR_TIMEOUT Timeout (no answer in timeout_ms)
* @retval #VPNSVC_ERROR_NOT_SUPPORTED Not Supported
- *
* @pre The VPN interface should be initialized already.
* @see vpnsvc_init()
* @see vpnsvc_up()
/**
* @brief Writes the data supplied into the TUN interface
- *
* @since_tizen 3.0
- *
* @param[in] handle The VPN tun interface handle
* @param[in] data Data writing to tun 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
* @retval #VPNSVC_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #VPNSVC_ERROR_NOT_SUPPORTED Not Supported
* @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()
/**
* @brief Blocks all traffics except specified allowing networks
- *
* @since_tizen 3.0
- * @remarks The license needed if you want to use this VPN API
- *
* @param[in] handle The VPN tun interface handle
* @param[in] allow_routes_vpn The list of allowing networks over VPN interface (Please see vpnsvc_route structure).
* @param[in] nr_allow_routes_vpn The number of allowing networks over VPN interface
* @param[in] allow_routes_orig The list of allowing networks over the original interface (Please see vpnsvc_route structure).
* @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
* @retval #VPNSVC_ERROR_IPC_FAILED Cannot connect to service daemon
- * @retval #VPNSVC_ERROR_LICENSE_FAILED Failed to verify license
* @retval #VPNSVC_ERROR_NOT_SUPPORTED Not Supported
- *
* @post Please call vpnsvc_unblock_networks() if you want to allow all traffics.
* @see vpnsvc_unblock_networks()
*/
/**
* @brief Removes any restrictions imposed by vpnsvc_block_networks()
- *
* @since_tizen 3.0
- * @remarks The license needed if you want to use this VPN API
- *
* @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_IPC_FAILED Cannot connect to service daemon
- * @retval #VPNSVC_ERROR_LICENSE_FAILED Failed to verify license
* @retval #VPNSVC_ERROR_NOT_SUPPORTED Not Supported
- *
*/
API int vpnsvc_unblock_networks(vpnsvc_tun_h handle);
/**
* @brief Gets the fd of the VPN tun interface
- *
* @since_tizen 3.0
- *
* @param[in] handle The VPN tun interface handle
- *
* @return The fd value of VPN tun 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);
/**
- * @brief Gets the index of VPN tun interface (if.if_index)
- *
+ * @brief Gets the index of VPN tun interface
* @since_tizen 3.0
- *
* @param[in] handle The VPN tun interface handle
- *
* @return The index of the VPN tun 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.
* @see vpnsvc_init()
*/
API int vpnsvc_get_tun_index(vpnsvc_tun_h handle);
/**
- * @brief Gets the name of VPN tun interface (if.if_name)
- *
+ * @brief Gets the name of VPN tun 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
- *
* @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.
* @see vpnsvc_init()
*/
API int vpnsvc_get_tun_name(vpnsvc_tun_h handle, char* tun_name);
/**
- * @brief Sets the MTU of the VPN tun interface (if.if_name)
- *
+ * @brief Sets the MTU of the VPN tun 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.
- *
* @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.
* @see vpnsvc_init()
*/
/**
* @brief Sets blocking mode of the file descriptor of VPN tun 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
- *
* @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.
* @see vpnsvc_init()
*/
/**
* @brief Sets the session name for the VPN
- *
* @since_tizen 3.0
- *
+ * @remarks a tun_name should be released using free()
* @param[in] handle The VPN tun 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.
* @see vpnsvc_init()
*/
-API int vpnsvc_set_session(vpnsvc_tun_h handle, const char* session);
+API int vpnsvc_set_session(vpnsvc_tun_h handle, const char* session_name);
/**
* @brief Gets the session name for the VPN
- *
* @since_tizen 3.0
- *
* @param[in] handle The VPN tun 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.
* @see vpnsvc_init()
*/
-API int vpnsvc_get_session(vpnsvc_tun_h handle, char* session);
+API int vpnsvc_get_session(vpnsvc_tun_h handle, char* session_name);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+/**
+* @}
+*/
#endif /* __TIZEN_CAPI_VPN_SERVICE_H__ */