]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Add MeshPeerConnected signal
authorSaurav Babu <saurav.babu@samsung.com>
Tue, 18 Jul 2017 07:07:54 +0000 (12:37 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 9 Sep 2017 22:39:35 +0000 (01:39 +0300)
This is similar to the control interface event MESH-PEER-CONNECTED.

Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
doc/dbus.doxygen
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new.h
wpa_supplicant/mesh_mpm.c
wpa_supplicant/notify.c
wpa_supplicant/notify.h

index ed908acd6f88a138b83bef96744a163b3301b5a4..bfdb5a7e3c718561b4c5bed1815b43ccaff91b77 100644 (file)
@@ -2279,6 +2279,15 @@ Interface for performing mesh operations.
       <dd>A dictionary containing information of the removed mesh group.</dd>
     </dl>
   </li>
+  <li>
+    <h3>MeshPeerConnected ( a{sv} : args )</h3>
+    <p></p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>a{sv} : args</dt>
+      <dd>A dictionary containing information of the connected mesh peer.</dd>
+    </dl>
+  </li>
 </ul>
 
 */
index 41d12e31dcd42f8d62d267f35cffc8b115c40d92..6c494c13268d343622cd94202f9905a0b46c6007 100644 (file)
@@ -862,6 +862,38 @@ void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
        dbus_message_unref(msg);
 }
 
+
+void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
+                                         const u8 *peer_addr)
+{
+       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 || !wpa_s->dbus_new_path)
+               return;
+
+       msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+                                     WPAS_DBUS_NEW_IFACE_MESH,
+                                     "MeshPeerConnected");
+       if (!msg)
+               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_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 */
 
 
@@ -3707,6 +3739,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
                  END_ARGS
          }
        },
+       { "MeshPeerConnected", WPAS_DBUS_NEW_IFACE_MESH,
+         {
+                 { "args", "a{sv}", ARG_OUT },
+                 END_ARGS
+         }
+       },
 #endif /* CONFIG_MESH */
        { NULL, NULL, { END_ARGS } }
 };
index dcc2767cd44ee1431d67688d4271d43631c4bced..979630617ea939b0476d6497745cd7aa6e006353 100644 (file)
@@ -246,6 +246,8 @@ void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
 void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
                                         const u8 *meshid, u8 meshid_len,
                                         int reason);
+void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
+                                         const u8 *peer_addr);
 
 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
@@ -574,6 +576,12 @@ void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline
+void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
+                                         const u8 *peer_addr)
+{
+}
+
 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
 #endif /* CTRL_IFACE_DBUS_H_NEW */
index f15204496d9759686a3273394b8c39dde548c3ef..2047fb8ec63f2cc7479248408a646373c86387c6 100644 (file)
@@ -20,6 +20,7 @@
 #include "driver_i.h"
 #include "mesh_mpm.h"
 #include "mesh_rsn.h"
+#include "notify.h"
 
 struct mesh_peer_mgmt_ie {
        const u8 *proto_id; /* Mesh Peering Protocol Identifier (2 octets) */
@@ -857,6 +858,9 @@ static void mesh_mpm_plink_estab(struct wpa_supplicant *wpa_s,
        /* Send ctrl event */
        wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
                MAC2STR(sta->addr));
+
+       /* Send D-Bus event */
+       wpas_notify_mesh_peer_connected(wpa_s, sta->addr);
 }
 
 
index e1f575939aa8b28450c74aa7d2ab74b846550c83..5ed414e5361756a9db6abf87fe9889e400cba40d 100644 (file)
@@ -875,4 +875,14 @@ void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
                                            reason_code);
 }
 
+
+void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
+                                    const u8 *peer_addr)
+{
+       if (wpa_s->p2p_mgmt)
+               return;
+
+       wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
+}
+
 #endif /* CONFIG_MESH */
index d79c7a5691e7c92f00c515d5501e4711a5979d5f..6c953b617af191b9ac75453bd9d91f3e79e1ffa8 100644 (file)
@@ -146,5 +146,7 @@ void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
                                    const u8 *meshid, u8 meshid_len,
                                    int reason_code);
+void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
+                                    const u8 *peer_addr);
 
 #endif /* NOTIFY_H */