]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Add new interface property to get connected mesh peers
authorSaurav Babu <saurav.babu@samsung.com>
Tue, 18 Jul 2017 07:07:56 +0000 (12:37 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 9 Sep 2017 22:39:37 +0000 (01:39 +0300)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
doc/dbus.doxygen
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/dbus/dbus_new_handlers.h

index 7f96a935b8f7ea76b7bcef6781927ec92e2fea3d..55857a7d2001edb9cce735f1a00f689537849dee 100644 (file)
@@ -2258,6 +2258,14 @@ Interface implemented by objects representing persistent P2P groups.
 
 Interface for performing mesh operations.
 
+\subsection dbus_mesh_properties Properties
+
+<ul>
+  <li>
+    <h3>MeshPeers - aay - (read)</h3>
+  </li>
+</ul>
+
 \subsection dbus_mesh_signals Signals
 
 <ul>
index e4cf2adbeba5f1fcad621229c91113627aae8674..3127142a39211d025be5eab11fe2473b4657e179 100644 (file)
@@ -3483,6 +3483,13 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
          NULL,
          NULL
        },
+#ifdef CONFIG_MESH
+       { "MeshPeers", WPAS_DBUS_NEW_IFACE_MESH, "aay",
+         wpas_dbus_getter_mesh_peers,
+         NULL,
+         NULL
+       },
+#endif /* CONFIG_MESH */
        { NULL, NULL, NULL, NULL, NULL, NULL }
 };
 
index 63f787a853e1ee49a0c3e4912d4956bccdd37827..a763bc9387bbdb10b7a3daed99825cdd0dd64178 100644 (file)
 #include "dbus_dict_helpers.h"
 #include "dbus_common_i.h"
 #include "drivers/driver.h"
+#ifdef CONFIG_MESH
+#include "ap/hostapd.h"
+#include "ap/sta_info.h"
+#endif /* CONFIG_MESH */
 
 static const char * const debug_strings[] = {
        "excessive", "msgdump", "debug", "info", "warning", "error", NULL
@@ -4798,3 +4802,67 @@ DBusMessage * wpas_dbus_handler_vendor_elem_remove(DBusMessage *message,
        return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
                                      "Not found");
 }
+
+
+#ifdef CONFIG_MESH
+/**
+ * wpas_dbus_getter_mesh_peers - Get connected mesh peers
+ * @iter: Pointer to incoming dbus message iter
+ * @error: Location to store error on failure
+ * @user_data: Function specific data
+ * Returns: TRUE on success, FALSE on failure
+ *
+ * Getter for "MeshPeers" property.
+ */
+dbus_bool_t wpas_dbus_getter_mesh_peers(
+       const struct wpa_dbus_property_desc *property_desc,
+       DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+       struct wpa_supplicant *wpa_s = user_data;
+       struct hostapd_data *hapd;
+       struct sta_info *sta;
+       DBusMessageIter variant_iter, array_iter;
+       int i;
+       DBusMessageIter inner_array_iter;
+
+       if (!wpa_s->ifmsh)
+               return FALSE;
+       hapd = wpa_s->ifmsh->bss[0];
+
+       if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
+                                             DBUS_TYPE_ARRAY_AS_STRING
+                                             DBUS_TYPE_ARRAY_AS_STRING
+                                             DBUS_TYPE_BYTE_AS_STRING,
+                                             &variant_iter) ||
+           !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
+                                             DBUS_TYPE_ARRAY_AS_STRING
+                                             DBUS_TYPE_BYTE_AS_STRING,
+                                             &array_iter))
+               return FALSE;
+
+       for (sta = hapd->sta_list; sta; sta = sta->next) {
+               if (!dbus_message_iter_open_container(
+                           &array_iter, DBUS_TYPE_ARRAY,
+                           DBUS_TYPE_BYTE_AS_STRING,
+                           &inner_array_iter))
+                       return FALSE;
+
+               for (i = 0; i < ETH_ALEN; i++) {
+                       if (!dbus_message_iter_append_basic(&inner_array_iter,
+                                                           DBUS_TYPE_BYTE,
+                                                           &(sta->addr[i])))
+                               return FALSE;
+               }
+
+               if (!dbus_message_iter_close_container(
+                           &array_iter, &inner_array_iter))
+                       return FALSE;
+       }
+
+       if (!dbus_message_iter_close_container(&variant_iter, &array_iter) ||
+           !dbus_message_iter_close_container(iter, &variant_iter))
+               return FALSE;
+
+       return TRUE;
+}
+#endif /* CONFIG_MESH */
index 7d3c3b1443fd24fff1bf626251b44c4ab99490b2..09c6411827f76183d9faa931ff15156baef17355 100644 (file)
@@ -208,6 +208,8 @@ DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_serial_number);
 DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_device_type);
 DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_device_type);
 
+DECLARE_ACCESSOR(wpas_dbus_getter_mesh_peers);
+
 DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message,
                                              struct wpa_supplicant *wpa_s);
 DBusMessage * wpas_dbus_handler_tdls_setup(DBusMessage *message,