P2P: Split add-group-info into a helper function

This functionality is needed for other messages, too, so split the group
info building code into a separate helper function.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-02-15 17:07:28 +02:00 committed by Jouni Malinen
parent 253f2e3795
commit 9f7cd9ae8a
2 changed files with 26 additions and 12 deletions

View file

@ -397,10 +397,31 @@ static void wifi_display_group_update(struct p2p_group *group)
#endif /* CONFIG_WIFI_DISPLAY */
void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf,
int max_clients)
{
u8 *group_info;
int count = 0;
struct p2p_group_member *m;
p2p_dbg(group->p2p, "* P2P Group Info");
group_info = wpabuf_put(buf, 0);
wpabuf_put_u8(buf, P2P_ATTR_GROUP_INFO);
wpabuf_put_le16(buf, 0); /* Length to be filled */
for (m = group->members; m; m = m->next) {
p2p_client_info(buf, m);
count++;
if (max_clients >= 0 && count >= max_clients)
break;
}
WPA_PUT_LE16(group_info + 1,
(u8 *) wpabuf_put(buf, 0) - group_info - 3);
}
static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
{
struct wpabuf *p2p_subelems, *ie;
struct p2p_group_member *m;
p2p_subelems = wpabuf_alloc(500);
if (p2p_subelems == NULL)
@ -413,17 +434,8 @@ static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL);
/* P2P Group Info: Only when at least one P2P Client is connected */
if (group->members) {
u8 *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,
(u8 *) wpabuf_put(p2p_subelems, 0) - group_info -
3);
}
if (group->members)
p2p_buf_add_group_info(group, p2p_subelems, -1);
ie = p2p_group_encaps_probe_resp(p2p_subelems);
wpabuf_free(p2p_subelems);

View file

@ -602,6 +602,8 @@ int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
void p2p_group_update_ies(struct p2p_group *group);
void p2p_group_force_beacon_update_ies(struct p2p_group *group);
struct wpabuf * p2p_group_get_wfd_ie(struct p2p_group *g);
void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf,
int max_clients);
void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token);