]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Add MeshGroupRemoved signal
authorSaurav Babu <saurav.babu@samsung.com>
Tue, 18 Jul 2017 07:07:53 +0000 (12:37 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 9 Sep 2017 11:12:33 +0000 (14:12 +0300)
This is similar to the control interface event MESH-GROUP-REMOVED.

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/notify.c
wpa_supplicant/notify.h
wpa_supplicant/wpa_supplicant.c

index ce588efd950605505b75bd163cbd8948d9317841..ed908acd6f88a138b83bef96744a163b3301b5a4 100644 (file)
@@ -2270,6 +2270,15 @@ Interface for performing mesh operations.
       <dd>A dictionary containing information of the started mesh group.</dd>
     </dl>
   </li>
+  <li>
+    <h3>MeshGroupRemoved ( a{sv} : args )</h3>
+    <p></p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>a{sv} : args</dt>
+      <dd>A dictionary containing information of the removed mesh group.</dd>
+    </dl>
+  </li>
 </ul>
 
 */
index 519908c7fd8fbd1dec968e559da1fdf5d38ac814..41d12e31dcd42f8d62d267f35cffc8b115c40d92 100644 (file)
@@ -795,6 +795,7 @@ nomem:
 
 
 #ifdef CONFIG_MESH
+
 void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
                                         struct wpa_ssid *ssid)
 {
@@ -825,6 +826,42 @@ void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
                dbus_connection_send(iface->con, msg, NULL);
        dbus_message_unref(msg);
 }
+
+
+void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
+                                        const u8 *meshid, u8 meshid_len,
+                                        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 || !wpa_s->dbus_new_path)
+               return;
+
+       msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+                                     WPAS_DBUS_NEW_IFACE_MESH,
+                                     "MeshGroupRemoved");
+       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, "SSID",
+                                            (const char *) meshid,
+                                            meshid_len) ||
+           !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 */
 
 
@@ -3664,6 +3701,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
                  END_ARGS
          }
        },
+       { "MeshGroupRemoved", WPAS_DBUS_NEW_IFACE_MESH,
+         {
+                 { "args", "a{sv}", ARG_OUT },
+                 END_ARGS
+         }
+       },
 #endif /* CONFIG_MESH */
        { NULL, NULL, { END_ARGS } }
 };
index 84c0a08f292a71bc84b7d16e49adaab2a76386f4..dcc2767cd44ee1431d67688d4271d43631c4bced 100644 (file)
@@ -243,6 +243,9 @@ void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
                                              int op_freq);
 void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
                                         struct wpa_ssid *ssid);
+void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
+                                        const u8 *meshid, u8 meshid_len,
+                                        int reason);
 
 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
@@ -564,6 +567,13 @@ void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline
+void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
+                                        const u8 *meshid, u8 meshid_len,
+                                        int reason)
+{
+}
+
 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
 #endif /* CTRL_IFACE_DBUS_H_NEW */
index e617022dba86d4b95e763c025d45226e26b4f228..e1f575939aa8b28450c74aa7d2ab74b846550c83 100644 (file)
@@ -853,6 +853,7 @@ void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
 
 
 #ifdef CONFIG_MESH
+
 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
                                    struct wpa_ssid *ssid)
 {
@@ -861,4 +862,17 @@ void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
 
        wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
 }
+
+
+void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
+                                   const u8 *meshid, u8 meshid_len,
+                                   int reason_code)
+{
+       if (wpa_s->p2p_mgmt)
+               return;
+
+       wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
+                                           reason_code);
+}
+
 #endif /* CONFIG_MESH */
index 53b880f3c4fe814ebb7bed232e80067980c90d34..d79c7a5691e7c92f00c515d5501e4711a5979d5f 100644 (file)
@@ -143,5 +143,8 @@ void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
                                         const u8 *bssid, int id, int op_freq);
 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
                                    struct wpa_ssid *ssid);
+void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
+                                   const u8 *meshid, u8 meshid_len,
+                                   int reason_code);
 
 #endif /* NOTIFY_H */
index c41093a45fbcc5e3425e0ca8e0a9314faa65335c..88142675ea71ff2fb820fd8b93f5dac5e8e86272 100644 (file)
 #include "wpas_kay.h"
 #include "mesh.h"
 #include "dpp_supplicant.h"
+#ifdef CONFIG_MESH
+#include "ap/ap_config.h"
+#include "ap/hostapd.h"
+#endif /* CONFIG_MESH */
 
 const char *const wpa_supplicant_version =
 "wpa_supplicant v" VERSION_STR "\n"
@@ -2983,8 +2987,13 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
 
 #ifdef CONFIG_MESH
        if (wpa_s->ifmsh) {
+               struct mesh_conf *mconf;
+
+               mconf = wpa_s->ifmsh->mconf;
                wpa_msg(wpa_s, MSG_INFO, MESH_GROUP_REMOVED "%s",
                        wpa_s->ifname);
+               wpas_notify_mesh_group_removed(wpa_s, mconf->meshid,
+                                              mconf->meshid_len, reason_code);
                wpa_supplicant_leave_mesh(wpa_s);
        }
 #endif /* CONFIG_MESH */