Added connection_profile_get_dhcp_lease_duration API 32/142232/1
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Thu, 3 Aug 2017 06:32:37 +0000 (12:02 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Thu, 3 Aug 2017 06:32:37 +0000 (12:02 +0530)
Change-Id: I428ad98cbdca4daabfcfc53d1983262903d6601a
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
src/connection_profile.c
test/connection_test.c

index 57bd958..e617348 100755 (executable)
@@ -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)
 {
index 262ed29..087ce68 100755 (executable)
@@ -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 {