From 23880ff5333c3ca1da1250e8821091f6ae62f566 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 9 Oct 2011 18:49:46 +0200 Subject: [PATCH] add ubus events for interface up/down --- interface-event.c | 2 ++ ubus.c | 9 +++++++++ ubus.h | 1 + 3 files changed, 12 insertions(+) diff --git a/interface-event.c b/interface-event.c index ba7405a..4661143 100644 --- a/interface-event.c +++ b/interface-event.c @@ -7,6 +7,7 @@ #include "netifd.h" #include "interface.h" +#include "ubus.h" char *hotplug_cmd_path = DEFAULT_HOTPLUG_PATH; static struct interface *current; @@ -79,6 +80,7 @@ interface_queue_event(struct interface *iface, enum interface_event ev) enum interface_event last_ev; D(SYSTEM, "Queue hotplug handler for interface '%s'\n", iface->name); + netifd_ubus_interface_event(iface, ev == IFEV_UP); if (current == iface) last_ev = current_ev; else diff --git a/ubus.c b/ubus.c index 7e2d2ea..ca5d110 100644 --- a/ubus.c +++ b/ubus.c @@ -308,6 +308,15 @@ static struct ubus_object_type iface_object_type = UBUS_OBJECT_TYPE("netifd_iface", iface_object_methods); +void +netifd_ubus_interface_event(struct interface *iface, bool up) +{ + blob_buf_init(&b, 0); + blobmsg_add_string(&b, "action", up ? "ifup" : "ifdown"); + blobmsg_add_string(&b, "interface", iface->name); + ubus_send_event(ctx, "network.interface", b.head); +} + void netifd_ubus_add_interface(struct interface *iface) { diff --git a/ubus.h b/ubus.h index 668a34b..a9166c6 100644 --- a/ubus.h +++ b/ubus.h @@ -5,5 +5,6 @@ int netifd_ubus_init(const char *path); void netifd_ubus_done(void); void netifd_ubus_add_interface(struct interface *iface); void netifd_ubus_remove_interface(struct interface *iface); +void netifd_ubus_interface_event(struct interface *iface, bool up); #endif -- 2.25.1