eloop_timeout_add_sec(ctx->eloop, timeout, handle_exit_timeout, ctx);
}
+int
+dhcpcd_oneup(struct dhcpcd_ctx *ctx)
+{
+ const struct interface *ifp;
+
+ TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+ if (D_STATE_RUNNING(ifp) ||
+ RS_STATE_RUNNING(ifp) ||
+ D6_STATE_RUNNING(ifp))
+ return 1;
+ }
+ return 0;
+}
+
+int
+dhcpcd_ipwaited(struct dhcpcd_ctx *ctx)
+{
+
+ if (ctx->options & DHCPCD_WAITIP4 &&
+ !ipv4_addrexists(ctx, NULL))
+ return 0;
+ if (ctx->options & DHCPCD_WAITIP6 &&
+ !ipv6nd_addrexists(ctx, NULL) &&
+ !dhcp6_addrexists(ctx, NULL))
+ return 0;
+ if ((ctx->options &
+ (DHCPCD_WAITIP | DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) ==
+ (DHCPCD_WAITIP | DHCPCD_WAITIP4 | DHCPCD_WAITIP6) &&
+ !ipv4_addrexists(ctx, NULL) &&
+ !ipv6nd_addrexists(ctx, NULL) &&
+ !dhcp6_addrexists(ctx, NULL))
+ return 0;
+ return 1;
+}
+
/* Returns the pid of the child, otherwise 0. */
pid_t
dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
if (ctx->options & DHCPCD_DAEMONISE &&
!(ctx->options & DHCPCD_DAEMONISED))
{
- if (ctx->options & DHCPCD_WAITIP4 &&
- !ipv4_addrexists(ctx, NULL))
- return 0;
- if (ctx->options & DHCPCD_WAITIP6 &&
- !ipv6nd_addrexists(ctx, NULL) &&
- !dhcp6_addrexists(ctx, NULL))
- return 0;
- if ((ctx->options &
- (DHCPCD_WAITIP | DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) ==
- (DHCPCD_WAITIP | DHCPCD_WAITIP4 | DHCPCD_WAITIP6) &&
- !ipv4_addrexists(ctx, NULL) &&
- !ipv6nd_addrexists(ctx, NULL) &&
- !dhcp6_addrexists(ctx, NULL))
+ if (!dhcpcd_ipwaited(ctx))
return 0;
}
if (ifp->ctx->options & DHCPCD_DUMPLEASE)
elen = 2;
else
- elen = 11;
+ elen = 13;
#define EMALLOC(i, l) if ((env[(i)] = malloc((l))) == NULL) goto eexit;
/* Make our env */
}
if (env[9] == NULL || env[10] == NULL)
goto eexit;
+ if (dhcpcd_oneup(ifp->ctx))
+ env[11] = strdup("if_oneup=true");
+ else
+ env[11] = strdup("if_oneup=false");
+ if (env[11] == NULL)
+ goto eexit;
+ if (dhcpcd_ipwaited(ifp->ctx))
+ env[12] = strdup("if_ipwaited=true");
+ else
+ env[12] = strdup("if_ipwaited=false");
+ if (env[12] == NULL)
+ goto eexit;
if (*ifp->profile) {
e = strlen("profile=") + strlen(ifp->profile) + 2;
EMALLOC(elen, e);