diff options
-rw-r--r-- | interface-event.c | 2 | ||||
-rw-r--r-- | ubus.c | 9 | ||||
-rw-r--r-- | ubus.h | 1 |
3 files changed, 12 insertions, 0 deletions
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 @@ -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; @@ -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 |