Merge branch 'bugfix/remove_unused_sco_state_v5.0' into 'release/v5.0'

Bugfix/remove unused sco state (v5.0)

See merge request espressif/esp-idf!36733
This commit is contained in:
Jiang Jiang Jian 2025-02-12 14:00:57 +08:00
commit 30eba26e51
4 changed files with 6 additions and 55 deletions

View File

@ -335,7 +335,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
#if (CLASSIC_BT_INCLUDED == TRUE)
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
/* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */
#if (SMP_INCLUDED == TRUE)
btm_sec_set_peer_sec_caps(p, p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
@ -350,7 +350,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
return;
}
} else {
/* If remote features indicated secure connection (SC) mode, check the remote feautres again*/
/* If remote features indicated secure connection (SC) mode, check the remote features again*/
/* this is to prevent from BIAS attack where attacker can downgrade SC mode*/
btm_read_remote_features (p->hci_handle);
}
@ -474,7 +474,7 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport)
BTM_TRACE_DEBUG("Bonded\n");
}
} else {
BTM_TRACE_DEBUG("Bletooth link down\n");
BTM_TRACE_DEBUG("Bluetooth link down\n");
p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED
| BTM_SEC_ENCRYPTED | BTM_SEC_ROLE_SWITCHED);
}
@ -1016,7 +1016,7 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
#if (SMP_INCLUDED == TRUE)
/* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
/* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */
btm_sec_set_peer_sec_caps(p_acl_cb, p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
@ -1455,7 +1455,7 @@ void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset)
**
** Function btm_acl_role_changed
**
** Description This function is called whan a link's master/slave role change
** Description This function is called when a link's master/slave role change
** event or command status event (with error) is received.
** It updates the link control block, and calls
** the registered callback with status and role (if registered).
@ -2705,7 +2705,7 @@ void btm_acl_connected(BD_ADDR bda, UINT16 handle, UINT8 link_type, UINT8 enc_mo
l2c_link_hci_conn_comp(status, handle, bda);
}
#if BTM_SCO_INCLUDED == TRUE
else {
else if (link_type == HCI_LINK_TYPE_SCO) {
memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA));
esco_data.link_type = HCI_LINK_TYPE_SCO;
memcpy (esco_data.bd_addr, bda, BD_ADDR_LEN);

View File

@ -117,8 +117,6 @@ void btm_sco_init (void)
}
#endif
/* Initialize nonzero defaults */
btm_cb.sco_cb.sco_disc_reason = BTM_INVALID_SCO_DISC_REASON;
btm_cb.sco_cb.def_esco_parms = btm_esco_defaults; /* Initialize with defaults */
btm_cb.sco_cb.desired_sco_mode = BTM_DEFAULT_SCO_MODE;
}
@ -1048,7 +1046,6 @@ void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle,
tBTM_CHG_ESCO_PARAMS parms;
#endif
btm_cb.sco_cb.sco_disc_reason = hci_status;
BTM_TRACE_API("%s, handle %x", __FUNCTION__, hci_handle);
#if (BTM_MAX_SCO_LINKS>0)
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) {
@ -1224,16 +1221,11 @@ void btm_sco_removed (UINT16 hci_handle, UINT8 reason)
#if (BTM_MAX_SCO_LINKS>0)
tSCO_CONN *p = &btm_cb.sco_cb.sco_db[0];
UINT16 xx;
#endif
btm_cb.sco_cb.sco_disc_reason = reason;
#if (BTM_MAX_SCO_LINKS>0)
p = &btm_cb.sco_cb.sco_db[0];
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) {
if ((p->state != SCO_ST_UNUSED) && (p->state != SCO_ST_LISTENING) && (p->hci_handle == hci_handle)) {
btm_sco_flush_sco_data(xx);
p->state = SCO_ST_UNUSED;
#if BTM_SCO_HCI_INCLUDED == TRUE
btm_cb.sco_cb.xmit_window_size += p->sent_not_acked;
@ -1375,24 +1367,6 @@ UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx)
#endif
}
/*******************************************************************************
**
** Function BTM_ReadScoDiscReason
**
** Description This function is returns the reason why an (e)SCO connection
** has been removed. It contains the value until read, or until
** another (e)SCO connection has disconnected.
**
** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
**
*******************************************************************************/
UINT16 BTM_ReadScoDiscReason (void)
{
UINT16 res = btm_cb.sco_cb.sco_disc_reason;
btm_cb.sco_cb.sco_disc_reason = BTM_INVALID_SCO_DISC_REASON;
return (res);
}
/*******************************************************************************
**
** Function BTM_ReadDeviceScoPacketTypes
@ -1894,10 +1868,6 @@ UINT8 *BTM_ReadScoBdAddr(UINT16 sco_inx)
{
return ((UINT8 *) NULL);
}
UINT16 BTM_ReadScoDiscReason (void)
{
return (BTM_INVALID_SCO_DISC_REASON);
}
tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, tBTM_ESCO_PARAMS *p_parms)
{
return (BTM_MODE_UNSUPPORTED);

View File

@ -464,7 +464,6 @@ typedef struct {
tSCO_CONN sco_db[BTM_MAX_SCO_LINKS];
tBTM_ESCO_PARAMS def_esco_parms;
BD_ADDR xfer_addr;
UINT16 sco_disc_reason;
BOOLEAN esco_supported; /* TRUE if 1.2 cntlr AND supports eSCO links */
tBTM_SCO_TYPE desired_sco_mode;
tBTM_SCO_TYPE xfer_sco_type;

View File

@ -980,9 +980,6 @@ typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
#define BTM_INVALID_SCO_INDEX 0xFFFF
#define BTM_INVALID_HCI_HANDLE 0xFFFF
/* Define an invalid SCO disconnect reason */
#define BTM_INVALID_SCO_DISC_REASON 0xFFFF
/* Define first active SCO index */
#define BTM_FIRST_ACTIVE_SCO_INDEX BTM_MAX_SCO_LINKS
@ -3161,21 +3158,6 @@ UINT16 BTM_ReadScoHandle (UINT16 sco_inx);
UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx);
/*******************************************************************************
**
** Function BTM_ReadScoDiscReason
**
** Description This function is returns the reason why an (e)SCO connection
** has been removed. It contains the value until read, or until
** another (e)SCO connection has disconnected.
**
** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
**
*******************************************************************************/
//extern
UINT16 BTM_ReadScoDiscReason (void);
/*******************************************************************************
**
** Function BTM_SetEScoMode