diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2013-01-17 16:34:16 +0000 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2013-01-17 16:34:16 +0000 |
commit | 30393100c1c80cf51e92af957fb87448f2099cfc (patch) | |
tree | 028c5d95f8fa73aa53cae5504a2620310114ac26 | |
parent | 459380965ad6becd285fdc95e5b663e1f5c29bb7 (diff) | |
download | dnsmasq-30393100c1c80cf51e92af957fb87448f2099cfc.tar.gz |
Wildcard IPv6 addresses in --dhcp-host, for constructed ranges.v2.66test11
-rw-r--r-- | man/dnsmasq.8 | 8 | ||||
-rw-r--r-- | src/dhcp6.c | 14 | ||||
-rw-r--r-- | src/dnsmasq.h | 1 | ||||
-rw-r--r-- | src/option.c | 8 |
4 files changed, 27 insertions, 4 deletions
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index 10c1d48..c1ceee3 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -717,7 +717,13 @@ A single .B dhcp-host may contain an IPv4 address or an IPv6 address, or both. IPv6 addresses must be bracketed by square brackets thus: .B --dhcp-host=laptop,[1234::56] -Note that in IPv6 DHCP, the hardware address is not normally available, so a client must be identified by client-id (called client DUID in IPv6-land) or hostname. +IPv6 addresses may contain only the host-identifier part: +.B --dhcp-host=laptop,[::56] +in which case thay act as wildcards in constructed dhcp ranges, with +the appropriate network part inserted. +Note that in IPv6 DHCP, the hardware address is not normally +available, so a client must be identified by client-id (called client +DUID in IPv6-land) or hostname. The special option id:* means "ignore any client-id and use MAC addresses only." This is useful when a client presents a client-id sometimes diff --git a/src/dhcp6.c b/src/dhcp6.c index c290993..4be071c 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -399,11 +399,19 @@ struct dhcp_context *narrow_context6(struct dhcp_context *context, static int is_config_in_context6(struct dhcp_context *context, struct dhcp_config *config) { - if (!context) /* called via find_config() from lease_update_from_configs() */ - return 1; + /* expand wildcard on contructed contexts */ + if ((config->flags & CONFIG_WILDCARD) && + (context->flags & CONTEXT_CONSTRUCTED)) + { + u64 addrpart = addr6part(&config->addr6); + config->addr6 = context->start6; + setaddr6part(&config->addr6, addrpart); + return 1; + } + if (!(config->flags & CONFIG_ADDR6) || is_addr_in_context6(context, &config->addr6)) return 1; - + return 0; } diff --git a/src/dnsmasq.h b/src/dnsmasq.h index d3a34ea..6838f0a 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -593,6 +593,7 @@ struct dhcp_config { #define CONFIG_DECLINED 1024 /* address declined by client */ #define CONFIG_BANK 2048 /* from dhcp hosts file */ #define CONFIG_ADDR6 4096 +#define CONFIG_WILDCARD 8192 struct dhcp_opt { int opt, len, flags; diff --git a/src/option.c b/src/option.c index 46d9b6a..1fab8ee 100644 --- a/src/option.c +++ b/src/option.c @@ -2468,6 +2468,14 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma if (!inet_pton(AF_INET6, arg, &new->addr6)) ret_err(_("bad IPv6 address")); + + for (i= 0; i < 8; i++) + if (new->addr6.s6_addr[i] != 0) + break; + + /* set WILDCARD if network part all zeros */ + if (i == 8) + new->flags |= CONFIG_WILDCARD; new->flags |= CONFIG_ADDR6; } |