From: Shivani Baranwal Date: Sun, 4 Aug 2024 22:12:08 +0000 (+0530) Subject: P2P2: Add P2P2 IE for groups using P2P2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=339f39e100c3b9ecccbbfa63f2799675051f52bb;p=thirdparty%2Fhostap.git P2P2: Add P2P2 IE for groups using P2P2 Signed-off-by: Shivani Baranwal --- diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 610f7db55..afca5a4c7 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1911,6 +1911,11 @@ struct p2p_group; * the per-group information with p2p_group_init(). */ struct p2p_group_config { + /** + * p2p2 - Whether the group was formed using P2P2 + */ + bool p2p2; + /** * persistent_group - Whether the group is persistent * 0 = not a persistent group diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c index c036f92a3..2659787f3 100644 --- a/src/p2p/p2p_group.c +++ b/src/p2p/p2p_group.c @@ -205,11 +205,28 @@ static struct wpabuf * p2p_group_encaps_probe_resp(struct wpabuf *subelems) } +struct wpabuf * p2p_group_build_p2p2_ie(struct p2p_data *p2p, + struct wpabuf *p2p2_ie, int freq) +{ + u8 *len; + + wpabuf_put_u8(p2p2_ie, WLAN_EID_VENDOR_SPECIFIC); + len = wpabuf_put(p2p2_ie, 1); + wpabuf_put_be32(p2p2_ie, P2P2_IE_VENDOR_TYPE); + wpa_printf(MSG_DEBUG, "P2P: * P2P2 IE header"); + p2p_buf_add_pcea(p2p2_ie, p2p); + *len = (u8 *) wpabuf_put(p2p2_ie, 0) - len - 1; + + return p2p2_ie; +} + + static struct wpabuf * p2p_group_build_beacon_ie(struct p2p_group *group) { struct wpabuf *ie; u8 *len; size_t extra = 0; + struct wpabuf *p2p2_ie; #ifdef CONFIG_WIFI_DISPLAY if (group->p2p->wfd_ie_beacon) @@ -220,7 +237,7 @@ static struct wpabuf * p2p_group_build_beacon_ie(struct p2p_group *group) group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]) extra += wpabuf_len(group->p2p->vendor_elem[VENDOR_ELEM_BEACON_P2P_GO]); - ie = wpabuf_alloc(257 + extra); + ie = wpabuf_alloc(500 + extra); if (ie == NULL) return NULL; @@ -240,6 +257,17 @@ static struct wpabuf * p2p_group_build_beacon_ie(struct p2p_group *group) p2p_group_add_noa(ie, group->noa); p2p_buf_update_ie_hdr(ie, len); + if (group->cfg->p2p2) { + p2p2_ie = wpabuf_alloc(255); + if (!p2p2_ie) { + wpabuf_free(ie); + return NULL; + } + + p2p_group_build_p2p2_ie(group->p2p, p2p2_ie, group->cfg->freq); + ie = wpabuf_concat(p2p2_ie, ie); + } + return ie; } @@ -443,6 +471,7 @@ void p2p_group_buf_add_id(struct p2p_group *group, struct wpabuf *buf) static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group) { struct wpabuf *p2p_subelems, *ie; + struct wpabuf *p2p2_ie; p2p_subelems = wpabuf_alloc(500); if (p2p_subelems == NULL) @@ -474,7 +503,16 @@ static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group) ie = wpabuf_concat(wfd, ie); } #endif /* CONFIG_WIFI_DISPLAY */ + if (group->cfg->p2p2) { + p2p2_ie = wpabuf_alloc(255); + if (!p2p2_ie) { + wpabuf_free(ie); + return NULL; + } + p2p_group_build_p2p2_ie(group->p2p, p2p2_ie, group->cfg->freq); + ie = wpabuf_concat(p2p2_ie, ie); + } return ie; } @@ -648,6 +686,7 @@ struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status) struct wpabuf *resp; u8 *rlen; size_t extra = 0; + struct wpabuf *p2p2_ie; #ifdef CONFIG_WIFI_DISPLAY if (group->wfd_ie) @@ -683,6 +722,17 @@ struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status) p2p_buf_add_status(resp, status); p2p_buf_update_ie_hdr(resp, rlen); + if (group->cfg->p2p2) { + p2p2_ie = wpabuf_alloc(255); + if (!p2p2_ie) { + wpabuf_free(resp); + return NULL; + } + + p2p_group_build_p2p2_ie(group->p2p, p2p2_ie, group->cfg->freq); + resp = wpabuf_concat(p2p2_ie, resp); + } + return resp; } diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index 89e5eeab4..2008a3084 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -923,6 +923,8 @@ void p2p_buf_add_pref_channel_list(struct wpabuf *buf, const struct weighted_pcl *pref_freq_list, unsigned int size); struct wpabuf * p2p_encaps_ie(const struct wpabuf *subelems, u32 ie_type); +struct wpabuf * p2p_group_build_p2p2_ie(struct p2p_data *p2p, + struct wpabuf *p2p2_ie, int freq); /* p2p_sd.c */ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 11c0809ac..cf1c1fb90 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -7511,6 +7511,7 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s, cfg->idle_update = wpas_p2p_idle_update; cfg->ip_addr_alloc = WPA_GET_BE32(wpa_s->p2pdev->conf->ip_addr_start) != 0; + cfg->p2p2 = wpa_s->p2p2; group = p2p_group_init(wpa_s->global->p2p, cfg); if (group == NULL)