From 703bc7fdc2095be2a8825e5ad3b602cf367a9c66 Mon Sep 17 00:00:00 2001 From: Matt Dunwoodie Date: Sun, 21 Jul 2019 22:49:43 +1000 Subject: Actually call SIOCSWGPEERAIP in wg(8) The set AIP ioctl was actually not called in openbsd_set_device. Also, specify ipv4 and ipv6 when copying the addresses. --- src/tools/ipc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/ipc.c b/src/tools/ipc.c index 099dfd1..64ea9e5 100644 --- a/src/tools/ipc.c +++ b/src/tools/ipc.c @@ -1079,10 +1079,10 @@ static int openbsd_get_device(struct wgdevice **device, const char *interface) aip->family = ip[j].c_af; if (ip[j].c_af == AF_INET) { - memcpy(&aip->ip4, &ip[j].c_ip, sizeof(aip->ip4)); + memcpy(&aip->ip4, &ip[j].c_ip.ipv4, sizeof(aip->ip4)); aip->cidr = ip[j].c_mask; } else if (ip[j].c_af == AF_INET6) { - memcpy(&aip->ip6, &ip[j].c_ip, sizeof(aip->ip6)); + memcpy(&aip->ip6, &ip[j].c_ip.ipv6, sizeof(aip->ip6)); aip->cidr = ip[j].c_mask; } } @@ -1169,6 +1169,9 @@ static int openbsd_set_device(struct wgdevice *dev) } else { return -1; } + + if (ioctl(s, SIOCSWGPEERAIP, (caddr_t)&wsp) == -1) + return -1; } } return 0; -- cgit v1.2.3-59-g8ed1b