aboutsummaryrefslogtreecommitdiffstats
path: root/lease.h
diff options
context:
space:
mode:
Diffstat (limited to 'lease.h')
-rw-r--r--lease.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/lease.h b/lease.h
index 23852e6..8e83135 100644
--- a/lease.h
+++ b/lease.h
@@ -37,10 +37,12 @@ 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.
+ * of assignable IPs or if requested IP(s) are already taken.
*/
struct wg_dynamic_lease *new_lease(wg_key pubkey, uint32_t leasetime,
- struct in_addr *ipv4, struct in6_addr *ipv6);
+ const struct in_addr *ipv4,
+ const struct in6_addr *ipv6,
+ struct wg_dynamic_lease *current);
/*
* Returns all leases belonging to pubkey, or NULL if there are none.
@@ -48,12 +50,12 @@ 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 seconds long again. Returns true on error,
- * or false otherwise.
+ * Release the lease and free allocated memory.
*/
-bool extend_lease(struct wg_dynamic_lease *lease, uint32_t leasetime);
+bool release_lease(struct wg_dynamic_lease *lease, wg_key pubkey);
-/* Refreshes all leases, meaning expired ones will be removed. Returns the
+/*
+ * 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.
*/
int leases_refresh(void (*update_cb)(wg_key *, int));
@@ -63,4 +65,13 @@ int leases_refresh(void (*update_cb)(wg_key *, int));
*/
void leases_update_pools(struct mnl_socket *nlsock);
+/*
+ * Return true if lease is !NULL and has not expired.
+ */
+bool lease_is_valid(const struct wg_dynamic_lease *lease);
+
+#ifdef DEBUG
+char *lease_to_str(const struct wg_dynamic_lease *l);
+#endif
+
#endif