summaryrefslogtreecommitdiff
path: root/proto.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-05-08 16:47:55 +0200
committerSteven Barth <steven@midlink.org>2013-05-08 16:47:55 +0200
commit19e05a68ba2c5d11480ddd23d9b0d5756cbc8183 (patch)
tree346e5de13443d4c5b8f4b9487848279a4089d2d2 /proto.c
parent24f5ed4b8b6c3c6f27e84e731b7682d3a5cc29d0 (diff)
downloadnetifd-19e05a68ba2c5d11480ddd23d9b0d5756cbc8183.tar.gz
IPv6: Use key=val format for prefix options
Diffstat (limited to 'proto.c')
-rw-r--r--proto.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/proto.c b/proto.c
index 634d31b..83c6345 100644
--- a/proto.c
+++ b/proto.c
@@ -274,7 +274,7 @@ parse_prefix_option(struct interface *iface, const char *str, size_t len)
char *prefstr = strtok_r(NULL, ",", &saveptr);
char *validstr = (!prefstr) ? NULL : strtok_r(NULL, ",", &saveptr);
- char *excludestr = (!validstr) ? NULL : strtok_r(NULL, ",", &saveptr);
+ char *addstr = (!validstr) ? NULL : strtok_r(NULL, ",", &saveptr);
uint32_t pref = (!prefstr) ? 0 : strtoul(prefstr, NULL, 10);
uint32_t valid = (!validstr) ? 0 : strtoul(validstr, NULL, 10);
@@ -287,20 +287,31 @@ parse_prefix_option(struct interface *iface, const char *str, size_t len)
if (inet_pton(AF_INET6, addrstr, &addr) < 1)
return false;
- if (excludestr) {
- char *sep = strchr(excludestr, '/');
- if (!sep)
- return false;
+ for (; addstr; addstr = strtok_r(NULL, ",", &saveptr)) {
+ char *key = NULL, *val = NULL, *addsaveptr;
+ if (!(key = strtok_r(addstr, "=", &addsaveptr)) ||
+ !(val = strtok_r(NULL, ",", &addsaveptr)))
+ continue;
- *sep = 0;
- excl_length = atoi(sep + 1);
+ if (!strcmp(key, "excluded")) {
+ char *sep = strchr(val, '/');
+ if (!sep)
+ return false;
- if (inet_pton(AF_INET6, excludestr, &excluded) < 1)
- return false;
+ *sep = 0;
+ excl_length = atoi(sep + 1);
+
+ if (inet_pton(AF_INET6, val, &excluded) < 1)
+ return false;
+
+ excludedp = &excluded;
+ }
- excludedp = &excluded;
}
+
+
+
time_t now = system_get_rtime();
time_t preferred_until = 0;
if (prefstr && pref != 0xffffffffU)