Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device: add ubus event for link state change #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions ubus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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