From: Shivani Baranwal Date: Wed, 3 Jul 2024 16:41:26 +0000 (+0530) Subject: P2P2: Remember password from connect command to starting after scan X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5edc8a6feb412c7c975d6dced394458129f3641;p=thirdparty%2Fhostap.git P2P2: Remember password from connect command to starting after scan The password for pairing setup needs to be kept in memory so that it can be used once a scan for the GO has completed. Signed-off-by: Shivani Baranwal --- diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index b60588dbe..f746c338b 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -5950,7 +5950,8 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s, NULL, 0, is_p2p_allow_6ghz(wpa_s->global->p2p), wpa_s->p2p2, wpa_s->p2p_bootstrap, - NULL); + wpa_s->pending_join_password[0] ? + wpa_s->pending_join_password : NULL); return; } @@ -6279,6 +6280,13 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq, os_memcpy(res.peer_device_addr, wpa_s->pending_join_dev_addr, ETH_ALEN); os_memcpy(res.peer_interface_addr, wpa_s->pending_join_iface_addr, ETH_ALEN); + if (wpa_s->pending_join_password[0]) { + 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, + sizeof(wpa_s->pending_join_password)); + } res.wps_method = wpa_s->pending_join_wps_method; res.p2p2 = wpa_s->p2p2; res.cipher = WPA_CIPHER_CCMP; @@ -6602,6 +6610,10 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr, } else wpa_s->p2p_pin[0] = '\0'; + if (!password) + os_memset(wpa_s->pending_join_password, 0, + sizeof(wpa_s->pending_join_password)); + if (join || auto_join) { u8 iface_addr[ETH_ALEN], dev_addr[ETH_ALEN]; if (auth) { @@ -6670,6 +6682,9 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr, wpa_s->p2p_auto_started.usec); } wpa_s->user_initiated_pd = 1; + if (password) + os_strlcpy(wpa_s->pending_join_password, password, + sizeof(wpa_s->pending_join_password)); if (wpas_p2p_join(wpa_s, iface_addr, dev_addr, wps_method, auto_join, freq, group_ssid, group_ssid_len) < 0) diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 1f41c149e..f497644b7 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1115,6 +1115,7 @@ struct wpa_supplicant { u8 pending_join_dev_addr[ETH_ALEN]; u8 p2p_bootstrap_dev_addr[ETH_ALEN]; int pending_join_wps_method; + char pending_join_password[100]; u8 p2p_join_ssid[SSID_MAX_LEN]; size_t p2p_join_ssid_len; int p2p_join_scan_count;