mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Wildcard IPv6 addresses in --dhcp-host, for constructed ranges.
This commit is contained in:
14
src/dhcp6.c
14
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user