ubus: Display the IPv6 prefix assigned address
authorHans Dedecker <hans.dedecker@technicolor.com>
Fri, 9 Dec 2016 07:47:39 +0000 (08:47 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Mon, 12 Dec 2016 07:55:50 +0000 (08:55 +0100)
Display the IPv6 address obtained from a prefix assignment
as local-address element in the ubus ipv6-prefix-assignment
list so it's explicitly clear which IPv6 address from the
delegated prefix is assigned to interface.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
ubus.c

diff --git a/ubus.c b/ubus.c
index 8ba43c0f27c8a26ec5a168ffe0cddad500cbbe53..29924c11700786aff0c21231c14f2fef25eb0c6e 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -600,12 +600,21 @@ interface_ip_dump_prefix_assignment_list(struct interface *iface)
                        if (prefix->valid_until)
                                blobmsg_add_u32(&b, "valid", prefix->valid_until - now);
 
+                       void *c = blobmsg_open_table(&b, "local-address");
+                       if (assign->enabled) {
+                               buf = blobmsg_alloc_string_buffer(&b, "address", buflen);
+                               inet_ntop(AF_INET6, &assign->addr, buf, buflen);
+                               blobmsg_add_string_buffer(&b);
+
+                               blobmsg_add_u32(&b, "mask", assign->length < 64 ? 64 : assign->length);
+                       }
+                       blobmsg_close_table(&b, c);
+
                        blobmsg_close_table(&b, a);
                }
        }
 }
 
-
 static void
 interface_ip_dump_dns_server_list(struct interface_ip_settings *ip,
                                   bool enabled)