Add --shared-network DHCP configuration.

This commit is contained in:
Simon Kelley
2019-03-27 22:33:28 +00:00
parent 305ffb5ef0
commit ae5b7e04a1
8 changed files with 333 additions and 135 deletions

View File

@@ -166,6 +166,7 @@ struct myoption {
#define LOPT_UBUS 354
#define LOPT_NAME_MATCH 355
#define LOPT_CAA 356
#define LOPT_SHARED_NET 357
#ifdef HAVE_GETOPT_LONG
static const struct option opts[] =
@@ -259,6 +260,7 @@ static const struct myoption opts[] =
{ "ptr-record", 1, 0, LOPT_PTR },
{ "naptr-record", 1, 0, LOPT_NAPTR },
{ "bridge-interface", 1, 0 , LOPT_BRIDGE },
{ "shared-network", 1, 0, LOPT_SHARED_NET },
{ "dhcp-option-force", 1, 0, LOPT_FORCE },
{ "tftp-no-blocksize", 0, 0, LOPT_NOBLOCK },
{ "log-dhcp", 0, 0, LOPT_LOG_OPTS },
@@ -431,6 +433,7 @@ static struct {
{ '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 },
{ LOPT_SHARED_NET, ARG_DUP, "<iface>|<addr>,<addr>", gettext_noop("Specify extra networks sharing a broadcast domain for DHCP"), NULL},
{ '5', OPT_NO_PING, NULL, gettext_noop("Disable ICMP echo address checking in the DHCP server."), NULL },
{ '6', ARG_ONE, "<path>", gettext_noop("Shell script to run on DHCP lease creation and destruction."), NULL },
{ LOPT_LUASCRIPT, ARG_DUP, "path", gettext_noop("Lua script to run on DHCP lease creation and destruction."), NULL },
@@ -2873,6 +2876,44 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
}
#ifdef HAVE_DHCP
case LOPT_SHARED_NET: /* --shared-network */
{
struct shared_network *new = opt_malloc(sizeof(struct shared_network));
#ifdef HAVE_DHCP6
new->shared_addr.s_addr = 0;
#endif
new->if_index = 0;
if (!(comma = split(arg)))
{
snerr:
free(new);
ret_err(_("bad shared-network"));
}
if (inet_pton(AF_INET, comma, &new->shared_addr))
{
if (!inet_pton(AF_INET, arg, &new->match_addr) &&
!(new->if_index = if_nametoindex(arg)))
goto snerr;
}
#ifdef HAVE_DHCP6
else if (inet_pton(AF_INET6, comma, &new->shared_addr6))
{
if (!inet_pton(AF_INET6, arg, &new->match_addr6) &&
!(new->if_index = if_nametoindex(arg)))
goto snerr;
}
#endif
else
goto snerr;
new->next = daemon->shared_networks;
daemon->shared_networks = new;
break;
}
case 'F': /* --dhcp-range */
{
int k, leasepos = 2;