bluetooth: ssp: support pairing_accept for ssp

when receiving the io cap request from controller, call
pairing_accept to check whether application accept the
pairing. If no, reply BT_HCI_OP_IO_CAPABILITY_NEG_REPLY.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
This commit is contained in:
Mark Wang 2024-11-25 15:57:02 +08:00 committed by Benjamin Cabé
commit fb811f1599
2 changed files with 15 additions and 1 deletions

View file

@ -2195,7 +2195,8 @@ struct bt_conn_auth_cb {
* This callback may be unregistered in which case pairing continues
* as if the Kconfig flag was not set.
*
* This callback is not called for BR/EDR Secure Simple Pairing (SSP).
* For BR/EDR Secure Simple Pairing (SSP), this callback is called
* when receiving the BT_HCI_EVT_IO_CAPA_REQ hci event.
*
* @param conn Connection where pairing is initiated.
* @param feat Pairing req/resp info.

View file

@ -650,6 +650,19 @@ void bt_hci_io_capa_req(struct net_buf *buf)
return;
}
#if defined(CONFIG_BT_SMP_APP_PAIRING_ACCEPT)
if (bt_auth && bt_auth->pairing_accept) {
enum bt_security_err err;
err = bt_auth->pairing_accept(conn, NULL);
if (err != BT_SECURITY_ERR_SUCCESS) {
io_capa_neg_reply(&evt->bdaddr,
BT_HCI_ERR_PAIRING_NOT_ALLOWED);
return;
}
}
#endif
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY,
sizeof(*cp));
if (!resp_buf) {