summaryrefslogtreecommitdiff
path: root/ubus.c
diff options
context:
space:
mode:
authormeurisa <alexander.meuris@technicolor.com>2019-04-12 09:56:28 +0200
committerHans Dedecker <dedeckeh@gmail.com>2019-04-15 22:31:38 +0200
commit08989e46b9030671ce57b8872538d40e2ddcbbe0 (patch)
treec0119c3ca57b572adcfa6462d34411a6e0c2f0ac /ubus.c
parentbfd4de3666901070d805878e55b02417fef6277c (diff)
downloadnetifd-08989e46b9030671ce57b8872538d40e2ddcbbe0.tar.gz
interface: add neighbor config support
The neighbor or neighbor6 network section makes neighbours configurable via UCI or proto shell handlers. It allows to install neighbor proxy entries or static neighbor entries The neighbor or neighbor6 section has the following types: interface : declares the logical OpenWrt interface ipaddr : the ip address of the neighbor mac : the mac address of the neighbor proxy : specifies whether the neighbor ia a proxy entry (can be 1 or 0) router : specifies whether the neighbor is a router (can be 1 or 0) Signed-off-by: Alexander Meuris <meurisalexander@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'ubus.c')
-rw-r--r--ubus.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/ubus.c b/ubus.c
index 14688c2..e7cbfb9 100644
--- a/ubus.c
+++ b/ubus.c
@@ -459,6 +459,43 @@ interface_ip_dump_address_list(struct interface_ip_settings *ip, bool v6, bool e
}
static void
+interface_ip_dump_neighbor_list(struct interface_ip_settings *ip, bool enabled)
+{
+ struct device_neighbor *neighbor;
+ int buflen = 128;
+ char *buf;
+ void *r;
+ int af;
+
+ vlist_for_each_element(&ip->neighbor, neighbor, node) {
+ if (neighbor->enabled != enabled)
+ continue;
+
+ if ((neighbor->flags & DEVADDR_FAMILY) == DEVADDR_INET4)
+ af = AF_INET;
+ else
+ af = AF_INET6;
+
+ r = blobmsg_open_table(&b, NULL);
+
+ if (neighbor->flags & DEVNEIGH_MAC)
+ blobmsg_add_string(&b, "mac", format_macaddr(neighbor->macaddr));
+
+ buf = blobmsg_alloc_string_buffer(&b , "address", buflen);
+ inet_ntop(af, &neighbor->addr, buf, buflen);
+ blobmsg_add_string_buffer(&b);
+
+ if (neighbor->proxy)
+ blobmsg_add_u32(&b, "proxy", neighbor->proxy);
+
+ if (neighbor->router)
+ blobmsg_add_u32(&b, "router", neighbor->router);
+
+ blobmsg_close_table(&b, r);
+ }
+}
+
+static void
interface_ip_dump_route_list(struct interface_ip_settings *ip, bool enabled)
{
struct device_route *route;
@@ -737,6 +774,10 @@ netifd_dump_status(struct interface *iface)
interface_ip_dump_dns_search_list(&iface->config_ip, true);
interface_ip_dump_dns_search_list(&iface->proto_ip, true);
blobmsg_close_array(&b, a);
+ a = blobmsg_open_array(&b, "neighbors");
+ interface_ip_dump_neighbor_list(&iface->config_ip, true);
+ interface_ip_dump_neighbor_list(&iface->proto_ip, true);
+ blobmsg_close_array(&b, a);
inactive = blobmsg_open_table(&b, "inactive");
a = blobmsg_open_array(&b, "ipv4-address");
@@ -759,6 +800,10 @@ netifd_dump_status(struct interface *iface)
interface_ip_dump_dns_search_list(&iface->config_ip, false);
interface_ip_dump_dns_search_list(&iface->proto_ip, false);
blobmsg_close_array(&b, a);
+ a = blobmsg_open_array(&b, "neighbors");
+ interface_ip_dump_neighbor_list(&iface->config_ip, false);
+ interface_ip_dump_neighbor_list(&iface->proto_ip, false);
+ blobmsg_close_array(&b, a);
blobmsg_close_table(&b, inactive);
}