component/bt:separate the SMP, GATT module set the macro output the function.

1. close classic bt, can save 233k code size;
2. close smp module, can save 136k code size;
3. close gattc module, can save 24k code size;
4. close gatts module, can save 16k code size;
4. close the bluedroid stack log, can save 120k code size.
This commit is contained in:
Yulong 2017-04-25 04:55:29 -04:00
parent 45999b69d6
commit 5544f98add
15 changed files with 169 additions and 117 deletions

View file

@ -218,7 +218,7 @@ const tBTM_APPL_INFO bta_security = {
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
&bta_dm_sp_cback,
#else
NULL
NULL,
#endif
#if BLE_INCLUDED == TRUE
&bta_dm_ble_smp_cback,

View file

@ -1139,8 +1139,9 @@ static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisa
BTM_SetLinkPolicy(p_dev->peer_bdaddr, &policy_setting);
}
#endif ///BTM_SSR_INCLUDED == TRUE
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_dm_pm_obtain_controller_state
@ -1163,5 +1164,3 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void)
}
#endif
#endif ///BTM_SSR_INCLUDED == TRUE

View file

@ -934,8 +934,10 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
#endif ///SMP_INCLUDED == TRUE
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
if (req_pend) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Request for remaining Security Features (if any) */
l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
}

View file

@ -2130,7 +2130,9 @@ void btm_ble_read_remote_name_cmpl(BOOLEAN status, BD_ADDR bda, UINT16 length, c
}
btm_process_remote_name(bda, bd_name, length + 1, hci_status);
#if (SMP_INCLUDED == TRUE)
btm_sec_rmt_name_request_complete (bda, (UINT8 *)p_name, hci_status);
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************

View file

@ -2353,8 +2353,9 @@ void btm_inq_rmt_name_failed (void)
} else {
btm_process_remote_name (NULL, NULL, 0, HCI_ERR_UNSPECIFIED);
}
#if (SMP_INCLUDED == TRUE)
btm_sec_rmt_name_request_complete (NULL, NULL, HCI_ERR_UNSPECIFIED);
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
**

View file

@ -59,7 +59,9 @@ void btm_init (void)
/* Initialize BTM component structures */
btm_inq_db_init(); /* Inquiry Database and Structures */
btm_acl_init(); /* ACL Database and Structures */
#if (SMP_INCLUDED == TRUE)
btm_sec_init(BTM_SEC_MODE_SP); /* Security Manager Database and Structures */
#endif ///SMP_INCLUDED == TRUE
#if BTM_SCO_INCLUDED == TRUE
btm_sco_init(); /* SCO Database and Structures (If included) */
#endif

View file

