Changes required for DHCP leased seconds API 88/142188/1 accepted/tizen/unified/20170811.021044 submit/tizen/20170808.043745 submit/tizen/20170809.085632
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Thu, 3 Aug 2017 03:57:22 +0000 (09:27 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Thu, 3 Aug 2017 03:57:22 +0000 (09:27 +0530)
Change-Id: I0727c24f30be5162d27e49996dfa376348f98527
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
gdhcp/client.c
gdhcp/gdhcp.h
src/connman.h
src/dhcp.c
src/ipconfig.c

index ff4539b..d3794bd 100755 (executable)
@@ -178,6 +178,7 @@ struct _GDHCPClient {
        struct timeval start_time;
        bool request_bcast;
 #if defined TIZEN_EXT
+       uint32_t dhcp_lease_seconds;
        gboolean init_reboot;
 #endif
 };
@@ -2383,6 +2384,10 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
 
                        dhcp_client->lease_seconds = get_lease(&packet);
 
+#if defined TIZEN_EXT
+                       dhcp_client->dhcp_lease_seconds = dhcp_client->lease_seconds;
+#endif
+
                        get_request(dhcp_client, &packet);
 
                        switch_listening_mode(dhcp_client, L_NONE);
@@ -3036,6 +3041,13 @@ char *g_dhcp_client_get_server_address(GDHCPClient *dhcp_client)
 #endif
 }
 
+#if defined TIZEN_EXT
+int g_dhcp_client_get_dhcp_lease_duration(GDHCPClient *dhcp_client)
+{
+       return dhcp_client->dhcp_lease_seconds;
+}
+#endif
+
 char *g_dhcp_client_get_address(GDHCPClient *dhcp_client)
 {
        return g_strdup(dhcp_client->assigned_ip);
index 59b562b..fd6ce54 100755 (executable)
@@ -151,6 +151,11 @@ GDHCPClientError g_dhcp_client_set_send(GDHCPClient *client,
                                                const char *option_value);
 
 char *g_dhcp_client_get_server_address(GDHCPClient *client);
+
+#if defined TIZEN_EXT
+int g_dhcp_client_get_dhcp_lease_duration(GDHCPClient *client);
+#endif
+
 char *g_dhcp_client_get_address(GDHCPClient *client);
 char *g_dhcp_client_get_netmask(GDHCPClient *client);
 GList *g_dhcp_client_get_option(GDHCPClient *client,
index 7c44d1c..237c1ec 100755 (executable)
@@ -367,6 +367,11 @@ const char *__connman_ipconfig_get_broadcast(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_broadcast(struct connman_ipconfig *ipconfig, const char *broadcast);
 const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig, const char *gateway);
+
+#if defined TIZEN_EXT
+void __connman_ipconfig_set_dhcp_lease_duration(struct connman_ipconfig *ipconfig, int dhcp_lease_duration);
+#endif
+
 unsigned char __connman_ipconfig_get_prefixlen(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_prefixlen(struct connman_ipconfig *ipconfig, unsigned char prefixlen);
 
index 7e5f71d..b627362 100755 (executable)
@@ -473,6 +473,10 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
        __connman_ipconfig_set_dhcp_address(dhcp->ipconfig, address);
        DBG("last address %s", address);
 
+#if defined TIZEN_EXT
+       int dhcp_lease_duration = g_dhcp_client_get_dhcp_lease_duration(dhcp_client);
+#endif
+
        option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
        if (option)
                netmask = g_strdup(option->data);
@@ -505,6 +509,11 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
 
        __connman_ipconfig_set_method(dhcp->ipconfig,
                                                CONNMAN_IPCONFIG_METHOD_DHCP);
+
+#if defined TIZEN_EXT
+       __connman_ipconfig_set_dhcp_lease_duration(dhcp->ipconfig, dhcp_lease_duration);
+#endif
+
        if (ip_change) {
                __connman_ipconfig_set_local(dhcp->ipconfig, address);
                __connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
index 411fc45..700384f 100755 (executable)
@@ -53,6 +53,10 @@ struct connman_ipconfig {
        struct connman_ipaddress *address;
        struct connman_ipaddress *system;
 
+#if defined TIZEN_EXT
+       int dhcp_lease_duration;
+#endif
+
        int ipv6_privacy_config;
        char *last_dhcp_address;
        char **last_dhcpv6_prefixes;
@@ -1098,6 +1102,14 @@ void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
 }
 
 #if defined TIZEN_EXT
+void __connman_ipconfig_set_dhcp_lease_duration(struct connman_ipconfig *ipconfig,
+               int dhcp_lease_duration)
+{
+       ipconfig->dhcp_lease_duration = dhcp_lease_duration;
+}
+#endif
+
+#if defined TIZEN_EXT
 int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig, struct connman_service *service)
 #else
 int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig)
@@ -1903,6 +1915,8 @@ void __connman_ipconfig_append_ipv4(struct connman_ipconfig *ipconfig,
                                        DBUS_TYPE_STRING, &server_ip);
                        g_free(server_ip);
                }
+               connman_dbus_dict_append_basic(iter, "DHCPLeaseDuration",
+                               DBUS_TYPE_INT32, &ipconfig->dhcp_lease_duration);
        }
 #endif
 }