From 10d13c7b37f8e470bde3bd6dea0857c81ffefd63 Mon Sep 17 00:00:00 2001 From: Thomas Gschwantner Date: Tue, 16 Jul 2019 01:12:06 +0200 Subject: Implement lease expiration --- lease.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'lease.h') diff --git a/lease.h b/lease.h index 4052bf9..95a7b58 100644 --- a/lease.h +++ b/lease.h @@ -35,12 +35,9 @@ void leases_free(); /* * Creates a new lease and returns a pointer to it, or NULL if either we ran out * of assignable IPs or the requested IP is already taken. - * expires contains the (monotonic) timestamp after which the next lease, - * possibly the newly created one, will expire. */ struct wg_dynamic_lease *new_lease(wg_key pubkey, uint32_t leasetime, - struct in_addr *ipv4, struct in6_addr *ipv6, - time_t *expires); + struct in_addr *ipv4, struct in6_addr *ipv6); /* * Returns all leases belonging to pubkey, or NULL if there are none. @@ -48,17 +45,15 @@ struct wg_dynamic_lease *new_lease(wg_key pubkey, uint32_t leasetime, struct wg_dynamic_lease *get_leases(wg_key pubkey); /* - * Extend the lease to be leasetime long again. Returns true on error, or false - * otherwise. expires behaves exactly as in new_lease(). + * Extend the lease to be leasetime seconds long again. Returns true on error, + * or false otherwise. */ -bool extend_lease(struct wg_dynamic_lease *lease, uint32_t leasetime, - time_t *expires); +bool extend_lease(struct wg_dynamic_lease *lease, uint32_t leasetime); -/* - * Refreshes all leases, meaning expired ones will be removed. Returns the - * expiration timestamp of the lease that will expire next. +/* Refreshes all leases, meaning expired ones will be removed. Returns the + * amount of seconds until the next lease will expire, or at most INT_MAX/1000. */ -time_t leases_refresh(); +int leases_refresh(); /* * Updates all pools with information from the netlink file descriptor fd. -- cgit v1.2.3-59-g8ed1b