@ -79,9 +79,7 @@ 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);
#endif ///SMP_INCLUDED == TRUE
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);
static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec);
@ -830,10 +828,10 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda)
void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
{
tBTM_SEC_DEV_REC *p_dev_rec;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_API ("BTM_PINCodeReply(): PairState: %s PairFlags: 0x%02x PinLen:%d Result:%d\n",
btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, pin_len, res);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
/* If timeout already expired or has been canceled, ignore the reply */
if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN) {
BTM_TRACE_WARNING ("BTM_PINCodeReply() - Wrong State: %d\n", btm_cb.pairing_state);
@ -946,10 +944,10 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
**
** Note: After 2.1 parameters are not used and preserved here not to change API
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_STATUS status;
UINT8 *p_features;
@ -963,7 +961,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
/* Other security process is in progress */
if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) {
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_ERROR ("BTM_SecBond: already busy in state: %s\n", btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
return (BTM_WRONG_MODE);
}
@ -1091,8 +1091,10 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
/* We are accepting connection request from peer */
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ);
}
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_DEBUG ("State:%s sm4: 0x%x sec_state:%d\n",
btm_pair_state_descr (btm_cb.pairing_state), p_dev_rec->sm4, p_dev_rec->sec_state);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
return BTM_CMD_STARTED;
}
@ -1104,9 +1106,6 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
}
return status;
#else
return BTM_MODE_UNSUPPORTED;
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -1128,7 +1127,6 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[])
{
#if SMP_INCLUDED == TRUE
tBT_DEVICE_TYPE dev_type;
tBLE_ADDR_TYPE addr_type;
@ -1138,9 +1136,9 @@ tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
(transport == BT_TRANSPORT_BR_EDR && (dev_type & BT_DEVICE_TYPE_BREDR) == 0)) {
return BTM_ILLEGAL_ACTION;
}
#endif
return btm_sec_bond_by_transport(bd_addr, transport, pin_len, p_pin, trusted_mask);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1180,10 +1178,10 @@ tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 tr
tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr)
{
tBTM_SEC_DEV_REC *p_dev_rec;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_API ("BTM_SecBondCancel() State: %s flags:0x%x\n",
btm_pair_state_descr (btm_cb.pairing_state), btm_cb.pairing_flags);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
if (((p_dev_rec = btm_find_dev (bd_addr)) == NULL)
|| (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) {
return BTM_UNKNOWN_ADDR;
@ -1479,14 +1477,14 @@ static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UIN
** bd_addr - Address of the peer device
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("BTM_ConfirmReqReply() State: %s Res: %u",
btm_pair_state_descr(btm_cb.pairing_state), res);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
/* If timeout already expired or has been canceled, ignore the reply */
if ( (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_NUMERIC_CONFIRM)
|| (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) {
@ -1511,8 +1509,8 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr)
btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY;
btsnd_hcic_user_conf_reply (bd_addr, FALSE);
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1530,9 +1528,10 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr)
#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 (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_API ("BTM_PasskeyReqReply: State: %s res:%d\n",
btm_pair_state_descr(btm_cb.pairing_state), res);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
if ( (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE)
|| (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) {
return;
@ -1618,9 +1617,10 @@ 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 (BT_USE_TRACES == TRUE && 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);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
if ( (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS)
|| (memcmp (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0) ) {
return;
@ -1671,9 +1671,10 @@ tBTM_STATUS BTM_ReadLocalOobData(void)
*******************************************************************************/
void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r)
{
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() - State: %s res: %d\n", __func__,
btm_pair_state_descr(btm_cb.pairing_state), res);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
/* If timeout already expired or has been canceled, ignore the reply */
if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP) {
return;
@ -2183,8 +2184,10 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
/* there are some devices (moto KRZR) which connects to several services at the same time */
/* we will process one after another */
if ( (p_dev_rec->p_callback) || (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) ) {
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() - busy - PSM:%d delayed state: %s mode:%d, sm4:0x%x\n", __func__,
psm, btm_pair_state_descr(btm_cb.pairing_state), btm_cb.security_mode, p_dev_rec->sm4);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
BTM_TRACE_EVENT ("security_flags:x%x, sec_flags:x%x\n", security_required, p_dev_rec->sec_flags);
rc = BTM_CMD_STARTED;
if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED ||
@ -2446,9 +2449,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
/* there are some devices (moto phone) which connects to several services at the same time */
/* we will process one after another */
if ( (p_dev_rec->p_callback) || (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) ) {
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() service PSM:%d Proto:%d SCN:%d delayed state: %s\n", __func__,
psm, mx_proto_id, mx_chan_id, btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
rc = BTM_CMD_STARTED;
if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED ||
@ -2514,9 +2518,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
(*p_callback) (bd_addr, transport, p_ref_data, (UINT8)rc);
}
}
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT("%s: return with rc = 0x%02x in delayed state %s\n", __FUNCTION__, rc,
btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
return rc;
}
@ -2599,9 +2604,9 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
BTM_TRACE_ERROR ("%s\n", __func__);
/* Some device may request a connection before we are done with the HCI_Reset sequence */
@ -2658,8 +2663,8 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
p_dev_rec->sm4 |= BTM_SM4_CONN_PEND;
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -2671,9 +2676,9 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btm_sec_bond_cancel_complete (void)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) ||
@ -2697,8 +2702,9 @@ static void btm_sec_bond_cancel_complete (void)
btm_cb.api.p_bond_cancel_cmpl_callback(BTM_SUCCESS);
}
}
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -2724,7 +2730,9 @@ void btm_create_conn_cancel_complete (UINT8 *p)
*/
switch (status) {
case HCI_SUCCESS:
#if (SMP_INCLUDED == TRUE)
btm_sec_bond_cancel_complete();
#endif ///SMP_INCLUDED == TRUE
break;
case HCI_ERR_CONNECTION_EXISTS:
case HCI_ERR_NO_CONNECTION:
@ -2757,7 +2765,9 @@ void btm_sec_check_pending_reqs (void)
/* First, resubmit L2CAP requests */
if (btm_cb.sec_req_pending) {
btm_cb.sec_req_pending = FALSE;
#if (CLASSIC_BT_INCLUDED == TRUE)
l2cu_resubmit_pending_sec_req (NULL);
#endif ///SMP_INCLUDED == TRUE
}
/* Now, re-submit anything in the mux queue */
@ -2798,14 +2808,14 @@ void btm_sec_check_pending_reqs (void)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_init (UINT8 sec_mode)
{
#if (SMP_INCLUDED == TRUE)
btm_cb.security_mode = sec_mode;
memset (btm_cb.pairing_bda, 0xff, BD_ADDR_LEN);
btm_cb.max_collision_delay = BTM_SEC_MAX_COLLISION_DELAY;
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -2817,13 +2827,16 @@ void btm_sec_init (UINT8 sec_mode)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_device_down (void)
{
#if (SMP_INCLUDED == TRUE)
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() State: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -2939,9 +2952,9 @@ static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT8 status)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
int i;
DEV_CLASS dev_class;
@ -2976,7 +2989,7 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
/* Commenting out trace due to obf/compilation problems.
*/
#if (BT_USE_TRACES == TRUE)
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
if (!p_bd_name) {
p_bd_name = (UINT8 *)"";
}
@ -3166,8 +3179,9 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
/* There is no next procedure or start of procedure failed, notify the waiting layer */
btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -3228,9 +3242,9 @@ void btm_io_capabilities_req (UINT8 *p)
evt_data.io_cap = btm_cb.devcb.loc_io_caps;
evt_data.oob_data = BTM_OOB_NONE;
evt_data.auth_req = BTM_DEFAULT_AUTH_REQ;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT("%s: State: %s\n", __FUNCTION__, btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
p_dev_rec = btm_find_or_alloc_dev (evt_data.bd_addr);
BTM_TRACE_DEBUG("%s:Security mode: %d, Num Read Remote Feat pages: %d\n", __FUNCTION__,
@ -3245,11 +3259,11 @@ void btm_io_capabilities_req (UINT8 *p)
}
p_dev_rec->sm4 |= BTM_SM4_TRUE;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT("%s: State: %s Flags: 0x%04x p_cur_service: %p\n",
__FUNCTION__, btm_pair_state_descr(btm_cb.pairing_state),
btm_cb.pairing_flags, p_dev_rec->p_cur_service);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
if (p_dev_rec->p_cur_service) {
BTM_TRACE_EVENT("%s: cur_service psm: 0x%04x, security_flags: 0x%04x\n",
__FUNCTION__, p_dev_rec->p_cur_service->psm,
@ -3381,11 +3395,11 @@ void btm_io_capabilities_req (UINT8 *p)
/* send the response right now. Save the current IO capability in the control block */
btm_cb.devcb.loc_auth_req = evt_data.auth_req;
btm_cb.devcb.loc_io_caps = evt_data.io_cap;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT("%s: State: %s IO_CAP:%d oob_data:%d auth_req:%d",
__FUNCTION__, btm_pair_state_descr(btm_cb.pairing_state), evt_data.io_cap,
evt_data.oob_data, evt_data.auth_req);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
btsnd_hcic_io_cap_req_reply(evt_data.bd_addr, evt_data.io_cap,
evt_data.oob_data, evt_data.auth_req);
}
@ -3476,11 +3490,11 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
/* All events start with bd_addr */
STREAM_TO_BDADDR (p_bda, p);
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("btm_proc_sp_req_evt() BDA: %08x%04x event: 0x%x, State: %s\n",
(p_bda[0] << 24) + (p_bda[1] << 16) + (p_bda[2] << 8) + p_bda[3], (p_bda[4] << 8) + p_bda[5],
event, btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
if ( ((p_dev_rec = btm_find_dev (p_bda)) != NULL)
&& (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)
&& (memcmp (btm_cb.pairing_bda, p_bda, BD_ADDR_LEN) == 0) ) {
@ -3635,10 +3649,10 @@ void btm_simple_pair_complete (UINT8 *p)
(evt_data.bd_addr[4] << 8) + evt_data.bd_addr[5]);
return;
}
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("btm_simple_pair_complete() Pair State: %s Status:%d sec_state: %u\n",
btm_pair_state_descr(btm_cb.pairing_state), status, p_dev_rec->sec_state);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
evt_data.status = BTM_ERR_PROCESSING;
if (status == HCI_SUCCESS) {
evt_data.status = BTM_SUCCESS;
@ -3820,7 +3834,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
/* Commenting out trace due to obf/compilation problems.
*/
#if (BT_USE_TRACES == TRUE)
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
if (p_dev_rec) {
BTM_TRACE_EVENT ("Security Manager: auth_complete PairState: %s handle:%u status:%d dev->sec_state: %u Bda:%08x, RName:%s\n",
btm_pair_state_descr (btm_cb.pairing_state),
@ -4126,7 +4140,9 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
if (BTM_SEC_STATE_DELAY_FOR_ENC == p_dev_rec->sec_state) {
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
p_dev_rec->p_callback = NULL;
#if (CLASSIC_BT_INCLUDED == TRUE)
l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
return;
}
@ -4189,9 +4205,9 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
UINT8 res;
BOOLEAN is_pairing_device = FALSE;
@ -4203,7 +4219,7 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
BTM_TRACE_ERROR ("%s\n", __func__);
/* Commenting out trace due to obf/compilation problems.
*/
#if (BT_USE_TRACES == TRUE)
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
if (p_dev_rec) {
BTM_TRACE_EVENT ("Security Manager: btm_sec_connected in state: %s handle:%d status:%d enc_mode:%d bda:%x RName:%s\n",
btm_pair_state_descr(btm_cb.pairing_state), handle, status, enc_mode,
@ -4468,7 +4484,6 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
}
}
return;
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -4482,7 +4497,6 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
*******************************************************************************/
tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
/* In some weird race condition we may not have a record */
@ -4501,9 +4515,6 @@ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason)
}
return (btm_sec_send_hci_disconnect(p_dev_rec, reason, handle));
#else
return BTM_MODE_UNSUPPORTED;
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -4518,7 +4529,6 @@ tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason)
*******************************************************************************/
void btm_sec_disconnected (UINT16 handle, UINT8 reason)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
UINT8 old_pairing_flags = btm_cb.pairing_flags;
int result = HCI_ERR_AUTH_FAILURE;
@ -4545,12 +4555,12 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason)
/* clear unused flags */
p_dev_rec->sm4 &= BTM_SM4_TRUE;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
uint8_t *bd_addr = (uint8_t *)p_dev_rec->bd_addr;
BTM_TRACE_EVENT("%s sec_req:x%x state:%s reason:%d bd_addr:%02x:%02x:%02x:%02x:%02x:%02x"
" remote_name:%s\n", __func__, p_dev_rec->security_required, btm_pair_state_descr(btm_cb.pairing_state),
reason, bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5], p_dev_rec->sec_bd_name);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
BTM_TRACE_EVENT("%s before update sec_flags=0x%x\n", __func__, p_dev_rec->sec_flags);
/* If we are in the process of bonding we need to tell client that auth failed */
@ -4609,7 +4619,6 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason)
}
BTM_TRACE_EVENT("%s after update sec_flags=0x%x\n", __func__, p_dev_rec->sec_flags);
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -4624,7 +4633,6 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason)
*******************************************************************************/
void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_type)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda);
BOOLEAN we_are_bonding = FALSE;
BOOLEAN ltk_derived_lk = FALSE;
@ -4739,7 +4747,6 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
}
}
}
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -4753,7 +4760,6 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
*******************************************************************************/
void btm_sec_link_key_request (UINT8 *p_bda)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda);
BTM_TRACE_EVENT ("btm_sec_link_key_request() BDA: %02x:%02x:%02x:%02x:%02x:%02x\n",
@ -4778,8 +4784,8 @@ void btm_sec_link_key_request (UINT8 *p_bda)
/* The link key is not in the database and it is not known to the manager */
btsnd_hcic_link_key_neg_reply (p_bda);
#endif ///SMP_INCLUDED == TRUE
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -4811,10 +4817,10 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
/* coverity[UNUSED_VALUE] pointer p_dev_rec is actually used several times... This is a Coverity false-positive, i.e. a fake issue.
*/
p_dev_rec = btm_find_dev (p_cb->pairing_bda);
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("btm_sec_pairing_timeout() State: %s Flags: %u\n",
btm_pair_state_descr(p_cb->pairing_state), p_cb->pairing_flags);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
switch (p_cb->pairing_state) {
case BTM_PAIR_STATE_WAIT_PIN_REQ:
btm_sec_bond_cancel_complete();
@ -4899,12 +4905,13 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
break;
default:
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_WARNING ("btm_sec_pairing_timeout() not processed state: %s\n", btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
break;
}
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -4917,8 +4924,6 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
*******************************************************************************/
void btm_sec_pin_code_request (UINT8 *p_bda)
{
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_CB *p_cb = &btm_cb;
@ -4926,10 +4931,11 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
UINT8 default_pin_code_len = 4;
PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30};
#endif
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("btm_sec_pin_code_request() State: %s, BDA:%04x%08x\n",
btm_pair_state_descr(btm_cb.pairing_state),
(p_bda[0] << 8) + p_bda[1], (p_bda[2] << 24) + (p_bda[3] << 16) + (p_bda[4] << 8) + p_bda[5] );
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) {
if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) &&
(btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) ) {
@ -4944,9 +4950,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
}
} else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ)
|| memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) {
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_WARNING ("btm_sec_pin_code_request() rejected - state: %s\n",
btm_pair_state_descr(btm_cb.pairing_state));
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
#ifdef PORCHE_PAIRING_CONFLICT
/* reply pin code again due to counter in_rand when local initiates pairing */
BTM_TRACE_EVENT ("btm_sec_pin_code_request from remote dev. for local initiated pairing\n");
@ -5070,9 +5077,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
}
}
}
#endif ///SMP_INCLUDED == TRUE
return;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -5541,7 +5549,7 @@ static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle)
/*******************************************************************************
**
** Function btm_sec_link_key_request
** Function btm_send_link_key_notif
**
** Description This function is called when controller requests link key
**
@ -5641,10 +5649,11 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state)
static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state)
{
tBTM_PAIRING_STATE old_state = btm_cb.pairing_state;
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() Old: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state));
BTM_TRACE_EVENT ("%s() New: %s pairing_flags:0x%x\n\n", __func__,
btm_pair_state_descr(new_state), btm_cb.pairing_flags);
#endif ///BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE
btm_cb.pairing_state = new_state;

View file

@ -81,9 +81,11 @@ static void btu_hcif_flush_occured_evt (void);
static void btu_hcif_role_change_evt (UINT8 *p);
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p);
static void btu_hcif_mode_change_evt (UINT8 *p);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_pin_code_request_evt (UINT8 *p);
static void btu_hcif_link_key_request_evt (UINT8 *p);
static void btu_hcif_link_key_notification_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
static void btu_hcif_loopback_command_evt (void);
static void btu_hcif_data_buf_overflow_evt (void);
static void btu_hcif_max_slots_changed_evt (void);
@ -235,6 +237,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_MODE_CHANGE_EVT:
btu_hcif_mode_change_evt (p);
break;
#if (SMP_INCLUDED == TRUE)
case HCI_PIN_CODE_REQUEST_EVT:
btu_hcif_pin_code_request_evt (p);
break;
@ -244,6 +247,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_LINK_KEY_NOTIFICATION_EVT:
btu_hcif_link_key_notification_evt (p);
break;
#endif ///SMP_INCLUDED == TRUE
case HCI_LOOPBACK_COMMAND_EVT:
btu_hcif_loopback_command_evt ();
break;
@ -517,7 +521,9 @@ static void btu_hcif_connection_comp_evt (UINT8 *p)
UINT16 handle;
BD_ADDR bda;
UINT8 link_type;
#if SMP_INCLUDED == TRUE
UINT8 enc_mode;
#endif ///SMP_INCLUDED == TRUE
#if BTM_SCO_INCLUDED == TRUE
tBTM_ESCO_DATA esco_data;
#endif
@ -526,13 +532,15 @@ static void btu_hcif_connection_comp_evt (UINT8 *p)
STREAM_TO_UINT16 (handle, p);
STREAM_TO_BDADDR (bda, p);
STREAM_TO_UINT8 (link_type, p);
#if (SMP_INCLUDED == TRUE)
STREAM_TO_UINT8 (enc_mode, p);
#endif ///SMP_INCLUDED == TRUE
handle = HCID_GET_HANDLE (handle);
if (link_type == HCI_LINK_TYPE_ACL) {
#if (SMP_INCLUDED == TRUE)
btm_sec_connected (bda, handle, status, enc_mode);
#endif ///SMP_INCLUDED == TRUE
l2c_link_hci_conn_comp (status, handle, bda);
}
#if BTM_SCO_INCLUDED == TRUE
@ -564,11 +572,12 @@ static void btu_hcif_connection_request_evt (UINT8 *p)
STREAM_TO_BDADDR (bda, p);
STREAM_TO_DEVCLASS (dc, p);
STREAM_TO_UINT8 (link_type, p);
/* Pass request to security manager to check connect filters before */
/* passing request to l2cap */
if (link_type == HCI_LINK_TYPE_ACL) {
#if (SMP_INCLUDED == TRUE)
btm_sec_conn_req (bda, dc);
#endif ///SMP_INCLUDED == TRUE
}
#if BTM_SCO_INCLUDED == TRUE
else {
@ -606,9 +615,10 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p)
#else
l2c_link_hci_disc_comp (handle, reason);
#endif /* BTM_SCO_INCLUDED */
#if (SMP_INCLUDED == TRUE)
/* Notify security manager */
btm_sec_disconnected (handle, reason);
#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
@ -653,8 +663,9 @@ static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len)
evt_len -= (1 + BD_ADDR_LEN);
btm_process_remote_name (bd_addr, p, evt_len, status);
#if (SMP_INCLUDED == TRUE)
btm_sec_rmt_name_request_complete (bd_addr, p, status);
#endif ///SMP_INCLUDED == TRUE
}
@ -1055,8 +1066,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
case HCI_RMT_NAME_REQUEST:
/* Tell inquiry processing that we are done */
btm_process_remote_name (NULL, NULL, 0, status);
#if (SMP_INCLUDED == TRUE)
btm_sec_rmt_name_request_complete (NULL, NULL, status);
#endif ///SMP_INCLUDED == TRUE
break;
case HCI_QOS_SETUP_COMP_EVT:
@ -1082,7 +1094,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_BDADDR (bd_addr, p_cmd);
#if (SMP_INCLUDED == TRUE)
btm_sec_connected (bd_addr, HCI_INVALID_HANDLE, status, 0);
#endif ///SMP_INCLUDED == TRUE
l2c_link_hci_conn_comp (status, HCI_INVALID_HANDLE, bd_addr);
}
break;
@ -1337,6 +1351,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_pin_code_request_evt (UINT8 *p)
{
BD_ADDR bda;
@ -1368,7 +1383,6 @@ static void btu_hcif_link_key_request_evt (UINT8 *p)
btm_sec_link_key_request (bda);
}
/*******************************************************************************
**
** Function btu_hcif_link_key_notification_evt
@ -1390,6 +1404,7 @@ static void btu_hcif_link_key_notification_evt (UINT8 *p)
btm_sec_link_key_notification (bda, key, key_type);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************

View file

@ -345,7 +345,11 @@ tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
if (p_tcb->att_lcid == L2CAP_ATT_CID) {
l2cap_ret = L2CA_SendFixedChnlData (L2CAP_ATT_CID, p_tcb->peer_bda, p_toL2CAP);
} else {
#if (CLASSIC_BT_INCLUDED == TRUE)
l2cap_ret = (UINT16) L2CA_DataWrite (p_tcb->att_lcid, p_toL2CAP);
#else
l2cap_ret = L2CAP_DW_FAILED;
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
if (l2cap_ret == L2CAP_DW_FAILED) {

View file

@ -48,7 +48,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
UINT16 reason, tBT_TRANSPORT transport);
static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf);
static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congest);
#if (CLASSIC_BT_INCLUDED == TRUE)
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 l2cap_cid,
UINT16 psm, UINT8 l2cap_id);
static void gatt_l2cif_connect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
@ -57,9 +57,10 @@ static void gatt_l2cif_config_cfm_cback (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cf
static void gatt_l2cif_disconnect_ind_cback (UINT16 l2cap_cid, BOOLEAN ack_needed);
static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg);
#endif ///CLASSIC_BT_INCLUDED == TRUE
static void gatt_send_conn_cback (tGATT_TCB *p_tcb);
#if (CLASSIC_BT_INCLUDED == TRUE)
static void gatt_l2cif_congest_cback (UINT16 cid, BOOLEAN congested);
static const tL2CAP_APPL_INFO dyn_info = {
gatt_l2cif_connect_ind_cback,
gatt_l2cif_connect_cfm_cback,
@ -73,6 +74,7 @@ static const tL2CAP_APPL_INFO dyn_info = {
gatt_l2cif_congest_cback,
NULL
} ;
#endif ///SMP_INCLUDED == TRUE
#if GATT_DYNAMIC_MEMORY == FALSE
tGATT_CB gatt_cb;
@ -412,7 +414,9 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
gatt_send_conn_cback(p_tcb);
}
if (check_srv_chg) {
#if (GATTS_INCLUDED == TRUE)
gatt_chk_srv_chg (p_srv_chg_clt);
#endif ///GATTS_INCLUDED == TRUE
}
}
/* this is incoming connection or background connection callback */
@ -427,7 +431,9 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
gatt_send_conn_cback (p_tcb);
if (check_srv_chg) {
#if (GATTS_INCLUDED == TRUE)
gatt_chk_srv_chg (p_srv_chg_clt);
#endif ///GATTS_INCLUDED == TRUE
}
} else {
GATT_TRACE_ERROR("CCB max out, no rsources");
@ -535,9 +541,9 @@ static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
/* do we already have a control channel for this peer? */
UINT8 result = L2CAP_CONN_OK;
tL2CAP_CFG_INFO cfg;
@ -574,7 +580,6 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16
L2CA_ConfigReq(lcid, &cfg);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
@ -590,7 +595,6 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16
*******************************************************************************/
static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb;
tL2CAP_CFG_INFO cfg;
@ -622,8 +626,6 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
}
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
/*******************************************************************************
@ -638,7 +640,6 @@ static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
*******************************************************************************/
void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb;
tGATTS_SRV_CHG *p_srv_chg_clt = NULL;
@ -656,7 +657,9 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL) {
#if (GATTS_INCLUDED == TRUE)
gatt_chk_srv_chg(p_srv_chg_clt);
#endif ///GATTS_INCLUDED == TRUE
} else {
if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda)) {
gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
@ -674,8 +677,6 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
}
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
/*******************************************************************************
@ -690,7 +691,6 @@ void gatt_l2cif_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
*******************************************************************************/
void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb;
tGATTS_SRV_CHG *p_srv_chg_clt = NULL;
/* look up clcb for this channel */
@ -717,7 +717,9 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
if (p_tcb->ch_flags & GATT_L2C_CFG_CFM_DONE) {
gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL) {
#if (GATTS_INCLUDED == TRUE)
gatt_chk_srv_chg(p_srv_chg_clt);
#endif ///GATTS_INCLUDED == TRUE
} else {
if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda)) {
gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
@ -729,8 +731,6 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
}
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
/*******************************************************************************
@ -745,7 +745,6 @@ void gatt_l2cif_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
*******************************************************************************/
void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb;
UINT16 reason;
@ -768,8 +767,6 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
/* send disconnect callback */
gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
/*******************************************************************************
@ -784,7 +781,6 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
*******************************************************************************/
static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb;
UINT16 reason;
UNUSED(result);
@ -806,8 +802,6 @@ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
/*******************************************************************************
@ -822,7 +816,6 @@ static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
*******************************************************************************/
static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb;
/* look up clcb for this channel */
@ -833,7 +826,6 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
} else { /* prevent buffer leak */
GKI_freebuf(p_buf);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
@ -848,15 +840,14 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
*******************************************************************************/
static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tGATT_TCB *p_tcb = gatt_find_tcb_by_cid(lcid);
if (p_tcb != NULL) {
gatt_channel_congestion(p_tcb, congested);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -990,9 +981,9 @@ void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda)
** Returns void
**
*******************************************************************************/
#if (GATTS_INCLUDED == TRUE)
void gatt_send_srv_chg_ind (BD_ADDR peer_bda)
{
#if (GATTS_INCLUDED == TRUE)
UINT8 handle_range[GATT_SIZE_OF_SRV_CHG_HNDL_RANGE];
UINT8 *p = handle_range;
UINT16 conn_id;
@ -1013,9 +1004,9 @@ void gatt_send_srv_chg_ind (BD_ADDR peer_bda)
(peer_bda[4] << 8) + peer_bda[5] );
}
}
#endif ///GATTS_INCLUDED == TRUE
}
/*******************************************************************************
**
** Function gatt_chk_srv_chg
@ -1034,6 +1025,8 @@ void gatt_chk_srv_chg(tGATTS_SRV_CHG *p_srv_chg_clt)
gatt_send_srv_chg_ind(p_srv_chg_clt->bda);
}
}
#endif ///GATTS_INCLUDED == TRUE
/*******************************************************************************
**
@ -1087,6 +1080,7 @@ void gatt_init_srv_chg (void)
** Returns void
**
*******************************************************************************/
#if (GATTS_INCLUDED == TRUE)
void gatt_proc_srv_chg (void)
{
UINT8 start_idx, found_idx;
@ -1113,6 +1107,7 @@ void gatt_proc_srv_chg (void)
}
}
}
#endif ///GATTS_INCLUDED == TRUE
/*******************************************************************************
**

View file

@ -1754,11 +1754,13 @@ BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda)
** L2CAP_DW_FAILED, if error
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data)
{
L2CAP_TRACE_API ("L2CA_DataWrite() CID: 0x%04x Len: %d", cid, p_data->len);
return l2c_data_write (cid, p_data, L2CAP_FLUSHABLE_CH_BASED);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -1806,12 +1808,14 @@ BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable)
** L2CAP_DW_FAILED, if error
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags)
{
L2CAP_TRACE_API ("L2CA_DataWriteEx() CID: 0x%04x Len: %d Flags:0x%04X",
cid, p_data->len, flags);
return l2c_data_write (cid, p_data, flags);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**

View file

@ -272,13 +272,17 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
if (!p_lcb) {
p_lcb = l2cu_allocate_lcb (bda, FALSE, BT_TRANSPORT_LE);
if (!p_lcb) {
#if (SMP_INCLUDED == TRUE)
btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
L2CAP_TRACE_ERROR ("l2cble_scanner_conn_comp - failed to allocate LCB");
#endif ///SMP_INCLUDED == TRUE
return;
} else {
if (!l2cu_initialize_fixed_ccb (p_lcb, L2CAP_ATT_CID, &l2cb.fixed_reg[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts)) {
#if (SMP_INCLUDED == TRUE)
btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
L2CAP_TRACE_WARNING ("l2cble_scanner_conn_comp - LCB but no CCB");
#endif ///SMP_INCLUDED == TRUE
return ;
}
}
@ -371,12 +375,16 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
if (!p_lcb) {
p_lcb = l2cu_allocate_lcb (bda, FALSE, BT_TRANSPORT_LE);
if (!p_lcb) {
#if (SMP_INCLUDED == TRUE)
btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
#endif ///SMP_INCLUDED == TRUE
L2CAP_TRACE_ERROR ("l2cble_advertiser_conn_comp - failed to allocate LCB");
return;
} else {
if (!l2cu_initialize_fixed_ccb (p_lcb, L2CAP_ATT_CID, &l2cb.fixed_reg[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts)) {
#if (SMP_INCLUDED == TRUE)
btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
#endif ///SMP_INCLUDED == TRUE
L2CAP_TRACE_WARNING ("l2cble_scanner_conn_comp - LCB but no CCB");
return ;
}

View file

@ -519,9 +519,10 @@ void l2c_link_timeout (tL2C_LCB *p_lcb)
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
#endif ///CLASSIC_BT_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
UINT16 timeout;
tBTM_STATUS rc;
#endif ///SMP_INCLUDED == TRUE
L2CAP_TRACE_EVENT ("L2CAP - l2c_link_timeout() link state %d first CCB %p is_bonding:%d",
p_lcb->link_state, p_lcb->ccb_queue.p_first_ccb, p_lcb->is_bonding);
@ -577,6 +578,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb)
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
#if (SMP_INCLUDED == TRUE)
/* If no channels in use, drop the link. */
if (!p_lcb->ccb_queue.p_first_ccb) {
rc = btm_sec_disconnect (p_lcb->handle, HCI_ERR_PEER_USER);
@ -611,7 +613,8 @@ void l2c_link_timeout (tL2C_LCB *p_lcb)
} else {
/* Check in case we were flow controlled */
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
}
}
#endif ///SMP_INCLUDED == TRUE
}
}

