From 02364b443c4e53b26dac43813f61ee70cf57d70a Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Fri, 28 Apr 2017 17:31:47 +0900 Subject: [PATCH] Removed code for IPv6 from subnet mask APIs Change-Id: Ia5135d3ce840ae03295366972163d3dea489215e Signed-off-by: Seonah Moon --- include/connection_profile.h | 2 ++ packaging/capi-network-connection.spec | 2 +- src/connection_profile.c | 49 ++++++++++++++-------------------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/include/connection_profile.h b/include/connection_profile.h index 50b3ffd..d1df149 100755 --- a/include/connection_profile.h +++ b/include/connection_profile.h @@ -430,6 +430,7 @@ int connection_profile_get_ip_address(connection_profile_h profile, * @brief Gets the Subnet Mask. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You must release @a subnet_mask using free(). + * This function is supported only for IPv4 address family. * @param[in] profile The profile handle * @param[in] address_family The address family * @param[out] subnet_mask The subnet mask @@ -578,6 +579,7 @@ int connection_profile_set_ip_address(connection_profile_h profile, * @brief Sets the Subnet Mask. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You must release @a subnet_mask using free(). + * This function is supported only for IPv4 address family. * @param[in] profile The profile handle * @param[in] address_family The address family * @param[in] subnet_mask The subnet mask \n diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index 93ab4b0..28f179a 100755 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -1,6 +1,6 @@ Name: capi-network-connection Summary: Network Connection library in TIZEN C API -Version: 1.0.101 +Version: 1.0.102 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/connection_profile.c b/src/connection_profile.c index efcc81d..57bd958 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -588,8 +588,6 @@ EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile, EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, char** subnet_mask) { - char* prefixlen; - CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); if (!(_connection_libnet_check_profile_validity(profile)) || @@ -600,22 +598,18 @@ EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile, return CONNECTION_ERROR_INVALID_PARAMETER; } + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + CONNECTION_LOG(CONNECTION_ERROR, + "Please uses connection_profile_get_prefix_length()"); + return CONNECTION_ERROR_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; - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { - //LCOV_EXCL_START - prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH); - if (prefixlen != NULL) { - snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6); - *subnet_mask = prefixlen; - } else - *subnet_mask = NULL; - //LCOV_EXCL_STOP - } else - *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask, + *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask, address_family); if (*subnet_mask == NULL) @@ -921,32 +915,29 @@ EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile, CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { + (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && + address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + CONNECTION_LOG(CONNECTION_ERROR, + "Please uses connection_profile_set_prefix_length()"); + return CONNECTION_ERROR_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; - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { - //LCOV_EXCL_START - if (subnet_mask == NULL) - net_info->PrefixLen6 = 0 ; - else - net_info->PrefixLen6 = atoi(subnet_mask) ; - //LCOV_EXCL_STOP - } 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; + 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; - net_info->PrefixLen = __profile_convert_netmask_to_prefix_len(subnet_mask); - } + net_info->PrefixLen = __profile_convert_netmask_to_prefix_len(subnet_mask); return CONNECTION_ERROR_NONE; } -- 2.7.4