Add new APIs for IPv6 and DNS configuration 52/114652/20
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 14 Feb 2017 09:54:35 +0000 (18:54 +0900)
committerseonah moon <seonah1.moon@samsung.com>
Fri, 10 Mar 2017 06:33:04 +0000 (22:33 -0800)
Change-Id: Ie41e572f780c12c837edf78cca84e3a8fdeaf111
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
include/connection_profile.h
include/net_connection.h

index 48460a9..77b37ac 100755 (executable)
@@ -176,6 +176,16 @@ typedef enum {
        CONNECTION_PROXY_TYPE_MANUAL  = 2, /**< Manual configuration */
 } connection_proxy_type_e;
 
+/**
+ * @brief Enumeration for DNS configuration type.
+ * @since_tizen 4.0
+ */
+typedef enum
+{
+       CONNECTION_DNS_CONFIG_TYPE_NONE = 0,     /**< Not defined */
+       CONNECTION_DNS_CONFIG_TYPE_STATIC = 1,   /**< Manual DNS configuration */
+       CONNECTION_DNS_CONFIG_TYPE_DYNAMIC = 2,  /**< Config DNS using DHCP client*/
+} connection_dns_config_type_e;
 
 /**
  * @brief Enumeration for network connection type.
@@ -626,6 +636,83 @@ int connection_profile_set_state_changed_cb(connection_profile_h profile, connec
 */
 int connection_profile_unset_state_changed_cb(connection_profile_h profile);
 
+/**
+ * @brief Gets the IPv6 network state.
+ * @since_tizen 4.0
+ * @param[in] profile The profile handle
+ * @param[out] state  The profile state
+ * @return 0 on success, otherwise negative error value.
+ * @retval #CONNECTION_ERROR_NONE               Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
+ */
+int connection_profile_get_ipv6_state(connection_profile_h profile, connection_profile_state_e *state);
+
+/**
+ * @brief Sets the DNS config type.
+ * @since_tizen 4.0
+ * @param[in] profile         The profile handle
+ * @param[in] address_family  The address family
+ * @param[in] type            The DNS config type
+ * @return 0 on success, otherwise negative error value.
+ * @retval #CONNECTION_ERROR_NONE               Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
+ */
+int connection_profile_set_dns_config_type(connection_profile_h profile,
+               connection_address_family_e address_family, connection_dns_config_type_e type);
+
+/**
+ * @brief Gets the DNS config type.
+ * @since_tizen 4.0
+ * @param[in] profile         The profile handle
+ * @param[in] address_family  The address family
+ * @param[out] type           The DNS config type
+ * @return 0 on success, otherwise negative error value.
+ * @retval #CONNECTION_ERROR_NONE               Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
+ */
+int connection_profile_get_dns_config_type(connection_profile_h profile,
+               connection_address_family_e address_family, connection_dns_config_type_e *type);
+
+/**
+ * @brief Gets the network prefix length.
+ * @since_tizen 4.0
+ * @param[in] profile         The profile handle
+ * @param[in] address_family  The address family
+ * @param[out] prefix_len     The network prefix length.
+ *                            In case of IPv4, it means netmask length
+ *                            (also called a prefix, e.g. 8, 16, 24, 32)
+ * @return 0 on success, otherwise negative error value.
+ * @retval #CONNECTION_ERROR_NONE               Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
+ */
+int connection_profile_get_prefix_length(connection_profile_h profile,
+               connection_address_family_e address_family, int *prefix_len);
+
+/**
+ * @brief Sets the network prefix length.
+ * @since_tizen 4.0
+ * @param[in] profile         The profile handle
+ * @param[in] address_family  The address family
+ * @param[in] prefix_len      The network prefix length.
+ *                            In case of IPv4, it means netmask length
+ *                            (also called a prefix, e.g. 8, 16, 24, 32)
+ * @return 0 on success, otherwise negative error value.
+ * @retval #CONNECTION_ERROR_NONE               Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
+ * @see connection_update_profile()
+ */
+int connection_profile_set_prefix_length(connection_profile_h profile,
+               connection_address_family_e address_family, int prefix_len);
 
 /**
 * @}
@@ -897,7 +984,7 @@ int connection_profile_get_cellular_roam_pdn_type(connection_profile_h profile,
 
 
 /**
- * @brief Checks wheter the connection is in roaming state.
+ * @brief Checks whether the connection is in roaming state.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] profile The profile handle
  * @param[out] is_roaming @c true if the cellular is roaming,
index 47a2455..59198ac 100755 (executable)
@@ -167,7 +167,6 @@ typedef enum {
        CONNECTION_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED      /**< Not Supported */
 } connection_error_e;
 
-
 /**
  * @}
 */
@@ -267,6 +266,17 @@ typedef void(*connection_address_changed_cb)(const char* ipv4_address, const cha
 */
 typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data);
 
+/* @brief Called with an IPv6 address.
+ * @since_tizen 4.0
+ * @remarks   If @a ipv6_address is needed outside the callback, a copy should be made. \n
+ *            @a ipv6_address will be freed automatically after the execution of this callback.
+ * @param[in]  ipv6_address  The IPv6 address
+ * @param[in]  user_data     The user data passed from the foreach function
+ * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @pre  connection_foreach_ipv6_addresses() will invoke this callback.
+ * @see  connection_foreach_ipv6_addresses()
+ */
+typedef bool(*connection_ipv6_address_cb)(char *ipv6_address, void *user_data);
 
 /**
  * @brief Gets the type of the current profile for data connection.
@@ -620,7 +630,7 @@ int connection_update_profile(connection_h connection, connection_profile_h prof
  * @privilege %http://tizen.org/privilege/network.get
  * @remarks You must release @a profile_iterator using connection_destroy().
  * @param[in] connection The connection handle
- * @param[in] type The type of the connetion iterator
+ * @param[in] type The type of the connection iterator
  * @param[out] profile_iterator The iterator of profile
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -706,7 +716,7 @@ int connection_get_current_profile(connection_h connection, connection_profile_h
  * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
  * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
- * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denieda
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
  * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
  */
 int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
@@ -950,6 +960,21 @@ int connection_add_route_ipv6(connection_h connection, const char *interface_nam
  */
 int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway);
 
+/*
+ * @brief Gets all IPv6 addresses assigned to the network interface.
+ * @since_tizen 4.0
+ * @param[in] connection       The connection handle
+ * @param[in] connection_type  The connection type
+ * @param[in] callback         The callback to be called for each IPv6 address
+ * @param[in] user_data        The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value.
+ * @retval #CONNECTION_ERROR_NONE               Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
+ */
+int connection_foreach_ipv6_address(connection_h connection, connection_type_e connection_type,
+               connection_ipv6_address_cb callback, void *user_data);
 
 /**
  * @}
@@ -1000,7 +1025,6 @@ int connection_get_statistics(connection_h connection, connection_type_e connect
  */
 int connection_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type);
 
-
 /**
  * @}
 */