feat(ble/bluedroid): add CS Security Requirements host support (Core 6.3)

This commit is contained in:
zhiweijian
2026-06-24 17:54:53 +08:00
parent 3844e24207
commit 919622c01c
17 changed files with 389 additions and 9 deletions
@@ -2523,3 +2523,39 @@ void btm_ble_cs_subevt_continue_result_evt(tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EV
}
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
/* Host does not validate conn_handle range or CS_Security_Requirements reserved bits; Controller checks. */
void BTM_BleGapCsSetSecurityRequirements(UINT16 conn_handle, UINT64 cs_security_requirements)
{
tBTM_STATUS status = BTM_SUCCESS;
tHCI_STATUS err = HCI_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((err = btsnd_hcic_ble_cs_set_security_requirements(conn_handle, cs_security_requirements)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("cs set security requirements, cmd err=0x%x", err);
status = BTM_HCI_ERROR | err;
}
cb_params.cs_set_security_requirements.status = status;
cb_params.cs_set_security_requirements.conn_handle = conn_handle;
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SET_SECURITY_REQUIREMENTS_CMPL_EVT, &cb_params);
}
/* Host does not validate CS_Security_Requirements reserved bits; Controller checks. */
void BTM_BleGapCsSetDefaultSecurityRequirements(UINT64 cs_security_requirements)
{
tBTM_STATUS status = BTM_SUCCESS;
tHCI_STATUS err = HCI_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((err = btsnd_hcic_ble_cs_set_default_security_requirements(cs_security_requirements)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("cs set default security requirements, cmd err=0x%x", err);
status = BTM_HCI_ERROR | err;
}
cb_params.cs_set_default_security_requirements.status = status;
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_CMPL_EVT, &cb_params);
}
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
@@ -3770,3 +3770,42 @@ UINT8 btsnd_hcic_ble_cs_procedure_enable(UINT16 conn_handle, UINT8 config_id, UI
return TRUE;
}
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
UINT8 btsnd_hcic_ble_cs_set_security_requirements(UINT16 conn_handle, UINT64 cs_security_requirements)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("cs set security requirements conn_handle %d", conn_handle);
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CS_SET_SECURITY_REQUIREMENTS_LEN);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_CS_SET_SECURITY_REQUIREMENTS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CS_SET_SECURITY_REQUIREMENTS_LEN);
UINT16_TO_STREAM(pp, conn_handle);
ARRAY_TO_STREAM(pp, (UINT8 *)&cs_security_requirements, 8);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_cs_set_default_security_requirements(UINT64 cs_security_requirements)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("cs set default security requirements");
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_LEN);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_LEN);
ARRAY_TO_STREAM(pp, (UINT8 *)&cs_security_requirements, 8);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
@@ -1000,7 +1000,11 @@ typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS st
#define BTM_BLE_5_GAP_UTP_SEND_COMPLETE_EVT 84
#define BTM_BLE_5_GAP_UTP_RECEIVE_EVT 85
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#define BTM_BLE_5_GAP_UNKNOWN_EVT 91
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#define BTM_BLE_GAP_CS_SET_SECURITY_REQUIREMENTS_CMPL_EVT 88
#define BTM_BLE_GAP_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_CMPL_EVT 89
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#define BTM_BLE_5_GAP_UNKNOWN_EVT 90
typedef UINT8 tBTM_BLE_5_GAP_EVENT;
#if (BLE_FEAT_ISO_EN == TRUE)
@@ -1543,6 +1547,16 @@ typedef struct {
UINT16 conn_handle;
} tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT;
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
typedef struct {
UINT8 status;
UINT16 conn_handle;
} tBTM_BLE_CS_SET_SECURITY_REQUIREMENTS_CMPL_EVT;
typedef struct {
UINT8 status;
} tBTM_BLE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_CMPL_EVT;
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
typedef struct {
UINT8 status;
@@ -2045,6 +2059,10 @@ typedef union {
#if (BLE_FEAT_LE_UTP == TRUE)
tBTM_BLE_UTP_RECEIVE utp_receive;
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
tBTM_BLE_CS_SET_SECURITY_REQUIREMENTS_CMPL_EVT cs_set_security_requirements;
tBTM_BLE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_CMPL_EVT cs_set_default_security_requirements;
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
} tBTM_BLE_5_GAP_CB_PARAMS;
typedef struct {
@@ -3371,5 +3389,9 @@ void BTM_BleGapCsSetProcPatams(UINT16 conn_handle, UINT8 config_id, UINT16 max_p
UINT8 SNR_control_initiator, UINT8 SNR_control_reflector);
void BTM_BleGapCsProcEnable(UINT16 conn_handle, UINT8 config_id, UINT8 enable);
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
void BTM_BleGapCsSetSecurityRequirements(UINT16 conn_handle, UINT64 cs_security_requirements);
void BTM_BleGapCsSetDefaultSecurityRequirements(UINT64 cs_security_requirements);
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#endif
@@ -493,6 +493,10 @@
#define HCI_BLE_CS_SET_PROCEDURE_ENABLE (0x0094 | HCI_GRP_BLE_CMDS)
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#define HCI_BLE_CS_SET_SECURITY_REQUIREMENTS (0x00A7 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS (0x00A8 | HCI_GRP_BLE_CMDS)
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
#define HCI_BLE_ENABLE_UTP_OTA_MODE (0x009F | HCI_GRP_BLE_CMDS)
@@ -1415,5 +1415,12 @@ UINT8 btsnd_hcic_ble_cs_set_procedure_params(UINT16 conn_handle, UINT8 config_id
UINT8 btsnd_hcic_ble_cs_procedure_enable(UINT16 conn_handle, UINT8 config_id, UINT8 enable);
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#if (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#define HCIC_PARAM_SIZE_CS_SET_SECURITY_REQUIREMENTS_LEN 10
#define HCIC_PARAM_SIZE_CS_SET_DEFAULT_SECURITY_REQUIREMENTS_LEN 8
UINT8 btsnd_hcic_ble_cs_set_security_requirements(UINT16 conn_handle, UINT64 cs_security_requirements);
UINT8 btsnd_hcic_ble_cs_set_default_security_requirements(UINT64 cs_security_requirements);
#endif // (BT_BLE_FEAT_CS_SECURITY_REQUIREMENTS == TRUE)
#endif