summaryrefslogtreecommitdiff
path: root/proto-shell.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 /proto-shell.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 'proto-shell.c')
-rw-r--r--proto-shell.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/proto-shell.c b/proto-shell.c
index 47a9568..07ec21a 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -414,6 +414,23 @@ proto_shell_parse_route_list(struct interface *iface, struct blob_attr *attr,
}
static void
+proto_shell_parse_neighbor_list(struct interface *iface, struct blob_attr *attr,
+ bool v6)
+{
+ struct blob_attr *cur;
+ int rem;
+
+ blobmsg_for_each_attr(cur, attr, rem) {
+ if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE) {
+ DPRINTF("Ignore wrong neighbor type: %d\n", blobmsg_type(cur));
+ continue;
+ }
+
+ interface_ip_add_neighbor(iface, cur, v6);
+ }
+}
+
+static void
proto_shell_parse_data(struct interface *iface, struct blob_attr *attr)
{
struct blob_attr *cur;
@@ -456,6 +473,8 @@ enum {
NOTIFY_HOST,
NOTIFY_DNS,
NOTIFY_DNS_SEARCH,
+ NOTIFY_NEIGHBORS,
+ NOTIFY_NEIGHBORS6,
__NOTIFY_LAST
};
@@ -477,6 +496,8 @@ static const struct blobmsg_policy notify_attr[__NOTIFY_LAST] = {
[NOTIFY_HOST] = { .name = "host", .type = BLOBMSG_TYPE_STRING },
[NOTIFY_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
[NOTIFY_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
+ [NOTIFY_NEIGHBORS]= {.name = "neighbor", .type = BLOBMSG_TYPE_ARRAY},
+ [NOTIFY_NEIGHBORS6]= {.name = "neighbor6", .type = BLOBMSG_TYPE_ARRAY},
};
static int
@@ -546,6 +567,12 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
if ((cur = tb[NOTIFY_ROUTES6]) != NULL)
proto_shell_parse_route_list(state->proto.iface, cur, true);
+ if ((cur = tb[NOTIFY_NEIGHBORS]) != NULL)
+ proto_shell_parse_neighbor_list(state->proto.iface, cur, false);
+
+ if ((cur = tb[NOTIFY_NEIGHBORS6]) != NULL)
+ proto_shell_parse_neighbor_list(state->proto.iface, cur, true);
+
if ((cur = tb[NOTIFY_DNS]))
interface_add_dns_server_list(&iface->proto_ip, cur);