[PATCH] dbus: Add SsidTempDisabled signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




>From f84bac62c94d22664e2928f4b64ee94574677eaf Mon Sep 17 00:00:00 2001
From: Peter Malo <peter.malo@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Feb 2021 20:32:45 +0100
Subject: [PATCH] dbus: Add SsidTempDisabled signal

Signed-off-by: Peter Malo <peter.malo@xxxxxxxxxxxxxxxxxxx>
---
 doc/dbus.doxygen                | 15 +++++++++
 wpa_supplicant/dbus/dbus_new.c  | 54 +++++++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new.h  | 10 +++++-
 wpa_supplicant/notify.c         |  6 ++++
 wpa_supplicant/notify.h         |  2 ++
 wpa_supplicant/wpa_supplicant.c |  2 ++
 6 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 8231aac41..388eb8644 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1261,6 +1261,21 @@ fi.w1.wpa_supplicant1.CreateInterface.
 	  <dd>A dictionary with pairs of field names and their values. Possible dictionary keys are: "addr", "dst", "bssid", "ies", "signal".</dd>
 	</dl>
       </li>
+
+      <li>
+	<h3>SsidTempDisabled ( s : ssid, u : auth_failures, s : reason )</h3>
+	<p>Information about SSID being temporarily disabled.</p>
+	<h4>Arguments</h4>
+	<dl>
+	  <dt>s : ssid</dt>
+	  <dd>SSID of the network that has been temp disabled.</dd>
+	  <dt>u : auth_failures</dt>
+	  <dd>Number of authentication failures</dd>
+	  <dt>s : reason</dt>
+	  <dd>Reason for the disabling of the network e.g., "WRONG_KEY"</dd>
+	</dl>
+      </li>
+
     </ul>
 
 
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 2c01943f7..e88172ac5 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1155,6 +1155,54 @@ static void wpas_dbus_signal_station_removed(struct wpa_supplicant *wpa_s,
 				 FALSE);
 }
 
+/**
+ * wpas_dbus_signal_ssid_temp_disabled - Send a signal ssid been temp disabled
+ * @wpa_s: %wpa_supplicant network interface data
+ * @ssid: struct holding SSID related data
+ * @reason: reason for the disabling of the network
+ *
+ * Notify listeners about temporarily disabled ssid
+ */
+void wpas_dbus_signal_ssid_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;
+
+	iface = wpa_s->global->dbus;
+
+	/* Do nothing if the control interface is not turned on */
+	if (iface == NULL || !wpa_s->dbus_new_path)
+		return;
+
+	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+					  WPAS_DBUS_NEW_IFACE_INTERFACE,
+					  "SsidTempDisabled");
+
+	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_byte_array(&dict_iter, "SSID",
+					 (const char *) ssid->ssid,
+					 ssid->ssid_len) ||
+		!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);
+}
 
 #ifdef CONFIG_P2P
 
@@ -4137,6 +4185,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
 	  }
 	},
 #endif /* CONFIG_MESH */
+	{ "SsidTempDisabled", 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..54284953c 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -264,7 +264,9 @@ 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_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
+					struct wpa_ssid *ssid,
+					const char *reason);
 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
 static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
@@ -616,6 +618,12 @@ void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline void wpas_dbus_signal_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
+					  struct wpa_ssid *ssid,
+					  const char *reason)
+{
+}
+
 #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..cc752399f 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -937,3 +937,9 @@ void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
 }
 
 #endif /* CONFIG_MESH */
+
+void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
+			struct wpa_ssid *ssid, const char* reason)
+{
+	wpas_dbus_signal_ssid_temp_disabled(wpa_s, ssid, reason);
+}
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index e843aa124..bc01a6739 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -156,5 +156,7 @@ 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_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
+					struct wpa_ssid *ssid, const char* reason);
 
 #endif /* NOTIFY_H */
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index e1497e1f5..b0d4b9303 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -7805,6 +7805,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_ssid_temp_disabled(wpa_s, ssid, reason);
 }
 
 
-- 
2.25.1

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux