Patchwork [1/2] P2P: Allow wildcard service discovery from DBus API

login
register
mail settings
Submitter Adrien Bustany
Date April 13, 2012, 7:33 a.m.
Message ID <1334302413-22098-2-git-send-email-adrien@bustany.org>
Download mbox | patch
Permalink /patch/152258/
State Accepted
Commit e56fc9e81b99ee110fa083cbdc913823ca6e9890
Headers show

Comments

Adrien Bustany - April 13, 2012, 7:33 a.m.
From: Adrien Bustany <adrien.bustany@nokia.com>

Using the socket command interface, it is possible to pass a NULL dst
to wpas_p2p_sd_request, however you could not do so using the DBus API,
since it required a valid Peer object path.
This patch changes the behaviour, so that if the "peer_object" is
missing from the parameters, a NULL dst is passed to
wpas_p2p_sd_request.

Signed-hostap: Adrien Bustany <adrien.bustany@nokia.com>
---
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
Jouni Malinen - April 14, 2012, 6:08 p.m.
On Fri, Apr 13, 2012 at 10:33:32AM +0300, Adrien Bustany wrote:
> Using the socket command interface, it is possible to pass a NULL dst
> to wpas_p2p_sd_request, however you could not do so using the DBus API,
> since it required a valid Peer object path.
> This patch changes the behaviour, so that if the "peer_object" is
> missing from the parameters, a NULL dst is passed to
> wpas_p2p_sd_request.

Thanks, applied. I also marked it for inclusion into the 1.x releases
since it sounds reasonable to keep this functionality consistent
starting from the first release branch that includes P2P support.

Patch

diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index 62930c7..12e095a 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -2258,7 +2258,7 @@  DBusMessage * wpas_dbus_handler_p2p_service_sd_req(
 	struct wpabuf *tlv = NULL;
 	u8 version = 0;
 	u64 ref = 0;
-	u8 addr[ETH_ALEN];
+	u8 addr_buf[ETH_ALEN], *addr;
 
 	dbus_message_iter_init(message, &iter);
 
@@ -2295,10 +2295,15 @@  DBusMessage * wpas_dbus_handler_p2p_service_sd_req(
 		wpa_dbus_dict_entry_clear(&entry);
 	}
 
-	if (!peer_object_path ||
-	    (parse_peer_object_path(peer_object_path, addr) < 0) ||
-	    !p2p_peer_known(wpa_s->global->p2p, addr))
-		goto error;
+	if (!peer_object_path) {
+		addr = 0;
+	} else {
+		if ((parse_peer_object_path(peer_object_path, addr_buf) < 0) ||
+		    !p2p_peer_known(wpa_s->global->p2p, addr_buf))
+			goto error;
+
+		addr = addr_buf;
+	}
 
 	if (upnp == 1) {
 		if (version <= 0 || service == NULL)