]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Add P2P2 IE for groups using P2P2
authorShivani Baranwal <quic_shivbara@quicinc.com>
Sun, 4 Aug 2024 22:12:08 +0000 (03:42 +0530)
committerJouni Malinen <j@w1.fi>
Sun, 13 Oct 2024 18:41:53 +0000 (21:41 +0300)
Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
src/p2p/p2p.h
src/p2p/p2p_group.c
src/p2p/p2p_i.h
wpa_supplicant/p2p_supplicant.c

index 610f7db558b1ddd43d40fb4e9ac37b1bd753235b..afca5a4c7fec34e5f47d9c83880b43c7c4ecd228 100644 (file)
@@ -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
index c036f92a3cba233f1ac5c5e6b4557f37ebc7463b..2659787f372ff3b92a7a75fbb61387c0cf1f5f1f 100644 (file)
@@ -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;
 }
 
index 89e5eeab40913e54b2a774c42bf29a10afa87f78..2008a30840646dde3cb16a05009f18772453d652 100644 (file)
@@ -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,
index 11c0809ac79ad0ff9e7e8e53d90180119d24fd67..cf1c1fb902f5d6e9f643cd7437ee637fa333c7de 100644 (file)
@@ -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)