View file

@ -41,8 +41,9 @@
/********************************************************************************/
/* L O C A L F U N C T I O N P R O T O T Y P E S */
/********************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/********************************************************************************/
/* G L O B A L L 2 C A P D A T A */
/********************************************************************************/
@ -217,7 +218,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
if (rcv_cid == L2CAP_SIGNALLING_CID) {
//counter_add("l2cap.sig.rx.bytes", l2cap_len);
//counter_add("l2cap.sig.rx.pkts", 1);
#if (CLASSIC_BT_INCLUDED == TRUE)
process_l2cap_cmd (p_lcb, p, l2cap_len);
#endif ///CLASSIC_BT_INCLUDED == TRUE
GKI_freebuf (p_msg);
} else if (rcv_cid == L2CAP_CONNECTIONLESS_CID) {
//counter_add("l2cap.ch2.rx.bytes", l2cap_len);
@ -302,9 +305,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 *p_pkt_end, *p_next_cmd, *p_cfg_end, *p_cfg_start;
UINT8 cmd_code, cfg_code, cfg_len, id;
tL2C_CONN_INFO con_info;
@ -739,8 +742,9 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -904,9 +908,9 @@ void l2c_process_timeout (TIMER_LIST_ENT *p_tle)
** L2CAP_DW_FAILED, if error
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
/* Find the channel control block. We don't know the link it is on. */
@ -945,7 +949,8 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
if (p_ccb->cong_sent) {
return (L2CAP_DW_CONGESTED);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
return (L2CAP_DW_SUCCESS);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE

View file

@ -2048,9 +2048,9 @@ void l2cu_process_our_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
/* If peer wants QoS, we are allowed to change the values in a positive response */
if ( (p_cfg->qos_present) && (p_ccb->peer_cfg.qos_present) ) {
p_ccb->peer_cfg.qos = p_cfg->qos;
@ -2059,8 +2059,8 @@ void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg)
}
l2c_fcr_adj_our_rsp_options (p_ccb, p_cfg);
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
@ -2420,9 +2420,9 @@ void l2cu_set_non_flushable_pbf (BOOLEAN is_supported)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_LCB *p_lcb;
tL2C_CCB *p_ccb;
tL2C_CCB *p_next_ccb;
@ -2454,8 +2454,8 @@ void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda)
}
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
#if L2CAP_CONFORMANCE_TESTING == TRUE
/*******************************************************************************
@ -2592,7 +2592,9 @@ BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR
*******************************************************************************/
void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb)
{
#if (SMP_INCLUDED == TRUE)
tBTM_STATUS rc;
#endif ///SMP_INCLUDED == TRUE
UINT16 timeout = p_lcb->idle_timeout;
#if (L2CAP_NUM_FIXED_CHNLS > 0)
@ -2612,7 +2614,7 @@ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb)
if (timeout == 0) {
L2CAP_TRACE_DEBUG ("l2cu_no_dynamic_ccbs() IDLE timer 0, disconnecting link");
#if (SMP_INCLUDED == TRUE)
rc = btm_sec_disconnect (p_lcb->handle, HCI_ERR_PEER_USER);
if (rc == BTM_CMD_STARTED) {
l2cu_process_fixed_disc_cback(p_lcb);
@ -2632,6 +2634,7 @@ void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb)
/* probably no buffer to send disconnect */
timeout = BT_1SEC_TIMEOUT;
}
#endif ///SMP_INCLUDED == TRUE
}
if (timeout != 0xFFFF) {