diff --git a/device.c b/device.c index 322e009..c896a32 100644 --- a/device.c +++ b/device.c @@ -969,6 +969,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 f8662c2..69e9751 100644 --- a/ubus.c +++ b/ubus.c @@ -1405,6 +1405,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 b9b4b69..1a48643 100644 --- a/ubus.h +++ b/ubus.h @@ -29,5 +29,6 @@ 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_get_procd_data(const char *type, procd_data_cb cb); +void netifd_ubus_device_event(struct device *dev, bool state); #endif