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-<ADDED|REMOVED>
is followed by the network entry identifier. The event matches the
corresponding Network<Added|Removed> signal on the d-bus interface.

Signed-off-by: Andrew Beltrano <anbeltra@microsoft.com>
This commit is contained in:
Andrew Beltrano 2021-04-14 23:25:05 +00:00 committed by Jouni Malinen
parent f238610616
commit 0030590fb3
2 changed files with 12 additions and 2 deletions

View file

@ -126,6 +126,10 @@ extern "C" {
#define WPA_EVENT_FREQ_CONFLICT "CTRL-EVENT-FREQ-CONFLICT " #define WPA_EVENT_FREQ_CONFLICT "CTRL-EVENT-FREQ-CONFLICT "
/** Frequency ranges that the driver recommends to avoid */ /** Frequency ranges that the driver recommends to avoid */
#define WPA_EVENT_AVOID_FREQ "CTRL-EVENT-AVOID-FREQ " #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 */ /** Result of MSCS setup */
#define WPA_EVENT_MSCS_RESULT "CTRL-EVENT-MSCS-RESULT " #define WPA_EVENT_MSCS_RESULT "CTRL-EVENT-MSCS-RESULT "
/** WPS overlap detected in PBC mode */ /** WPS overlap detected in PBC mode */

View file

@ -350,8 +350,11 @@ void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
* applications since these network objects won't behave like * applications since these network objects won't behave like
* regular ones. * 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); 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) if (wpa_s->wpa)
wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s && 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); 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)) if (network_is_persistent_group(ssid))
wpas_notify_persistent_group_removed(wpa_s, ssid); wpas_notify_persistent_group_removed(wpa_s, ssid);