diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-28 22:55:45 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2024-01-13 19:08:01 +0000 |
commit | bcc1040a1c3f5394cea82503034d2b78696d0a4b (patch) | |
tree | 8484478f8c4d1552a7b82e583f9e2c830f0a2ed2 /src/ubus.c | |
parent | ddaa102a4f51f95def99cde2584219ec8f57d95c (diff) |
dhcpv4: add peer-4o6 to ipv4 ubus messages
Diffstat (limited to 'src/ubus.c')
-rw-r--r-- | src/ubus.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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); } |