Tighten syntax checking for dhcp-range and clarify man page.

This commit is contained in:
Simon Kelley
2016-03-03 20:33:54 +00:00
parent a93bd4b016
commit fa79466c2a
2 changed files with 11 additions and 7 deletions

View File

@@ -783,7 +783,7 @@ compiled in and the kernel must have conntrack support
included and configured. This option cannot be combined with included and configured. This option cannot be combined with
--query-port. --query-port.
.TP .TP
.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>] .B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-addr>[,<end-addr>|<mode>][,<netmask>[,<broadcast>]][,<lease time>]
.TP .TP
.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-IPv6addr>[,<end-IPv6addr>|constructor:<interface>][,<mode>][,<prefix-len>][,<lease time>] .B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-IPv6addr>[,<end-IPv6addr>|constructor:<interface>][,<mode>][,<prefix-len>][,<lease time>]

View File

@@ -2772,13 +2772,14 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
leasepos = 3; leasepos = 3;
if (!is_same_net(new->start, new->end, new->netmask)) if (!is_same_net(new->start, new->end, new->netmask))
ret_err(_("inconsistent DHCP range")); ret_err(_("inconsistent DHCP range"));
}
if (k >= 4 && strchr(a[3], '.') && if (k >= 4 && strchr(a[3], '.') &&
(inet_pton(AF_INET, a[3], &new->broadcast) > 0)) (inet_pton(AF_INET, a[3], &new->broadcast) > 0))
{ {
new->flags |= CONTEXT_BRDCAST; new->flags |= CONTEXT_BRDCAST;
leasepos = 4; leasepos = 4;
}
} }
} }
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
@@ -2868,6 +2869,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
if (leasepos < k) if (leasepos < k)
{ {
if (leasepos != k-1)
ret_err(_("bad dhcp-range"));
if (strcmp(a[leasepos], "infinite") == 0) if (strcmp(a[leasepos], "infinite") == 0)
new->lease_time = 0xffffffff; new->lease_time = 0xffffffff;
else if (strcmp(a[leasepos], "deprecated") == 0) else if (strcmp(a[leasepos], "deprecated") == 0)