aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-09-14 17:58:26 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-09-14 17:58:26 +0200
commit00060edca9598685d7b1299b5be1b6adb74ab5dd (patch)
tree5e67840fb0853c4e6d4d43224e5e6331d55a6896
parented9ebcd264efb17a5ae528be5c14dc2192737c2c (diff)
downloadnetlink-notify-00060edca9598685d7b1299b5be1b6adb74ab5dd.tar.gz
netlink-notify-00060edca9598685d7b1299b5be1b6adb74ab5dd.tar.zst
do not show notification if state did not change
-rw-r--r--netlink-notify.c8
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;