[PATCH] P2P: Inviting a p2p device from already running persistent p2p go

Neeraj Kumar Garg neerajkg
Wed Feb 1 04:37:36 PST 2012


Hello Jouni,
Thanks for your earlier comments of adding group=xxx option for a persistent invite. I tried to take that approach but with my limited knowledge, I found it equally unclean from implementation point of view. My patch is based on below understanding:
1. In the receive path of persistent invitation, supplicant code already checks for an already running group. So in that way, it makes more sense to check already running group in persistent= command for transmit case too.
2. We have to use either group= or persistent= command to find out if we are already running a persistent group. Lets say we use p2p_invite peer=xx group=xxx persistent=x command. [Doing automatically without persistent= will be difficult as we might have multiple entries in conf file with same go_dev_addr but different ssid]. For this we have to add the complete code of persistent verification from persistent invite to group invite.
3. Logic is since an application want to do a persistent invite, we can make persistent invite to find out if the group is already running or not. The alternative logic is since group is already running, should the application do a persistent invite or a normal invite. I think both weighs equal in this aspect.


From: Neeraj Garg<neerajkg at neeraj-ubuntu64.(none)>
Date: Fri, 21 Oct 2011 12:22:04 +0530
Subject: [PATCH] P2P: Inviting a p2p device from already running persistent p2p go
 Signed-off-by: Neeraj Garg <neerajkg at neeraj-ubuntu64.(none)>

---
 wpa_supplicant/p2p_supplicant.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)
 mode change 100644 => 100755 wpa_supplicant/p2p_supplicant.c

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
old mode 100644
new mode 100755
index 9af1839..2935e81
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3517,6 +3517,7 @@ int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
 {
 	enum p2p_invite_role role;
 	u8 *bssid = NULL;
+	int go;
 
 	if (ssid->mode == WPAS_MODE_P2P_GO) {
 		role = P2P_INVITE_ROLE_GO;
@@ -3525,17 +3526,25 @@ int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
 				   "address in invitation command");
 			return -1;
 		}
-		if (wpas_p2p_create_iface(wpa_s)) {
-			if (wpas_p2p_add_group_interface(wpa_s,
-							 WPA_IF_P2P_GO) < 0) {
-				wpa_printf(MSG_ERROR, "P2P: Failed to "
-					   "allocate a new interface for the "
-					   "group");
-				return -1;
-			}
-			bssid = wpa_s->pending_interface_addr;
-		} else
-			bssid = wpa_s->own_addr;
+		/* P2P: Check to see if we are already running a persistent group */
+		if (wpas_get_p2p_group(wpa_s, ssid->ssid, ssid->ssid_len, &go)) {
+			if (go)
+				bssid = wpa_s->own_addr;
+		}
+		else {
+			/* P2P: We are not already running a persistent group so create an interface */
+			if (wpas_p2p_create_iface(wpa_s)) {
+				if (wpas_p2p_add_group_interface(wpa_s,
+								 WPA_IF_P2P_GO) < 0) {
+					wpa_printf(MSG_ERROR, "P2P: Failed to "
+						   "allocate a new interface for the "
+						   "group");
+					return -1;
+				}
+				bssid = wpa_s->pending_interface_addr;
+			} else
+				bssid = wpa_s->own_addr;
+		}
 	} else {
 		role = P2P_INVITE_ROLE_CLIENT;
 		peer_addr = ssid->bssid;
-- 
 
Regards,
-Neeraj




More information about the Hostap mailing list