From patchwork Tue Mar 9 14:22:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fionn Cleary X-Patchwork-Id: 1450001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=lzoeK9mM; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dw0lP4C2mz9rx6 for ; Wed, 10 Mar 2021 03:19:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=//TawxL4PPG0bMmZN5CbEqGkj2LZ3Zk/gWDaVAF7zRA=; b=lzoeK9mMSGsCf/ 73QYJZAi8BW2c4iXfhscXtIopmkTDJrtuUOcBMz2F9IHZXlw6di49y/wNnN7a3+7u5OjU+cfxhn80 e9oBZT051kWenb3Zf1Ni6BpabnGwdX4hTcUaUUiXOmatFL8F8CS2cbOFhArgGrzIg7zhqL/q6rYWC Msw14iUUa6aaX9uopkgh7jbhDRJKaNerBOWPPYLlsxHSXnhH7FfwWd8dTFRKAw1/cY2NzGX19QCvd 6vyL5Xm/Z+pd9Fb0V49fuXDsLivdm5qr3D7yHzSf07BwHuScAm0PLD08jTnsPR9vcBZbtqXXHlJyZ IqfFPu8iDEyTN3Jf0udg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJf3n-0053kD-Eb; Tue, 09 Mar 2021 16:18:15 +0000 Received: from bsmtp.bon.at ([213.33.87.14]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJdFe-004pXx-CD for hostap@lists.infradead.org; Tue, 09 Mar 2021 14:22:24 +0000 Received: from localhost (h081217024165.dyn.cm.kabsi.at [81.217.24.165]) by bsmtp.bon.at (Postfix) with ESMTPSA id 4Dvy8X11qkz5tlB for ; Tue, 9 Mar 2021 15:22:19 +0100 (CET) From: Fionn Cleary To: hostap@lists.infradead.org Subject: [PATCH v2] dbus: Add NetworkTempDisabled & NetworkReenabled signals Date: Tue, 09 Mar 2021 14:22:19 +0000 Message-ID: <87czw8h0f8.fsf@tcd.ie> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210309_142222_600791_53C09F38 X-CRM114-Status: GOOD ( 15.93 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Fionn Cleary These can be used to determine if a particular network has incorrect credentials, as the existing DisconnectReason signal is only useful for determining that a network has a problem, but not which one [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [213.33.87.14 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [213.33.87.14 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Mailman-Approved-At: Tue, 09 Mar 2021 16:18:14 +0000 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Fionn Cleary These can be used to determine if a particular network has incorrect credentials, as the existing DisconnectReason signal is only useful for determining that a network has a problem, but not which one. Signed-off-by: Peter Malo [Code formatting & adding NetworkReenabled] Signed-off-by: Fionn Cleary --- doc/dbus.doxygen | 20 ++++++ wpa_supplicant/dbus/dbus_new.c | 109 ++++++++++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new.h | 16 +++++ wpa_supplicant/notify.c | 12 ++++ wpa_supplicant/notify.h | 4 ++ wpa_supplicant/wpa_supplicant.c | 4 ++ 6 files changed, 165 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 8231aac41..57b7c3b5a 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -1261,6 +1261,26 @@ fi.w1.wpa_supplicant1.CreateInterface.
A dictionary with pairs of field names and their values. Possible dictionary keys are: "addr", "dst", "bssid", "ies", "signal".
+ +
  • +

    NetworkTempDisabled ( a{sv} : parameters )

    +

    Notification of a network being temporarily disabled.

    +

    Arguments

    +
    +
    a{sv} : parameters
    +
    A dictionary with pairs of field names and their values. Possible dictionary keys are: "network", "auth_failures", "reason".
    +
    +
  • + +
  • +

    NetworkReenabled ( a{sv} : paramaters )

    +

    Notification that a network is being reenabled after it was temporarily disabled.

    +

    Arguments

    +
    +
    a{sv} : parameters
    +
    A dictionary with pairs of field names and their values. Possible dictionary keys are: "network".
    +
    +
  • diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 2c01943f7..03d50d780 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -1155,6 +1155,103 @@ static void wpas_dbus_signal_station_removed(struct wpa_supplicant *wpa_s, FALSE); } +/** + * wpas_dbus_signal_network_temp_disabled - Send a signal that a network been temporarily disabled + * @wpa_s: %wpa_supplicant network interface data + * @ssid: struct holding SSID related data + * @reason: reason why the network was disabled + * + * Notify listeners about a temporarily disabled network + */ +void wpas_dbus_signal_network_temp_disabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, + const char *reason) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter, dict_iter; + char path[WPAS_DBUS_OBJECT_PATH_MAX]; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL || !wpa_s->dbus_new_path) + return; + + os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, + "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d", + wpa_s->dbus_new_path, ssid->id); + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NetworkTempDisabled"); + + if (msg == NULL) + return; + + dbus_message_iter_init_append(msg, &iter); + + if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) + goto nomem; + + if (!wpa_dbus_dict_append_object_path(&dict_iter, "network", path) || + !wpa_dbus_dict_append_uint32(&dict_iter, "auth_failures", + ssid->auth_failures) || + !wpa_dbus_dict_append_string(&dict_iter, "reason", + reason) || + !wpa_dbus_dict_close_write(&iter, &dict_iter)) + goto nomem; + else + dbus_connection_send(iface->con, msg, NULL); +nomem: + dbus_message_unref(msg); +} + +/** + * wpas_dbus_signal_network_reenabled - Send a signal that a network has been reenabled + * @wpa_s: %wpa_supplicant network interface data + * @ssid: struct holding SSID related data + * + * Notify listeners about reenabled network + */ +void wpas_dbus_signal_network_reenabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter, dict_iter; + char path[WPAS_DBUS_OBJECT_PATH_MAX]; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL || !wpa_s->dbus_new_path) + return; + + os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, + "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d", + wpa_s->dbus_new_path, ssid->id); + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NetworkReenabled"); + + if (msg == NULL) + return; + + dbus_message_iter_init_append(msg, &iter); + + if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) + goto nomem; + + if (!wpa_dbus_dict_append_object_path(&dict_iter, "network", path) || + !wpa_dbus_dict_close_write(&iter, &dict_iter)) + goto nomem; + else + dbus_connection_send(iface->con, msg, NULL); +nomem: + dbus_message_unref(msg); +} #ifdef CONFIG_P2P @@ -4137,6 +4234,18 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { } }, #endif /* CONFIG_MESH */ + { "NetworkTempDisabled", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "properties", "a{sv}", ARG_OUT }, + END_ARGS + } + }, + { "NetworkRenabled", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "properties", "a{sv}", ARG_OUT }, + END_ARGS + } + }, { NULL, NULL, { END_ARGS } } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 42db3892e..b22bd6e78 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -264,6 +264,11 @@ void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s, const u8 *peer_addr); void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s, const u8 *peer_addr, int reason); +void wpas_dbus_signal_network_temp_disabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, + const char *reason); +void wpas_dbus_signal_network_reenabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid); #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ @@ -616,6 +621,17 @@ void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s, { } +static inline void wpas_dbus_signal_network_temp_disabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, + const char *reason) +{ +} + +static inline void wpas_dbus_signal_network_reenabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid) +{ +} + #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ #endif /* CTRL_IFACE_DBUS_H_NEW */ diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index e0e7e5433..6bd4bcb9f 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -937,3 +937,15 @@ void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_MESH */ + +void wpas_notify_network_temp_disabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, const char* reason) +{ + wpas_dbus_signal_network_temp_disabled(wpa_s, ssid, reason); +} + +void wpas_notify_network_reenabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid) +{ + wpas_dbus_signal_network_reenabled(wpa_s, ssid); +} diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index e843aa124..7fa687282 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -156,5 +156,9 @@ void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s, const u8 *peer_addr); void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s, const u8 *peer_addr, u16 reason_code); +void wpas_notify_network_temp_disabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, const char* reason); +void wpas_notify_network_reenabled(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid); #endif /* NOTIFY_H */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 6a02ed7c5..59f45a1d5 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -7804,6 +7804,8 @@ void wpas_auth_failed(struct wpa_supplicant *wpa_s, char *reason) "id=%d ssid=\"%s\" auth_failures=%u duration=%d reason=%s", ssid->id, wpa_ssid_txt(ssid->ssid, ssid->ssid_len), ssid->auth_failures, dur, reason); + + wpas_notify_network_temp_disabled(wpa_s, ssid, reason); } @@ -7822,6 +7824,8 @@ void wpas_clear_temp_disabled(struct wpa_supplicant *wpa_s, ssid->disabled_until.usec = 0; if (clear_failures) ssid->auth_failures = 0; + + wpas_notify_network_reenabled(wpa_s, ssid); }