diff options
| author | Roy Marples <roy@marples.name> | 2020-06-18 21:15:15 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-06-18 21:15:15 +0100 |
| commit | 009dc39be56be9b2fae857e64aa55c20f2842d13 (patch) | |
| tree | 6085381f2e63161a8aa72f49eaac34f255f970be /src/if.c | |
| parent | 3f9355273c90c21bb1fdaa8bac9776f8195301b2 (diff) | |
| download | dhcpcd-009dc39be56be9b2fae857e64aa55c20f2842d13.tar.xz | |
dhcpcd: Add an option to poll the interface carrier state
Only to be used if the interface does not report carrier state
changes for whatever reason.
Diffstat (limited to 'src/if.c')
| -rw-r--r-- | src/if.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -64,7 +64,9 @@ #include <syslog.h> #include <unistd.h> +#define ELOOP_QUEUE ELOOP_IF #include "common.h" +#include "eloop.h" #include "dev.h" #include "dhcp.h" #include "dhcp6.h" @@ -661,6 +663,30 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, return ifs; } +static void +if_poll(void *arg) +{ + struct interface *ifp = arg; + unsigned int flags = ifp->flags; + int carrier; + + carrier = if_carrier(ifp); /* if_carrier will update ifp->flags */ + if (ifp->carrier != carrier || ifp->flags != flags) + dhcpcd_handlecarrier(ifp->ctx, carrier, ifp->flags, ifp->name); + + if (ifp->options->poll != 0 || ifp->carrier != LINK_UP) + if_pollinit(ifp); +} + +int +if_pollinit(struct interface *ifp) +{ + unsigned long msec; + + msec = ifp->options->poll != 0 ? ifp->options->poll : IF_POLL_UP; + return eloop_timeout_add_msec(ifp->ctx->eloop, msec, if_poll, ifp); +} + /* * eth0.100:2 OR eth0i100:2 (seems to be NetBSD xvif(4) only) * |
