[PATCHv2 5/7] dbus: Added dbus signal MeshPeerDisconnected

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

 



This is similar to the control interface event MESH-PEER-DISCONNECTED

Signed-off-by: Saurav Babu <saurav.babu@xxxxxxxxxxx>
---
 doc/dbus.doxygen               |  9 +++++++++
 wpa_supplicant/dbus/dbus_new.c | 38 ++++++++++++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new.h |  8 ++++++++
 wpa_supplicant/mesh_mpm.c      |  3 +++
 wpa_supplicant/notify.c        | 11 +++++++++++
 wpa_supplicant/notify.h        |  2 ++
 6 files changed, 71 insertions(+)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 6f2eeaf..f9244a5 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -2287,6 +2287,15 @@ Interface for performing Mesh operations.
       <dd>A dictionary containing information of connected Mesh Peer.</dd>
     </dl>
   </li>
+  <li>
+    <h3>MeshPeerDisconnected ( a{sv} : args )</h3>
+    <p></p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>a{sv} : args</dt>
+      <dd>A dictionary containing information of disconnected Mesh Peer.</dd>
+    </dl>
+  </li>
 </ul>
 
 */
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 7ca9605..9c9208a 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -887,6 +887,38 @@ void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
 		dbus_connection_send(iface->con, msg, NULL);
 	dbus_message_unref(msg);
 }
+
+void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
+										const u8 *peer_addr, int 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_MESH,
+				      "MeshPeerDisconnected");
+	if (msg == NULL)
+		return;
+
+	dbus_message_iter_init_append(msg, &iter);
+	if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
+		!wpa_dbus_dict_append_byte_array(&dict_iter, "PeerAddress",
+					     (const char *) peer_addr,
+					     ETH_ALEN) ||
+		!wpa_dbus_dict_append_int32(&dict_iter, "DisconnectReason", reason) ||
+		!wpa_dbus_dict_close_write(&iter, &dict_iter))
+		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+	else
+		dbus_connection_send(iface->con, msg, NULL);
+	dbus_message_unref(msg);
+}
 #endif /* CONFIG_MESH */
 
 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
@@ -3737,6 +3769,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
 		  END_ARGS
 	  }
 	},
+	{ "MeshPeerDisconnected", WPAS_DBUS_NEW_IFACE_MESH,
+	  {
+		  { "args", "a{sv}", ARG_OUT },
+		  END_ARGS
+	  }
+	},
 #endif /* CONFIG_MESH */
 	{ NULL, NULL, { END_ARGS } }
 };
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index df7da3f..19ccc39 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -247,6 +247,8 @@ void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
 					      u8 *meshid, u8 meshid_len, int reason);
 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);
 
 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
@@ -580,6 +582,12 @@ void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline
+void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
+										const u8 *peer_addr, int reason)
+{
+}
+
 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
 #endif /* CTRL_IFACE_DBUS_H_NEW */
diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c
index 6106b07..cf7107e 100644
--- a/wpa_supplicant/mesh_mpm.c
+++ b/wpa_supplicant/mesh_mpm.c
@@ -1013,6 +1013,9 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
 			wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
 				MAC2STR(sta->addr));
 
+			/* Send DBUS event */
+			wpas_notify_mesh_peer_disconnected(wpa_s, sta->addr, reason);
+
 			hapd->num_plinks--;
 
 			mesh_mpm_send_plink_action(wpa_s, sta,
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 574b066..e993730 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -883,3 +883,14 @@ void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
 	wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
 #endif /* CONFIG_MESH */
 }
+
+void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
+								const u8 *peer_addr, int reason_code)
+{
+	if (wpa_s->p2p_mgmt)
+		return;
+
+#ifdef CONFIG_MESH
+	wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
+#endif /* CONFIG_MESH */
+}
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 020eaaa..2dde3ac 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -147,5 +147,7 @@ void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
 								u8 *meshid, u8 meshid_len, int reason_code);
 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, int reason_code);
 
 #endif /* NOTIFY_H */
-- 
1.9.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