---
 gdhcp/client.c |   31 +++++++++++++++++++++++++++++++
 gdhcp/gdhcp.h  |    3 +++
 2 files changed, 34 insertions(+)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index ddcbeb3..433a1a6 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -154,6 +154,8 @@ struct _GDHCPClient {
        uint32_t expire;
        bool retransmit;
        struct timeval start_time;
+       time_t last_renew;
+       time_t last_rebind;
 };
 
 static inline void debug(GDHCPClient *client, const char *format, ...)
@@ -492,6 +494,8 @@ static int send_renew(GDHCPClient *dhcp_client)
 
        add_send_options(dhcp_client, &packet);
 
+       dhcp_client->last_renew = time(NULL);
+
        return dhcp_send_kernel_packet(&packet,
                dhcp_client->requested_ip, CLIENT_PORT,
                dhcp_client->server_ip, SERVER_PORT);
@@ -511,6 +515,8 @@ static int send_rebound(GDHCPClient *dhcp_client)
 
        add_send_options(dhcp_client, &packet);
 
+       dhcp_client->last_rebind = time(NULL);
+
        return dhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT,
                                        INADDR_BROADCAST, SERVER_PORT,
                                        MAC_BCAST_ADDR, dhcp_client->ifindex);
@@ -2957,6 +2963,31 @@ char *g_dhcp_client_get_netmask(GDHCPClient *dhcp_client)
        return NULL;
 }
 
+int g_dhcp_client_get_timeouts(GDHCPClient *dhcp_client,
+                               uint32_t *lease_seconds, time_t *last_renew,
+                time_t *last_rebind, time_t *expire)
+{
+
+       if (dhcp_client == NULL || dhcp_client->type == G_DHCP_IPV6)
+               return -EINVAL;
+
+       if (lease_seconds != NULL)
+               *lease_seconds = dhcp_client->lease_seconds;
+
+       if (last_renew != NULL)
+               *last_renew = dhcp_client->last_renew;
+
+       if (last_rebind != NULL)
+               *last_rebind = dhcp_client->last_rebind;
+
+       if (expire != NULL)
+               *expire = dhcp_client->expire;
+
+       return 0;
+
+
+}
+
 const char* g_dhcp_client_get_state(GDHCPClient *dhcp_client)
 {
        switch (dhcp_client->state) {
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index 4a3e6d2..ae76011 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -156,6 +156,9 @@ char *g_dhcp_client_get_netmask(GDHCPClient *client);
 GList *g_dhcp_client_get_option(GDHCPClient *client,
                                                unsigned char option_code);
 int g_dhcp_client_get_index(GDHCPClient *client);
+int g_dhcp_client_get_timeouts(GDHCPClient *dhcp_client,
+               uint32_t *lease_seconds, time_t *last_renew,
+               time_t *last_rebind, time_t *expire);
 
 const char* g_dhcp_client_get_state(GDHCPClient *state);
 
-- 
1.7.9.5

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to