diff options
author | Christian Hesse <mail@eworm.de> | 2014-09-14 17:58:26 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-09-14 17:58:26 +0200 |
commit | 00060edca9598685d7b1299b5be1b6adb74ab5dd (patch) | |
tree | 5e67840fb0853c4e6d4d43224e5e6331d55a6896 | |
parent | ed9ebcd264efb17a5ae528be5c14dc2192737c2c (diff) | |
download | netlink-notify-00060edca9598685d7b1299b5be1b6adb74ab5dd.tar.gz netlink-notify-00060edca9598685d7b1299b5be1b6adb74ab5dd.tar.zst |
do not show notification if state did not change
-rw-r--r-- | netlink-notify.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/netlink-notify.c b/netlink-notify.c index de4e184..40da52b 100644 --- a/netlink-notify.c +++ b/netlink-notify.c @@ -64,6 +64,7 @@ struct addresses_seen { struct ifs { char *name; + int state; unsigned char deleted; struct addresses_seen *addresses_seen; NotifyNotification *notification; @@ -293,6 +294,7 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { ifs[maxinterface] = malloc(sizeof(struct ifs)); ifs[maxinterface]->name = NULL; + ifs[maxinterface]->state = -1; ifs[maxinterface]->deleted = 0; ifs[maxinterface]->notification = @@ -407,6 +409,12 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { case RTM_DELROUTE: return 0; case RTM_NEWLINK: + /* ignore if state did not change */ + if ((ifi->ifi_flags & CHECK_CONNECTED) == ifs[ifi->ifi_index]->state) + return 0; + + ifs[ifi->ifi_index]->state = ifi->ifi_flags & CHECK_CONNECTED; + notifystr = newstr_link(TEXT_NEWLINK, ifs[ifi->ifi_index]->name, ifi->ifi_flags); icon = ifi->ifi_flags & CHECK_CONNECTED ? ICON_NETWORK_UP : ICON_NETWORK_DOWN; |