From 49ffd290f273417c62e395cbbcb65ab7d75cd36a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 4 May 2012 14:54:57 +0200 Subject: [PATCH] add global interface event notifier --- interface.c | 13 +++++++++++-- interface.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/interface.c b/interface.c index 9301628..5614d39 100644 --- a/interface.c +++ b/interface.c @@ -12,6 +12,7 @@ #include "system.h" struct vlist_tree interfaces; +static LIST_HEAD(iface_all_users); enum { IFACE_ATTR_IFNAME, @@ -122,7 +123,10 @@ interface_event(struct interface *iface, enum interface_event ev) struct interface_user *dep, *tmp; list_for_each_entry_safe(dep, tmp, &iface->users, list) - dep->cb(dep, IFEV_UP); + dep->cb(dep, iface, ev); + + list_for_each_entry_safe(dep, tmp, &iface_all_users, list) + dep->cb(dep, iface, ev); interface_queue_event(iface, ev); } @@ -206,10 +210,15 @@ interface_set_available(struct interface *iface, bool new_state) void interface_add_user(struct interface_user *dep, struct interface *iface) { + if (!iface) { + list_add(&dep->list, &iface_all_users); + return; + } + dep->iface = iface; list_add(&dep->list, &iface->users); if (iface->state == IFS_UP) - dep->cb(dep, IFEV_UP); + dep->cb(dep, iface, IFEV_UP); } void diff --git a/interface.h b/interface.h index c89411a..e89db70 100644 --- a/interface.h +++ b/interface.h @@ -36,7 +36,7 @@ struct interface_error { struct interface_user { struct list_head list; struct interface *iface; - void (*cb)(struct interface_user *dep, enum interface_event ev); + void (*cb)(struct interface_user *dep, struct interface *iface, enum interface_event ev); }; struct interface_ip_settings { -- 2.25.1