]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Include the requested method in the bootstrap response notification
authorVinay Gannevaram <quic_vganneva@quicinc.com>
Wed, 16 Apr 2025 19:45:17 +0000 (01:15 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 27 May 2025 20:45:05 +0000 (23:45 +0300)
In the bootstrap response indication, send the requested bootstrap
method by the device to align with config method indicated in P2P-R1
provision discovery indication to the applications.

Signed-off-by: Vinay Gannevaram <quic_vganneva@quicinc.com>
src/p2p/p2p_pd.c

index f08fa0e10909d15801f4db4db9b6da8a0d01aa6d..b0f893e7f5ee8511587412efdbbaf3c4b3caa290 100644 (file)
@@ -1713,7 +1713,8 @@ static void p2p_process_prov_disc_bootstrap_resp(struct p2p_data *p2p,
 
                if (p2p->cfg->bootstrap_rsp_rx)
                        p2p->cfg->bootstrap_rsp_rx(p2p->cfg->cb_ctx, sa, status,
-                                                  rx_freq, bootstrap);
+                                                  rx_freq,
+                                                  dev->req_bootstrap_method);
                return;
        }
 
@@ -1721,13 +1722,35 @@ static void p2p_process_prov_disc_bootstrap_resp(struct p2p_data *p2p,
        if (msg->pbma_info_len >= 2)
                bootstrap = WPA_GET_LE16(msg->pbma_info);
 
+       /* Overwrite the status if bootstrap method does not match */
+       if (status == P2P_SC_SUCCESS &&
+           !(bootstrap == P2P_PBMA_PIN_CODE_DISPLAY &&
+             dev->req_bootstrap_method == P2P_PBMA_PIN_CODE_KEYPAD) &&
+           !(bootstrap == P2P_PBMA_PIN_CODE_KEYPAD &&
+             dev->req_bootstrap_method == P2P_PBMA_PIN_CODE_DISPLAY) &&
+           !(bootstrap == P2P_PBMA_PASSPHRASE_DISPLAY &&
+             dev->req_bootstrap_method == P2P_PBMA_PASSPHRASE_KEYPAD) &&
+           !(bootstrap == P2P_PBMA_PASSPHRASE_KEYPAD &&
+             dev->req_bootstrap_method == P2P_PBMA_PASSPHRASE_DISPLAY) &&
+           !(bootstrap == P2P_PBMA_NFC_TAG &&
+             dev->req_bootstrap_method == P2P_PBMA_NFC_READER) &&
+           !(bootstrap == P2P_PBMA_NFC_READER &&
+             dev->req_bootstrap_method == P2P_PBMA_NFC_TAG) &&
+           !(bootstrap == P2P_PBMA_QR_DISPLAY &&
+             dev->req_bootstrap_method == P2P_PBMA_QR_SCAN) &&
+           !(bootstrap == P2P_PBMA_QR_SCAN &&
+             dev->req_bootstrap_method == P2P_PBMA_QR_DISPLAY) &&
+           !(bootstrap == P2P_PBMA_OPPORTUNISTIC &&
+             dev->req_bootstrap_method == P2P_PBMA_OPPORTUNISTIC))
+               status = P2P_SC_FAIL_INVALID_PARAMS;
+
        p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
        if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG)
                dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
 
        if (p2p->cfg->bootstrap_rsp_rx)
                p2p->cfg->bootstrap_rsp_rx(p2p->cfg->cb_ctx, sa, status,
-                                          rx_freq, bootstrap);
+                                          rx_freq, dev->req_bootstrap_method);
 }