[PATCH] Dbus: Add InterfaceAddress in peer properties

Purushottam Kushwaha p.kushwaha
Fri Aug 21 02:42:41 PDT 2015


Allow Applications using dbus to fetch interface address in peer
properties similar to control interface.

Signed-off-by: Purushottam Kushwaha <p.kushwaha at samsung.com>
Signed-off-by: Mayank Haarit <mayank.h at samsung.com>
---
 doc/dbus.doxygen                            |  5 +++++
 wpa_supplicant/dbus/dbus_new.c              |  4 ++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 26 ++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.h |  4 ++++
 4 files changed, 39 insertions(+)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 3a08ad7..6abcb7a 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1726,6 +1726,11 @@ Interface implemented by objects representing P2P peer devices.
   </li>
 
   <li>
+    <h3>InterfaceAddress - ay - (read)</h3>
+    <p>The P2P Interface Address of the peer.</p>
+  </li>
+
+  <li>
     <h3>Groups - ao - (read)</h3>
     <p>The current groups in which this peer is connected.</p>
   </li>
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 1959ea7..5940bc0 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3435,6 +3435,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
 	  wpas_dbus_getter_p2p_peer_device_address,
 	  NULL
 	},
+	{ "InterfaceAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
+	  wpas_dbus_getter_p2p_peer_interface_address,
+	  NULL
+	},
 	{ "Groups", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ao",
 	  wpas_dbus_getter_p2p_peer_groups,
 	  NULL
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index e9d60df..5711375 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1729,6 +1729,32 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_device_address(DBusMessageIter *iter,
 		ETH_ALEN, error);
 }
 
+dbus_bool_t wpas_dbus_getter_p2p_peer_interface_address(DBusMessageIter *iter,
+							DBusError *error,
+							void *user_data)
+{
+	struct peer_handler_args *peer_args = user_data;
+	const struct p2p_peer_info *info;
+	u8 interface_address[ETH_ALEN];
+
+	info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
+				  peer_args->p2p_device_addr, 0);
+	if (info == NULL) {
+		dbus_set_error(error, DBUS_ERROR_FAILED,
+			       "failed to find peer");
+		return FALSE;
+	}
+	if (p2p_get_interface_addr(peer_args->wpa_s->global->p2p,
+				   peer_args->p2p_device_addr,
+				   interface_address) < 0) {
+		os_memset(interface_address, 0, ETH_ALEN);
+	}
+
+	return wpas_dbus_simple_array_property_getter(
+		iter, DBUS_TYPE_BYTE, (char *) interface_address,
+		ETH_ALEN, error);
+}
+
 
 struct peer_group_data {
 	struct wpa_supplicant *wpa_s;
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
index 2aecbbe..d452243 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -168,6 +168,10 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_device_address(DBusMessageIter *iter,
 						     DBusError *error,
 						     void *user_data);
 
+dbus_bool_t wpas_dbus_getter_p2p_peer_interface_address(DBusMessageIter *iter,
+							DBusError *error,
+							void *user_data);
+
 dbus_bool_t wpas_dbus_getter_p2p_peer_groups(DBusMessageIter *iter,
 					     DBusError *error,
 					     void *user_data);
-- 
1.9.1




More information about the Hostap mailing list