summaryrefslogtreecommitdiffhomepage
path: root/interface.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-05-04 14:54:57 +0200
committerFelix Fietkau <nbd@openwrt.org>2012-05-04 14:54:57 +0200
commit49ffd290f273417c62e395cbbcb65ab7d75cd36a (patch)
tree786edc62c71028b656d16be0c02f8b5a541da1d1 /interface.c
parent23bb091077348d3b87b9900ae3ff923cdd25a662 (diff)
add global interface event notifier
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c13
1 files changed, 11 insertions, 2 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