diff options
Diffstat (limited to 'package/network/services/hostapd/src')
-rw-r--r-- | package/network/services/hostapd/src/src/ap/ubus.c | 37 | ||||
-rw-r--r-- | package/network/services/hostapd/src/src/ap/ubus.h | 2 |
2 files changed, 39 insertions, 0 deletions
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c index d03b848f94..a34695f36a 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.c +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -1364,6 +1364,43 @@ void hostapd_ubus_free_bss(struct hostapd_data *hapd) free(name); } +static void +hostapd_ubus_vlan_action(struct hostapd_data *hapd, struct hostapd_vlan *vlan, + const char *action) +{ + struct vlan_description *desc = &vlan->vlan_desc; + void *c; + int i; + + if (!hapd->ubus.obj.has_subscribers) + return; + + blob_buf_init(&b, 0); + blobmsg_add_string(&b, "ifname", vlan->ifname); + blobmsg_add_string(&b, "bridge", vlan->bridge); + blobmsg_add_u32(&b, "vlan_id", vlan->vlan_id); + + if (desc->notempty) { + blobmsg_add_u32(&b, "untagged", desc->untagged); + c = blobmsg_open_array(&b, "tagged"); + for (i = 0; i < ARRAY_SIZE(desc->tagged) && desc->tagged[i]; i++) + blobmsg_add_u32(&b, "", desc->tagged[i]); + blobmsg_close_array(&b, c); + } + + ubus_notify(ctx, &hapd->ubus.obj, action, b.head, -1); +} + +void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan) +{ + hostapd_ubus_vlan_action(hapd, vlan, "vlan_add"); +} + +void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan) +{ + hostapd_ubus_vlan_action(hapd, vlan, "vlan_remove"); +} + static const struct ubus_method daemon_methods[] = { UBUS_METHOD("config_add", hostapd_config_add, config_add_policy), UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy), diff --git a/package/network/services/hostapd/src/src/ap/ubus.h b/package/network/services/hostapd/src/src/ap/ubus.h index e16017394f..de0d1182fd 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.h +++ b/package/network/services/hostapd/src/src/ap/ubus.h @@ -43,6 +43,8 @@ void hostapd_ubus_add_iface(struct hostapd_iface *iface); void hostapd_ubus_free_iface(struct hostapd_iface *iface); void hostapd_ubus_add_bss(struct hostapd_data *hapd); void hostapd_ubus_free_bss(struct hostapd_data *hapd); +void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan); +void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan); int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req); void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac); |