]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
options: allow --ia_na=1 and --ia_pd=2 on the command line
authorRoy Marples <roy@marples.name>
Wed, 25 Nov 2020 14:05:18 +0000 (14:05 +0000)
committerRoy Marples <roy@marples.name>
Wed, 25 Nov 2020 14:05:18 +0000 (14:05 +0000)
This only works for non master mode.

src/dhcpcd.c
src/if-options.c

index 205635e7f0ec3b5527e92f7d8edd2188a4657551..71575d1d1912c951bfdb0a3a1d0d0a8cfa02665a 100644 (file)
@@ -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;
index 653cb03d4af4482dbe1c2519e8586d71a3138a42..d15034dde15b8b1bfb35cf4201aaa5b7370c74a0 100644 (file)
@@ -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;