From 6c3bc0141dacc88992583d6f2cdc8a360df7422d Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Thu, 17 Nov 2016 16:11:56 +0100 Subject: config: Support infinite as DHCP pool leasetime value Add support for infinite leasetime value; this can be done by specifying "infinite" as leasetime value which is similar to dnsmasq infinite leasetime support. Specifying "infinite" as leasetime is valid for both the host and dhcp uci sections. A DHCPv4/DHCPv6 assignment is now considered infinite if valid_unil holds the value 0. Signed-off-by: Hans Dedecker --- src/config.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index ef51112..44b049d 100644 --- a/src/config.c +++ b/src/config.c @@ -218,9 +218,10 @@ static void set_config(struct uci_section *s) } static double parse_leasetime(struct blob_attr *c) { - char *val = blobmsg_get_string(c), *endptr; - double time = strtod(val, &endptr); - if (time && endptr[0]) { + char *val = blobmsg_get_string(c), *endptr = NULL; + double time = strcmp(val, "infinite") ? strtod(val, &endptr) : UINT32_MAX; + + if (time && endptr && endptr[0]) { if (endptr[0] == 's') time *= 1; else if (endptr[0] == 'm') -- cgit v1.2.3