From c98ad635e775333e7d913b88bb963a5558195f7e Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Thu, 14 Apr 2016 15:48:36 +0900 Subject: [PATCH] Add some APIs to get and set cellular pdn type Change-Id: I2f8be0e95bc54d776450f66eec112a50a6897644 Signed-off-by: hyunuktak --- include/connection_profile.h | 65 +++++++++++++++ packaging/capi-network-connection.spec | 2 +- src/connection_profile.c | 148 +++++++++++++++++++++++++++++++++ test/connection_test.c | 46 ++++++++++ 4 files changed, 260 insertions(+), 1 deletion(-) diff --git a/include/connection_profile.h b/include/connection_profile.h index 433c4ca..abf17f1 100755 --- a/include/connection_profile.h +++ b/include/connection_profile.h @@ -84,6 +84,18 @@ typedef enum } connection_cellular_service_type_e; /** + * @brief Enumeration for cellular pdn type. + * @since_tizen 3.0 + */ +typedef enum +{ + CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN = 0, + CONNECTION_CELLULAR_PDN_TYPE_IPV4 = 1, + CONNECTION_CELLULAR_PDN_TYPE_IPV6 = 2, + CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6 = 3, +} connection_cellular_pdn_type_e; + +/** * @brief Enumeration for cellular authentication type. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ @@ -763,6 +775,32 @@ int connection_profile_get_cellular_auth_info(connection_profile_h profile, conn int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url); /** + * @brief Gets the cellular pdn type. + * @since_tizen 3.0 + * @param[in] profile The profile handle + * @param[out] type The cellular pdn type + * @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_NOT_SUPPORTED Not Supported +*/ +int connection_profile_get_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e* type); + +/** + * @brief Gets the cellular roam pdn type. + * @since_tizen 3.0 + * @param[in] profile The profile handle + * @param[out] type The cellular pdn type + * @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_NOT_SUPPORTED Not Supported +*/ +int connection_profile_get_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e* type); + +/** * @brief Checks wheter the connection is in roaming state. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] profile The profile handle @@ -865,6 +903,33 @@ int connection_profile_set_cellular_auth_info(connection_profile_h profile, conn int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url); /** + * @brief Sets the cellular pdn type. + * @since_tizen 3.0 + * @param[in] profile The profile handle + * @param[in] type The cellular pdn type + * @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_NOT_SUPPORTED Not Supported +*/ +int connection_profile_set_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type); + +/** + * @brief Sets the cellular roam pdn type. + * @since_tizen 3.0 + * @param[in] profile The profile handle + * @param[in] type The cellular pdn type + * @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 + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported +*/ +int connection_profile_set_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type); + +/** * @} */ diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index 4f6cd24..d85e002 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.82 +Version: 1.0.83 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/connection_profile.c b/src/connection_profile.c index 8e03298..b2e95c6 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -79,6 +79,8 @@ static void __profile_init_cellular_profile(net_profile_info_t *profile_info, co profile_info->profile_type = NET_DEVICE_CELLULAR; profile_info->ProfileState = NET_STATE_TYPE_IDLE; + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_UNKNOWN; + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_UNKNOWN; profile_info->ProfileInfo.Pdp.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF; profile_info->ProfileInfo.Pdp.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; g_strlcpy(profile_info->ProfileInfo.Pdp.Keyword, keyword, NET_PDP_APN_LEN_MAX); @@ -1440,6 +1442,82 @@ EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h pro return CONNECTION_ERROR_NONE; } +EXPORT_API int connection_profile_get_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e* type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (profile_info->ProfileInfo.Pdp.PdnType) { + //LCOV_EXCL_START + case NET_PDN_TYPE_UNKNOWN: + *type = CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN; + break; + case NET_PDN_TYPE_IPV4: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4; + break; + case NET_PDN_TYPE_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV6; + break; + case NET_PDN_TYPE_IPV4_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6; + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} + +EXPORT_API int connection_profile_get_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e* type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (profile_info->ProfileInfo.Pdp.RoamPdnType) { + //LCOV_EXCL_START + case NET_PDN_TYPE_UNKNOWN: + *type = CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN; + break; + case NET_PDN_TYPE_IPV4: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4; + break; + case NET_PDN_TYPE_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV6; + break; + case NET_PDN_TYPE_IPV4_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6; + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} + EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); @@ -1663,3 +1741,73 @@ EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h pro return CONNECTION_ERROR_NONE; } + +EXPORT_API int connection_profile_set_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (type) { + //LCOV_EXCL_START + case CONNECTION_CELLULAR_PDN_TYPE_IPV4: + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV4; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV6: + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV6; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6: + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV4_IPV6; + break; + default: + return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} + +EXPORT_API int connection_profile_set_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (type) { + //LCOV_EXCL_START + case CONNECTION_CELLULAR_PDN_TYPE_IPV4: + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV4; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV6: + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV6; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6: + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV4_IPV6; + break; + default: + return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} diff --git a/test/connection_test.c b/test/connection_test.c index 2e6d097..ec4cfcb 100755 --- a/test/connection_test.c +++ b/test/connection_test.c @@ -460,6 +460,40 @@ static int test_update_cellular_info(connection_profile_h profile) } } + if (test_get_user_int("Input PdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) { + switch (input_int) { + case 1: + rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4); + break; + case 2: + rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6); + break; + case 3: + rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6); + break; + } + + if (rv != CONNECTION_ERROR_NONE) + return -1; + } + + if (test_get_user_int("Input RoamPdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) { + switch (input_int) { + case 1: + rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4); + break; + case 2: + rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6); + break; + case 3: + rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6); + break; + } + + if (rv != CONNECTION_ERROR_NONE) + return -1; + } + return 1; } @@ -618,6 +652,8 @@ static int test_update_network_info(connection_profile_h profile) static void test_print_cellular_info(connection_profile_h profile) { connection_cellular_service_type_e service_type; + connection_cellular_pdn_type_e pdn_type; + connection_cellular_pdn_type_e roam_pdn_type; char *apn = NULL; connection_cellular_auth_type_e auth_type; char *user_name = NULL; @@ -632,6 +668,16 @@ static void test_print_cellular_info(connection_profile_h profile) else printf("Cellular service type : %d\n", service_type); + if (connection_profile_get_cellular_pdn_type(profile, &pdn_type) != CONNECTION_ERROR_NONE) + printf("Fail to get cellular pdn type!\n"); + else + printf("Cellular pdn type : %d\n", pdn_type); + + if (connection_profile_get_cellular_roam_pdn_type(profile, &roam_pdn_type) != CONNECTION_ERROR_NONE) + printf("Fail to get cellular roam pdn type!\n"); + else + printf("Cellular roam pdn type : %d\n", roam_pdn_type); + if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE) printf("Fail to get cellular APN!\n"); else { -- 2.7.4