From 6bb30afe2f505851b816dd3f80102b28f0a5939f Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 1 Nov 2025 05:19:23 +0000 Subject: [PATCH] wpa_supplicant: pass control events on the per-interface ubus object Events are passed in the same format as they would be sent on the control socket. Signed-off-by: Felix Fietkau --- .../services/hostapd/files/wpa_supplicant.uc | 12 +++++++++++ .../hostapd/patches/601-ucode_support.patch | 18 ++++++++++++++++ .../hostapd/src/wpa_supplicant/ucode.c | 21 +++++++++++++++++++ .../hostapd/src/wpa_supplicant/ucode.h | 5 +++++ 4 files changed, 56 insertions(+) diff --git a/package/network/services/hostapd/files/wpa_supplicant.uc b/package/network/services/hostapd/files/wpa_supplicant.uc index 2f0279d0690..94a0c533dc0 100644 --- a/package/network/services/hostapd/files/wpa_supplicant.uc +++ b/package/network/services/hostapd/files/wpa_supplicant.uc @@ -732,6 +732,15 @@ function iface_ubus_remove(ifname) delete wpas.data.iface_ubus[ifname]; } +function iface_ubus_notify(ifname, event) +{ + let obj = wpas.data.iface_ubus[ifname]; + if (!obj) + return; + + obj.notify('ctrl-event', { event }, null, null, null, -1); +} + function iface_ubus_add(ifname) { let ubus = wpas.data.ubus; @@ -813,6 +822,9 @@ return { iface_event("remove", name); iface_ubus_remove(name); }, + ctrl_event: function(name, iface, ev) { + iface_ubus_notify(name, ev); + }, state: function(ifname, iface, state) { let event_data = iface.status(); event_data.name = ifname; diff --git a/package/network/services/hostapd/patches/601-ucode_support.patch b/package/network/services/hostapd/patches/601-ucode_support.patch index f72f2601c3e..835e856ff68 100644 --- a/package/network/services/hostapd/patches/601-ucode_support.patch +++ b/package/network/services/hostapd/patches/601-ucode_support.patch @@ -995,3 +995,21 @@ as adding/removing interfaces. switch (event) { case EVENT_AUTH: #ifdef CONFIG_FST +--- a/wpa_supplicant/ctrl_iface_unix.c ++++ b/wpa_supplicant/ctrl_iface_unix.c +@@ -28,6 +28,7 @@ + #include "config.h" + #include "wpa_supplicant_i.h" + #include "ctrl_iface.h" ++#include "ucode.h" + + /* Per-interface ctrl_iface */ + +@@ -436,6 +437,7 @@ static void wpa_supplicant_ctrl_iface_ms + if (wpa_s == NULL) + return; + ++ wpas_ucode_ctrl_event(wpa_s, txt, len); + gpriv = wpa_s->global->ctrl_iface; + + if (type != WPA_MSG_NO_GLOBAL && gpriv && diff --git a/package/network/services/hostapd/src/wpa_supplicant/ucode.c b/package/network/services/hostapd/src/wpa_supplicant/ucode.c index fd0d3405c96..35345323c3e 100644 --- a/package/network/services/hostapd/src/wpa_supplicant/ucode.c +++ b/package/network/services/hostapd/src/wpa_supplicant/ucode.c @@ -157,6 +157,27 @@ void wpas_ucode_event(struct wpa_supplicant *wpa_s, int event, union wpa_event_d ucv_put(wpa_ucode_call(4)); } +void wpas_ucode_ctrl_event(struct wpa_supplicant *wpa_s, const char *str, size_t len) +{ + uc_value_t *val; + +#define _EV_PREFIX "CTRL-EVENT-" + if (strncmp(str, _EV_PREFIX, sizeof(_EV_PREFIX) - 1) != 0) + return; + + val = wpa_ucode_registry_get(iface_registry, wpa_s->ucode.idx); + if (!val) + return; + + if (wpa_ucode_call_prepare("ctrl_event")) + return; + + uc_value_push(ucv_string_new(wpa_s->ifname)); + uc_value_push(ucv_get(val)); + uc_value_push(ucv_string_new_length(str, len)); + ucv_put(wpa_ucode_call(3)); +} + void wpas_ucode_wps_complete(struct wpa_supplicant *wpa_s, const struct wps_credential *cred) { diff --git a/package/network/services/hostapd/src/wpa_supplicant/ucode.h b/package/network/services/hostapd/src/wpa_supplicant/ucode.h index de9930bec52..1b9ef50f1b5 100644 --- a/package/network/services/hostapd/src/wpa_supplicant/ucode.h +++ b/package/network/services/hostapd/src/wpa_supplicant/ucode.h @@ -22,6 +22,7 @@ void wpas_ucode_add_bss(struct wpa_supplicant *wpa_s); void wpas_ucode_free_bss(struct wpa_supplicant *wpa_s); void wpas_ucode_update_state(struct wpa_supplicant *wpa_s); void wpas_ucode_event(struct wpa_supplicant *wpa_s, int event, union wpa_event_data *data); +void wpas_ucode_ctrl_event(struct wpa_supplicant *wpa_s, const char *str, size_t len); bool wpas_ucode_bss_allowed(struct wpa_supplicant *wpa_s, struct wpa_bss *bss); void wpas_ucode_wps_complete(struct wpa_supplicant *wpa_s, const struct wps_credential *cred); @@ -49,6 +50,10 @@ static inline void wpas_ucode_event(struct wpa_supplicant *wpa_s, int event, uni { } +static inline void wpas_ucode_ctrl_event(struct wpa_supplicant *wpa_s, const char *str, size_t len) +{ +} + static inline bool wpas_ucode_bss_allowed(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) { return true; -- 2.47.3