]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Add support for P2P client to join PCC/P2P2 mode Auto GO
authorShivani Baranwal <shivani.baranwal@oss.qualcomm.com>
Tue, 20 May 2025 09:35:04 +0000 (15:05 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 24 Jun 2025 08:31:33 +0000 (11:31 +0300)
Add support for P2P client to join PCC/P2P2 mode Auto GO via
wpa_p2p_group_add_persistent().

Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/dbus/dbus_new_handlers_p2p.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index 4e0c1eda32da83006f9cfc277f5194043b5551af..ab6871c09ae841f7207264b1c18baa518381ae8b 100644 (file)
@@ -7299,9 +7299,11 @@ static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s,
                                         int id, int freq, int vht_center_freq2,
                                         int ht40, int vht, int vht_chwidth,
                                         int he, int edmg, bool allow_6ghz,
-                                        const u8 *go_bssid)
+                                        const u8 *go_bssid, bool p2p2,
+                                        enum wpa_p2p_mode p2p_mode)
 {
        struct wpa_ssid *ssid;
+       bool join = false;
 
        ssid = wpa_config_get_network(wpa_s->conf, id);
        if (ssid == NULL || ssid->disabled != 2) {
@@ -7311,11 +7313,17 @@ static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s,
                return -1;
        }
 
+       if (p2p2) {
+               wpa_s->p2p2 = p2p2;
+               wpa_s->p2p_mode = p2p_mode;
+               join = true;
+       }
        return wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, freq,
                                             vht_center_freq2, ht40, vht,
                                             vht_chwidth, he, edmg,
                                             NULL, 0, 0, allow_6ghz, 0,
-                                            go_bssid, NULL, NULL, NULL, 0);
+                                            go_bssid, NULL, NULL, NULL, 0,
+                                            join);
 }
 
 
@@ -7324,6 +7332,7 @@ static int p2p_ctrl_group_add(struct wpa_supplicant *wpa_s, char *cmd)
        int freq = 0, persistent = 0, group_id = -1;
        bool p2p2 = false;
        int p2pmode = WPA_P2P_MODE_WFD_R1;
+       enum wpa_p2p_mode p2p_mode;
        bool allow_6ghz = false;
        int vht = wpa_s->conf->p2p_go_vht;
        int ht40 = wpa_s->conf->p2p_go_ht40 || vht;
@@ -7417,19 +7426,21 @@ static int p2p_ctrl_group_add(struct wpa_supplicant *wpa_s, char *cmd)
        wpa_s->p2p_go_allow_dfs = !!(wpa_s->drv_flags &
                                     WPA_DRIVER_FLAGS_DFS_OFFLOAD);
 
+       if (p2pmode < WPA_P2P_MODE_WFD_R1 || p2pmode > WPA_P2P_MODE_WFD_PCC)
+               return -1;
+       p2p_mode = p2pmode;
+
        if (group_id >= 0)
                return p2p_ctrl_group_add_persistent(wpa_s, group_id,
                                                     freq, freq2, ht40, vht,
                                                     max_oper_chwidth, he,
                                                     edmg, allow_6ghz,
-                                                    go_bssid);
-
-       if (p2pmode < WPA_P2P_MODE_WFD_R1 || p2pmode > WPA_P2P_MODE_WFD_PCC)
-               return -1;
+                                                    go_bssid, p2p2,
+                                                    p2p_mode);
 
        return wpas_p2p_group_add(wpa_s, persistent, freq, freq2, ht40, vht,
                                  max_oper_chwidth, he, edmg, allow_6ghz, p2p2,
-                                 (enum wpa_p2p_mode) p2pmode);
+                                 p2p_mode);
 }
 
 
index 192c65d66ad0b303a3c88dda8b8b39cab50689f1..129f359341f7d0dde9796656db2fee6979d6236d 100644 (file)
@@ -478,7 +478,7 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
                                                  max_oper_chwidth, he, edmg,
                                                  NULL, 0, 0, allow_6ghz,
                                                  retry_limit, go_bssid, NULL,
