mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-03-14 06:49:43 +01:00
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 <nbd@nbd.name>
This commit is contained in:
parent
4ed96e54cd
commit
6bb30afe2f
4 changed files with 56 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 &&
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue