summaryrefslogtreecommitdiffstats
path: root/src/wireguard.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-08-08 20:34:54 +1000
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-08-08 21:37:38 +1000
commit659d1c4ba4f9a5942619772b5a635f8a39b6ce63 (patch)
tree24c54059c04eded8cc0cc519a7231b768d8c221e /src/wireguard.h
parentRemove struct wg_pkt (diff)
downloadwireguard-openbsd-659d1c4ba4f9a5942619772b5a635f8a39b6ce63.tar.xz
wireguard-openbsd-659d1c4ba4f9a5942619772b5a635f8a39b6ce63.zip
Move timers to wireguard.c
It makes more sense for the timers to be in wireguard.c, it still has work to do as there are still references to t_last_handshake in if_wg.c, but this is the first step.
Diffstat (limited to 'src/wireguard.h')
-rw-r--r--src/wireguard.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/wireguard.h b/src/wireguard.h
index c0d8834bc5b..38a69b02ac7 100644
--- a/src/wireguard.h
+++ b/src/wireguard.h
@@ -3,6 +3,7 @@
#include <sys/types.h>
#include <sys/time.h>
+#include <sys/timeout.h>
#include <sys/rwlock.h>
#define WG_KEY_SIZE 32
@@ -100,6 +101,17 @@ struct wg_session {
} s_ar;
};
+struct wg_timers {
+ struct timeout t_ka;
+ struct timeout t_pka;
+ struct timeout t_broken;
+ struct timeout t_reinit;
+ struct timeout t_cleanup;
+ struct timespec t_last_initiation;
+ struct timespec t_last_handshake;
+ uint16_t t_pka_interval;
+};
+
struct wg_msg_unknown {
uint32_t type;
} __packed;
@@ -172,6 +184,21 @@ enum wg_error wg_session_from_handshake(struct wg_session *, struct wg_handshake
void wg_keypair_from_bytes(struct wg_keypair *, const uint8_t [WG_KEY_SIZE]);
enum wg_pkt_type wg_pkt_type(uint8_t *, size_t);
+/* Timer functions */
+void wg_timer_broken(void *);
+void wg_timer_reinit(void *);
+void wg_timer_cleanup(void *);
+void wg_timer_setup(struct wg_timers *, void *, void (*)(void *),
+ void (*)(void *), void (*)(void *), void (*)(void *));
+void wg_timer_persistent_keepalive_tick(struct wg_timers *);
+void wg_timer_cleanup_tick(struct wg_timers *);
+void wg_timer_keepalive_flag(struct wg_timers *);
+void wg_timer_keepalive_unflag(struct wg_timers *);
+void wg_timer_broken_flag(struct wg_timers *);
+void wg_timer_broken_unflag(struct wg_timers *);
+void wg_timer_reinit_flag(struct wg_timers *);
+void wg_timer_reinit_unflag(struct wg_timers *);
+
/* TODO make better */
void wg_keypair_generate(struct wg_keypair *);
int wg_timespec_timedout(struct timespec *, time_t);