diff mbox

[4/7] dbus: Add a Group property to Peer object which will hold its group path

Message ID 1400586674-18542-5-git-send-email-tomasz.bursztyka@linux.intel.com
State Changes Requested
Headers show

Commit Message

Tomasz Bursztyka May 20, 2014, 11:51 a.m. UTC
If only the Peer is part of a group, this property will tell about the
group object path.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
 wpa_supplicant/dbus/dbus_new.c              |  4 ++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 33 +++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.h |  4 ++++
 3 files changed, 41 insertions(+)

Comments

Jouni Malinen May 21, 2014, 9:17 p.m. UTC | #1
On Tue, May 20, 2014 at 02:51:11PM +0300, Tomasz Bursztyka wrote:
> If only the Peer is part of a group, this property will tell about the
> group object path.

> diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
> @@ -1544,6 +1544,39 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_interface_address(DBusMessageIter *iter,
>  
> +dbus_bool_t wpas_dbus_getter_p2p_peer_group(DBusMessageIter *iter,
> +					    DBusError *error,
> +					    void *user_data)
> +{
> +	char groupobj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
> +	struct peer_handler_args *peer_args = user_data;
> +	struct wpa_supplicant *wpa_s = peer_args->wpa_s;
> +	struct wpa_supplicant *wpa_s_go;
> +	const struct p2p_peer_info *info;
> +
> +	info = p2p_get_peer_info(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;
> +	}
> +
> +	wpa_s_go = wpas_get_go_p2p_client(wpa_s, info->p2p_device_addr);
> +	if (wpa_s_go == NULL)
> +		wpa_s_go = wpas_get_go_p2p_go(wpa_s, info->p2p_device_addr);

As noted in the previous emails, this may not be unique, i.e., there
could be multiple matching interfaces since P2P supports multiple
groups. Is it acceptable for this interface to support properly only the
case of a single group being in use (and have undefined behavior on
group selection if more than a single group is in place between the two
P2P Devices)?
Tomasz Bursztyka May 27, 2014, 1:33 p.m. UTC | #2
Hi Jouni,

> As noted in the previous emails, this may not be unique, i.e., there
> could be multiple matching interfaces since P2P supports multiple
> groups. Is it acceptable for this interface to support properly only the
> case of a single group being in use (and have undefined behavior on
> group selection if more than a single group is in place between the two
> P2P Devices)?

Let's change this interface from Group to Groups, a list of group object 
path.
Thus it will fit in all case, multi group or not

Tomasz
diff mbox

Patch

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 881082a..91d5b1b 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3275,6 +3275,10 @@  static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
 	  wpas_dbus_getter_p2p_peer_interface_address,
 	  NULL
 	},
+	{ "Group", WPAS_DBUS_NEW_IFACE_P2P_PEER, "o",
+	  wpas_dbus_getter_p2p_peer_group,
+	  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 f76e2b6..9465cea 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1544,6 +1544,39 @@  dbus_bool_t wpas_dbus_getter_p2p_peer_interface_address(DBusMessageIter *iter,
 						      ETH_ALEN, error);
 }
 
+dbus_bool_t wpas_dbus_getter_p2p_peer_group(DBusMessageIter *iter,
+					    DBusError *error,
+					    void *user_data)
+{
+	char groupobj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+	struct peer_handler_args *peer_args = user_data;
+	struct wpa_supplicant *wpa_s = peer_args->wpa_s;
+	struct wpa_supplicant *wpa_s_go;
+	const struct p2p_peer_info *info;
+
+	info = p2p_get_peer_info(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;
+	}
+
+	wpa_s_go = wpas_get_go_p2p_client(wpa_s, info->p2p_device_addr);
+	if (wpa_s_go == NULL)
+		wpa_s_go = wpas_get_go_p2p_go(wpa_s, info->p2p_device_addr);
+
+	if (wpa_s_go == NULL || wpa_s_go->dbus_groupobj_path == NULL)
+		os_snprintf(groupobj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/");
+	else
+		os_snprintf(groupobj_path, WPAS_DBUS_OBJECT_PATH_MAX, "%s",
+			    wpa_s_go->dbus_groupobj_path);
+
+	path = groupobj_path;
+	return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
+						&path, error);
+}
+
 /**
  * wpas_dbus_getter_persistent_groups - Get array of persistent group objects
  * @iter: Pointer to incoming dbus message iter
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
index 3f1b577..d7cdfa2 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -155,6 +155,10 @@  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_group(DBusMessageIter *iter,
+					    DBusError *error,
+					    void *user_data);
+
 /*
  * P2P Group properties
  */