Add --no-dhcpv4-interface and --no-dhcpv6-interface options.

This commit is contained in:
Simon Kelley
2023-04-12 22:55:14 +01:00
parent 597378cdf5
commit aaba66efbd
10 changed files with 51 additions and 15 deletions

View File

@@ -188,6 +188,8 @@ struct myoption {
#define LOPT_NO_IDENT 379
#define LOPT_CACHE_RR 380
#define LOPT_FILTER_RR 381
#define LOPT_NO_DHCP6 382
#define LOPT_NO_DHCP4 383
#ifdef HAVE_GETOPT_LONG
static const struct option opts[] =
@@ -248,6 +250,8 @@ static const struct myoption opts[] =
{ "query-port", 1, 0, 'Q' },
{ "except-interface", 1, 0, 'I' },
{ "no-dhcp-interface", 1, 0, '2' },
{ "no-dhcpv4-interface", 1, 0, LOPT_NO_DHCP4 },
{ "no-dhcpv6-interface", 1, 0, LOPT_NO_DHCP6 },
{ "domain-needed", 0, 0, 'D' },
{ "dhcp-lease-max", 1, 0, 'X' },
{ "bind-interfaces", 0, 0, 'z' },
@@ -478,6 +482,8 @@ static struct {
{ '1', ARG_ONE, "[=<busname>]", gettext_noop("Enable the DBus interface for setting upstream servers, etc."), NULL },
{ LOPT_UBUS, ARG_ONE, "[=<busname>]", gettext_noop("Enable the UBus interface."), NULL },
{ '2', ARG_DUP, "<interface>", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },
{ LOPT_NO_DHCP6, ARG_DUP, "<interface>", gettext_noop("Do not provide DHCPv6 on this interface."), NULL },
{ LOPT_NO_DHCP4, ARG_DUP, "<interface>", gettext_noop("Do not provide DHCPv4 on this interface."), NULL },
{ '3', ARG_DUP, "[=tag:<tag>]...", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
{ '4', ARG_DUP, "set:<tag>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
{ LOPT_BRIDGE, ARG_DUP, "<iface>,<alias>..", gettext_noop("Treat DHCP requests on aliases as arriving from interface."), NULL },
@@ -2846,10 +2852,13 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
case 'I': /* --except-interface */
case '2': /* --no-dhcp-interface */
case LOPT_NO_DHCP6: /* --no-dhcpv6-interface */
case LOPT_NO_DHCP4: /* --no-dhcpv4-interface */
do {
struct iname *new = opt_malloc(sizeof(struct iname));
comma = split(arg);
new->name = opt_string_alloc(arg);
new->flags = INAME_4 | INAME_6;
if (option == 'I')
{
new->next = daemon->if_except;
@@ -2862,6 +2871,10 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
}
else
{
if (option == LOPT_NO_DHCP6)
new->flags &= ~INAME_4;
if (option == LOPT_NO_DHCP4)
new->flags &= ~INAME_6;
new->next = daemon->dhcp_except;
daemon->dhcp_except = new;
}