summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-11-25 14:05:18 +0000
committerRoy Marples <roy@marples.name>2020-11-25 14:05:18 +0000
commitba04408c085ddf6b626352dc34f95dace33a78d2 (patch)
tree3bf773f7c3038e0d6b5e7ff2282c6c7aae6089de
parent3ca5bffd2de92ee21ea733cb0b2716a0a975942d (diff)
downloaddhcpcd-ba04408c085ddf6b626352dc34f95dace33a78d2.tar.xz
options: allow --ia_na=1 and --ia_pd=2 on the command line
This only works for non master mode.
-rw-r--r--src/dhcpcd.c6
-rw-r--r--src/if-options.c16
2 files changed, 16 insertions, 6 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index 205635e7..71575d1d 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -1883,6 +1883,7 @@ main(int argc, char **argv, char **envp)
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 @@ main(int argc, char **argv, char **envp)
}
}
+ if (optind != argc - 1)
+ ctx.options |= DHCPCD_MASTER;
+
logsetopts(logopts);
logopen(ctx.logfile);
@@ -1973,6 +1977,7 @@ main(int argc, char **argv, char **envp)
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 @@ main(int argc, char **argv, char **envp)
goto exit_success;
}
ctx.options |= ifo->options;
+
if (i == 1 || i == 3) {
if (i == 1)
ctx.options |= DHCPCD_TEST;
diff --git a/src/if-options.c b/src/if-options.c
index 653cb03d..d15034dd 100644
--- a/src/if-options.c
+++ b/src/if-options.c
@@ -134,9 +134,9 @@ const struct option cf_options[] = {
{"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 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
#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 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
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 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
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;