diff options
| author | Roy Marples <roy@marples.name> | 2014-09-07 19:03:41 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2014-09-07 19:03:41 +0000 |
| commit | 2f4d126e24bd7aa64bd2e0d57d9de4570b90c472 (patch) | |
| tree | 0fdb56408be9c7424eb47cc25e219be0a57a0931 /dhcpcd.c | |
| parent | 89c3551de19090928dae9cb4491d86d8a607c6aa (diff) | |
| download | dhcpcd-2f4d126e24bd7aa64bd2e0d57d9de4570b90c472.tar.xz | |
Add variables if_oneup and if_ipwaited so hook scripts know the overall state of dhcpcd better.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 49 |
1 files changed, 36 insertions, 13 deletions
@@ -209,6 +209,41 @@ handle_exit_timeout(void *arg) 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) @@ -225,19 +260,7 @@ 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; } |
