summaryrefslogtreecommitdiffhomepage
path: root/interface.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-04-03 20:03:15 +0200
committerSteven Barth <steven@midlink.org>2013-04-03 20:03:15 +0200
commit48ffedb4a2b6701eec99e32e91b8a66a0a4be950 (patch)
tree1b6bbf54657783f07cc346c1bb912dd64938fba4 /interface.c
parent059242dea7a7c1e51314cf41ad27aac853a385f3 (diff)
Rewrite IPv6 prefix assignment
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/interface.c b/interface.c
index b304e00..335e0be 100644
--- a/interface.c
+++ b/interface.c
@@ -37,6 +37,8 @@ enum {
IFACE_ATTR_DNS_SEARCH,
IFACE_ATTR_METRIC,
IFACE_ATTR_INTERFACE,
+ IFACE_ATTR_IP6ASSIGN,
+ IFACE_ATTR_IP6HINT,
IFACE_ATTR_MAX
};
@@ -50,6 +52,8 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
[IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
+ [IFACE_ATTR_IP6ASSIGN] = { .name = "ip6assign", .type = BLOBMSG_TYPE_INT32 },
+ [IFACE_ATTR_IP6HINT] = { .name = "ip6hint", .type = BLOBMSG_TYPE_STRING },
};
static const union config_param_info iface_attr_info[IFACE_ATTR_MAX] = {
@@ -483,6 +487,14 @@ interface_init(struct interface *iface, const char *name,
if ((cur = tb[IFACE_ATTR_METRIC]))
iface->metric = blobmsg_get_u32(cur);
+ if ((cur = tb[IFACE_ATTR_IP6ASSIGN]))
+ iface->config_ip.assignment_length = blobmsg_get_u32(cur);
+
+ iface->config_ip.assignment_hint = -1;
+ if ((cur = tb[IFACE_ATTR_IP6HINT]))
+ iface->config_ip.assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16) &
+ ~((1 << (64 - iface->config_ip.assignment_length)) - 1);
+
iface->config_autostart = iface->autostart;
}
@@ -755,6 +767,9 @@ interface_change_config(struct interface *if_old, struct interface *if_new)
interface_ip_set_enabled(&if_old->proto_ip, if_new->proto_ip.enabled);
}
+ if (UPDATE(config_ip.assignment_length) || UPDATE(config_ip.assignment_hint))
+ interface_refresh_assignments(true);
+
interface_write_resolv_conf();
#undef UPDATE