From 0030590fb3337cd0667775c63c8eef2d39012db3 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Wed, 14 Apr 2021 23:25:05 +0000 Subject: [PATCH] Generate an event when a network is added or removed Generate an event on the control socket interface when a network is added or removed. The event name CTRL-EVENT-NETWORK- is followed by the network entry identifier. The event matches the corresponding Network signal on the d-bus interface. Signed-off-by: Andrew Beltrano --- src/common/wpa_ctrl.h | 4 ++++ wpa_supplicant/notify.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 8da5683c2..2b8f04bec 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -126,6 +126,10 @@ extern "C" { #define WPA_EVENT_FREQ_CONFLICT "CTRL-EVENT-FREQ-CONFLICT " /** Frequency ranges that the driver recommends to avoid */ #define WPA_EVENT_AVOID_FREQ "CTRL-EVENT-AVOID-FREQ " +/** A new network profile was added (followed by network entry id) */ +#define WPA_EVENT_NETWORK_ADDED "CTRL-EVENT-NETWORK-ADDED " +/** A network profile was removed (followed by prior network entry id) */ +#define WPA_EVENT_NETWORK_REMOVED "CTRL-EVENT-NETWORK-REMOVED " /** Result of MSCS setup */ #define WPA_EVENT_MSCS_RESULT "CTRL-EVENT-MSCS-RESULT " /** WPS overlap detected in PBC mode */ diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index e0e7e5433..fe5e072c2 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -350,8 +350,11 @@ void wpas_notify_network_added(struct wpa_supplicant *wpa_s, * applications since these network objects won't behave like * regular ones. */ - if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) + if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) { wpas_dbus_register_network(wpa_s, ssid); + wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d", + ssid->id); + } } @@ -381,8 +384,11 @@ void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, if (wpa_s->wpa) wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s && - !wpa_s->p2p_mgmt) + !wpa_s->p2p_mgmt) { wpas_dbus_unregister_network(wpa_s, ssid->id); + wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d", + ssid->id); + } if (network_is_persistent_group(ssid)) wpas_notify_persistent_group_removed(wpa_s, ssid);