* @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
* @see connection_profile_get_network_interface_name()
*/
-int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address);
+
+int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway);
+
+/**
+ * @brief Removes a IPV6 route from the routing table.
+ * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
+ * @since_tizen 2.3.1
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ * @param[in] connection The connection handle
+ * @param[in] interface_name The name of network interface
+ * @param[in] host_address The IP address of the host
+ * @param[in] gateway The gateway address
+ * @return @c 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_PERMISSION_DENIED Permission Denied
+ * @see connection_profile_get_network_interface_name()
+ */
+int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway);
/**
* @}
int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data);
int _connection_libnet_add_route(const char *interface_name, const char *host_address);
int _connection_libnet_remove_route(const char *interface_name, const char *host_address);
+int _connection_libnet_add_route_ipv6(const char *interface_name, const char *host_address, const char * gateway);
+int _connection_libnet_remove_route_ipv6(const char *interface_name, const char *host_address, const char * gateway);
void _connection_libnet_add_to_profile_list(connection_profile_h profile);
void _connection_libnet_remove_from_profile_list(connection_profile_h profile);
bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
Name: capi-network-connection
Summary: Network Connection library in TIZEN C API
-Version: 0.1.3_22
+Version: 0.1.3_23
Release: 1
Group: System/Network
License: Apache-2.0
}
EXPORT_API int connection_get_ip_address(connection_h connection,
- connection_address_family_e address_family, char** ip_address)
+ connection_address_family_e address_family, char **ip_address)
{
if (ip_address == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
switch (address_family) {
case CONNECTION_ADDRESS_FAMILY_IPV4:
- *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
- break;
case CONNECTION_ADDRESS_FAMILY_IPV6:
- CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n");
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
break;
+
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (*ip_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed");
return CONNECTION_ERROR_OPERATION_FAILED;
}
}
EXPORT_API int connection_get_proxy(connection_h connection,
- connection_address_family_e address_family, char** proxy)
+ connection_address_family_e address_family, char **proxy)
{
if (proxy == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
switch (address_family) {
case CONNECTION_ADDRESS_FAMILY_IPV4:
- *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
- break;
case CONNECTION_ADDRESS_FAMILY_IPV6:
- CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n");
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
break;
+
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (*proxy == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed");
return CONNECTION_ERROR_OPERATION_FAILED;
}
return _connection_libnet_remove_route(interface_name, host_address);
}
+EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
+{
+ if (!(__connection_check_handle_validity(connection)) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_add_route_ipv6(interface_name, host_address, gateway);
+}
+
+EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
+{
+ if (!(__connection_check_handle_validity(connection)) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_remove_route_ipv6(interface_name, host_address, gateway);
+}
+
/* Connection Statistics module ******************************************************************/
static int __get_statistic(connection_type_e connection_type,
#include "net_connection_private.h"
#define HTTP_PROXY "http_proxy"
+#define MAX_PREFIX_LENGTH 6
static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info)
{
}
}
-static char* __profile_convert_ip_to_string(net_addr_t *ip_addr)
+static char *__profile_convert_ip_to_string(net_addr_t *ip_addr, connection_address_family_e address_family)
{
- unsigned char *ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
+ unsigned char *ipaddr = NULL;
+ char *ipstr = NULL;
- char *ipstr = g_try_malloc0(16);
- if (ipstr == NULL)
- return NULL;
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
+ ipstr = g_try_malloc0(INET_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
+
+ inet_ntop(AF_INET, ipaddr, ipstr, INET_ADDRSTRLEN);
+ } else {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv6.s6_addr;
+ ipstr = g_try_malloc0(INET6_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
- snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
+ inet_ntop(AF_INET6, ipaddr, ipstr, INET6_ADDRSTRLEN);
+ }
return ipstr;
}
EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profile,
connection_address_family_e address_family, connection_ip_config_type_e* type)
{
+ net_ip_config_type_t profile_type;
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- switch (net_info->IpConfigType) {
- case NET_IP_CONFIG_TYPE_STATIC:
- *type = CONNECTION_IP_CONFIG_TYPE_STATIC;
- break;
- case NET_IP_CONFIG_TYPE_DYNAMIC:
- *type = CONNECTION_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case NET_IP_CONFIG_TYPE_AUTO_IP:
- *type = CONNECTION_IP_CONFIG_TYPE_AUTO;
- break;
- case NET_IP_CONFIG_TYPE_FIXED:
- *type = CONNECTION_IP_CONFIG_TYPE_FIXED;
- break;
- case NET_IP_CONFIG_TYPE_OFF:
- *type = CONNECTION_IP_CONFIG_TYPE_NONE;
- break;
- default:
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ profile_type = net_info->IpConfigType;
+ else
+ profile_type = net_info->IpConfigType6;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ switch (profile_type) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = CONNECTION_IP_CONFIG_TYPE_STATIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_DYNAMIC:
+ *type = CONNECTION_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = CONNECTION_IP_CONFIG_TYPE_AUTO;
+ break;
+
+ case NET_IP_CONFIG_TYPE_FIXED:
+ *type = CONNECTION_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = CONNECTION_IP_CONFIG_TYPE_NONE;
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ switch (profile_type) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = CONNECTION_IP_CONFIG_TYPE_STATIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = CONNECTION_IP_CONFIG_TYPE_AUTO;
+ break;
+
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = CONNECTION_IP_CONFIG_TYPE_NONE;
+ break;
+
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ }
}
return CONNECTION_ERROR_NONE;
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
ip_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return CONNECTION_ERROR_OPERATION_FAILED;
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr6,
+ address_family);
+ else
+ *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr,
+ address_family);
- *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr);
if (*ip_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, char** subnet_mask)
{
+ char* prefixlen;
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
subnet_mask == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH);
+ snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6);
+ *subnet_mask = prefixlen;
+ } else
+ *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask,
+ address_family);
- *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask);
if (*subnet_mask == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profile,
connection_address_family_e address_family, char** gateway_address)
-{
+{
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
gateway_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
+ *gateway_address = __profile_convert_ip_to_string(
+ &net_info->GatewayAddr6, address_family);
+ else
+ *gateway_address = __profile_convert_ip_to_string(
+ &net_info->GatewayAddr, address_family);
- *gateway_address = __profile_convert_ip_to_string(&net_info->GatewayAddr);
if (*gateway_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
dns_address == NULL ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1],
+ address_family);
+ else if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
+ *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1],
+ address_family);
+ else
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid address family\n");
- *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1]);
if (*dns_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
proxy_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- const char *proxy;
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- if (profile_info->profile_type == NET_DEVICE_ETHERNET) {
- proxy = __profile_get_ethernet_proxy();
- if (proxy == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
-
- *proxy_address = g_strdup(proxy);
- } else
- *proxy_address = g_strdup(net_info->ProxyAddr);
+ *proxy_address = g_strdup(net_info->ProxyAddr);
if (*proxy_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profile,
connection_address_family_e address_family, connection_ip_config_type_e type)
{
+ net_ip_config_type_t *profile_type = NULL;
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- switch (type) {
- case CONNECTION_IP_CONFIG_TYPE_STATIC:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
- net_info->IpAddr.Data.Ipv4.s_addr = 0;
- net_info->SubnetMask.Data.Ipv4.s_addr = 0;
- net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
- break;
- case CONNECTION_IP_CONFIG_TYPE_DYNAMIC:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case CONNECTION_IP_CONFIG_TYPE_AUTO:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_AUTO_IP;
- break;
- case CONNECTION_IP_CONFIG_TYPE_FIXED:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
- break;
- case CONNECTION_IP_CONFIG_TYPE_NONE:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- break;
- default:
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ profile_type = &net_info->IpConfigType ;
+ else
+ profile_type = &net_info->IpConfigType6 ;
+
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ switch (type) {
+ case CONNECTION_IP_CONFIG_TYPE_STATIC:
+ *profile_type = NET_IP_CONFIG_TYPE_STATIC;
+ net_info->IpAddr.Data.Ipv4.s_addr = 0;
+ net_info->SubnetMask.Data.Ipv4.s_addr = 0;
+ net_info->GatewayAddr.Data.Ipv4.s_addr = 0 ;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_DYNAMIC:
+ *profile_type = NET_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_AUTO:
+ *profile_type = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_FIXED:
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_NONE:
+ *profile_type = NET_IP_CONFIG_TYPE_OFF;
+ break;
+
+ default:
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ switch (type) {
+ case CONNECTION_IP_CONFIG_TYPE_STATIC:
+ *profile_type = NET_IP_CONFIG_TYPE_STATIC;
+ inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
+ net_info->PrefixLen6 = 0 ;
+ inet_pton(AF_INET6, "::",
+ &net_info->GatewayAddr6.Data.Ipv6);
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_AUTO:
+ *profile_type = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_NONE:
+ *profile_type = NET_IP_CONFIG_TYPE_OFF;
+ break;
+
+ default:
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
}
return CONNECTION_ERROR_NONE;
EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile,
connection_address_family_e address_family, const char* ip_address)
-{
+{
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- if (ip_address == NULL)
- net_info->IpAddr.Data.Ipv4.s_addr = 0;
- else if (inet_aton(ip_address, &(net_info->IpAddr.Data.Ipv4)) == 0)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ if (ip_address == NULL)
+ inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, ip_address,
+ &net_info->IpAddr6.Data.Ipv6) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ } else {
+ if (ip_address == NULL)
+ net_info->IpAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, ip_address,
+ &net_info->IpAddr.Data.Ipv4) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, const char* subnet_mask)
-{
+{
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- if (subnet_mask == NULL)
- net_info->SubnetMask.Data.Ipv4.s_addr = 0;
- else if (inet_aton(subnet_mask, &(net_info->SubnetMask.Data.Ipv4)) == 0)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ if (subnet_mask == NULL)
+ net_info->PrefixLen6 = 0 ;
+ else
+ net_info->PrefixLen6 = atoi(subnet_mask) ;
+ } else {
+ if (subnet_mask == NULL)
+ net_info->SubnetMask.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1 )
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
return CONNECTION_ERROR_NONE;
}
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- if (gateway_address == NULL)
- net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
- else if (inet_aton(gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) == 0)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ if (gateway_address == NULL)
+ inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ } else {
+ if (gateway_address == NULL)
+ net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
return CONNECTION_ERROR_NONE;
}
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- if (dns_address == NULL)
- net_info->DnsAddr[order-1].Data.Ipv4.s_addr = 0;
- else if (inet_aton(dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) == 0)
- return CONNECTION_ERROR_INVALID_PARAMETER;
-
- if (net_info->DnsCount < order)
- net_info->DnsCount = order;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ net_info->DnsAddr6[order-1].Type = NET_ADDR_IPV6;
+ if (dns_address == NULL)
+ inet_pton(AF_INET6, "::", &net_info->DnsAddr6[order-1].Data.Ipv6);
+ else if (inet_pton(AF_INET6, dns_address, &net_info->DnsAddr6[order-1].Data.Ipv6) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (net_info->DnsCount6 < order)
+ net_info->DnsCount6 = order;
+ } else {
+ net_info->DnsAddr[order-1].Type = NET_ADDR_IPV4;
+ if (dns_address == NULL)
+ net_info->DnsAddr[order-1].Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (net_info->DnsCount < order)
+ net_info->DnsCount = order;
+ }
return CONNECTION_ERROR_NONE;
}
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
if (proxy_address == NULL)
net_info->ProxyAddr[0] = '\0';
else
#include <string.h>
#include <glib.h>
#include <vconf/vconf.h>
+#include <arpa/inet.h>
#include "net_connection_private.h"
}
}
+static int __libnet_check_address_type(int address_family, const char *address)
+{
+ struct in6_addr buf;
+ int err = 0;
+
+ err = inet_pton(address_family, address, &buf);
+ if(err > 0)
+ return 1;
+
+ return 0;
+}
+
int __libnet_get_connected_count(struct _profile_list_s *profile_list)
{
int count = 0;
int _connection_libnet_add_route(const char *interface_name, const char *host_address)
{
int rv;
- char *endstr = strrchr(host_address, '.');
+ char *endstr = NULL;
+ int address_family = 0;
- if (endstr == NULL ||
- strcmp(endstr, ".0") == 0 ||
- strncmp(host_address, "0.", 2) == 0 ||
- strstr(host_address, ".0.") != NULL ||
- strstr(host_address, "255") != NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ if(__libnet_check_address_type(AF_INET, host_address))
+ address_family = AF_INET;
+ else
return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ switch(address_family) {
+ case AF_INET:
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
}
- rv = net_add_route(host_address, interface_name);
+ rv = net_add_route(host_address, interface_name, address_family);
if (rv == NET_ERR_ACCESS_DENIED) {
CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
return CONNECTION_ERROR_PERMISSION_DENIED;
{
int rv;
char *endstr = strrchr(host_address, '.');
+ int address_family = 0;
- if (endstr == NULL ||
- strcmp(endstr, ".0") == 0 ||
- strncmp(host_address, "0.", 2) == 0 ||
- strstr(host_address, ".0.") != NULL ||
- strstr(host_address, "255") != NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed");
+ if (__libnet_check_address_type(AF_INET, host_address))
+ address_family = AF_INET;
+ else
return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ switch(address_family) {
+ case AF_INET:
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, ".0.") != NULL ||strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ rv = net_remove_route(host_address, interface_name, address_family);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_add_route_ipv6(const char *interface_name, const char *host_address, const char *gateway)
+{
+ int rv;
+ int address_family = 0;
+
+ address_family = AF_INET6;
+/* if(__libnet_check_address_type(AF_INET6, host_address))
+ address_family = AF_INET6;
+ else
+ return CONNECTION_ERROR_INVALID_PARAMETER;*/
+
+ switch(address_family) {
+ case AF_INET6:
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ rv = net_add_route_ipv6(host_address, interface_name, address_family, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_remove_route_ipv6(const char *interface_name, const char *host_address, const char *gateway)
+{
+ int rv;
+ int address_family = 0;
+
+ address_family = AF_INET6;
+/* if (__libnet_check_address_type(AF_INET6, host_address))
+ address_family = AF_INET6;
+ else
+ return CONNECTION_ERROR_INVALID_PARAMETER;*/
+
+ switch(address_family) {
+ case AF_INET6:
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
}
- rv = net_remove_route(host_address, interface_name);
+ rv = net_remove_route_ipv6(host_address, interface_name, address_family, gateway);
if (rv == NET_ERR_ACCESS_DENIED) {
CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
return CONNECTION_ERROR_PERMISSION_DENIED;
return 1;
}
-static int test_update_ip_info(connection_profile_h profile)
+static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
{
int rv = 0;
char input_str[100] = {0,};
if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_ip_address(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_subnet_mask(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_gateway_address(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_dns_address(profile,
1,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_dns_address(profile,
2,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
return 1;
}
-static int test_update_proxy_info(connection_profile_h profile)
+static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
{
int rv = 0;
int input_int = 0;
if (test_get_user_string("Input auto Proxy URL or Proxy address"
" - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_proxy_address(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
{
int rv = 0;
int input_int = 0;
+ int address_family;
+
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
" - (Enter for skip) :", &input_int)) {
switch (input_int) {
case 1:
rv = connection_profile_set_ip_config_type(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
- CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
break;
case 2:
rv = connection_profile_set_ip_config_type(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
- CONNECTION_IP_CONFIG_TYPE_STATIC);
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_STATIC);
if (rv != CONNECTION_ERROR_NONE)
return -1;
- if (test_update_ip_info(profile) == -1)
+ if (test_update_ip_info(profile, address_family) == -1)
return -1;
- if (test_update_proxy_info(profile) == -1)
+ if (test_update_proxy_info(profile, address_family) == -1)
return -1;
break;
default:
printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
}
-static void test_print_network_info(connection_profile_h profile)
+static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
{
char *interface_name = NULL;
connection_ip_config_type_e ip_type;
g_free(interface_name);
}
- if (connection_profile_get_ip_config_type(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_type) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
printf("Fail to get ipconfig type!\n");
else
printf("Ipconfig type : %d\n", ip_type);
- if (connection_profile_get_ip_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
printf("Fail to get IP address!\n");
else {
printf("IP address : %s\n", ip);
g_free(ip);
}
- if (connection_profile_get_subnet_mask(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &subnet) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
printf("Fail to get subnet mask!\n");
else {
printf("Subnet mask : %s\n", subnet);
g_free(subnet);
}
- if (connection_profile_get_gateway_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &gateway) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
printf("Fail to get gateway!\n");
else {
printf("Gateway : %s\n", gateway);
g_free(gateway);
}
- if (connection_profile_get_dns_address(profile, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &dns1) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
printf("Fail to get DNS1!\n");
else {
printf("DNS1 : %s\n", dns1);
g_free(dns1);
}
- if (connection_profile_get_dns_address(profile, 2, CONNECTION_ADDRESS_FAMILY_IPV4, &dns2) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
printf("Fail to get DNS2!\n");
else {
printf("DNS2 : %s\n", dns2);
else
printf("Proxy type : %d\n", proxy_type);
- if (connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
printf("Fail to get proxy!\n");
else {
printf("Proxy : %s\n", proxy);
int test_get_current_ip(void)
{
char *ip_addr = NULL;
+ int input;
+ bool rv;
+
+ rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
- connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+ if (rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ switch (input) {
+ case 1:
+ connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+ if (ip_addr == NULL) {
+ printf("IPv4 address does not exist\n");
+ return -1;
+ }
+ printf("IPv4 address : %s\n", ip_addr);
+ break;
- if (ip_addr == NULL) {
- printf("IP address does not exist\n");
+ case 2:
+ connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
+ if (ip_addr == NULL) {
+ printf("IPv6 address does not exist\n");
+ return -1;
+ }
+ printf("IPv6 address : %s\n", ip_addr);
+ break;
+ default:
+ printf("Wrong IP address family!!\n");
return -1;
}
- printf("IPv4 address : %s\n", ip_addr);
g_free(ip_addr);
-
return 1;
}
connection_profile_state_e profile_state;
connection_profile_h profile;
char *profile_name = NULL;
+ int address_family = 0;
printf("\n** Choose a profile to print. **\n");
if (test_get_user_selected_profile(&profile, true) == false)
} else
printf("Profile State : %s\n", test_print_state(profile_state));
-
if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
return -1;
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
switch (prof_type) {
case CONNECTION_PROFILE_TYPE_CELLULAR:
printf("Profile Type : Cellular\n");
return -1;
}
- test_print_network_info(profile);
+ test_print_network_info(profile, address_family);
return 1;
}
connection_profile_state_e profile_state;
connection_profile_h profile;
char *profile_name = NULL;
+ int address_family = 0;
printf("\n** Choose a profile to refresh. **\n");
if (test_get_user_selected_profile(&profile, true) == false)
if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
return -1;
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
switch (prof_type) {
case CONNECTION_PROFILE_TYPE_CELLULAR:
printf("Profile Type : Cellular\n");
return -1;
}
- test_print_network_info(profile);
+ test_print_network_info(profile, address_family);
return 1;
}
int test_add_route(void)
{
int rv = 0;
- char ip_addr[30];
- char if_name[40];
+ char ip_addr[100] = {0};
+ char if_name[40] = {0};
- if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 30) == false)
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
return -1;
if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
return -1;
+ g_strstrip(ip_addr);
+ g_strstrip(if_name);
rv = connection_add_route(connection, if_name, ip_addr);
if (rv != CONNECTION_ERROR_NONE) {
printf("Fail to get add new route [%d]\n", rv);
return -1;
}
+ printf("Add Route successfully\n");
return 1;
}
int test_remove_route(void)
{
int rv = 0;
- char ip_addr[30];
- char if_name[40];
+ char ip_addr[100] = {0};
+ char if_name[40] = {0};
- if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 30) == false)
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
return -1;
if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
return -1;
+ g_strstrip(ip_addr);
+ g_strstrip(if_name);
rv = connection_remove_route(connection, if_name, ip_addr);
if (rv != CONNECTION_ERROR_NONE) {
printf("Fail to remove the route [%s]\n", test_print_error(rv));
return -1;
}
+ printf("Remove Route successfully\n");
+
+ return 1;
+}
+
+int test_add_route_ipv6(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+
+ return 1;
+}
+
+int test_remove_route_ipv6(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%d]\n", rv);
+ return -1;
+ }
+ printf("Remove Route successfully\n");
return 1;
}
printf("v - Get all cellular default profiles\n");
printf("w - Get mac address\n");
printf("x - Get ethernet cable state\n");
+ printf("B - Add IPv6 new route\n");
+ printf("C - Remove IPv6 route\n");
printf("0 - Exit \n");
printf("ENTER - Show options menu.......\n");
}
case 'x':
rv = test_get_ethernet_cable_state();
break;
+ case 'B':
+ rv = test_add_route_ipv6();
+ break;
+ case 'C':
+ rv = test_remove_route_ipv6();
+ break;
}
if (rv == 1)