From: Abhishek Sansanwal Date: Thu, 3 Aug 2017 06:32:37 +0000 (+0530) Subject: Added connection_profile_get_dhcp_lease_duration API X-Git-Tag: accepted/tizen/4.0/unified/20170828.223656~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fapi%2Fconnection.git;a=commitdiff_plain;h=47d6150437cba7fe5a3925990ef46c0226a65971 Added connection_profile_get_dhcp_lease_duration API Change-Id: I428ad98cbdca4daabfcfc53d1983262903d6601a Signed-off-by: Abhishek Sansanwal --- diff --git a/src/connection_profile.c b/src/connection_profile.c index 57bd958..e617348 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -684,6 +684,31 @@ EXPORT_API int connection_profile_get_dhcp_server_address( return CONNECTION_ERROR_NONE; } +EXPORT_API int connection_profile_get_dhcp_lease_duration( + connection_profile_h profile, + connection_address_family_e address_family, int* dhcp_lease_duration) +{ + 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)) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + 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; + + CONNECTION_LOG(CONNECTION_INFO, "Lease duration : %d", + net_info->DHCPLeaseDuration); + + *dhcp_lease_duration = net_info->DHCPLeaseDuration; + + return CONNECTION_ERROR_NONE; +} + EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, char** dns_address) { diff --git a/test/connection_test.c b/test/connection_test.c index 262ed29..087ce68 100755 --- a/test/connection_test.c +++ b/test/connection_test.c @@ -860,6 +860,7 @@ static void test_print_network_info(connection_profile_h profile, connection_add char *subnet = NULL; char *gateway = NULL; char *dhcp_server = NULL; + int dhcp_lease_duration = 0; char *dns1 = NULL; char *dns2 = NULL; char *proxy = NULL; @@ -901,6 +902,12 @@ static void test_print_network_info(connection_profile_h profile, connection_add g_free(dhcp_server); } + if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE) + printf("Fail to get DHCP lease duration!\n"); + else { + printf("DHCP lease duration : %d\n", dhcp_lease_duration); + } + if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE) printf("Fail to get subnet mask!\n"); else {