summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-01-14 18:07:43 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2024-01-13 19:08:01 +0000
commitddaa102a4f51f95def99cde2584219ec8f57d95c (patch)
tree931f145b0272e9479309c69a9d57475d75bea9ee
parent8e89b1fb27309741b54485d35f6c215f3a1c976d (diff)
dhcpv6: add peer to ubus dhcpv6leases
Add the peer address to allow relating the lease to a WireGuard peer.
-rw-r--r--src/ubus.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ubus.c b/src/ubus.c
index c4fbf92..7d8fb2a 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -3,6 +3,8 @@
#include <libubox/uloop.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netdb.h>
#include <libubox/utils.h>
@@ -150,6 +152,11 @@ static int handle_dhcpv6_leases(_unused struct ubus_context *ctx, _unused struct
else
blobmsg_add_u16(&b, "assigned", a->assigned_subnet_id);
+ char hbuf[NI_MAXHOST] = "";
+ getnameinfo((struct sockaddr *)&a->peer, sizeof(a->peer),
+ hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
+ blobmsg_add_string(&b, "peer", hbuf);
+
m = blobmsg_open_array(&b, "flags");
if (a->flags & OAF_BOUND)
blobmsg_add_string(&b, NULL, "bound");