component/bt: Set the style to the same, output the macro in the function.

1.After the separate, can save 15k~25k ram & 240k~460k code size(depending on the menuconfig).
This commit is contained in:
Yulong 2017-04-24 23:46:37 -04:00
parent 2cfde4dfd9
commit 45999b69d6
21 changed files with 280 additions and 198 deletions

View File

@ -57,10 +57,12 @@ static void bta_dm_discover_next_device(void);
#if (SDP_INCLUDED == TRUE)
static void bta_dm_sdp_callback (UINT16 sdp_status);
#endif ///SDP_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator);
static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, BOOLEAN min_16_digit);
static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type);
static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result);
#endif ///SMP_INCLUDED == TRUE
static void bta_dm_local_name_cback(BD_ADDR bd_addr);
static BOOLEAN bta_dm_check_av(UINT16 event);
static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data);
@ -69,7 +71,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data);
static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
/* Extended Inquiry Response */
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE)
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
#endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */
@ -86,7 +88,9 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch);
#if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE)
static char *bta_dm_get_remname(void);
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result);
#endif ///SMP_INCLUDED == TRUE
#if (SDP_INCLUDED == TRUE)
static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport);
static void bta_dm_discover_device(BD_ADDR remote_bd_addr);
@ -97,8 +101,8 @@ static void bta_dm_disable_search_and_disc(void);
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
#if ((defined SMP_INCLUDED) && (SMP_INCLUDED == TRUE))
static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
#endif
static void bta_dm_ble_id_key_cback (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
#endif ///SMP_INCLUDED == TRUE
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
static void bta_dm_gattc_register(void);
static void btm_dm_start_gatt_discovery(BD_ADDR bd_addr);
@ -115,8 +119,9 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result);
#define BTA_DM_BLE_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37|BTM_BLE_ADV_CHNL_38|BTM_BLE_ADV_CHNL_39)
#endif
#endif
#if (SMP_INCLUDED == TRUE)
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
#endif ///SMP_INCLUDED == TRUE
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
static void bta_dm_observe_cmpl_cb(void *p_result);
static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
@ -203,6 +208,7 @@ const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl [BTA_MAX_SERVICE_ID] = {
};
/* bta security callback */
#if (SMP_INCLUDED == TRUE)
const tBTM_APPL_INFO bta_security = {
&bta_dm_authorize_cback,
&bta_dm_pin_cback,
@ -210,22 +216,22 @@ const tBTM_APPL_INFO bta_security = {
&bta_dm_authentication_complete_cback,
&bta_dm_bond_cancel_complete_cback,
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
&bta_dm_sp_cback
&bta_dm_sp_cback,
#else
NULL
#endif
#if BLE_INCLUDED == TRUE
#if SMP_INCLUDED == TRUE
, &bta_dm_ble_smp_cback
#endif
, &bta_dm_ble_id_key_cback
#endif
&bta_dm_ble_smp_cback,
&bta_dm_ble_id_key_cback,
#endif ///BLE_INCLUDED == TRUE
};
#endif ///SMP_INCLUDED == TRUE
#if (SDP_INCLUDED == TRUE)
#define MAX_DISC_RAW_DATA_BUF (1024)
UINT8 g_disc_raw_data_buf[MAX_DISC_RAW_DATA_BUF];
#endif ///SDP_INCLUDED == TRUE
extern DEV_CLASS local_device_default_class;
/*******************************************************************************
@ -331,7 +337,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
/* hw is ready, go on with BTA DM initialization */
memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb));
#if (BTM_SSR_INCLUDED == TRUE)
memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs));
#endif ///BTM_SSR_INCLUDED == TRUE
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class));
@ -351,8 +359,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
bta_dm_search_cb.conn_id = BTA_GATT_INVALID_CONN_ID;
#endif
#endif
#if (SMP_INCLUDED == TRUE)
BTM_SecRegister((tBTM_APPL_INFO *)&bta_security);
#endif ///SMP_INCLUDED == TRUE
BTM_SetDefaultLinkSuperTout(p_bta_dm_cfg->link_timeout);
BTM_WritePageTimeout(p_bta_dm_cfg->page_timeout);
bta_dm_cb.cur_policy = p_bta_dm_cfg->policy_settings;
@ -371,10 +380,10 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
BTM_ReadLocalDeviceNameFromController((tBTM_CMPL_CB *)bta_dm_local_name_cback);
bta_sys_rm_register((tBTA_SYS_CONN_CBACK *)bta_dm_rm_cback);
#if (BTM_SSR_INCLUDED == TRUE)
/* initialize bluetooth low power manager */
bta_dm_init_pm();
#endif ///BTM_SSR_INCLUDED == TRUE
bta_sys_policy_register((tBTA_SYS_CONN_CBACK *)bta_dm_policy_cback);
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE)
@ -411,8 +420,9 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
BTM_SetDiscoverability(BTM_NON_DISCOVERABLE, 0, 0);
BTM_SetConnectability(BTM_NON_CONNECTABLE, 0, 0);
#if (BTM_SSR_INCLUDED == TRUE)
bta_dm_disable_pm();
#endif ///BTM_SSR_INCLUDED == TRUE
bta_dm_disable_search_and_disc();
bta_dm_cb.disabling = TRUE;
@ -837,6 +847,7 @@ void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void bta_dm_bond (tBTA_DM_MSG *p_data)
{
tBTM_STATUS status;
@ -933,6 +944,7 @@ void bta_dm_pin_reply (tBTA_DM_MSG *p_data)
}
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -975,7 +987,9 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
if (policy & (HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)) {
/* if clearing sniff/park, wake the link */
#if (BTM_SSR_INCLUDED == TRUE)
bta_dm_pm_active(p_dev->peer_bdaddr);
#endif ///BTM_SSR_INCLUDED == TRUE
}
break;
@ -1008,6 +1022,7 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void bta_dm_confirm(tBTA_DM_MSG *p_data)
{
tBTM_STATUS res = BTM_NOT_AUTHORIZED;
@ -1017,6 +1032,7 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data)
}
BTM_ConfirmReqReply(res, p_data->confirm.bd_addr);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1027,7 +1043,7 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data)
** Returns void
**
*******************************************************************************/
#if (BTM_OOB_INCLUDED == TRUE)
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
void bta_dm_loc_oob(tBTA_DM_MSG *p_data)
{
UNUSED(p_data);
@ -1073,7 +1089,7 @@ void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data)
BTM_RemoteOobDataReply(res, p_data->ci_rmt_oob.bd_addr,
p_data->ci_rmt_oob.c, p_data->ci_rmt_oob.r );
}
#endif /* BTM_OOB_INCLUDED */
#endif /* BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE */
/*******************************************************************************
**
@ -1857,16 +1873,16 @@ static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle)
** Returns void
**
*******************************************************************************/
#if (SDP_INCLUDED == TRUE)
void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data)
{
#if (SDP_INCLUDED == TRUE)
UNUSED(p_data);
if (bta_dm_search_cb.p_sdp_db) {
GKI_freebuf(bta_dm_search_cb.p_sdp_db);
bta_dm_search_cb.p_sdp_db = NULL;
}
#endif ///SDP_INCLUDED == TRUE
}
#endif ///SDP_INCLUDED == TRUE
/*******************************************************************************
**
@ -2511,6 +2527,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator)
{
@ -2554,8 +2571,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
return BTM_NOT_AUTHORIZED;
}
}
@ -2568,7 +2584,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
** Returns void
**
*******************************************************************************/
static void bta_dm_pinname_cback (void *p_data)
static void bta_dm_pinname_cback (void *p_data)
{
tBTM_REMOTE_DEV_NAME *p_result = (tBTM_REMOTE_DEV_NAME *)p_data;
tBTA_DM_SEC sec_event;
@ -2901,6 +2917,9 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
}
#endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function bta_dm_local_name_cback
@ -3267,10 +3286,10 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
{
UNUSED(p_tle);
tBTA_SYS_HW_MSG *sys_enable_event;
#if (BTM_SSR_INCLUDED == TRUE)
/* disable the power managment module */
bta_dm_disable_pm();
#endif ///BTM_SSR_INCLUDED == TRUE
/* register our callback to SYS HW manager */
bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
@ -3333,7 +3352,9 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
}
/* AV calls bta_sys_conn_open with the A2DP stream count as app_id */
if (BTA_ID_AV == id) {
#if (BTM_SSR_INCLUDED == TRUE)
bta_dm_cb.cur_av_count = bta_dm_get_av_count();
#endif ///BTM_SSR_INCLUDED == TRUE
}
} else if ( status == BTA_SYS_CONN_IDLE) {
if (p_dev) {
@ -3342,7 +3363,9 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
/* get cur_av_count from connected services */
if (BTA_ID_AV == id) {
#if (BTM_SSR_INCLUDED == TRUE)
bta_dm_cb.cur_av_count = bta_dm_get_av_count();
#endif ///BTM_SSR_INCLUDED == TRUE
}
}
APPL_TRACE_WARNING("bta_dm_rm_cback:%d, status:%d", bta_dm_cb.cur_av_count, status);
@ -3383,6 +3406,7 @@ static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
{
UINT16 index = 0;
@ -3410,6 +3434,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
#endif
}
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
@ -3527,6 +3552,7 @@ static char *bta_dm_get_remname(void)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result)
{
@ -3542,6 +3568,7 @@ static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result)
bta_dm_cb.p_sec_cback(BTA_DM_BOND_CANCEL_CMPL_EVT, &sec_event);
}
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -4019,6 +4046,7 @@ void bta_dm_encrypt_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_
** Returns None
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void bta_dm_set_encryption (tBTA_DM_MSG *p_data)
{
UINT8 i ;
@ -4050,6 +4078,7 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data)
}
}
}
#endif ///SMP_INCLUDED == TRUE
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
@ -4249,7 +4278,6 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
}
return status;
}
#endif /* SMP_INCLUDED == TRUE */
/*******************************************************************************
**
@ -4386,6 +4414,7 @@ void bta_dm_security_grant (tBTA_DM_MSG *p_data)
{
BTM_SecurityGrant(p_data->ble_sec_grant.bd_addr, p_data->ble_sec_grant.res);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**

View File

@ -338,6 +338,7 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void BTA_DmBond(BD_ADDR bd_addr)
{
tBTA_DM_API_BOND *p_msg;
@ -429,7 +430,7 @@ void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin
}
#if (BTM_OOB_INCLUDED == TRUE)
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTA_DmLocalOob
@ -550,6 +551,7 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
return BTA_SUCCESS;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -685,10 +687,10 @@ void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK *p_callback, void *p_param)
** BTA_FAIL if operation failed.
**
*******************************************************************************/
#if BLE_INCLUDED == TRUE
#if SMP_INCLUDED == TRUE
void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_TYPE key_type)
{
#if BLE_INCLUDED == TRUE
tBTA_DM_API_ADD_BLEKEY *p_msg;
if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL) {
@ -702,7 +704,6 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
bta_sys_sendmsg(p_msg);
}
#endif
}
/*******************************************************************************
@ -722,7 +723,6 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
*******************************************************************************/
void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type)
{
#if BLE_INCLUDED == TRUE
tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL) {
@ -735,7 +735,6 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
bta_sys_sendmsg(p_msg);
}
#endif
}
/*******************************************************************************
**
@ -753,7 +752,6 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
*******************************************************************************/
void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
{
#if BLE_INCLUDED == TRUE
tBTA_DM_API_PASSKEY_REPLY *p_msg;
if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL) {
@ -768,7 +766,6 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
}
bta_sys_sendmsg(p_msg);
}
#endif
}
/*******************************************************************************
**
@ -784,7 +781,6 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
*******************************************************************************/
void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
{
#if BLE_INCLUDED == TRUE
tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
@ -793,7 +789,6 @@ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
p_msg->accept = accept;
bta_sys_sendmsg(p_msg);
}
#endif
}
/*******************************************************************************
@ -810,7 +805,6 @@ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
*******************************************************************************/
void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
{
#if BLE_INCLUDED == TRUE
tBTA_DM_API_BLE_SEC_GRANT *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL) {
@ -822,8 +816,9 @@ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
bta_sys_sendmsg(p_msg);
}
#endif
}
#endif ///SMP_INCLUDED == TRUE
#endif ///BLE_INCLUDED == TRUE
/*******************************************************************************
@ -2062,6 +2057,7 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback,
tBTA_DM_BLE_SEC_ACT sec_act)
{
@ -2081,6 +2077,7 @@ void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCR
bta_sys_sendmsg(p_msg);
}
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**

View File

@ -30,7 +30,7 @@
#include "bta_dm_ci.h"
#if (BTM_OOB_INCLUDED == TRUE)
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_dm_ci_io_req

View File

@ -57,22 +57,24 @@ enum {
BTA_DM_ACL_CHANGE_EVT,
BTA_DM_API_ADD_DEVICE_EVT,
BTA_DM_API_REMOVE_ACL_EVT,
#if (SMP_INCLUDED == TRUE)
/* security API events */
BTA_DM_API_BOND_EVT,
BTA_DM_API_BOND_CANCEL_EVT,
BTA_DM_API_PIN_REPLY_EVT,
#endif ///SMP_INCLUDED == TRUE
#if (BTM_SSR_INCLUDED == TRUE)
/* power manger events */
BTA_DM_PM_BTM_STATUS_EVT,
BTA_DM_PM_TIMER_EVT,
#endif ///BTM_SSR_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
/* simple pairing events */
BTA_DM_API_CONFIRM_EVT,
BTA_DM_API_SET_ENCRYPTION_EVT,
#if (BTM_OOB_INCLUDED == TRUE)
#endif ///SMP_INCLUDED == TRUE
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
BTA_DM_API_LOC_OOB_EVT,
BTA_DM_CI_IO_REQ_EVT,
BTA_DM_CI_RMT_OOB_EVT,
@ -80,11 +82,13 @@ enum {
#if BLE_INCLUDED == TRUE
#if SMP_INCLUDED == TRUE
BTA_DM_API_ADD_BLEKEY_EVT,
BTA_DM_API_ADD_BLEDEVICE_EVT,
BTA_DM_API_BLE_PASSKEY_REPLY_EVT,
BTA_DM_API_BLE_CONFIRM_REPLY_EVT,
BTA_DM_API_BLE_SEC_GRANT_EVT,
#endif ///SMP_INCLUDED == TRUE
BTA_DM_API_BLE_SET_BG_CONN_TYPE,
BTA_DM_API_BLE_CONN_PARAM_EVT,
BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
@ -874,8 +878,10 @@ typedef struct {
UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */
UINT8 wbt_scn; /* WIDCOMM Extensions SCN */
UINT8 num_master_only;
#if BTM_SSR_INCLUDED == TRUE
UINT8 pm_id;
tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
#endif ///BTM_SSR_INCLUDED == TRUE
UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */
UINT16 cur_policy; /* current default link policy */
UINT16 rs_event; /* the event waiting for role switch */

View File

@ -54,22 +54,23 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
#if (SMP_INCLUDED == TRUE)
/* security API events */
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
#endif ///SMP_INCLUDED == TRUE
#if (BTM_SSR_INCLUDED == TRUE)
/* power manger events */
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
#endif ///BTM_SSR_INCLUDED == TRUE
/* simple pairing events */
#if (SMP_INCLUDED == TRUE)
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
#if (BTM_OOB_INCLUDED == TRUE)
#endif ///SMP_INCLUDED == TRUE
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
@ -77,11 +78,13 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
#if BLE_INCLUDED == TRUE
#if SMP_INCLUDED == TRUE
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
bta_dm_security_grant,
#endif ///SMP_INCLUDED == TRUE
bta_dm_ble_set_bg_conn_type,
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
@ -153,7 +156,9 @@ enum {
BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */
#endif ///SDP_INCLUDED == TRUE
BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/
#if (SDP_INCLUDED == TRUE)
BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */
#endif ///SDP_INCLUDED == TRUE
BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */
BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */
BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */
@ -191,7 +196,9 @@ const tBTA_DM_ACTION bta_dm_search_action[] = {
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
#endif ///SDP_INCLUDED == TRUE
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
#if (SDP_INCLUDED == TRUE)
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
#endif ///SDP_INCLUDED == TRUE
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
@ -232,7 +239,9 @@ const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
#endif ///SDP_INCLUDED == TRUE
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
/* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
#if (SDP_INCLUDED == TRUE)
/* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
#endif ///SDP_INCLUDED == TRUE
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
#if (SDP_INCLUDED == TRUE)

View File

@ -32,6 +32,7 @@
#include "bta_dm_int.h"
#include "btm_api.h"
#if (BTM_SSR_INCLUDED == TRUE)
static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_mode,
@ -45,6 +46,7 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive);
static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable);
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
UINT8 timer_idx);
#endif///BTM_SSR_INCLUDED == TRUE
#if (BTM_SSR_INCLUDED == TRUE)
#if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE)
@ -53,7 +55,6 @@ static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
#define BTA_DM_PM_SSR_HH BTA_DM_PM_SSR1
#endif
static void bta_dm_pm_ssr(BD_ADDR peer_addr);
#endif
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
@ -1015,6 +1016,8 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data)
APPL_TRACE_EVENT("%s", __func__);
bta_dm_pm_set_mode(p_data->pm_timer.bd_addr, p_data->pm_timer.pm_request, BTA_DM_PM_EXECUTE);
}
#endif ///BTM_SSR_INCLUDED == TRUE
/*******************************************************************************
**
@ -1039,6 +1042,7 @@ tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
return p_dev;
}
#if (BTM_SSR_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_dm_is_sco_active
@ -1158,3 +1162,6 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void)
return cur_state;
}
#endif
#endif ///BTM_SSR_INCLUDED == TRUE

View File

@ -90,8 +90,10 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
uint2devclass((UINT32)cod, dev_class);
}
btc_config_get_int(name, "PinLength", &pin_length);
#if (SMP_INCLUDED == TRUE)
BTA_DmAddDevice(bd_addr.address, dev_class, link_key, 0, 0,
(UINT8)linkkey_type, 0, pin_length);
#endif ///SMP_INCLUDED == TRUE
}
bt_linkkey_file_found = TRUE;
} else {

View File

@ -568,6 +568,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
}
}
#if (SMP_INCLUDED == TRUE)
static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status)
{
UNUSED(bd_addr);
@ -575,7 +576,7 @@ static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transpor
LOG_DEBUG("enc_status = %x\n", enc_status);
return;
}
#endif ///SMP_INCLUDED == TRUE
static void btc_ble_start_scanning(uint8_t duration,
tBTA_DM_SEARCH_CBACK *results_cb,
@ -881,10 +882,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
btc_scan_rsp_data_raw_callback);
break;
case BTC_GAP_BLE_SET_ENCRYPTION_EVT: {
#if (SMP_INCLUDED == TRUE)
BD_ADDR bd_addr;
memcpy(bd_addr, arg->set_encryption.bd_addr, sizeof(BD_ADDR));
BTA_DmSetEncryption(bd_addr, BT_TRANSPORT_LE, btc_set_encryption_callback,
(tBTA_DM_BLE_SEC_ACT)arg->set_encryption.sec_act);
#endif ///SMP_INCLUDED == TRUE
break;
}

View File

@ -228,7 +228,7 @@
#endif
#ifndef BT_USE_TRACES
#define BT_USE_TRACES TRUE
#define BT_USE_TRACES FALSE
#endif
#ifndef BT_TRACE_BTIF
@ -563,7 +563,11 @@
/* The number of SCO links. */
#ifndef BTM_MAX_SCO_LINKS
#if (CLASSIC_BT_INCLUDED == TRUE)
#define BTM_MAX_SCO_LINKS 1 //3
#else ///CLASSIC_BT_INCLUDED == TRUE
#define BTM_MAX_SCO_LINKS 0
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif
/* The preferred type of SCO links (2-eSCO, 0-SCO). */
@ -686,7 +690,7 @@
/* TRUE to include Sniff Subrating */
#ifndef BTM_SSR_INCLUDED
#define BTM_SSR_INCLUDED TRUE
#define BTM_SSR_INCLUDED FALSE
#endif
/*************************

View File

@ -281,7 +281,9 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
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) */
#if (SMP_INCLUDED == TRUE)
btm_sec_set_peer_sec_caps(p, p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
#if (CLASSIC_BT_INCLUDED == TRUE)
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
if (req_pend) {
@ -926,10 +928,10 @@ 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) */
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);
if (req_pend) {
/* Request for remaining Security Features (if any) */
@ -1478,10 +1480,9 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role)
** Returns Allocated SCN number or 0 if none.
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 BTM_AllocateSCN(void)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 x;
BTM_TRACE_DEBUG ("BTM_AllocateSCN\n");
// stack reserves scn 1 for HFP, HSP we still do the correct way
@ -1491,9 +1492,9 @@ UINT8 BTM_AllocateSCN(void)
return (x + 1);
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
return (0); /* No free ports */
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -1504,10 +1505,9 @@ UINT8 BTM_AllocateSCN(void)
** Returns Returns TRUE if server channel was available
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
BOOLEAN BTM_TryAllocateSCN(UINT8 scn)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Make sure we don't exceed max port range.
* Stack reserves scn 1 for HFP, HSP we still do the correct way.
*/
@ -1520,11 +1520,11 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn)
btm_cb.btm_scn[scn - 1] = TRUE;
return TRUE;
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
return (FALSE); /* Port was busy */
}
/*******************************************************************************
**
** Function BTM_FreeSCN
@ -1536,8 +1536,6 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn)
*******************************************************************************/
BOOLEAN BTM_FreeSCN(UINT8 scn)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
BTM_TRACE_DEBUG ("BTM_FreeSCN \n");
if (scn <= BTM_MAX_SCN) {
btm_cb.btm_scn[scn - 1] = FALSE;
@ -1545,10 +1543,9 @@ BOOLEAN BTM_FreeSCN(UINT8 scn)
} else {
return (FALSE); /* Illegal SCN passed in */
}
#else
return (FALSE);
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -2345,9 +2342,9 @@ void btm_acl_reset_paging (void)
** Description send a paging command or queue it in btm_cb
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
void btm_acl_paging (BT_HDR *p, BD_ADDR bda)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_DEBUG ("btm_acl_paging discing:%d, paging:%d BDA: %06x%06x\n",
@ -2379,8 +2376,8 @@ void btm_acl_paging (BT_HDR *p, BD_ADDR bda)
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**

View File

@ -68,10 +68,10 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
** Returns TRUE if added OK, else FALSE
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE dev_type,
tBLE_ADDR_TYPE addr_type)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
UINT8 i = 0;
tBTM_INQ_INFO *p_info = NULL;
@ -133,9 +133,10 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d
BTM_TRACE_DEBUG ("InqDb device_type =0x%x addr_type=0x%x",
p_info->results.device_type, p_info->results.ble_addr_type);
}
#endif ///SMP_INCLUDED == TRUE
return (TRUE);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -152,9 +153,9 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d
** Returns TRUE if added OK, else FALSE
**
*******************************************************************************/
#if SMP_INCLUDED == TRUE
BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_KEY_TYPE key_type)
{
#if SMP_INCLUDED == TRUE
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_DEBUG ("BTM_SecAddBleKey");
p_dev_rec = btm_find_dev (bd_addr);
@ -181,10 +182,11 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_
}
#endif
#endif
return (TRUE);
}
#endif
/*******************************************************************************
**
@ -431,9 +433,9 @@ void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey)
** res - comparison result BTM_SUCCESS if success
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_PASSKEY_ENTRY_FAIL;
@ -445,8 +447,8 @@ void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res)
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
BTM_TRACE_DEBUG ("%s\n", __func__);
SMP_ConfirmReply(bd_addr, res_smp);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -837,9 +839,9 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_enc_cplt_cback)
{
#if (SMP_INCLUDED == TRUE)
tBTM_RAND_ENC params;
UINT8 *p_dest = params.param_buf;
@ -867,8 +869,8 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en
(*p_enc_cplt_cback)(&params); /* Call the Encryption complete callback function */
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
@ -879,9 +881,9 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en
** Returns None
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local )
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_DEBUG ("btm_ble_increment_sign_ctr is_local=%d", is_local);
@ -897,8 +899,8 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local )
p_dev_rec->ble.keys.local_counter,
p_dev_rec->ble.keys.counter);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -910,9 +912,9 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local )
** Returns p_key_type: output parameter to carry the key type value.
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_DEBUG ("btm_ble_get_enc_key_type");
@ -922,7 +924,6 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types)
return TRUE;
}
#endif ///SMP_INCLUDED == TRUE
return FALSE;
}
@ -936,7 +937,6 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types)
*******************************************************************************/
BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BOOLEAN status = FALSE;
BTM_TRACE_DEBUG ("btm_get_local_div");
@ -955,11 +955,9 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div)
}
BTM_TRACE_DEBUG ("btm_get_local_div status=%d (1-OK) DIV=0x%x", status, *p_div);
return status;
#else
return FALSE;
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
**
** Function btm_sec_save_le_key
@ -976,7 +974,6 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div)
void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY_VALUE *p_keys,
BOOLEAN pass_to_application)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_rec;
tBTM_LE_EVT_DATA cb_data;
UINT8 i;
@ -1104,7 +1101,6 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY
if (p_rec) {
BTM_TRACE_DEBUG ("sec_flags=0x%x", p_rec->sec_flags);
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -1118,7 +1114,6 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY
*******************************************************************************/
void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_rec;
BTM_TRACE_DEBUG("btm_ble_update_sec_key_size enc_key_size = %d", enc_key_size);
@ -1126,9 +1121,9 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size)
if ((p_rec = btm_find_dev (bd_addr)) != NULL ) {
p_rec->enc_key_size = enc_key_size;
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
**
** Function btm_ble_read_sec_key_size
@ -1140,7 +1135,6 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size)
*******************************************************************************/
UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_rec;
if ((p_rec = btm_find_dev (bd_addr)) != NULL ) {
@ -1148,9 +1142,7 @@ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr)
} else {
return 0;
}
#else
return 0;
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -1164,7 +1156,6 @@ UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr)
*******************************************************************************/
void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
UINT8 req_sec_level = BTM_LE_SEC_NONE, cur_sec_level = BTM_LE_SEC_NONE;
@ -1216,9 +1207,10 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE
req_sec_level,
*p_sec_req_act);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1300,9 +1292,9 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv)
{
#if (SMP_INCLUDED == TRUE)
tBTM_CB *p_cb = &btm_cb;
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
BT_OCTET8 dummy_stk = {0};
@ -1318,9 +1310,10 @@ void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv)
btm_ble_ltk_request_reply(p_dev_rec->bd_addr, FALSE, dummy_stk);
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1386,9 +1379,9 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
BOOLEAN enc_cback;
@ -1420,8 +1413,9 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable)
}
/* to notify GATT to send data if any request is pending */
gatt_notify_enc_cmpl(p_dev_rec->ble.pseudo_addr);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1433,9 +1427,9 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bda);
tBTM_CB *p_cb = &btm_cb;
@ -1458,7 +1452,6 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
btsnd_hcic_ble_ltk_req_neg_reply(btm_cb.enc_handle);
}
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -1473,7 +1466,6 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data)
{
UINT8 callback_rc = BTM_SUCCESS;
#if (SMP_INCLUDED == TRUE)
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req");
if (btm_cb.api.p_le_callback) {
/* the callback function implementation may change the IO capability... */
@ -1543,9 +1535,10 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:0x%02x\n",
p_data->io_cap, p_data->oob_data, p_data->auth_req);
}
#endif ///SMP_INCLUDED == TRUE
return callback_rc;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1557,19 +1550,20 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
UINT8 btm_ble_br_keys_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data)
{
UINT8 callback_rc = BTM_SUCCESS;
#if (SMP_INCLUDED)
BTM_TRACE_DEBUG ("%s\n", __func__);
if (btm_cb.api.p_le_callback) {
/* the callback function implementation may change the IO capability... */
callback_rc = (*btm_cb.api.p_le_callback) (BTM_LE_IO_REQ_EVT, p_dev_rec->bd_addr,
(tBTM_LE_EVT_DATA *)p_data);
}
#endif ///SMP_INCLUDED
return callback_rc;
}
#endif ///SMP_INCLUDED
#if (BLE_PRIVACY_SPT == TRUE )
/*******************************************************************************
@ -1803,9 +1797,9 @@ void btm_ble_create_ll_conn_complete (UINT8 status)
** Description This function is the SMP callback handler.
**
******************************************************************************/
#if (SMP_INCLUDED == TRUE)
UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
UINT8 res = 0;
@ -1911,9 +1905,10 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
} else {
BTM_TRACE_ERROR("btm_proc_smp_cback received for unknown device");
}
#endif ///SMP_INCLUDED == TRUE
return 0;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1931,10 +1926,10 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
** Returns TRUE if signing sucessul, otherwise FALSE.
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
BLE_SIGNATURE signature)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr);
BTM_TRACE_DEBUG ("%s", __func__);
@ -1971,7 +1966,6 @@ BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
GKI_freebuf(p_buf);
}
}
#endif ///SMP_INCLUDED == TRUE
return ret;
}
@ -1994,7 +1988,6 @@ BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, UINT16 len, UINT
UINT8 *p_comp)
{
BOOLEAN verified = FALSE;
#if SMP_INCLUDED == TRUE
tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr);
UINT8 p_mac[BTM_CMAC_TLEN_SIZE];
@ -2015,9 +2008,10 @@ BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, UINT16 len, UINT
}
}
}
#endif /* SMP_INCLUDED */
return verified;
}
#endif /* SMP_INCLUDED */
/*******************************************************************************
**
@ -2315,7 +2309,6 @@ static void btm_ble_process_dhk(tSMP_ENC *p)
memset(&btm_cb.devcb.id_keys, 0, sizeof(tBTM_BLE_LOCAL_ID_KEYS));
}
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -2330,7 +2323,6 @@ static void btm_ble_process_dhk(tSMP_ENC *p)
*******************************************************************************/
static void btm_ble_process_ir2(tBTM_RAND_ENC *p)
{
#if SMP_INCLUDED == TRUE
UINT8 btm_ble_dhk_pt = 0x03;
tSMP_ENC output;
@ -2350,7 +2342,6 @@ static void btm_ble_process_ir2(tBTM_RAND_ENC *p)
} else {
memset(&btm_cb.devcb.id_keys, 0, sizeof(tBTM_BLE_LOCAL_ID_KEYS));
}
#endif
}
/*******************************************************************************
@ -2397,6 +2388,7 @@ void btm_ble_reset_id( void )
BTM_TRACE_DEBUG("Generating IR failed.");
}
}
#endif ///SMP_INCLUDED == TRUE
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
/*******************************************************************************

View File

@ -61,25 +61,21 @@ static tBTM_SEC_SERV_REC *btm_sec_find_next_serv (tBTM_SEC_SERV_REC *p_cur);
static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm,
UINT32 mx_proto_id,
UINT32 mx_chan_id);
#endif ///SMP_INCLUDED == TRUE
static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_start_encryption (tBTM_SEC_DEV_REC *p_dev_rec);
#if (SMP_INCLUDED == TRUE)
static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle);
static void btm_restore_mode(void);
static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle);
static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state);
#endif ///SMP_INCLUDED == TRUE
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
static char *btm_pair_state_descr (tBTM_PAIRING_STATE state);
#endif
static void btm_sec_check_pending_reqs(void);
#if (SMP_INCLUDED == TRUE)
static void btm_sec_check_pending_reqs(void);
static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_orig,
UINT32 mx_proto_id, UINT32 mx_chan_id,
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
@ -88,8 +84,8 @@ static void btm_sec_bond_cancel_complete (void);
#if (SMP_INCLUDED == TRUE)
static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
BOOLEAN btm_sec_are_all_trusted(UINT32 p_mask[]);
#if (SMP_INCLUDED == TRUE)
static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle);
@ -107,11 +103,9 @@ static BOOLEAN btm_dev_authorized(tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *p_serv_rec);
static BOOLEAN btm_sec_is_serv_level0 (UINT16 psm);
static UINT16 btm_sec_set_serv_level4_flags (UINT16 cur_security, BOOLEAN is_originator);
#endif ///SMP_INCLUDED == TRUE
static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT transport,
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
#if (SMP_INCLUDED == TRUE)
static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport,
UINT8 encr_enable);
static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec);
@ -242,10 +236,8 @@ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info)
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
LOG_DEBUG("%s p_cb_info->p_le_callback == 0x%p\n", __func__, p_cb_info->p_le_callback);
if (p_cb_info->p_le_callback) {
#if SMP_INCLUDED == TRUE
BTM_TRACE_EVENT("%s SMP_Register( btm_proc_smp_cback )\n", __func__);
SMP_Register(btm_proc_smp_cback);
#endif
/* if no IR is loaded, need to regenerate all the keys */
if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) {
btm_ble_reset_id();
@ -290,9 +282,9 @@ BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (tBTM_LINK_KEY_CALLBACK *p_ca
** Returns TRUE if registered OK, else FALSE
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback)
{
#if (SMP_INCLUDED == TRUE)
int i;
for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
@ -301,9 +293,9 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback)
return (TRUE);
}
}
#endif ///SMP_INCLUDED == TRUE
return (FALSE);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
@ -316,9 +308,9 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback)
** Returns TRUE if OK, else FALSE
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback)
{
#if (SMP_INCLUDED == TRUE)
int i;
for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
@ -327,9 +319,9 @@ BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback)
return (TRUE);
}
}
#endif ///SMP_INCLUDED == TRUE
return (FALSE);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -729,9 +721,9 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_na
** Returns Number of records that were freed.
**
*******************************************************************************/
#if (SDP_INCLUDED == TRUE)
UINT8 BTM_SecClrService (UINT8 service_id)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0];
UINT8 num_freed = 0;
int i;
@ -750,10 +742,8 @@ UINT8 BTM_SecClrService (UINT8 service_id)
}
return (num_freed);
#else
return 0;
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SDP_INCLUDED == TRUE
/*******************************************************************************
**
@ -771,9 +761,9 @@ UINT8 BTM_SecClrService (UINT8 service_id)
** Returns Number of records that were freed.
**
*******************************************************************************/
#if (SDP_INCLUDED== TRUE)
UINT8 btm_sec_clr_service_by_psm (UINT16 psm)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0];
UINT8 num_freed = 0;
int i;
@ -789,10 +779,8 @@ UINT8 btm_sec_clr_service_by_psm (UINT16 psm)
BTM_TRACE_API("btm_sec_clr_service_by_psm psm:0x%x num_freed:%d\n", psm, num_freed);
return (num_freed);
#else
return 0;
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SDP_INCLUDED== TRUE
/*******************************************************************************
**
@ -838,9 +826,9 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda)
** trusted_mask - bitwise OR of trusted services (array of UINT32)
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_API ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d\n",
@ -941,8 +929,9 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
btm_cb.pin_code_len_saved = pin_len;
#endif
btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1168,14 +1157,13 @@ tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
**
** Note: After 2.1 parameters are not used and preserved here not to change API
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
{
tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
#if BLE_INCLUDED == TRUE
if (BTM_UseLeLink(bd_addr)) {
transport = BT_TRANSPORT_LE;
}
#endif
return btm_sec_bond_by_transport(bd_addr, transport, pin_len, p_pin, trusted_mask);
}
/*******************************************************************************
@ -1191,7 +1179,6 @@ tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 tr
*******************************************************************************/
tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_API ("BTM_SecBondCancel() State: %s flags:0x%x\n",
@ -1258,10 +1245,10 @@ tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr)
return BTM_NOT_AUTHORIZED;
}
}
#endif ///SMP_INCLUDED == TRUE
return BTM_WRONG_MODE;
}
/*******************************************************************************
**
** Function BTM_SecGetDeviceLinkKey
@ -1286,6 +1273,7 @@ tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr, LINK_KEY link_key)
}
return (BTM_UNKNOWN_ADDR);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1338,6 +1326,7 @@ tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType (BD_ADDR bd_addr)
** BTM_MODE_UNSUPPORTED - if security manager not linked in.
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CBACK *p_callback,
void *p_ref_data)
{
@ -1425,7 +1414,6 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
/*******************************************************************************
* disconnect the ACL link, if it's not done yet.
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle)
{
UINT8 old_state = p_dev_rec->sec_state;
@ -1539,10 +1527,9 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr)
** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
**
*******************************************************************************/
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE)
void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey)
{
#if (SMP_INCLUDED == TRUE)
BTM_TRACE_API ("BTM_PasskeyReqReply: State: %s res:%d\n",
btm_pair_state_descr(btm_cb.pairing_state), res);
@ -1586,9 +1573,8 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey)
btm_cb.acl_disc_reason = HCI_SUCCESS;
btsnd_hcic_user_passkey_reply (bd_addr, passkey);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif
#endif ///BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1604,19 +1590,17 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey)
** type - notification type
**
*******************************************************************************/
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE)
void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type)
{
#if (SMP_INCLUDED == TRUE)
/* This API only make sense between PASSKEY_REQ and SP complete */
if (btm_cb.pairing_state == BTM_PAIR_STATE_KEY_ENTRY) {
btsnd_hcic_send_keypress_notif (bd_addr, type);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif
#endif ///BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function BTM_IoCapRsp
@ -1634,7 +1618,6 @@ void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type)
*******************************************************************************/
void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req)
{
#if (SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("BTM_IoCapRsp: state: %s oob: %d io_cap: %d\n",
btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap);
@ -1653,7 +1636,6 @@ void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob, tBTM_A
btsnd_hcic_io_cap_req_reply (bd_addr, io_cap, oob, auth_req);
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -1689,7 +1671,6 @@ tBTM_STATUS BTM_ReadLocalOobData(void)
*******************************************************************************/
void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r)
{
#if (SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() - State: %s res: %d\n", __func__,
btm_pair_state_descr(btm_cb.pairing_state), res);
@ -1708,7 +1689,6 @@ void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_O
btm_cb.acl_disc_reason = HCI_SUCCESS;
btsnd_hcic_rem_oob_reply (bd_addr, c, r);
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -1908,7 +1888,7 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len)
return p_ret;
}
#endif
#endif ///BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1924,9 +1904,9 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_SEC_SERV_REC *p_serv_rec = &btm_cb.sec_serv_rec[0];
@ -1946,8 +1926,9 @@ void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id)
break;
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/************************************************************************
** I N T E R N A L F U N C T I O N S
@ -2766,9 +2747,9 @@ void btm_create_conn_cancel_complete (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_check_pending_reqs (void)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_QUEUE_ENTRY *p_e;
BUFFER_Q bq;
@ -2804,8 +2785,9 @@ void btm_sec_check_pending_reqs (void)
GKI_freebuf (p_e);
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -3229,9 +3211,9 @@ void btm_sec_rmt_host_support_feat_evt (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_io_capabilities_req (UINT8 *p)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SP_IO_REQ evt_data;
UINT8 err_code = 0;
tBTM_SEC_DEV_REC *p_dev_rec;
@ -3407,7 +3389,6 @@ void btm_io_capabilities_req (UINT8 *p)
btsnd_hcic_io_cap_req_reply(evt_data.bd_addr, evt_data.io_cap,
evt_data.oob_data, evt_data.auth_req);
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -3422,7 +3403,6 @@ void btm_io_capabilities_req (UINT8 *p)
*******************************************************************************/
void btm_io_capabilities_rsp (UINT8 *p)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_SP_IO_RSP evt_data;
@ -3473,7 +3453,6 @@ void btm_io_capabilities_rsp (UINT8 *p)
if (btm_cb.api.p_sp_callback) {
(*btm_cb.api.p_sp_callback) (BTM_SP_IO_RSP_EVT, (tBTM_SP_EVT_DATA *)&evt_data);
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -3487,10 +3466,9 @@ void btm_io_capabilities_rsp (UINT8 *p)
**
** Returns void
**
*******************************************************************************/
*******************************************************************************/
void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
{
#if (SMP_INCLUDED == TRUE)
tBTM_STATUS status = BTM_ERR_PROCESSING;
tBTM_SP_EVT_DATA evt_data;
UINT8 *p_bda = evt_data.cfm_req.bd_addr;
@ -3602,9 +3580,9 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
btsnd_hcic_user_passkey_neg_reply(p_bda);
}
#endif
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
**
** Function btm_keypress_notif_evt
@ -3643,7 +3621,6 @@ void btm_keypress_notif_evt (UINT8 *p)
*******************************************************************************/
void btm_simple_pair_complete (UINT8 *p)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SP_COMPLT evt_data;
tBTM_SEC_DEV_REC *p_dev_rec;
UINT8 status;
@ -3701,10 +3678,11 @@ void btm_simple_pair_complete (UINT8 *p)
btm_sec_send_hci_disconnect (p_dev_rec, HCI_ERR_AUTH_FAILURE, p_dev_rec->hci_handle);
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function btm_rem_oob_req
@ -3832,9 +3810,9 @@ static void btm_sec_auth_collision (UINT16 handle)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_auth_complete (UINT16 handle, UINT8 status)
{
#if (SMP_INCLUDED == TRUE)
UINT8 old_sm4;
tBTM_PAIRING_STATE old_state = btm_cb.pairing_state;
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
@ -4013,8 +3991,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
if (status != BTM_CMD_STARTED) {
btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -4026,9 +4005,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
tACL_CONN *p_acl = NULL;
@ -4165,8 +4144,8 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
if (status != BTM_CMD_STARTED) {
btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -5142,6 +5121,7 @@ void btm_sec_update_clock_offset (UINT16 handle, UINT16 clock_offset)
** BTM_NO_RESOURCES - permission declined
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec)
{
BTM_TRACE_EVENT ("btm_sec_execute_procedure: Required:0x%x Flags:0x%x State:%d\n",
@ -5271,7 +5251,6 @@ static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec)
return (BTM_SUCCESS);
}
/*******************************************************************************
**
** Function btm_sec_start_get_name
@ -5400,6 +5379,7 @@ static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec)
btm_sec_start_get_name (p_dev_rec);
return (BTM_CMD_STARTED);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -5657,9 +5637,9 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state)
** Description This function is called to change pairing state
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state)
{
#if (SMP_INCLUDED == TRUE)
tBTM_PAIRING_STATE old_state = btm_cb.pairing_state;
BTM_TRACE_EVENT ("%s() Old: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state));
@ -5692,8 +5672,8 @@ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state)
btu_start_timer (&btm_cb.pairing_tle, BTU_TTYPE_USER_FUNC, BTM_SEC_TIMEOUT_VALUE);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
@ -5754,8 +5734,9 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA
#endif
(*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res);
}
#if (SMP_INCLUDED == TRUE)
btm_sec_check_pending_reqs();
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -5836,7 +5817,6 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
return rv;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -5940,7 +5920,6 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec)
** Returns TRUE if the service is security mode 4 level 0 service
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static BOOLEAN btm_sec_is_serv_level0(UINT16 psm)
{
if (psm == BT_PSM_SDP) {

View File

@ -63,9 +63,13 @@ static void btu_hcif_extended_inquiry_result_evt (UINT8 *p);
static void btu_hcif_connection_comp_evt (UINT8 *p);
static void btu_hcif_connection_request_evt (UINT8 *p);
static void btu_hcif_disconnection_comp_evt (UINT8 *p);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_authentication_comp_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_encryption_change_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
static void btu_hcif_read_rmt_features_comp_evt (UINT8 *p);
static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p);
static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p);
@ -93,18 +97,20 @@ static void btu_hcif_esco_connection_chg_evt(UINT8 *p);
/* Simple Pairing Events */
static void btu_hcif_host_support_evt (UINT8 *p);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_io_cap_request_evt (UINT8 *p);
static void btu_hcif_io_cap_response_evt (UINT8 *p);
static void btu_hcif_user_conf_request_evt (UINT8 *p);
static void btu_hcif_user_passkey_request_evt (UINT8 *p);
static void btu_hcif_user_passkey_notif_evt (UINT8 *p);
static void btu_hcif_keypress_notif_evt (UINT8 *p);
#if BTM_OOB_INCLUDED == TRUE
#endif ///SMP_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_hcif_rem_oob_request_evt (UINT8 *p);
#endif
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_simple_pair_complete_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
static void btu_hcif_enhanced_flush_complete_evt (void);
#endif
@ -118,8 +124,10 @@ static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len);
static void btu_ble_process_adv_pkt (UINT8 *p);
static void btu_ble_read_remote_feat_evt (UINT8 *p);
static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len);
#if (SMP_INCLUDED == TRUE)
static void btu_ble_proc_ltk_req (UINT8 *p);
static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
static void btu_ble_data_length_change_evt (UINT8 *p, UINT16 evt_len);
#if (BLE_LLT_INCLUDED == TRUE)
static void btu_ble_rc_param_req_evt(UINT8 *p);
@ -173,17 +181,23 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
btu_hcif_disconnection_comp_evt (p);
break;
case HCI_AUTHENTICATION_COMP_EVT:
#if (SMP_INCLUDED == TRUE)
btu_hcif_authentication_comp_evt (p);
#endif ///SMP_INCLUDED == TRUE
break;
case HCI_RMT_NAME_REQUEST_COMP_EVT:
btu_hcif_rmt_name_request_comp_evt (p, hci_evt_len);
break;
case HCI_ENCRYPTION_CHANGE_EVT:
#if (SMP_INCLUDED == TRUE)
btu_hcif_encryption_change_evt (p);
#endif ///SMP_INCLUDED == TRUE
break;
#if BLE_INCLUDED == TRUE
case HCI_ENCRYPTION_KEY_REFRESH_COMP_EVT:
#if (SMP_INCLUDED == TRUE)
btu_hcif_encryption_key_refresh_cmpl_evt(p);
#endif ///SMP_INCLUDED == TRUE
break;
#endif
case HCI_READ_RMT_FEATURES_COMP_EVT:
@ -268,6 +282,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT:
btu_hcif_host_support_evt (p);
break;
#if (SMP_INCLUDED == TRUE)
case HCI_IO_CAPABILITY_REQUEST_EVT:
btu_hcif_io_cap_request_evt (p);
break;
@ -280,11 +295,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_USER_PASSKEY_REQUEST_EVT:
btu_hcif_user_passkey_request_evt (p);
break;
#if BTM_OOB_INCLUDED == TRUE
#endif ///SMP_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
case HCI_REMOTE_OOB_DATA_REQUEST_EVT:
btu_hcif_rem_oob_request_evt (p);
break;
#endif
#if (SMP_INCLUDED == TRUE)
case HCI_SIMPLE_PAIRING_COMPLETE_EVT:
btu_hcif_simple_pair_complete_evt (p);
break;
@ -294,6 +311,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_KEYPRESS_NOTIFY_EVT:
btu_hcif_keypress_notif_evt (p);
break;
#endif ///SMP_INCLUDED == TRUE
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
case HCI_ENHANCED_FLUSH_COMPLETE_EVT:
btu_hcif_enhanced_flush_complete_evt ();
@ -320,7 +338,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
btu_ble_read_remote_feat_evt(p);
break;
case HCI_BLE_LTK_REQ_EVT: /* received only at slave device */
#if (SMP_INCLUDED == TRUE)
btu_ble_proc_ltk_req(p);
#endif ///SMP_INCLUDED == TRUE
break;
//#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT:
@ -600,6 +620,7 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_authentication_comp_evt (UINT8 *p)
{
UINT8 status;
@ -610,7 +631,7 @@ static void btu_hcif_authentication_comp_evt (UINT8 *p)
btm_sec_auth_complete (handle, status);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -646,6 +667,7 @@ static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_encryption_change_evt (UINT8 *p)
{
UINT8 status;
@ -659,6 +681,7 @@ static void btu_hcif_encryption_change_evt (UINT8 *p)
btm_acl_encrypt_change (handle, status, encr_enable);
btm_sec_encrypt_change (handle, status, encr_enable);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -854,7 +877,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
break;
case HCI_READ_LOCAL_OOB_DATA:
#if BTM_OOB_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
btm_read_local_oob_complete(p);
#endif
break;
@ -880,7 +903,9 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
case HCI_BLE_RAND:
case HCI_BLE_ENCRYPT:
#if (SMP_INCLUDED == TRUE)
btm_ble_rand_enc_complete (p, opcode, (tBTM_RAND_ENC_CB *)p_cplt_cback);
#endif ///SMP_INCLUDED == TRUE
break;
case HCI_BLE_READ_ADV_CHNL_TX_POWER:
@ -1074,13 +1099,17 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
break;
case HCI_AUTHENTICATION_REQUESTED:
#if (SMP_INCLUDED == TRUE)
/* Device refused to start authentication. That should be treated as authentication failure. */
btm_sec_auth_complete (BTM_INVALID_HCI_HANDLE, status);
#endif ///SMP_INCLUDED == TRUE
break;
case HCI_SET_CONN_ENCRYPTION:
#if (SMP_INCLUDED == TRUE)
/* Device refused to start encryption. That should be treated as encryption failure. */
btm_sec_encrypt_change (BTM_INVALID_HCI_HANDLE, status, FALSE);
#endif ///SMP_INCLUDED == TRUE
break;
#if BLE_INCLUDED == TRUE
@ -1527,6 +1556,7 @@ static void btu_hcif_host_support_evt (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_io_cap_request_evt (UINT8 *p)
{
btm_io_capabilities_req(p);
@ -1562,7 +1592,6 @@ static void btu_hcif_user_conf_request_evt (UINT8 *p)
btm_proc_sp_req_evt(BTM_SP_CFM_REQ_EVT, p);
}
/*******************************************************************************
**
** Function btu_hcif_user_passkey_request_evt
@ -1604,6 +1633,8 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p)
{
btm_keypress_notif_evt(p);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1614,7 +1645,7 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if BTM_OOB_INCLUDED == TRUE
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_hcif_rem_oob_request_evt (UINT8 *p)
{
btm_rem_oob_req(p);
@ -1630,11 +1661,12 @@ static void btu_hcif_rem_oob_request_evt (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_simple_pair_complete_evt (UINT8 *p)
{
btm_simple_pair_complete(p);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function btu_hcif_enhanced_flush_complete_evt
@ -1659,6 +1691,7 @@ static void btu_hcif_enhanced_flush_complete_evt (void)
** BLE Events
***********************************************/
#if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p)
{
UINT8 status;
@ -1674,6 +1707,7 @@ static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p)
btm_sec_encrypt_change (handle, status, enc_enable);
}
#endif ///SMP_INCLUDED == TRUE
static void btu_ble_process_adv_pkt (UINT8 *p)
{
@ -1710,9 +1744,10 @@ static void btu_ble_read_remote_feat_evt (UINT8 *p)
btm_ble_read_remote_features_complete(p);
}
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_ble_proc_ltk_req (UINT8 *p)
{
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
UINT16 ediv, handle;
UINT8 *pp;
@ -1721,9 +1756,10 @@ static void btu_ble_proc_ltk_req (UINT8 *p)
STREAM_TO_UINT16(ediv, pp);
btm_ble_ltk_request(handle, p, ediv);
#endif
/* This is empty until an upper layer cares about returning event */
}
#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_ble_data_length_change_evt(UINT8 *p, UINT16 evt_len)
{

View File

@ -1165,9 +1165,10 @@ static void gap_release_ccb (tGAP_CCB *p_ccb)
return;
}
}
#if (SDP_INCLUDED == TRUE)
/* Free the security record for this PSM */
BTM_SecClrService(service_id);
#endif ///SDP_INCLUDED == TRUE
L2CA_DEREGISTER (psm);
}

View File

@ -41,6 +41,7 @@
** Returns TRUE if encrypted, otherwise FALSE.
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
{
tGATT_VALUE *p_attr = (tGATT_VALUE *)p_clcb->p_attr_buf;
@ -84,6 +85,7 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
return status;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -95,6 +97,7 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
** Returns
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf)
{
UINT16 cmd_len;
@ -125,6 +128,8 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf)
return;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function gatt_sec_check_complete
@ -146,7 +151,7 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb, UINT8 s
gatt_act_write(p_clcb, sec_act);
} else if (p_clcb->operation == GATTC_OPTYPE_READ) {
gatt_act_read(p_clcb, p_clcb->counter);
}
}
#endif ///GATTC_INCLUDED == TRUE
}
/*******************************************************************************
@ -299,8 +304,8 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb )
BOOLEAN is_link_encrypted = FALSE;
BOOLEAN is_link_key_known = FALSE;
BOOLEAN is_key_mitm = FALSE;
UINT8 key_type;
#if (SMP_INCLUDED == TRUE)
UINT8 key_type;
tBTM_BLE_SEC_REQ_ACT sec_act = BTM_LE_SEC_NONE;
#endif ///SMP_INCLUDED == TRUE
if (auth_req == GATT_AUTH_REQ_NONE ) {
@ -359,8 +364,9 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb )
/* this is a write command request
check data signing required or not */
if (!is_link_encrypted) {
#if (SMP_INCLUDED == TRUE)
btm_ble_get_enc_key_type(p_tcb->peer_bda, &key_type);
#endif ///SMP_INCLUDED == TRUE
if (
#if (SMP_INCLUDED == TRUE)
(key_type & BTM_LE_KEY_LCSRK) &&
@ -459,7 +465,9 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb)
tGATT_SEC_ACTION gatt_sec_act;
tBTM_BLE_SEC_ACT btm_ble_sec_act;
BOOLEAN status = TRUE;
#if (SMP_INCLUDED == TRUE)
tBTM_STATUS btm_status;
#endif ///SMP_INCLUDED == TRUE
tGATT_SEC_ACTION sec_act_old = gatt_get_sec_act(p_tcb);
gatt_sec_act = gatt_determine_sec_act(p_clcb);
@ -470,8 +478,10 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb)
switch (gatt_sec_act ) {
case GATT_SEC_SIGN_DATA:
#if (SMP_INCLUDED == TRUE)
GATT_TRACE_DEBUG("gatt_security_check_start: Do data signing");
gatt_sign_data(p_clcb);
#endif ///SMP_INCLUDED == TRUE
break;
case GATT_SEC_ENCRYPT:
case GATT_SEC_ENCRYPT_NO_MITM:
@ -479,11 +489,13 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb)
if (sec_act_old < GATT_SEC_ENCRYPT) {
GATT_TRACE_DEBUG("gatt_security_check_start: Encrypt now or key upgreade first");
gatt_convert_sec_action(gatt_sec_act, &btm_ble_sec_act);
#if (SMP_INCLUDED == TRUE)
btm_status = BTM_SetEncryption(p_tcb->peer_bda, p_tcb->transport , gatt_enc_cmpl_cback, &btm_ble_sec_act);
if ( (btm_status != BTM_SUCCESS) && (btm_status != BTM_CMD_STARTED)) {
GATT_TRACE_ERROR("gatt_security_check_start BTM_SetEncryption failed btm_status=%d", btm_status);
status = FALSE;
}
#endif ///SMP_INCLUDED == TRUE
}
if (status) {
gatt_add_pending_enc_channel_clcb (p_tcb, p_clcb);

View File

@ -930,7 +930,9 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
if (pseudo_op_code < GATT_OP_CODE_MAX) {
if (op_code == GATT_SIGN_CMD_WRITE) {
#if (SMP_INCLUDED == TRUE)
gatt_verify_signature(p_tcb, p_buf);
#endif ///SMP_INCLUDED == TRUE
} else {
/* message from client */
if ((op_code % 2) == 0) {

View File

@ -1380,8 +1380,9 @@ void gatt_sr_get_sec_info(BD_ADDR rem_bda, tBT_TRANSPORT transport, UINT8 *p_sec
BTM_GetSecurityFlagsByTransport(rem_bda, &sec_flag, transport);
sec_flag &= (GATT_SEC_FLAG_LKEY_UNAUTHED | GATT_SEC_FLAG_LKEY_AUTHED | GATT_SEC_FLAG_ENCRYPTED);
#if (SMP_INCLUDED == TRUE)
*p_key_size = btm_ble_read_sec_key_size(rem_bda);
#endif ///SMP_INCLUDED == TRUE
*p_sec_flag = sec_flag;
}
/*******************************************************************************

View File

@ -164,7 +164,9 @@ BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
#if !defined (BT_10A)
UINT8_TO_STREAM (pp, allow_switch);
#endif
#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
btm_acl_paging (p, dest);
#endif ///SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE
return (TRUE);
}
@ -489,8 +491,9 @@ BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, UINT8 page_scan_rep_mode,
UINT8_TO_STREAM (pp, page_scan_rep_mode);
UINT8_TO_STREAM (pp, page_scan_mode);
UINT16_TO_STREAM (pp, clock_offset);
#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
btm_acl_paging (p, bd_addr);
#endif ///SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE
return (TRUE);
}

View File

@ -2032,6 +2032,7 @@ tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
**
*******************************************************************************/
//extern
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 BTM_AllocateSCN(void);
// btla-specific ++
@ -2060,6 +2061,7 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
*******************************************************************************/
//extern
BOOLEAN BTM_FreeSCN(UINT8 scn);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************

View File

@ -847,8 +847,8 @@ typedef struct {
TIMER_LIST_ENT pairing_tle; /* Timer for pairing process */
UINT16 disc_handle; /* for legacy devices */
UINT8 disc_reason; /* for legacy devices */
#endif ///SMP_INCLUDED == TRUE
tBTM_SEC_SERV_REC sec_serv_rec[BTM_SEC_MAX_SERVICE_RECORDS];
#endif ///SMP_INCLUDED == TRUE
tBTM_SEC_DEV_REC sec_dev_rec[BTM_SEC_MAX_DEVICE_RECORDS];
tBTM_SEC_SERV_REC *p_out_serv;
tBTM_MKEY_CALLBACK *mkey_cback;

View File

@ -1594,11 +1594,11 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb)
if (!p_ccb->in_use) {
return;
}
#if (SDP_INCLUDED == TRUE)
if (p_rcb && (p_rcb->psm != p_rcb->real_psm)) {
btm_sec_clr_service_by_psm(p_rcb->psm);
}
#endif ///SMP_INCLUDED == TRUE
if (p_ccb->should_free_rcb) {
osi_free(p_rcb);
p_ccb->p_rcb = NULL;