Patchwork Omit P2P Group Info, in case of no connected peers

login
register
mail settings
Submitter Chaitanya TK
Date March 20, 2013, 7:30 a.m.
Message ID <514965A8.5050804@gmail.com>
Download mbox | patch
Permalink /patch/229257/
State Accepted
Commit 558d69e3ba17093c3e800dd18faed5e17506af56
Headers show

Comments

Chaitanya TK - March 20, 2013, 7:30 a.m.
As per P2P-sec V1.2: "The P2P Group
Info attribute shall be omitted if there are zero
connected P2P Clients."

Don't add the IE if the no of peers are zero.

Signed-hostap: Chaitanya T K <chaitanya.mgit@gmail.com>
---
@Jan/Arend, 

In that particular line, "+" sign is not there because of the
line wrapping. The patch applied cleanly, so that should 
not be an issue.

---

 src/p2p/p2p_group.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
Jouni Malinen - March 30, 2013, 6:10 p.m.
On Wed, Mar 20, 2013 at 01:00:48PM +0530, Chaitanya TK wrote:
> As per P2P-sec V1.2: "The P2P Group
> Info attribute shall be omitted if there are zero
> connected P2P Clients."
> 
> Don't add the IE if the no of peers are zero.

Thanks, applied.

Patch

diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index edb8d72..697aa64 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -413,14 +413,16 @@  static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
 	/* P2P Device Info */
 	p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL);
 
-	/* P2P Group Info */
-	group_info = wpabuf_put(p2p_subelems, 0);
-	wpabuf_put_u8(p2p_subelems, P2P_ATTR_GROUP_INFO);
-	wpabuf_put_le16(p2p_subelems, 0); /* Length to be filled */
-	for (m = group->members; m; m = m->next)
-		p2p_client_info(p2p_subelems, m);
-	WPA_PUT_LE16(group_info + 1,
+	/* P2P Group Info: Only when at least 1 P2P CLI is connected */
+	if (group->members != 0) {
+		group_info = wpabuf_put(p2p_subelems, 0);
+		wpabuf_put_u8(p2p_subelems, P2P_ATTR_GROUP_INFO);
+		wpabuf_put_le16(p2p_subelems, 0); /* Length to be filled */
+		for (m = group->members; m; m = m->next)
+			p2p_client_info(p2p_subelems, m);
+		WPA_PUT_LE16(group_info + 1,
 		     (u8 *) wpabuf_put(p2p_subelems, 0) - group_info - 3);
+	}
 
 	ie = p2p_group_encaps_probe_resp(p2p_subelems);
 	wpabuf_free(p2p_subelems);