From fb58afd37e07e47abb837b658b243af1108275d6 Mon Sep 17 00:00:00 2001 From: Matt Dunwoodie Date: Tue, 21 May 2019 21:27:25 +1000 Subject: Add support for OpenBSD keepalive --- src/tools/ipc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tools/ipc.c b/src/tools/ipc.c index 0b0bc66..099dfd1 100644 --- a/src/tools/ipc.c +++ b/src/tools/ipc.c @@ -1051,6 +1051,11 @@ static int openbsd_get_device(struct wgdevice **device, const char *interface) peer->flags |= WGPEER_HAS_PRESHARED_KEY; } + if (wgp.gp_pka != 0) { + peer->persistent_keepalive_interval = wgp.gp_pka; + peer->flags |= WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL; + } + if (wgp.gp_ip.sa.sa_family != AF_UNSPEC) memcpy(&peer->endpoint.addr, &wgp.gp_ip.sa, wgp.gp_ip.sa.sa_len); @@ -1142,8 +1147,12 @@ static int openbsd_set_device(struct wgdevice *dev) return -1; } - if (peer->flags & WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL) - printf("Persistent keepalive not supported\n"); + if (peer->flags & WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL) { + wsp.sp_pka = peer->persistent_keepalive_interval; + if (ioctl(s, SIOCSWGPEERPKA, (caddr_t)&wsp) == -1) + return -1; + } + if (peer->flags & WGPEER_REPLACE_ALLOWEDIPS) if (ioctl(s, SIOCCWGPEERAIP, (caddr_t)&wsp) == -1) return -1; -- cgit v1.2.3-59-g8ed1b