aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2020-09-22 15:25:57 +0200
committerDavid Bauer <mail@david-bauer.net>2020-09-22 17:40:08 +0200
commit560e54c69e98a08dd161755da3feb7aa85bbae34 (patch)
tree0298f7e607aca1b00893ece4f7c6493130cc1bbc /package
parent006cd489f047d059af62334661e77f2f5a68289b (diff)
downloadupstream-560e54c69e98a08dd161755da3feb7aa85bbae34.tar.gz
upstream-560e54c69e98a08dd161755da3feb7aa85bbae34.tar.bz2
upstream-560e54c69e98a08dd161755da3feb7aa85bbae34.zip
hostapd: ubus: send notification instead of event
Rafal Milecki pointed out that ubus events are meant for low-level ubus events only (e.g. addition or removal of an object). Higher level events should happen as notifications on the ubus object itself. Dispatch BSS events on the main hostapd ubus object instead of publishing them as ubus events. Signed-off-by: David Bauer <mail@david-bauer.net>
Diffstat (limited to 'package')
-rw-r--r--package/network/services/hostapd/Makefile2
-rw-r--r--package/network/services/hostapd/src/src/ap/ubus.c23
2 files changed, 13 insertions, 12 deletions
diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
index ceb6014c4b..372539bd06 100644
--- a/package/network/services/hostapd/Makefile
+++ b/package/network/services/hostapd/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_RELEASE:=9
+PKG_RELEASE:=10
PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_PROTO:=git
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
index 9dd263837f..9e407538f7 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.c
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
@@ -108,19 +108,20 @@ void hostapd_ubus_free_iface(struct hostapd_iface *iface)
return;
}
-static void hostapd_send_ubus_event(char *bssname, char *event)
+static void hostapd_notify_ubus(struct ubus_object *obj, char *bssname, char *event)
{
- char *name;
+ char *event_type;
- if (!ctx)
+ if (!ctx || !obj)
return;
- if (asprintf(&name, "hostapd.%s.%s", bssname, event) < 0)
+ if (asprintf(&event_type, "bss.%s", event) < 0)
return;
blob_buf_init(&b, 0);
- ubus_send_event(ctx, name, b.head);
- free(name);
+ blobmsg_add_string(&b, "name", bssname);
+ ubus_notify(ctx, obj, event_type, b.head, -1);
+ free(event_type);
}
static void hostapd_send_procd_event(char *bssname, char *event)
@@ -149,10 +150,10 @@ static void hostapd_send_procd_event(char *bssname, char *event)
free(name);
}
-static void hostapd_send_shared_event(char *bssname, char *event)
+static void hostapd_send_shared_event(struct ubus_object *obj, char *bssname, char *event)
{
hostapd_send_procd_event(bssname, event);
- hostapd_send_ubus_event(bssname, event);
+ hostapd_notify_ubus(obj, bssname, event);
}
static void
@@ -201,7 +202,7 @@ hostapd_bss_reload(struct ubus_context *ctx, struct ubus_object *obj,
struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
int ret = hostapd_reload_config(hapd->iface, 1);
- hostapd_send_shared_event(hapd->conf->iface, "reload");
+ hostapd_send_shared_event(&hapd->iface->interfaces->ubus, hapd->conf->iface, "reload");
return ret;
}
@@ -1136,7 +1137,7 @@ void hostapd_ubus_add_bss(struct hostapd_data *hapd)
ret = ubus_add_object(ctx, obj);
hostapd_ubus_ref_inc();
- hostapd_send_shared_event(hapd->conf->iface, "add");
+ hostapd_send_shared_event(&hapd->iface->interfaces->ubus, hapd->conf->iface, "add");
}
void hostapd_ubus_free_bss(struct hostapd_data *hapd)
@@ -1147,7 +1148,7 @@ void hostapd_ubus_free_bss(struct hostapd_data *hapd)
if (!ctx)
return;
- hostapd_send_shared_event(hapd->conf->iface, "remove");
+ hostapd_send_shared_event(&hapd->iface->interfaces->ubus, hapd->conf->iface, "remove");
if (obj->id) {
ubus_remove_object(ctx, obj);