]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Generate an event when a network is added or removed
authorAndrew Beltrano <anbeltra@microsoft.com>
Wed, 14 Apr 2021 23:25:05 +0000 (23:25 +0000)
committerJouni Malinen <j@w1.fi>
Thu, 19 Aug 2021 14:21:06 +0000 (17:21 +0300)
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>
src/common/wpa_ctrl.h
wpa_supplicant/notify.c

index 8da5683c2bf6df7a7bd5895085dcaeb04f43c2ba..2b8f04becb2a2a440d2e409f24782b696bee6afe 100644 (file)
@@ -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 */
index e0e7e5433d77336d87f226e6e45cbaa205c8d2c1..fe5e072c24c284d7230bdd249f719fcbd0a05568 100644 (file)
@@ -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);