[PATCH] P2P,DBUS: Patch for getting manufacturer info from found p2p peer device similar to p2p_peer <mac address> on ctrl interface .

Amit Khatri amit.khatriatsamsung.com
Thu May 28 05:19:46 PDT 2015


Signed-off-by: Amit Khatri <amit.khatri at samsung.com>
Signed-off-by: Rahul Jain <rahul.jain at samsung.com>
Signed-off-by: Ashutosh Kaushik <k.ashutosh at samsung.com>
---
 doc/dbus.doxygen                            |  5 ++++
 wpa_supplicant/dbus/dbus_new.c              |  4 ++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 36 +++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.h |  4 ++++
 4 files changed, 49 insertions(+)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index d623116..721d3a0 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1234,6 +1234,7 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.
     <table>
     <tr><th>Key</th><th>Value type</th><th>Description</th></tr>
     <tr><td>DeviceName</td><td>s</td><td></td></tr>
+    <tr><td>Manufacturer</td><td>s</td><td></td></tr>
     <tr><td>PrimaryDeviceType</td><td>ay</td><td></td></tr>
     <tr><td>SecondaryDeviceTypes</td><td>aay</td><td></td></tr>
     <tr><td>VendorExtension</td><td>aay</td><td></td></tr>
@@ -1629,6 +1630,10 @@ Interface implemented by objects representing P2P peer devices.
   </li>
 
   <li>
+    <h3>Manufacturer - s - (read)</h3>
+  </li>
+
+  <li>
     <h3>PrimaryDeviceType - ay - (read)</h3>
   </li>
 
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 840d105..e0f2392 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3295,6 +3295,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
 	  wpas_dbus_getter_p2p_peer_device_name,
 	  NULL
 	},
+	{ "Manufacturer", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
+	  wpas_dbus_getter_p2p_peer_manufacturer,
+	  NULL
+	},
 	{ "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
 	  wpas_dbus_getter_p2p_peer_primary_device_type,
 	  NULL
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index 9419ba8..83312a2 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1230,6 +1230,42 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_device_name(DBusMessageIter *iter,
 	return TRUE;
 }
 
+dbus_bool_t wpas_dbus_getter_p2p_peer_manufacturer(DBusMessageIter *iter,
+						  DBusError *error,
+						  void *user_data)
+{
+	struct peer_handler_args *peer_args = user_data;
+	const struct p2p_peer_info *info;
+	char *tmp;
+
+	if (!wpa_dbus_p2p_check_enabled(peer_args->wpa_s, NULL, NULL, error))
+		return FALSE;
+
+	/* get the peer info */
+	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;
+	}
+
+	tmp = os_strdup(info->manufacturer);
+	if (!tmp) {
+		dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+		return FALSE;
+	}
+
+	if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &tmp,
+					      error)) {
+		dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+		os_free(tmp);
+		return FALSE;
+	}
+
+	os_free(tmp);
+	return TRUE;
+}
 
 dbus_bool_t wpas_dbus_getter_p2p_peer_primary_device_type(
 	DBusMessageIter *iter, DBusError *error, void *user_data)
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
index fdaccba..6c5bc92 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -112,6 +112,10 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_device_name(DBusMessageIter *iter,
 						  DBusError *error,
 						  void *user_data);
 
+dbus_bool_t wpas_dbus_getter_p2p_peer_manufacturer(DBusMessageIter *iter,
+						  DBusError *error,
+						  void *user_data);
+
 dbus_bool_t wpas_dbus_getter_p2p_peer_primary_device_type(
 	DBusMessageIter *iter, DBusError *error, void *user_data);
 
-- 
1.9.1




More information about the Hostap mailing list