From 819ff4dd0ff91286a856119533b8980fd8399a2f Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Sun, 21 Oct 2012 18:25:12 +0100 Subject: [PATCH] Wildcard IPv6 dhcp-range. --- CHANGELOG | 4 ++++ src/dhcp6.c | 21 ++++++++++++++------- src/option.c | 6 +++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a11d4d..2de505e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -41,6 +41,10 @@ version 2.64 configured with --listen-address. Thanks to Gene Czarcinski for sorting this out. + Add a "wildcard" dhcp-range which works for any IPv6 + subnet, --dhcp-range=::,static Useful for Stateless + DHCPv6. Thanks to Vladislav Grishenko for the patch. + version 2.63 Do duplicate dhcp-host address check in --test mode. diff --git a/src/dhcp6.c b/src/dhcp6.c index 5525ca5..ba53f0f 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -126,17 +126,24 @@ void dhcp6_packet(time_t now) if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0)) return; - /* unlinked contexts are marked by context->current == context */ - for (context = daemon->dhcp6; context; context = context->next) - { - context->current = context; - memset(&context->local6, 0, IN6ADDRSZ); - } - parm.current = NULL; parm.ind = if_index; parm.addr_match = 0; memset(&parm.fallback, 0, IN6ADDRSZ); + + for (context = daemon->dhcp6; context; context = context->next) + if (IN6_IS_ADDR_UNSPECIFIED(&context->start6) && context->prefix == 0) + { + /* wildcard context for DHCP-stateless only */ + parm.current = context; + context->current = NULL; + } + else + { + /* unlinked contexts are marked by context->current == context */ + context->current = context; + memset(&context->local6, 0, IN6ADDRSZ); + } if (!iface_enumerate(AF_INET6, &parm, complete_context6)) return; diff --git a/src/option.c b/src/option.c index 8c7bfbf..714f2c2 100644 --- a/src/option.c +++ b/src/option.c @@ -2115,7 +2115,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma { new->prefix = 64; /* default */ new->end6 = new->start6; - + + /* dhcp-range=:: enables DHCP stateless on any interface */ + if (IN6_IS_ADDR_UNSPECIFIED(&new->start6)) + new->prefix = 0; + for (leasepos = 1; leasepos < k; leasepos++) { if (strcmp(a[leasepos], "static") == 0)