From: Felix Fietkau Date: Sun, 9 Oct 2011 16:49:46 +0000 (+0200) Subject: add ubus events for interface up/down X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=23880ff5333c3ca1da1250e8821091f6ae62f566 add ubus events for interface up/down --- 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 @@ -309,6 +309,15 @@ static struct ubus_object_type iface_object_type = 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) { struct ubus_object *obj = &iface->ubus; 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