changeset 5550:dba7608e00b3 draft

options: allow --ia_na=1 and --ia_pd=2 on the command line This only works for non master mode.
author Roy Marples <roy@marples.name>
date Wed, 25 Nov 2020 14:05:18 +0000
parents 6d72dc67a984
children 0c4608a6cc2a
files src/dhcpcd.c src/if-options.c
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcpcd.c	Tue Nov 24 10:30:08 2020 +0000
+++ b/src/dhcpcd.c	Wed Nov 25 14:05:18 2020 +0000
@@ -1883,6 +1883,7 @@
 		logopts |= LOGERR_ERR;
 
 	i = 0;
+
 	while ((opt = getopt_long(argc, argv,
 	    ctx.options & DHCPCD_PRINT_PIDFILE ? NOERR_IF_OPTS : IF_OPTS,
 	    cf_options, &oi)) != -1)
@@ -1957,6 +1958,9 @@
 		}
 	}
 
+	if (optind != argc - 1)
+		ctx.options |= DHCPCD_MASTER;
+
 	logsetopts(logopts);
 	logopen(ctx.logfile);
 
@@ -1973,6 +1977,7 @@
 			goto printpidfile;
 		goto exit_failure;
 	}
+
 	opt = add_options(&ctx, NULL, ifo, argc, argv);
 	if (opt != 1) {
 		if (ctx.options & DHCPCD_PRINT_PIDFILE)
@@ -2013,6 +2018,7 @@
 		goto exit_success;
 	}
 	ctx.options |= ifo->options;
+
 	if (i == 1 || i == 3) {
 		if (i == 1)
 			ctx.options |= DHCPCD_TEST;
--- a/src/if-options.c	Tue Nov 24 10:30:08 2020 +0000
+++ b/src/if-options.c	Wed Nov 25 14:05:18 2020 +0000
@@ -134,9 +134,9 @@
 	{"noipv6",          no_argument,       NULL, O_NOIPV6},
 	{"noalias",         no_argument,       NULL, O_NOALIAS},
 	{"iaid",            required_argument, NULL, O_IAID},
-	{"ia_na",           no_argument,       NULL, O_IA_NA},
-	{"ia_ta",           no_argument,       NULL, O_IA_TA},
-	{"ia_pd",           no_argument,       NULL, O_IA_PD},
+	{"ia_na",           optional_argument, NULL, O_IA_NA},
+	{"ia_ta",           optional_argument, NULL, O_IA_TA},
+	{"ia_pd",           optional_argument, NULL, O_IA_PD},
 	{"hostname_short",  no_argument,       NULL, O_HOSTNAME_SHORT},
 	{"dev",             required_argument, NULL, O_DEV},
 	{"nodev",           no_argument,       NULL, O_NODEV},
@@ -1344,7 +1344,7 @@
 #endif
 	case O_IAID:
 		ARG_REQUIRED;
-		if (!IN_CONFIG_BLOCK(ifo)) {
+		if (ctx->options & DHCPCD_MASTER && !IN_CONFIG_BLOCK(ifo)) {
 			logerrx("IAID must belong in an interface block");
 			return -1;
 		}
@@ -1386,7 +1386,9 @@
 			logwarnx("%s: IA_PD not compiled in", ifname);
 			return -1;
 #else
-			if (!IN_CONFIG_BLOCK(ifo)) {
+			if (ctx->options & DHCPCD_MASTER &&
+			    !IN_CONFIG_BLOCK(ifo))
+			{
 				logerrx("IA PD must belong in an "
 				    "interface block");
 				return -1;
@@ -1394,7 +1396,9 @@
 			i = D6_OPTION_IA_PD;
 #endif
 		}
-		if (!IN_CONFIG_BLOCK(ifo) && arg) {
+		if (ctx->options & DHCPCD_MASTER &&
+		    !IN_CONFIG_BLOCK(ifo) && arg)
+		{
 			logerrx("IA with IAID must belong in an "
 			    "interface block");
 			return -1;