From 08989e46b9030671ce57b8872538d40e2ddcbbe0 Mon Sep 17 00:00:00 2001 From: meurisa Date: Fri, 12 Apr 2019 09:56:28 +0200 Subject: 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 Signed-off-by: Hans Dedecker --- config.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index be10379..843c53f 100644 --- a/config.c +++ b/config.c @@ -143,6 +143,17 @@ config_parse_route(struct uci_section *s, bool v6) interface_ip_add_route(NULL, blob_data(b.head), v6); } +static void +config_parse_neighbor(struct uci_section *s, bool v6) +{ + void *neighbor; + blob_buf_init(&b,0); + neighbor = blobmsg_open_array(&b, "neighbor"); + uci_to_blob(&b,s, &neighbor_attr_list); + blobmsg_close_array(&b, neighbor); + interface_ip_add_neighbor(NULL, blob_data(b.head), v6); +} + static void config_parse_rule(struct uci_section *s, bool v6) { @@ -251,7 +262,7 @@ config_init_interfaces(void) } static void -config_init_routes(void) +config_init_ip(void) { struct interface *iface; struct uci_element *e; @@ -266,6 +277,10 @@ config_init_routes(void) config_parse_route(s, false); else if (!strcmp(s->type, "route6")) config_parse_route(s, true); + if (!strcmp(s->type, "neighbor")) + config_parse_neighbor(s, false); + else if (!strcmp(s->type, "neighbor6")) + config_parse_neighbor(s, true); } vlist_for_each_element(&interfaces, iface, node) @@ -417,7 +432,7 @@ config_init_all(void) device_reset_config(); config_init_devices(); config_init_interfaces(); - config_init_routes(); + config_init_ip(); config_init_rules(); config_init_globals(); config_init_wireless(); -- cgit v1.2.1