mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
import of dnsmasq-2.58.tar.gz
This commit is contained in:
50
src/option.c
50
src/option.c
@@ -110,6 +110,8 @@ struct myoption {
|
||||
#define LOPT_LOC_REBND 299
|
||||
#define LOPT_ADD_MAC 300
|
||||
#define LOPT_DNSSEC 301
|
||||
#define LOPT_INCR_ADDR 302
|
||||
#define LOPT_CONNTRACK 303
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
static const struct option opts[] =
|
||||
@@ -225,6 +227,8 @@ static const struct myoption opts[] =
|
||||
{ "rebind-localhost-ok", 0, 0, LOPT_LOC_REBND },
|
||||
{ "add-mac", 0, 0, LOPT_ADD_MAC },
|
||||
{ "proxy-dnssec", 0, 0, LOPT_DNSSEC },
|
||||
{ "dhcp-sequential-ip", 0, 0, LOPT_INCR_ADDR },
|
||||
{ "conntrack", 0, 0, LOPT_CONNTRACK },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -345,8 +349,10 @@ static struct {
|
||||
{ LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL },
|
||||
{ LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL },
|
||||
{ LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL },
|
||||
{ LOPT_ADD_MAC, OPT_ADD_MAC, NULL, gettext_noop("Add requestor's MAC address to forwarded DNS queries"), NULL },
|
||||
{ LOPT_DNSSEC, OPT_DNSSEC, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers"), NULL },
|
||||
{ LOPT_ADD_MAC, OPT_ADD_MAC, NULL, gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL },
|
||||
{ LOPT_DNSSEC, OPT_DNSSEC, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL },
|
||||
{ LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL },
|
||||
{ LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL },
|
||||
{ 0, 0, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -1590,6 +1596,10 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
{
|
||||
int source_port = 0, serv_port = NAMESERVER_PORT;
|
||||
char *portno, *source;
|
||||
#ifdef HAVE_IPV6
|
||||
int scope_index = 0;
|
||||
char *scope_id;
|
||||
#endif
|
||||
|
||||
if ((source = split_chr(arg, '@')) && /* is there a source. */
|
||||
(portno = split_chr(source, '#')) &&
|
||||
@@ -1600,6 +1610,10 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
!atoi_check16(portno, &serv_port))
|
||||
problem = _("bad port");
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
scope_id = split_chr(arg, '%');
|
||||
#endif
|
||||
|
||||
if ((newlist->addr.in.sin_addr.s_addr = inet_addr(arg)) != (in_addr_t) -1)
|
||||
{
|
||||
newlist->addr.in.sin_port = htons(serv_port);
|
||||
@@ -1627,16 +1641,22 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
#ifdef HAVE_IPV6
|
||||
else if (inet_pton(AF_INET6, arg, &newlist->addr.in6.sin6_addr) > 0)
|
||||
{
|
||||
if (scope_id && (scope_index = if_nametoindex(scope_id)) == 0)
|
||||
problem = _("bad interface name");
|
||||
|
||||
newlist->addr.in6.sin6_port = htons(serv_port);
|
||||
newlist->addr.in6.sin6_scope_id = scope_index;
|
||||
newlist->source_addr.in6.sin6_port = htons(source_port);
|
||||
newlist->source_addr.in6.sin6_scope_id = 0;
|
||||
newlist->addr.sa.sa_family = newlist->source_addr.sa.sa_family = AF_INET6;
|
||||
newlist->addr.in6.sin6_flowinfo = newlist->source_addr.in6.sin6_flowinfo = 0;
|
||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||
newlist->addr.in6.sin6_len = newlist->source_addr.in6.sin6_len = sizeof(newlist->addr.in6);
|
||||
#endif
|
||||
if (source)
|
||||
{
|
||||
newlist->flags |= SERV_HAS_SOURCE;
|
||||
if (inet_pton(AF_INET6, source, &newlist->source_addr.in6.sin6_addr) == 0)
|
||||
newlist->flags |= SERV_HAS_SOURCE;
|
||||
if (inet_pton(AF_INET6, source, &newlist->source_addr.in6.sin6_addr) == 0)
|
||||
{
|
||||
#if defined(SO_BINDTODEVICE)
|
||||
newlist->source_addr.in6.sin6_addr = in6addr_any;
|
||||
@@ -1652,7 +1672,6 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
#endif
|
||||
else
|
||||
option = '?'; /* error */
|
||||
|
||||
}
|
||||
|
||||
serv = newlist;
|
||||
@@ -1842,6 +1861,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
new->netmask.s_addr = 0;
|
||||
new->broadcast.s_addr = 0;
|
||||
new->router.s_addr = 0;
|
||||
new->local.s_addr = 0;
|
||||
new->netid.net = NULL;
|
||||
new->filter = NULL;
|
||||
new->flags = 0;
|
||||
@@ -2037,7 +2057,9 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
strcpy(newtag->net, arg+4);
|
||||
unhide_metas(newtag->net);
|
||||
}
|
||||
else
|
||||
else if (strstr(arg, "tag:") == arg)
|
||||
problem = _("cannot match tags in --dhcp-host");
|
||||
else
|
||||
{
|
||||
struct hwaddr_config *newhw = opt_malloc(sizeof(struct hwaddr_config));
|
||||
if ((newhw->hwaddr_len = parse_hex(a[j], newhw->hwaddr, DHCP_CHADDR_MAX,
|
||||
@@ -2218,7 +2240,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
option = '?';
|
||||
else
|
||||
{
|
||||
char *dhcp_file, *dhcp_sname = NULL;
|
||||
char *dhcp_file, *dhcp_sname = NULL, *tftp_sname = NULL;
|
||||
struct in_addr dhcp_next_server;
|
||||
comma = split(arg);
|
||||
dhcp_file = opt_string_alloc(arg);
|
||||
@@ -2231,8 +2253,17 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
if (comma)
|
||||
{
|
||||
unhide_metas(comma);
|
||||
if ((dhcp_next_server.s_addr = inet_addr(comma)) == (in_addr_t)-1)
|
||||
option = '?';
|
||||
if ((dhcp_next_server.s_addr = inet_addr(comma)) == (in_addr_t)-1) {
|
||||
|
||||
/*
|
||||
* The user may have specified the tftp hostname here.
|
||||
* save it so that it can be resolved/looked up during
|
||||
* actual dhcp_reply().
|
||||
*/
|
||||
|
||||
tftp_sname = opt_string_alloc(comma);
|
||||
dhcp_next_server.s_addr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (option != '?')
|
||||
@@ -2240,6 +2271,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
||||
struct dhcp_boot *new = opt_malloc(sizeof(struct dhcp_boot));
|
||||
new->file = dhcp_file;
|
||||
new->sname = dhcp_sname;
|
||||
new->tftp_sname = tftp_sname;
|
||||
new->next_server = dhcp_next_server;
|
||||
new->netid = id;
|
||||
new->next = daemon->boot_config;
|
||||
|
||||
Reference in New Issue
Block a user