aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-05-05 15:39:22 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-05-05 15:39:22 +0200
commit7c121c285301657268c8f346fdca0abb7acce748 (patch)
treea8fd8dfa3875f6de8fb5fcb22751c8c5a264a5fd
parent46b5251915aa9fbb78569443c8ae22efe90fd2e7 (diff)
downloaddyndhcpd-7c121c285301657268c8f346fdca0abb7acce748.tar.gz
dyndhcpd-7c121c285301657268c8f346fdca0abb7acce748.tar.zst
more useful behavior for up/down and connected/disconnected
-rw-r--r--dyndhcpd.c13
1 files 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;