diff options
author | Christian Hesse <mail@eworm.de> | 2014-05-05 15:39:22 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-05-05 15:39:22 +0200 |
commit | 7c121c285301657268c8f346fdca0abb7acce748 (patch) | |
tree | a8fd8dfa3875f6de8fb5fcb22751c8c5a264a5fd | |
parent | 46b5251915aa9fbb78569443c8ae22efe90fd2e7 (diff) | |
download | dyndhcpd-7c121c285301657268c8f346fdca0abb7acce748.tar.gz dyndhcpd-7c121c285301657268c8f346fdca0abb7acce748.tar.zst |
more useful behavior for up/down and connected/disconnected
-rw-r--r-- | dyndhcpd.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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; |