-                                                 NULL, NULL, 0)) {
+                                                 NULL, NULL, 0, false)) {
                        reply = wpas_dbus_error_unknown_error(
                                message,
                                "Failed to reinvoke a persistent group");
index 62567a0850e3941091111f84dbd83316dba1e760..300e118f33bde34f8297d97c9db508e44bdbea9e 100644 (file)
@@ -2080,7 +2080,7 @@ static void wpas_start_gc(struct wpa_supplicant *wpa_s,
                        wpa_s->p2p_pmksa_entry = entry;
                }
                ssid->pmk_valid = true;
-       } else if (res->akmp == WPA_KEY_MGMT_SAE && res->sae_password[0]) {
+       } else if ((res->akmp & WPA_KEY_MGMT_SAE) && res->sae_password[0]) {
                ssid->auth_alg = WPA_AUTH_ALG_SAE;
                ssid->sae_password = os_strdup(res->sae_password);
                if (!ssid->sae_password)
@@ -2092,7 +2092,10 @@ static void wpas_start_gc(struct wpa_supplicant *wpa_s,
                ssid->psk_set = 1;
        }
        ssid->proto = WPA_PROTO_RSN;
-       ssid->key_mgmt = WPA_KEY_MGMT_SAE;
+       if (wpa_s->p2p_mode == WPA_P2P_MODE_WFD_PCC)
+               ssid->key_mgmt = WPA_KEY_MGMT_SAE | WPA_KEY_MGMT_PSK;
+       else
+               ssid->key_mgmt = WPA_KEY_MGMT_SAE;
        ssid->pairwise_cipher = WPA_CIPHER_CCMP;
        ssid->group_cipher = WPA_CIPHER_CCMP;
        if (res->cipher)
@@ -3927,7 +3930,7 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
                                wpa_s->conf->p2p_go_edmg, NULL,
                                go ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0,
                                1, is_p2p_allow_6ghz(wpa_s->global->p2p), 0,
-                               bssid, sa, pmkid, pmk, pmk_len);
+                               bssid, sa, pmkid, pmk, pmk_len, false);
                } else if (bssid) {
                        wpa_s->user_initiated_pd = 0;
                        wpa_msg_global(wpa_s, MSG_INFO,
@@ -4232,7 +4235,7 @@ static void wpas_invitation_result(void *ctx, int status, const u8 *new_ssid,
                                      P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE :
                                      0, 1,
                                      is_p2p_allow_6ghz(wpa_s->global->p2p), 0,
-                                     bssid, peer, pmkid, pmk, pmk_len);
+                                     bssid, peer, pmkid, pmk, pmk_len, false);
 }
 
 
@@ -5301,7 +5304,7 @@ static void wpas_p2ps_prov_complete(void *ctx, enum p2p_status_code status,
                                        WPAS_MODE_P2P_GO ?
                                        P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE :
                                        0, 0, false, 0, NULL, NULL, NULL, NULL,
-                                       0);
+                                       0, false);
                        } else if (response_done) {
                                wpas_p2p_group_add(wpa_s, 1, freq,
                                                   0, 0, 0, 0, 0, 0, false,
@@ -5427,7 +5430,7 @@ static int wpas_prov_disc_resp_cb(void *ctx)
                        persistent_go->mode == WPAS_MODE_P2P_GO ?
                        P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0, 0,
                        is_p2p_allow_6ghz(wpa_s->global->p2p), 0, NULL, NULL,
-                       NULL, NULL, 0);
+                       NULL, NULL, 0, false);
        } else {
                wpas_p2p_group_add(wpa_s, 1, freq, 0, 0, 0, 0, 0, 0,
                                   is_p2p_allow_6ghz(wpa_s->global->p2p),
@@ -6697,7 +6700,10 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq,
                iface_addr = wpa_s->pending_join_iface_addr;
 
        if (wpa_s->pending_join_password[0]) {
-               res.akmp = WPA_KEY_MGMT_SAE;
+               if (wpa_s->p2p_mode == WPA_P2P_MODE_WFD_PCC)
+                       res.akmp = WPA_KEY_MGMT_SAE | WPA_KEY_MGMT_PSK;
+               else
+                       res.akmp = WPA_KEY_MGMT_SAE;
                os_strlcpy(res.sae_password, wpa_s->pending_join_password,
                           sizeof(res.sae_password));
                os_memset(wpa_s->pending_join_password, 0,
@@ -8232,7 +8238,7 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
                                  bool allow_6ghz, int retry_limit,
                                  const u8 *go_bssid, const u8 *dev_addr,
                                  const u8 *pmkid, const u8 *pmk,
-                                 size_t pmk_len)
+                                 size_t pmk_len, bool join)
 {
        struct p2p_go_neg_results params;
        int go = 0, freq;
@@ -8286,6 +8292,16 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
                }
        } else if (ssid->mode == WPAS_MODE_INFRA) {
                freq = neg_freq;
+
+               if (wpa_s->p2p2 && join) {
+                       if (ssid->passphrase)
+                               os_strlcpy(wpa_s->pending_join_password,
+                                          ssid->passphrase,
+                                          sizeof(wpa_s->pending_join_password));
+                       return wpas_p2p_join_start(wpa_s, 0, ssid->ssid,
+                                                  ssid->ssid_len);
+               }
+
                if (freq <= 0 || !freq_included(wpa_s, channels, freq)) {
                        struct os_reltime now;
                        struct wpa_bss *bss =
index 140a2f75dab3b2744b2235759d3cc00cff574114..0a25fa7fead26d41589168cf91014ea9144c66b9 100644 (file)
@@ -57,7 +57,7 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
                                  bool allow_6ghz, int retry_limit,
                                  const u8 *go_bssid, const u8 *dev_addr,
                                  const u8 *pmkid, const u8 *pmk,
-                                 size_t pmk_len);
+                                 size_t pmk_len, bool join);
 struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
                                       struct wpa_ssid *ssid);
 enum wpas_p2p_prov_disc_use {