[PATCH] P2P :- Listen frequence and Operating frequency information into DBUS peer interface. This information is required for debug over dbus interface

Amit Khatri amit.khatriatsamsung.com
Mon Jun 1 05:12:36 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                            |  8 +++++
 src/p2p/p2p.c                               | 23 +++++++++++++
 src/p2p/p2p.h                               | 15 +++++++++
 wpa_supplicant/dbus/dbus_new.c              |  8 +++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 50 +++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.h |  8 +++++
 6 files changed, 112 insertions(+)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 032d595..e9b14f7 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1642,6 +1642,14 @@ Interface implemented by objects representing P2P peer devices.
   </li>
 
   <li>
+    <h3>ListenFreq - i - (read)</h3>
+  </li>
+
+  <li>
+    <h3>OperFreq - i - (read)</h3>
+  </li>
+
+  <li>
     <h3>PrimaryDeviceType - ay - (read)</h3>
   </li>
 
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index c02044b..ed7dd66 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -4884,6 +4884,29 @@ p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next)
 }
 
 
+int
+p2p_get_peer_found_freq(struct p2p_data *p2p, const u8 *addr, enum p2p_freq_type type)
+{
+	struct p2p_device *dev;
+
+	if (!addr)
+		return -1;
+	else{
+		dev = p2p_get_device(p2p, addr);
+		if (!dev)
+			return -1;
+
+		if (dev->flags & P2P_DEV_PROBE_REQ_ONLY)
+			return -1;
+		if(type == LISTEN_FREQ_TYPE)
+			return dev->listen_freq;
+		else if(type == OPERATING_FREQ_TYPE)
+			return dev->oper_freq;
+	}
+	return -1;
+}
+
+
 int p2p_in_progress(struct p2p_data *p2p)
 {
 	if (p2p == NULL)
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index da2446d..d362932 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -67,6 +67,11 @@ enum p2p_wps_method {
 	WPS_P2PS
 };
 
+enum p2p_freq_type {
+	LISTEN_FREQ_TYPE=1,
+	OPERATING_FREQ_TYPE=2
+};
+
 /**
  * struct p2p_go_neg_results - P2P Group Owner Negotiation results
  */
@@ -2077,6 +2082,16 @@ const struct p2p_peer_info *
 p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
 
 /**
+ * p2p_get_peer_found_freq - Get P2P peer frequencies of a found peer
+ * @p2p: P2P module context from p2p_init()
+ * @addr: P2P Device Address of the peer
+ * @type: 1 for listen_freq 2 for operating freq
+ * Returns: The P2P peer frequency based on type
+ */
+int
+p2p_get_peer_found_freq(struct p2p_data *p2p, const u8 *addr, enum p2p_freq_type type);
+
+/**
  * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions
  * @p2p: P2P module context from p2p_init()
  */
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 6382d77..f583022 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3351,6 +3351,14 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
 	  wpas_dbus_getter_p2p_peer_groups,
 	  NULL
 	},
+	{ "ListenFreq", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
+	  wpas_dbus_getter_p2p_device_listen_freq,
+	  NULL
+	},
+	{ "OperFreq", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
+	  wpas_dbus_getter_p2p_device_oper_freq,
+	  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
index c8dd67b..a0608bb 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1364,6 +1364,56 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_level(DBusMessageIter *iter,
 }
 
 
+dbus_bool_t wpas_dbus_getter_p2p_device_listen_freq(DBusMessageIter *iter,
+					    DBusError *error,
+					    void *user_data)
+{
+	struct peer_handler_args *peer_args = user_data;
+	//const struct p2p_peer_info *info;
+	int listen=0;
+
+	listen = p2p_get_peer_found_freq(peer_args->wpa_s->global->p2p,
+				  peer_args->p2p_device_addr,LISTEN_FREQ_TYPE);
+	if (listen == -1) {
+		dbus_set_error(error, DBUS_ERROR_FAILED,
+			       "failed to find peer listen frequency");
+		return FALSE;
+	}
+
+	if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
+					      &listen, error)) {
+		dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+
+dbus_bool_t wpas_dbus_getter_p2p_device_oper_freq(DBusMessageIter *iter,
+					    DBusError *error,
+					    void *user_data)
+{
+	struct peer_handler_args *peer_args = user_data;
+	int operating=0;
+
+	operating = p2p_get_peer_found_freq(peer_args->wpa_s->global->p2p,
+				  peer_args->p2p_device_addr,2);
+	if (operating == -1) {
+		dbus_set_error(error, DBUS_ERROR_FAILED,
+			       "failed to find peer operating frequency");
+		return FALSE;
+	}
+
+	if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
+					      &operating, error)) {
+		dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 dbus_bool_t wpas_dbus_getter_p2p_peer_device_capability(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 a84fc4a..b8d2718 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -130,6 +130,14 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_level(DBusMessageIter *iter,
 					    DBusError *error,
 					    void *user_data);
 
+dbus_bool_t wpas_dbus_getter_p2p_device_listen_freq(DBusMessageIter *iter,
+					    DBusError *error,
+					    void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_device_oper_freq(DBusMessageIter *iter,
+					    DBusError *error,
+					    void *user_data);
+
 dbus_bool_t wpas_dbus_getter_p2p_peer_device_capability(DBusMessageIter *iter,
 							DBusError *error,
 							void *user_data);
-- 
1.9.1





------- Original Message -------
Sender : Jouni Malinen<j at w1.fi> 
Date   : May 29, 2015 23:51 (GMT+05:30)
Title  : Re: [EDT] [PATCH] P2P, DBUS: Getting listen freq info from found p2p
 peer device

On Fri, May 29, 2015 at 10:29:29AM +0000, Amit Khatri wrote:
> Subject: [PATCH] P2P,DBUS: Getting listen freq info from found p2p peer device
>  similar to p2p_peer <mac address> on ctrl interface.

What is this needed for? Please note that the peer may change its listen
frequency and in general, I would not recommend upper layer components
use this.

> diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
>  #include "p2p/p2p.h"
> +#include "p2p/p2p_i.h"

src/p2p/p2p_i.h (just like any other src/*/*_i.h header file) is
internal to the specific src module and it is not allowed to be included
into wpa_supplicant/*. If there is strong need for getting this
internal-to-P2P information into the D-Bus interface, a new accessor
function for listen frequency would likely need to be added into
src/p2p/p2p.h to enable this functionality.

The p2p_peer command includes number of private implementation specific
information for debugging purposes and as such, it cannot be used as a
justification for exposing this through the D-Bus interface.

-- 
Jouni Malinen                                            PGP id EFC895FA
<p> </p><p> </p>



More information about the Hostap mailing list