diff --git a/device.c b/device.c index 3ad1563..e02a01c 100644 --- a/device.c +++ b/device.c @@ -946,6 +946,7 @@ void device_set_link(struct device *dev, bool state) if (!state) dev->auth_status = false; device_broadcast_event(dev, state ? DEV_EVENT_LINK_UP : DEV_EVENT_LINK_DOWN); + netifd_ubus_device_event(dev, state); } void device_set_ifindex(struct device *dev, int ifindex) diff --git a/ubus.c b/ubus.c index e2aa3f8..d88a5ca 100644 --- a/ubus.c +++ b/ubus.c @@ -1402,6 +1402,15 @@ netifd_ubus_interface_event(struct interface *iface, bool up) ubus_send_event(ubus_ctx, "network.interface", b.head); } +void +netifd_ubus_device_event(struct device *dev, bool state) +{ + blob_buf_init(&b, 0); + blobmsg_add_string(&b, "ifname", dev->ifname); + blobmsg_add_string(&b, "link", state? "up" : "down"); + ubus_send_event(ubus_ctx, "network.device", b.head); +} + void netifd_ubus_interface_notify(struct interface *iface, bool up) { diff --git a/ubus.h b/ubus.h index dde7124..f4b9ae2 100644 --- a/ubus.h +++ b/ubus.h @@ -26,5 +26,6 @@ void netifd_ubus_remove_interface(struct interface *iface); void netifd_ubus_interface_event(struct interface *iface, bool up); void netifd_ubus_interface_notify(struct interface *iface, bool up); void netifd_ubus_device_notify(const char *event, struct blob_attr *data, int timeout); +void netifd_ubus_device_event(struct device *dev, bool state); #endif