bta_dm_cb.p_sec_cback(BTA_DM_BLE_NC_REQ_EVT, &sec_event);
break;
+ case BTM_LE_SC_OOB_REQ_EVT:
+ bdcpy(sec_event.ble_req.bd_addr, bda);
+ bta_dm_cb.p_sec_cback(BTA_DM_BLE_SC_OOB_REQ_EVT, &sec_event);
+ break;
+
case BTM_LE_KEY_EVT:
bdcpy(sec_event.ble_key.bd_addr, bda);
sec_event.ble_key.key_type = p_data->key.key_type;
#define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
#define BTA_DM_LE_FEATURES_READ 27 /* Cotroller specific LE features are read */
#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
-typedef UINT8 tBTA_DM_SEC_EVT;
+#define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
+typedef uint8_t tBTA_DM_SEC_EVT;
/* Structure associated with BTA_DM_ENABLE_EVT */
typedef struct
static void btif_dm_ble_passkey_req_evt(tBTA_DM_PIN_REQ *p_pin_req);
static void btif_dm_ble_key_nc_req_evt(tBTA_DM_SP_KEY_NOTIF *p_notif_req) ;
static void btif_dm_ble_oob_req_evt(tBTA_DM_SP_RMT_OOB *req_oob_type);
+static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB *req_oob_type);
#endif
static void bte_scan_filt_param_cfg_evt(UINT8 action_type,
uint32_t i;
bt_bdaddr_t bd_addr;
- BTIF_TRACE_EVENT("btif_dm_upstreams_cback ev: %s", dump_dm_event(event));
+ BTIF_TRACE_EVENT("%s: ev: %s", __func__, dump_dm_event(event));
switch (event)
{
BTIF_TRACE_DEBUG("BTA_DM_BLE_OOB_REQ_EVT. ");
btif_dm_ble_oob_req_evt(&p_data->rmt_oob);
break;
+ case BTA_DM_BLE_SC_OOB_REQ_EVT:
+ BTIF_TRACE_DEBUG("BTA_DM_BLE_SC_OOB_REQ_EVT. ");
+ btif_dm_ble_sc_oob_req_evt(&p_data->rmt_oob);
+ break;
case BTA_DM_BLE_LOCAL_IR_EVT:
BTIF_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
ble_local_key_cb.is_id_keys_rcvd = TRUE;
tBTA_LE_AUTH_REQ *p_auth_req)
{
- /* We currently support only Security Manager TK as OOB data for LE transport.
- If it's not present mark no OOB data.
- */
- if (!is_empty_128bit(oob_cb.oob_data.sm_tk))
- {
+ if (!is_empty_128bit(oob_cb.oob_data.le_sc_c) &&
+ !is_empty_128bit(oob_cb.oob_data.le_sc_r)) {
+ /* We have LE SC OOB data */
+
+ /* make sure OOB data is for this particular device */
+ if (memcmp(bd_addr, oob_cb.bdaddr, BD_ADDR_LEN) == 0) {
+ *p_auth_req = ((*p_auth_req) | BTM_LE_AUTH_REQ_SC_ONLY);
+ *p_has_oob_data = true;
+ } else {
+ *p_has_oob_data = false;
+ BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address",
+ __func__);
+ }
+ } else if (!is_empty_128bit(oob_cb.oob_data.sm_tk)) {
+ /* We have security manager TK */
+
/* make sure OOB data is for this particular device */
if (memcmp(bd_addr, oob_cb.bdaddr, BD_ADDR_LEN) == 0) {
// When using OOB with TK, SC Secure Connections bit must be disabled.
tBTA_LE_AUTH_REQ mask = ~BTM_LE_AUTH_REQ_SC_ONLY;
*p_auth_req = ((*p_auth_req) & mask);
- *p_has_oob_data = TRUE;
- }
- else
- {
- *p_has_oob_data = FALSE;
+ *p_has_oob_data = true;
+ } else {
+ *p_has_oob_data = false;
BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address",
__func__);
}
- }
- else
- {
- *p_has_oob_data = FALSE;
+ } else {
+ *p_has_oob_data = false;
}
BTIF_TRACE_DEBUG("%s *p_has_oob_data=%d", __func__, *p_has_oob_data);
}
bt_bdaddr_t bd_addr;
bdcpy(bd_addr.address, req_oob_type->bd_addr);
-
- /* We currently support only Security Manager TK as OOB data. We already
- * checked if it's present in btif_dm_set_oob_for_le_io_req, but check here
- * again. If it's not present do nothing, pairing will timeout.
+ /* We already checked if OOB data is present in
+ * btif_dm_set_oob_for_le_io_req, but check here again. If it's not present
+ * do nothing, pairing will timeout.
*/
if (is_empty_128bit(oob_cb.oob_data.sm_tk)) {
return;
BTM_BleOobDataReply(req_oob_type->bd_addr, 0, 16, oob_cb.oob_data.sm_tk);
}
+
+static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB *req_oob_type)
+{
+ BTIF_TRACE_DEBUG("%s", __func__);
+
+ bt_bdaddr_t bd_addr;
+ bdcpy(bd_addr.address, req_oob_type->bd_addr);
+
+ /* We already checked if OOB data is present in
+ * btif_dm_set_oob_for_le_io_req, but check here again. If it's not present
+ * do nothing, pairing will timeout.
+ */
+ if (!is_empty_128bit(oob_cb.oob_data.le_sc_c) &&
+ !is_empty_128bit(oob_cb.oob_data.le_sc_r)) {
+ return;
+ }
+
+ /* make sure OOB data is for this particular device */
+ if (memcmp(req_oob_type->bd_addr, oob_cb.bdaddr, BD_ADDR_LEN) != 0) {
+ BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address", __func__);
+ return;
+ }
+
+ /* Remote name update */
+ btif_update_remote_properties(req_oob_type->bd_addr , req_oob_type->bd_name,
+ NULL, BT_DEVICE_TYPE_BLE);
+
+ bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
+ pairing_cb.is_ssp = false;
+ pairing_cb.is_le_only = true; //TODO: we can derive classic pairing from this one
+ pairing_cb.is_le_nc = false;
+
+ BTM_BleSecureConnectionOobDataReply(req_oob_type->bd_addr,
+ oob_cb.oob_data.le_sc_c,
+ oob_cb.oob_data.le_sc_r);
+}
+
void btif_dm_update_ble_remote_properties( BD_ADDR bd_addr, BD_NAME bd_name,
tBT_DEVICE_TYPE dev_type)
{
** NULL if not found.
**
*******************************************************************************/
-tACL_CONN *btm_bda_to_acl (BD_ADDR bda, tBT_TRANSPORT transport)
+tACL_CONN *btm_bda_to_acl (const BD_ADDR bda, tBT_TRANSPORT transport)
{
tACL_CONN *p = &btm_cb.acl_db[0];
UINT16 xx;
tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_OOB_FAIL;
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
- BTM_TRACE_DEBUG ("BTM_BleOobDataReply");
+ BTM_TRACE_DEBUG ("%s:", __func__);
- if (p_dev_rec == NULL)
- {
- BTM_TRACE_ERROR("BTM_BleOobDataReply() to Unknown device");
+ if (p_dev_rec == NULL) {
+ BTM_TRACE_ERROR("%s: Unknown device", __func__);
return;
}
#endif
}
+/*******************************************************************************
+**
+** Function BTM_BleSecureConnectionOobDataReply
+**
+** Description This function is called to provide the OOB data for
+** SMP in response to BTM_LE_OOB_REQ_EVT when secure connection
+** data is available
+**
+** Parameters: bd_addr - Address of the peer device
+** p_c - pointer to Confirmation.
+** p_r - pointer to Randomizer
+**
+*******************************************************************************/
+void BTM_BleSecureConnectionOobDataReply(BD_ADDR bd_addr,
+ uint8_t *p_c, uint8_t *p_r)
+{
+#if SMP_INCLUDED == TRUE
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
+
+ BTM_TRACE_DEBUG ("%s:", __func__);
+
+ if (p_dev_rec == NULL) {
+ BTM_TRACE_ERROR("%s: Unknown device", __func__);
+ return;
+ }
+
+ p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
+
+ tSMP_SC_OOB_DATA oob;
+ memset(&oob, 0, sizeof(tSMP_SC_OOB_DATA));
+
+ oob.peer_oob_data.present = true;
+ memcpy(&oob.peer_oob_data.randomizer, p_r, BT_OCTET16_LEN);
+ memcpy(&oob.peer_oob_data.commitment, p_c, BT_OCTET16_LEN);
+ oob.peer_oob_data.addr_rcvd_from.type = p_dev_rec->ble.ble_addr_type;
+ memcpy(&oob.peer_oob_data.addr_rcvd_from.bda, bd_addr, sizeof(BD_ADDR));
+
+ SMP_SecureConnectionOobDataReply((uint8_t*)&oob);
+#endif
+}
+
/******************************************************************************
**
** Function BTM_BleSetConnScanParams
** Returns Pointer to the record or NULL
**
*******************************************************************************/
-tBTM_SEC_DEV_REC *btm_find_dev(BD_ADDR bd_addr)
+tBTM_SEC_DEV_REC *btm_find_dev(const BD_ADDR bd_addr)
{
if (!bd_addr)
return NULL;
- list_node_t *n = list_foreach(btm_cb.sec_dev_rec, is_address_equal, bd_addr);
+ list_node_t *n = list_foreach(btm_cb.sec_dev_rec, is_address_equal, (void*)bd_addr);
if (n)
return list_node(n);
** Returns pointer to entry, or NULL if not found
**
*******************************************************************************/
-tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda)
+tBTM_INQ_INFO *BTM_InqDbRead (const BD_ADDR p_bda)
{
BTM_TRACE_API ("BTM_InqDbRead: bd addr [%02x%02x%02x%02x%02x%02x]",
p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]);
** Returns pointer to entry, or NULL if not found
**
*******************************************************************************/
-tINQ_DB_ENT *btm_inq_db_find (BD_ADDR p_bda)
+tINQ_DB_ENT *btm_inq_db_find (const BD_ADDR p_bda)
{
UINT16 xx;
tINQ_DB_ENT *p_ent = btm_cb.btm_inq_vars.inq_db;
extern void btm_event_filter_complete (UINT8 *p);
extern void btm_inq_stop_on_ssp(void);
extern void btm_inq_clear_ssp(void);
-extern tINQ_DB_ENT *btm_inq_db_find (BD_ADDR p_bda);
+extern tINQ_DB_ENT *btm_inq_db_find (const BD_ADDR p_bda);
extern BOOLEAN btm_inq_find_bdaddr (BD_ADDR p_bda);
extern BOOLEAN btm_lookup_eir(BD_ADDR_PTR p_rem_addr);
extern void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type);
/* Read maximum data packet that can be sent over current connection */
extern UINT16 btm_get_max_packet_size (BD_ADDR addr);
-extern tACL_CONN *btm_bda_to_acl (BD_ADDR bda, tBT_TRANSPORT transport);
+extern tACL_CONN *btm_bda_to_acl (const BD_ADDR bda, tBT_TRANSPORT transport);
extern BOOLEAN btm_acl_notif_conn_collision (BD_ADDR bda);
extern void btm_pm_reset(void);
extern tBTM_SEC_DEV_REC *btm_sec_allocate_dev_rec(void);
extern tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr);
extern void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec);
-extern tBTM_SEC_DEV_REC *btm_find_dev (BD_ADDR bd_addr);
+extern tBTM_SEC_DEV_REC *btm_find_dev (const BD_ADDR bd_addr);
extern tBTM_SEC_DEV_REC *btm_find_or_alloc_dev (BD_ADDR bd_addr);
extern tBTM_SEC_DEV_REC *btm_find_dev_by_handle (UINT16 handle);
extern tBTM_BOND_TYPE btm_get_bond_type_dev(BD_ADDR bd_addr);
** Returns pointer to entry, or NULL if not found
**
*******************************************************************************/
-extern tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda);
+extern tBTM_INQ_INFO *BTM_InqDbRead (const BD_ADDR p_bda);
/*******************************************************************************
*******************************************************************************/
extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
+/*******************************************************************************
+**
+** Function BTM_BleSecureConnectionOobDataReply
+**
+** Description This function is called to provide the OOB data for
+** SMP in response to BTM_LE_OOB_REQ_EVT when secure connection
+** data is available
+**
+** Parameters: bd_addr - Address of the peer device
+** p_c - pointer to Confirmation
+** p_r - pointer to Randomizer.
+**
+*******************************************************************************/
+extern void BTM_BleSecureConnectionOobDataReply(BD_ADDR bd_addr,
+ uint8_t *p_c, uint8_t *p_r);
+
/*******************************************************************************
**