From 7c121c285301657268c8f346fdca0abb7acce748 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 5 May 2014 15:39:22 +0200 Subject: more useful behavior for up/down and connected/disconnected --- dyndhcpd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dyndhcpd.c b/dyndhcpd.c index 68a0a4e..e7b7bf9 100644 --- a/dyndhcpd.c +++ b/dyndhcpd.c @@ -135,11 +135,20 @@ int main(int argc, char ** argv) { continue; if (ifa->ifa_addr == NULL) continue; - if (!(ifa->ifa_flags & IFF_UP)) - continue; if (ifa->ifa_addr->sa_family != AF_INET) continue; + /* check if the device is up */ + if (!(ifa->ifa_flags & IFF_UP)) { + fprintf(stderr, "Interface %s is down.\n", interface); + goto out; + } + + /* check if the device is connected / cable is plugged in + * do warn here, but do not fail */ + if (!(ifa->ifa_flags & IFF_RUNNING)) + fprintf(stderr, "Warning: Interface %s is not connected.\n", interface); + s4 = (struct sockaddr_in *)ifa->ifa_addr; v_host = &s4->sin_addr; -- cgit v1.2.3-54-g00ecf