]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wpa_supplicant: pass control events on the per-interface ubus object
authorFelix Fietkau <nbd@nbd.name>
Sat, 1 Nov 2025 05:19:23 +0000 (05:19 +0000)
committerFelix Fietkau <nbd@nbd.name>
Thu, 6 Nov 2025 11:23:03 +0000 (11:23 +0000)
Events are passed in the same format as they would be sent on the control
socket.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/hostapd/files/wpa_supplicant.uc
package/network/services/hostapd/patches/601-ucode_support.patch
package/network/services/hostapd/src/wpa_supplicant/ucode.c
package/network/services/hostapd/src/wpa_supplicant/ucode.h

index 2f0279d06902f5964870460967a7687daaa1c93a..94a0c533dc01a056d2893303de90cd8a6a9504d1 100644 (file)
@@ -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;
index f72f2601c3e974a1e656e98377064c8c5446e256..835e856ff684ce5dcf90999c2071edfddb37a87f 100644 (file)
@@ -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 &&
index fd0d3405c966aca949a5dd74f9d02881c0e17c8d..35345323c3e8eab35c285c692ec6cfe0d3908892 100644 (file)
@@ -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)
 {
index de9930bec52774ef178d148246155d67677818a5..1b9ef50f1b5f10e22efa6bfe537713b970561651 100644 (file)
@@ -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;