#ifndef _BT_TRACE_H_
#define _BT_TRACE_H_
+#include "sdkconfig.h"
#include <stdio.h>
#include "bt_types.h"
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_LEVEL_INFO
#endif
-#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0)
-#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0)
-#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0)
-#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0)
-#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0)
+
+#if !CONFIG_BT_STACK_NO_LOG
+#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0)
+#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0)
+#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0)
+#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0)
+#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0)
/* Define tracing for the HCI unit
*/
*/
#define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
-#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
*/
#define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_WARNING(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
-#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_EVENT(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_DEBUG(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
/* Generic Access Profile traces */
#define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
-#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
/* define traces for HID Host */
#define PAN_TRACE_ERROR(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_WARNING(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
-#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_EVENT(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_DEBUG(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_WARNING(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_EVENT(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_DEBUG(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
-#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
/* AVDTP
*/
#define MCA_TRACE_WARNING(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define MCA_TRACE_EVENT(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define MCA_TRACE_DEBUG(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
-#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
/* Define tracing for the ATT/GATT unit
*/
*/
#define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
-#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
+#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
#define APPL_TRACE_DEBUG(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
#define APPL_TRACE_VERBOSE(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) BT_PRINTF(fmt, ## args);}
+#else
+#define LOG_ERROR(fmt, args...)
+#define LOG_WARN(fmt, args...)
+#define LOG_INFO(fmt, args...)
+#define LOG_DEBUG(fmt, args...)
+#define LOG_VERBOSE(fmt, args...)
+
+/* Define tracing for the HCI unit
+*/
+#define HCI_TRACE_ERROR(fmt, args...)
+#define HCI_TRACE_WARNING(fmt, args...)
+#define HCI_TRACE_EVENT(fmt, args...)
+#define HCI_TRACE_DEBUG(fmt, args...)
+
+/* Define tracing for BTM
+*/
+#define BTM_TRACE_ERROR(fmt, args...)
+#define BTM_TRACE_WARNING(fmt, args...)
+#define BTM_TRACE_API(fmt, args...)
+#define BTM_TRACE_EVENT(fmt, args...)
+#define BTM_TRACE_DEBUG(fmt, args...)
+
+/* Define tracing for the L2CAP unit
+*/
+#define L2CAP_TRACE_ERROR(fmt, args...)
+#define L2CAP_TRACE_WARNING(fmt, args...)
+#define L2CAP_TRACE_API(fmt, args...)
+#define L2CAP_TRACE_EVENT(fmt, args...)
+#define L2CAP_TRACE_DEBUG(fmt, args...)
+
+/* Define tracing for the SDP unit
+*/
+#define SDP_TRACE_ERROR(fmt, args...)
+#define SDP_TRACE_WARNING(fmt, args...)
+#define SDP_TRACE_API(fmt, args...)
+#define SDP_TRACE_EVENT(fmt, args...)
+#define SDP_TRACE_DEBUG(fmt, args...)
+
+/* Define tracing for the RFCOMM unit
+*/
+#define RFCOMM_TRACE_ERROR(fmt, args...)
+#define RFCOMM_TRACE_WARNING(fmt, args...)
+#define RFCOMM_TRACE_API(fmt, args...)
+#define RFCOMM_TRACE_EVENT(fmt, args...)
+#define RFCOMM_TRACE_DEBUG(fmt, args...)
+
+/* Generic Access Profile traces */
+#define GAP_TRACE_ERROR(fmt, args...)
+#define GAP_TRACE_EVENT(fmt, args...)
+#define GAP_TRACE_API(fmt, args...)
+#define GAP_TRACE_WARNING(fmt, args...)
+
+/* define traces for HID Host */
+#define HIDH_TRACE_ERROR(fmt, args...)
+#define HIDH_TRACE_WARNING(fmt, args...)
+#define HIDH_TRACE_API(fmt, args...)
+#define HIDH_TRACE_EVENT(fmt, args...)
+#define HIDH_TRACE_DEBUG(fmt, args...)
+
+/* define traces for BNEP */
+
+#define BNEP_TRACE_ERROR(fmt, args...)
+#define BNEP_TRACE_WARNING(fmt, args...)
+#define BNEP_TRACE_API(fmt, args...)
+#define BNEP_TRACE_EVENT(fmt, args...)
+#define BNEP_TRACE_DEBUG(fmt, args...)
+
+/* define traces for PAN */
+
+#define PAN_TRACE_ERROR(fmt, args...)
+#define PAN_TRACE_WARNING(fmt, args...)
+#define PAN_TRACE_API(fmt, args...)
+#define PAN_TRACE_EVENT(fmt, args...)
+#define PAN_TRACE_DEBUG(fmt, args...)
+
+/* Define tracing for the A2DP profile
+*/
+#define A2D_TRACE_ERROR(fmt, args...)
+#define A2D_TRACE_WARNING(fmt, args...)
+#define A2D_TRACE_EVENT(fmt, args...)
+#define A2D_TRACE_DEBUG(fmt, args...)
+#define A2D_TRACE_API(fmt, args...)
+
+/* AVDTP
+*/
+#define AVDT_TRACE_ERROR(fmt, args...)
+#define AVDT_TRACE_WARNING(fmt, args...)
+#define AVDT_TRACE_EVENT(fmt, args...)
+#define AVDT_TRACE_DEBUG(fmt, args...)
+#define AVDT_TRACE_API(fmt, args...)
+
+/* Define tracing for the AVCTP protocol
+*/
+#define AVCT_TRACE_ERROR(fmt, args...)
+#define AVCT_TRACE_WARNING(fmt, args...)
+#define AVCT_TRACE_EVENT(fmt, args...)
+#define AVCT_TRACE_DEBUG(fmt, args...)
+#define AVCT_TRACE_API(fmt, args...)
+
+/* Define tracing for the AVRCP profile
+*/
+#define AVRC_TRACE_ERROR(fmt, args...)
+#define AVRC_TRACE_WARNING(fmt, args...)
+#define AVRC_TRACE_EVENT(fmt, args...)
+#define AVRC_TRACE_DEBUG(fmt, args...)
+#define AVRC_TRACE_API(fmt, args...)
+
+/* MCAP
+*/
+#define MCA_TRACE_ERROR(fmt, args...)
+#define MCA_TRACE_WARNING(fmt, args...)
+#define MCA_TRACE_EVENT(fmt, args...)
+#define MCA_TRACE_DEBUG(fmt, args...)
+#define MCA_TRACE_API(fmt, args...)
+
+/* Define tracing for the ATT/GATT unit
+*/
+#define GATT_TRACE_ERROR(fmt, args...)
+#define GATT_TRACE_WARNING(fmt, args...)
+#define GATT_TRACE_API(fmt, args...)
+#define GATT_TRACE_EVENT(fmt, args...)
+#define GATT_TRACE_DEBUG(fmt, args...)
+
+/* Define tracing for the SMP unit
+*/
+#define SMP_TRACE_ERROR(fmt, args...)
+#define SMP_TRACE_WARNING(fmt, args...)
+#define SMP_TRACE_API(fmt, args...)
+#define SMP_TRACE_EVENT(fmt, args...)
+#define SMP_TRACE_DEBUG(fmt, args...)
+
+extern UINT8 btif_trace_level;
+
+// define traces for application
+#define BTIF_TRACE_ERROR(fmt, args...)
+#define BTIF_TRACE_WARNING(fmt, args...)
+#define BTIF_TRACE_API(fmt, args...)
+#define BTIF_TRACE_EVENT(fmt, args...)
+#define BTIF_TRACE_DEBUG(fmt, args...)
+#define BTIF_TRACE_VERBOSE(fmt, args...)
+
+/* define traces for application */
+
+#define APPL_TRACE_ERROR(fmt, args...)
+#define APPL_TRACE_WARNING(fmt, args...)
+#define APPL_TRACE_API(fmt, args...)
+#define APPL_TRACE_EVENT(fmt, args...)
+#define APPL_TRACE_DEBUG(fmt, args...)
+#define APPL_TRACE_VERBOSE(fmt, args...)
+#endif ///CONFIG_BT_STACK_NO_LOG
+
+
/* Simplified Trace Helper Macro
*/
#define bdld(fmt, args...) \
/********************************************************************************
** L O C A L F U N C T I O N P R O T O T Y P E S *
*********************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static tBTM_SEC_SERV_REC *btm_sec_find_first_serv (BOOLEAN is_originator, UINT16 psm);
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);
-#if (BT_USE_TRACES == 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 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);
-
+#endif ///SMP_INCLUDED == TRUE
static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec);
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);
+#endif ///SMP_INCLUDED == TRUE
UINT8 btm_sec_start_role_switch (tBTM_SEC_DEV_REC *p_dev_rec);
tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state);
static BOOLEAN btm_sec_set_security_level ( CONNECTION_TYPE conn_type, char *p_name, UINT8 service_id,
UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_id);
-
+#if (SMP_INCLUDED == TRUE)
static BOOLEAN btm_dev_authenticated(tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_dev_encrypted(tBTM_SEC_DEV_REC *p_dev_rec);
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);
static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec);
+#endif ///SMP_INCLUDED == TRUE
/* TRUE - authenticated link key is possible */
static const BOOLEAN btm_sec_io_map [BTM_IO_CAP_MAX][BTM_IO_CAP_MAX] = {
** Returns BOOLEAN TRUE or FALSE
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static BOOLEAN btm_dev_authenticated (tBTM_SEC_DEV_REC *p_dev_rec)
{
if (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED) {
}
return (FALSE);
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Returns BOOLEAN TRUE or FALSE
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *p_serv_rec)
{
if (BTM_SEC_IS_SERVICE_TRUSTED(p_dev_rec->trusted_mask, p_serv_rec->service_id)) {
}
return (FALSE);
}
-
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function BTM_SecRegister
*******************************************************************************/
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++) {
return (TRUE);
}
}
-
+#endif ///SMP_INCLUDED == TRUE
return (FALSE);
}
*******************************************************************************/
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++) {
return (TRUE);
}
}
-
+#endif ///SMP_INCLUDED == TRUE
return (FALSE);
}
UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_id)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_SERV_REC *p_srec;
UINT16 index;
UINT16 first_unused_record = BTM_NO_AVAIL_SEC_SERVICES;
return (record_allocated);
+#else
+ return FALSE;
+#endif ///SMP_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;
}
return (num_freed);
+#else
+ return 0;
+#endif ///SMP_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;
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
}
/*******************************************************************************
*******************************************************************************/
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",
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
}
/*******************************************************************************
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;
}
return status;
+#else
+ return BTM_MODE_UNSUPPORTED;
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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",
return BTM_NOT_AUTHORIZED;
}
}
-
+#endif ///SMP_INCLUDED == TRUE
return BTM_WRONG_MODE;
}
/*******************************************************************************
* 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;
return status;
}
-
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function BTM_ConfirmReqReply
*******************************************************************************/
void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
BTM_TRACE_EVENT ("BTM_ConfirmReqReply() State: %s Res: %u",
btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY;
btsnd_hcic_user_conf_reply (bd_addr, FALSE);
}
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
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);
btm_cb.acl_disc_reason = HCI_SUCCESS;
btsnd_hcic_user_passkey_reply (bd_addr, passkey);
}
+#endif ///SMP_INCLUDED == TRUE
}
#endif
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
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
*******************************************************************************/
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);
btsnd_hcic_io_cap_req_reply (bd_addr, io_cap, oob, auth_req);
}
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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);
btm_cb.acl_disc_reason = HCI_SUCCESS;
btsnd_hcic_rem_oob_reply (bd_addr, c, r);
}
+#endif ///SMP_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];
break;
}
}
+#endif ///SMP_INCLUDED == TRUE
}
/************************************************************************
** Returns BOOLEAN
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static BOOLEAN btm_sec_is_upgrade_possible(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN is_originator)
{
UINT16 mtm_check = is_originator ? BTM_SEC_OUT_MITM : BTM_SEC_IN_MITM;
BTM_TRACE_DEBUG ("%s() is_possible: %d sec_flags: 0x%x\n", __func__, is_possible, p_dev_rec->sec_flags);
return is_possible;
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Returns void
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static void btm_sec_check_upgrade(tBTM_SEC_DEV_REC *p_dev_rec, BOOLEAN is_originator)
{
}
}
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
tBTM_SEC_CALLBACK *p_callback,
void *p_ref_data)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_SEC_SERV_REC *p_serv_rec;
UINT16 security_required;
}
return (rc);
+#else
+ return BTM_MODE_UNSUPPORTED;
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
UINT32 mx_proto_id, UINT32 mx_chan_id,
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_SEC_SERV_REC *p_serv_rec;
tBTM_STATUS rc;
}
return rc;
+#else
+ return BTM_MODE_UNSUPPORTED;
+#endif ///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 */
p_dev_rec->sm4 |= BTM_SM4_CONN_PEND;
}
}
+#endif ///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) ||
btm_cb.api.p_bond_cancel_cmpl_callback(BTM_SUCCESS);
}
}
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
UINT8 status;
STREAM_TO_UINT8 (status, p);
- BTM_TRACE_EVENT ("btm_create_conn_cancel_complete(): in State: %s status:%d\n",
- btm_pair_state_descr(btm_cb.pairing_state), status);
+ //BTM_TRACE_EVENT ("btm_create_conn_cancel_complete(): in State: %s status:%d\n",
+ // btm_pair_state_descr(btm_cb.pairing_state), status);
/* if the create conn cancel cmd was issued by the bond cancel,
** the application needs to be notified that bond cancel succeeded
*******************************************************************************/
void btm_sec_check_pending_reqs (void)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_QUEUE_ENTRY *p_e;
BUFFER_Q bq;
GKI_freebuf (p_e);
}
}
+#endif ///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
}
/*******************************************************************************
*******************************************************************************/
void btm_sec_device_down (void)
{
+#if (SMP_INCLUDED == TRUE)
BTM_TRACE_EVENT ("%s() State: %s\n", __func__, btm_pair_state_descr(btm_cb.pairing_state));
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
** Returns void
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec)
{
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
p_dev_rec->bd_addr[3], p_dev_rec->bd_addr[4], p_dev_rec->bd_addr[5]);
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_PIN_REQ);
-
return (BTM_CMD_STARTED);
}
+#endif ///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;
/* 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
}
/*******************************************************************************
*******************************************************************************/
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;
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
}
/*******************************************************************************
*******************************************************************************/
void btm_io_capabilities_rsp (UINT8 *p)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_SP_IO_RSP evt_data;
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
}
/*******************************************************************************
*******************************************************************************/
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;
btsnd_hcic_user_passkey_neg_reply(p_bda);
}
#endif
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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;
btm_sec_send_hci_disconnect (p_dev_rec, HCI_ERR_AUTH_FAILURE, p_dev_rec->hci_handle);
}
}
+#endif ///SMP_INCLUDED == TRUE
}
#if BTM_OOB_INCLUDED == TRUE
** Returns void
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static void btm_sec_auth_collision (UINT16 handle)
{
tBTM_SEC_DEV_REC *p_dev_rec;
}
}
}
+#endif ///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);
if (status != BTM_CMD_STARTED) {
btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE);
}
+#endif ///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;
if (status != BTM_CMD_STARTED) {
btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE);
}
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
** Returns Pointer to the TLE struct
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
{
tBTM_SEC_DEV_REC *p_dev_rec = btm_cb.p_collided_dev_rec;
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
}
}
+#endif ///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;
}
}
return;
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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 */
}
return (btm_sec_send_hci_disconnect(p_dev_rec, reason, handle));
+#else
+ return BTM_MODE_UNSUPPORTED;
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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;
}
BTM_TRACE_EVENT("%s after update sec_flags=0x%x\n", __func__, p_dev_rec->sec_flags);
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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;
}
}
}
+#endif ///SMP_INCLUDED == TRUE
}
/*******************************************************************************
*******************************************************************************/
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",
/* 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
}
/*******************************************************************************
** Returns Pointer to the TLE struct
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
{
tBTM_CB *p_cb = &btm_cb;
break;
}
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
*******************************************************************************/
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;
}
}
}
-
+#endif ///SMP_INCLUDED == TRUE
return;
}
** Returns Pointer to the record or NULL
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static tBTM_SEC_SERV_REC *btm_sec_find_first_serv (CONNECTION_TYPE conn_type, UINT16 psm)
{
tBTM_SEC_SERV_REC *p_serv_rec = &btm_cb.sec_serv_rec[0];
return (NULL);
}
-
/*******************************************************************************
**
** Function btm_sec_find_mx_serv
}
return (NULL);
}
-
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Returns Pointer to the TLE struct
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle)
{
UNUSED(p_tle);
p_dev_rec->sec_bd_name, p_dev_rec->link_key,
p_dev_rec->link_key_type);
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Parameters: void
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static void btm_restore_mode(void)
{
if (btm_cb.security_mode_changed) {
btsnd_hcic_write_pin_type (btm_cb.cfg.pin_type);
}
}
-
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
*******************************************************************************/
tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state)
{
+#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0];
for (int i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i++, p_dev_rec++) {
return (p_dev_rec);
}
}
+#endif ///SMP_INCLUDED == TRUE
return (NULL);
}
*******************************************************************************/
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));
btu_start_timer (&btm_cb.pairing_tle, BTU_TTYPE_USER_FUNC, BTM_SEC_TIMEOUT_VALUE);
}
+#endif ///SMP_INCLUDED == TRUE
}
** Description Return state description for tracing
**
*******************************************************************************/
-#if (BT_USE_TRACES == TRUE)
+#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
static char *btm_pair_state_descr (tBTM_PAIRING_STATE state)
{
#if (BT_TRACE_VERBOSE == TRUE)
** Description Return state description for tracing
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
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)
return (FALSE);
}
-
static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
{
UINT8 major = (UINT8)(p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK);
return rv;
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** 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) {
p_e = (tBTM_SEC_QUEUE_ENTRY *) GKI_getnext ((void *)p_e);
}
}
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** connections only mode.
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static UINT16 btm_sec_set_serv_level4_flags(UINT16 cur_security, BOOLEAN is_originator)
{
UINT16 sec_level4_flags = is_originator ? BTM_SEC_OUT_LEVEL4_FLAGS : BTM_SEC_IN_LEVEL4_FLAGS;
return cur_security | sec_level4_flags;
}
-
+#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function btm_sec_clear_ble_keys
** Manager over BR).
**
*******************************************************************************/
+#if (SMP_INCLUDED == TRUE)
static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec)
{
UINT32 ext_feat;
tACL_CONN *p = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
return (p && (p->link_role == BTM_ROLE_MASTER));
}
+#endif ///SMP_INCLUDED == TRUE