summaryrefslogtreecommitdiffhomepage
path: root/src/ubus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ubus.c')
-rw-r--r--src/ubus.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ubus.c b/src/ubus.c
index 7d8fb2a..01a83cb 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -80,6 +80,11 @@ static int handle_dhcpv4_leases(struct ubus_context *ctx, _unused struct ubus_ob
blobmsg_add_u32(&b, "valid", INFINITE_VALID(c->valid_until) ?
(uint32_t)-1 : (uint32_t)(c->valid_until - now));
+ char hbuf[NI_MAXHOST] = "";
+ getnameinfo((struct sockaddr *)&c->peer, sizeof(c->peer),
+ hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
+ blobmsg_add_string(&b, "peer-4o6", hbuf);
+
blobmsg_close_table(&b, l);
}
@@ -349,7 +354,7 @@ static const struct blobmsg_policy obj_attrs[OBJ_ATTR_MAX] = {
void ubus_bcast_dhcp_event(const char *type, const uint8_t *mac,
const size_t mlen, const struct in_addr *addr, const char *name,
- const char *interface)
+ const char *interface, const struct in6_addr *peer_4o6)
{
if (!ubus || !main_object.has_subscribers)
return;
@@ -363,6 +368,11 @@ void ubus_bcast_dhcp_event(const char *type, const uint8_t *mac,
blobmsg_add_string(&b, "name", name);
if (interface)
blobmsg_add_string(&b, "interface", interface);
+ if (peer_4o6) {
+ char *peer = blobmsg_alloc_string_buffer(&b, "peer-4o6", INET6_ADDRSTRLEN);
+ inet_ntop(AF_INET6, peer_4o6, peer, INET6_ADDRSTRLEN);
+ blobmsg_add_string_buffer(&b);
+ }
ubus_notify(ubus, &main_object, type, b.head, -1);
}