mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Wildcards in dhcp-range constructors
This commit is contained in:
@@ -711,15 +711,20 @@ void log_context(int family, struct dhcp_context *context)
|
||||
|
||||
#ifdef HAVE_DHCP6
|
||||
if (context->flags & CONTEXT_CONSTRUCTED)
|
||||
{
|
||||
char ifrn_name[IFNAMSIZ];
|
||||
if (indextoname(daemon->doing_dhcp6 ? daemon->dhcp6fd : daemon->icmp6fd, context->if_index, ifrn_name))
|
||||
{
|
||||
n = p;
|
||||
p += sprintf(p, ", constructed for %s", context->template_interface);
|
||||
p += sprintf(p, ", constructed for %s", ifrn_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (context->flags & CONTEXT_TEMPLATE)
|
||||
{
|
||||
n = p;
|
||||
p += sprintf(p, ", template for %s", context->template_interface);
|
||||
p += sprintf(p, ", template for %s%s", context->template_interface,
|
||||
(context->flags & CONTEXT_WILDCARD) ? "*" : "");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -531,8 +531,9 @@ static int construct_worker(struct in6_addr *local, int prefix,
|
||||
}
|
||||
|
||||
}
|
||||
else if (strcmp(ifrn_name, template->template_interface) == 0 &&
|
||||
addr6part(local) == addr6part(&template->start6))
|
||||
else if (addr6part(local) == addr6part(&template->start6) &&
|
||||
strncmp(template->template_interface, ifrn_name, strlen(template->template_interface)) == 0 &&
|
||||
(strlen(template->template_interface) == strlen(ifrn_name) || (template->flags & CONTEXT_WILDCARD)))
|
||||
{
|
||||
start6 = *local;
|
||||
setaddr6part(&start6, addr6part(&template->start6));
|
||||
|
||||
@@ -706,7 +706,7 @@ struct dhcp_context {
|
||||
#define CONTEXT_CONSTRUCTED 2048
|
||||
#define CONTEXT_GC 4096
|
||||
#define CONTEXT_RA 8192
|
||||
|
||||
#define CONTEXT_WILDCARD 16384
|
||||
|
||||
struct ping_result {
|
||||
struct in_addr addr;
|
||||
|
||||
@@ -2291,6 +2291,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
||||
new->flags |= CONTEXT_DHCP;
|
||||
else if (strstr(a[leasepos], "constructor:") == a[leasepos])
|
||||
{
|
||||
if (a[leasepos][strlen(a[leasepos])-1] == '*')
|
||||
{
|
||||
a[leasepos][strlen(a[leasepos])-1] = 0;
|
||||
new->flags |= CONTEXT_WILDCARD;
|
||||
}
|
||||
new->template_interface = opt_string_alloc(a[leasepos] + 12);
|
||||
new->flags |= CONTEXT_TEMPLATE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user