aboutsummaryrefslogtreecommitdiffstats
path: root/lease.h
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2019-10-01 00:57:42 +0200
committerLinus Nordberg <linus@nordberg.se>2019-10-01 00:57:42 +0200
commit203f12fcdfbb8783d7416648657344471e55fbc3 (patch)
treed524a5d30d68fafba2127471581540e284960bc6 /lease.h
parentFix typo in the previous commits NULL check (diff)
downloadwg-dynamic-ln/remove-allowedips-3.tar.xz
wg-dynamic-ln/remove-allowedips-3.zip
Diffstat (limited to 'lease.h')
-rw-r--r--lease.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/lease.h b/lease.h
index 3e1402d..bffcd66 100644
--- a/lease.h
+++ b/lease.h
@@ -13,12 +13,15 @@
#include "common.h"
#include "netlink.h"
+#define WG_DYNAMIC_LEASE_CHUNKSIZE 256
+
struct wg_dynamic_lease {
time_t start_real;
time_t start_mono;
uint32_t leasetime; /* in seconds */
struct in_addr ipv4;
struct in6_addr ipv6;
+ struct in6_addr lladdr;
struct wg_dynamic_lease *next;
};
@@ -38,7 +41,8 @@ void leases_free();
* of assignable IPs or the requested IP is already taken.
*/
struct wg_dynamic_lease *new_lease(wg_key pubkey, uint32_t leasetime,
- struct in_addr *ipv4, struct in6_addr *ipv6);
+ struct in_addr *ipv4, struct in6_addr *ipv6,
+ const struct in6_addr *lladdr);
/*
* Returns all leases belonging to pubkey, or NULL if there are none.
@@ -54,7 +58,13 @@ bool extend_lease(struct wg_dynamic_lease *lease, uint32_t leasetime);
/* 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();
+int leases_refresh(const char *devname);
+
+/*
+ * Updates allowedips for peer_pubkey on devname, adding what's in
+ * lease (including lladdr), removing all others.
+ */
+void update_allowed_ips(const char *devname, wg_key peer_pubkey, const struct wg_dynamic_lease *lease);
/*
* Updates all pools with information from the mnl socket nlsock.