summaryrefslogtreecommitdiff
path: root/gdhcp
diff options
context:
space:
mode:
Diffstat (limited to 'gdhcp')
-rw-r--r--gdhcp/client.c18
-rw-r--r--gdhcp/gdhcp.h4
2 files changed, 20 insertions, 2 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index cd428cff..7743aa50 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -138,6 +138,7 @@ struct _GDHCPClient {
struct in6_addr ia_ta;
time_t last_renew;
time_t last_rebind;
+ time_t expire;
};
static inline void debug(GDHCPClient *client, const char *format, ...)
@@ -627,7 +628,8 @@ void g_dhcpv6_client_create_iaid(GDHCPClient *dhcp_client, int index,
int g_dhcpv6_client_get_timeouts(GDHCPClient *dhcp_client,
uint32_t *T1, uint32_t *T2,
- time_t *last_renew, time_t *last_rebind)
+ time_t *last_renew, time_t *last_rebind,
+ time_t *expire)
{
if (dhcp_client == NULL || dhcp_client->type == G_DHCP_IPV4)
return -EINVAL;
@@ -644,6 +646,9 @@ int g_dhcpv6_client_get_timeouts(GDHCPClient *dhcp_client,
if (last_rebind != NULL)
*last_rebind = dhcp_client->last_rebind;
+ if (expire != NULL)
+ *expire = dhcp_client->expire;
+
return 0;
}
@@ -884,6 +889,7 @@ GDHCPClient *g_dhcp_client_new(GDHCPType type,
dhcp_client->duid = NULL;
dhcp_client->duid_len = 0;
dhcp_client->last_renew = dhcp_client->last_rebind = time(0);
+ dhcp_client->expire = 0;
*error = G_DHCP_CLIENT_ERROR_NONE;
@@ -1656,6 +1662,8 @@ static GList *get_addresses(GDHCPClient *dhcp_client,
else
memcpy(&dhcp_client->ia_ta, &addr,
sizeof(struct in6_addr));
+
+ g_dhcpv6_client_set_expire(dhcp_client, valid);
}
return list;
@@ -2490,6 +2498,14 @@ void g_dhcpv6_client_reset_rebind(GDHCPClient *dhcp_client)
dhcp_client->last_rebind = time(0);
}
+void g_dhcpv6_client_set_expire(GDHCPClient *dhcp_client, uint32_t timeout)
+{
+ if (dhcp_client == NULL || dhcp_client->type == G_DHCP_IPV4)
+ return;
+
+ dhcp_client->expire = time(0) + timeout;
+}
+
uint16_t g_dhcpv6_client_get_status(GDHCPClient *dhcp_client)
{
if (dhcp_client == NULL || dhcp_client->type == G_DHCP_IPV4)
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index 29eea566..49b06b1a 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -144,12 +144,14 @@ void g_dhcpv6_client_create_iaid(GDHCPClient *dhcp_client, int index,
unsigned char *iaid);
int g_dhcpv6_client_get_timeouts(GDHCPClient *dhcp_client,
uint32_t *T1, uint32_t *T2,
- time_t *last_renew, time_t *last_rebind);
+ time_t *last_renew, time_t *last_rebind,
+ time_t *expire);
uint32_t g_dhcpv6_client_get_iaid(GDHCPClient *dhcp_client);
int g_dhcpv6_client_set_ia(GDHCPClient *dhcp_client, int index,
int code, uint32_t *T1, uint32_t *T2, gboolean add_iaaddr);
void g_dhcpv6_client_reset_renew(GDHCPClient *dhcp_client);
void g_dhcpv6_client_reset_rebind(GDHCPClient *dhcp_client);
+void g_dhcpv6_client_set_expire(GDHCPClient *dhcp_client, uint32_t timeout);
/* DHCP Server */
typedef enum {