P2P: Omit P2P Group Info in case of no connected peers

As per P2P specification v1.2: "The P2P Group Info attribute shall be
omitted if there are zero connected P2P Clients."

Do not add the attribute if there are not connected peers.

Signed-hostap: Chaitanya T K <chaitanya.mgit@gmail.com>
This commit is contained in:
Chaitanya TK 2013-03-30 20:08:42 +02:00 committed by Jouni Malinen
parent 65a32cdbcb
commit 558d69e3ba

View file

@ -399,7 +399,6 @@ static void wifi_display_group_update(struct p2p_group *group)
static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group) static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
{ {
u8 *group_info;
struct wpabuf *p2p_subelems, *ie; struct wpabuf *p2p_subelems, *ie;
struct p2p_group_member *m; struct p2p_group_member *m;
@ -413,14 +412,18 @@ static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
/* P2P Device Info */ /* P2P Device Info */
p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL); p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL);
/* P2P Group Info */ /* P2P Group Info: Only when at least one P2P Client is connected */
group_info = wpabuf_put(p2p_subelems, 0); if (group->members) {
wpabuf_put_u8(p2p_subelems, P2P_ATTR_GROUP_INFO); u8 *group_info;
wpabuf_put_le16(p2p_subelems, 0); /* Length to be filled */ group_info = wpabuf_put(p2p_subelems, 0);
for (m = group->members; m; m = m->next) wpabuf_put_u8(p2p_subelems, P2P_ATTR_GROUP_INFO);
p2p_client_info(p2p_subelems, m); wpabuf_put_le16(p2p_subelems, 0); /* Length to be filled */
WPA_PUT_LE16(group_info + 1, for (m = group->members; m; m = m->next)
(u8 *) wpabuf_put(p2p_subelems, 0) - group_info - 3); 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); ie = p2p_group_encaps_probe_resp(p2p_subelems);
wpabuf_free(p2p_subelems); wpabuf_free(p2p_subelems);