[PATCH] P2P: Add Peer Interface Address info to peer object

Maneesh Jain maneesh.jain
Wed Jun 3 03:26:47 PDT 2015


This patch extract the Peer Interface address for a found
peer device through D-Bus interface property.

<EP-65895668EA074D69A6D93488C7C4CDCA>
Signed-off-by: Maneesh Jain <maneesh.jain at samsung.com>
---
 doc/dbus.doxygen                            |    5 +++++
 wpa_supplicant/dbus/dbus_new.c              |    4 ++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c |   27 +++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.h |    5 +++++
 4 files changed, 41 insertions(+)
 mode change 100644 => 100755 wpa_supplicant/dbus/dbus_new.c
 mode change 100644 => 100755 wpa_supplicant/dbus/dbus_new_handlers_p2p.c
 mode change 100644 => 100755 wpa_supplicant/dbus/dbus_new_handlers_p2p.h

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 032d595..f60604e 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1688,6 +1688,11 @@ Interface implemented by objects representing P2P peer devices.
     <h3>Groups - ao - (read)</h3>
     <p>The current groups in which this peer is connected.</p>
   </li>
+
+  <li>
+    <h3>InterfaceAddress - ay - (read)</h3>
+    <p>The P2P Interface Address of the peer.</p>
+  </li>
 </ul>
 
 \subsection dbus_peer_signals Signals
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
old mode 100644
new mode 100755
index 6382d77..ba98db5
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3351,6 +3351,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
 	  wpas_dbus_getter_p2p_peer_groups,
 	  NULL
 	},
+	{ "InterfacedAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
+		wpas_dbus_getter_p2p_peer_interface_address,
+	  NULL
+	},
 	{ NULL, NULL, NULL, NULL, NULL }
 };
 
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
old mode 100644
new mode 100755
index c8dd67b..008a5a6
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1560,6 +1560,33 @@ 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_add[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_add) < 0) {
+		os_memcpy(interface_add, peer_args->p2p_device_addr, ETH_ALEN);
+	}
+
+	return wpas_dbus_simple_array_property_getter(
+		iter, DBUS_TYPE_BYTE, (char *) interface_add,
+		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
old mode 100644
new mode 100755
index a84fc4a..4f18f11
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -157,6 +157,11 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_groups(DBusMessageIter *iter,
 					     DBusError *error,
 					     void *user_data);
 
+dbus_bool_t wpas_dbus_getter_p2p_peer_interface_address(DBusMessageIter *iter,
+						     DBusError *error,
+						     void *user_data);
+
+
 /*
  * P2P Group properties
  */
-- 
1.7.9.5




More information about the Hostap mailing list