return callback_rc;
}
-#if (BLE_PRIVACY_SPT == TRUE)
-/*******************************************************************************
- *
- * Function btm_ble_resolve_random_addr_on_conn_cmpl
- *
- * Description resolve random address complete on connection complete
- * event.
- *
- * Returns void
- *
- ******************************************************************************/
-static void btm_ble_resolve_random_addr_on_conn_cmpl(void* p_rec,
- void* p_data) {
- uint8_t* p = (uint8_t*)p_data;
- tBTM_SEC_DEV_REC* match_rec = (tBTM_SEC_DEV_REC*)p_rec;
- uint8_t role, bda_type;
- uint16_t handle;
- BD_ADDR bda;
- uint16_t conn_interval, conn_latency, conn_timeout;
- bool match = false;
-
- ++p;
- STREAM_TO_UINT16(handle, p);
- STREAM_TO_UINT8(role, p);
- STREAM_TO_UINT8(bda_type, p);
- STREAM_TO_BDADDR(bda, p);
- STREAM_TO_UINT16(conn_interval, p);
- STREAM_TO_UINT16(conn_latency, p);
- STREAM_TO_UINT16(conn_timeout, p);
-
- handle = HCID_GET_HANDLE(handle);
-
- BTM_TRACE_EVENT("%s", __func__);
-
- if (match_rec) {
- LOG_INFO(LOG_TAG, "%s matched and resolved random address", __func__);
- match = true;
- match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
- memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
- if (!btm_ble_init_pseudo_addr(match_rec, bda)) {
- /* assign the original address to be the current report address */
- memcpy(bda, match_rec->ble.pseudo_addr, BD_ADDR_LEN);
- } else {
- memcpy(bda, match_rec->bd_addr, BD_ADDR_LEN);
- }
- } else {
- LOG_INFO(LOG_TAG, "%s unable to match and resolve random address",
- __func__);
- }
-
- btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type,
- match);
-
- l2cble_conn_comp(handle, role, bda, bda_type, conn_interval, conn_latency,
- conn_timeout);
-
- return;
-}
-#endif
-
/*******************************************************************************
*
* Function btm_ble_connected
void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,
bool enhanced) {
#if (BLE_PRIVACY_SPT == TRUE)
- uint8_t *p_data = p, peer_addr_type;
+ uint8_t peer_addr_type;
BD_ADDR local_rpa, peer_rpa;
#endif
uint8_t role, status, bda_type;
STREAM_TO_BDADDR(peer_rpa, p);
}
+ STREAM_TO_UINT16(conn_interval, p);
+ STREAM_TO_UINT16(conn_latency, p);
+ STREAM_TO_UINT16(conn_timeout, p);
+ handle = HCID_GET_HANDLE(handle);
+
/* possiblly receive connection complete with resolvable random while
the device has been paired */
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
- btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl,
- p_data);
- } else
+ tBTM_SEC_DEV_REC* match_rec = btm_ble_resolve_random_addr(bda);
+ if (match_rec) {
+ LOG_INFO(LOG_TAG, "%s matched and resolved random address", __func__);
+ match = true;
+ match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
+ memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
+ if (!btm_ble_init_pseudo_addr(match_rec, bda)) {
+ /* assign the original address to be the current report address */
+ memcpy(bda, match_rec->ble.pseudo_addr, BD_ADDR_LEN);
+ } else {
+ memcpy(bda, match_rec->bd_addr, BD_ADDR_LEN);
+ }
+ } else {
+ LOG_INFO(LOG_TAG, "%s unable to match and resolve random address",
+ __func__);
+ }
+ }
#endif
- {
- STREAM_TO_UINT16(conn_interval, p);
- STREAM_TO_UINT16(conn_latency, p);
- STREAM_TO_UINT16(conn_timeout, p);
- handle = HCID_GET_HANDLE(handle);
- btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type,
- match);
+ btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type,
+ match);
- l2cble_conn_comp(handle, role, bda, bda_type, conn_interval, conn_latency,
- conn_timeout);
+ l2cble_conn_comp(handle, role, bda, bda_type, conn_interval, conn_latency,
+ conn_timeout);
#if (BLE_PRIVACY_SPT == TRUE)
- if (enhanced) {
- btm_ble_refresh_local_resolvable_private_addr(bda, local_rpa);
+ if (enhanced) {
+ btm_ble_refresh_local_resolvable_private_addr(bda, local_rpa);
- if (peer_addr_type & BLE_ADDR_TYPE_ID_BIT)
- btm_ble_refresh_peer_resolvable_private_addr(bda, peer_rpa,
- BLE_ADDR_RANDOM);
- }
-#endif
+ if (peer_addr_type & BLE_ADDR_TYPE_ID_BIT)
+ btm_ble_refresh_peer_resolvable_private_addr(bda, peer_rpa,
+ BLE_ADDR_RANDOM);
}
+#endif
} else {
role = HCI_ROLE_UNKNOWN;
if (status != HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT) {
*
******************************************************************************/
static bool btm_ble_match_random_bda(void* data, void* context) {
+ uint8_t* random_bda = (uint8_t*)context;
/* use the 3 MSB of bd address as prand */
- tBTM_LE_RANDOM_CB* p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
uint8_t rand[3];
- rand[0] = p_mgnt_cb->random_bda[2];
- rand[1] = p_mgnt_cb->random_bda[1];
- rand[2] = p_mgnt_cb->random_bda[0];
+ rand[0] = random_bda[2];
+ rand[1] = random_bda[1];
+ rand[2] = random_bda[0];
BTM_TRACE_EVENT("%s next iteration", __func__);
* address is matched to.
*
******************************************************************************/
-void btm_ble_resolve_random_addr(BD_ADDR random_bda,
- tBTM_BLE_RESOLVE_CBACK* p_cback, void* p) {
- tBTM_LE_RANDOM_CB* p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
-
+tBTM_SEC_DEV_REC* btm_ble_resolve_random_addr(BD_ADDR random_bda) {
BTM_TRACE_EVENT("%s", __func__);
- if (!p_mgnt_cb->busy) {
- p_mgnt_cb->p = p;
- p_mgnt_cb->busy = true;
- memcpy(p_mgnt_cb->random_bda, random_bda, BD_ADDR_LEN);
- /* start to resolve random address */
- /* check for next security record */
-
- list_node_t* n =
- list_foreach(btm_cb.sec_dev_rec, btm_ble_match_random_bda, NULL);
- tBTM_SEC_DEV_REC* p_dev_rec = NULL;
- if (n != NULL) p_dev_rec = static_cast<tBTM_SEC_DEV_REC*>(list_node(n));
-
- BTM_TRACE_EVENT("%s: %sresolved", __func__,
- (p_dev_rec == NULL ? "not " : ""));
- p_mgnt_cb->busy = false;
-
- (*p_cback)(p_dev_rec, p);
- } else {
- (*p_cback)(NULL, p);
- }
+
+ /* start to resolve random address */
+ /* check for next security record */
+
+ list_node_t* n =
+ list_foreach(btm_cb.sec_dev_rec, btm_ble_match_random_bda, random_bda);
+ tBTM_SEC_DEV_REC* p_dev_rec = nullptr;
+ if (n != nullptr) p_dev_rec = static_cast<tBTM_SEC_DEV_REC*>(list_node(n));
+
+ BTM_TRACE_EVENT("%s: %sresolved", __func__,
+ (p_dev_rec == nullptr ? "not " : ""));
+ return p_dev_rec;
}
/*******************************************************************************
: BTM_BLE_MULTI_ADV_MAX;
}
-#if (BLE_PRIVACY_SPT == TRUE)
-/*******************************************************************************
- *
- * Function btm_ble_resolve_random_addr_on_adv
- *
- * Description resolve random address complete callback.
- *
- * Returns void
- *
- ******************************************************************************/
-static void btm_ble_resolve_random_addr_on_adv(void* p_rec, void* p) {
- tBTM_SEC_DEV_REC* match_rec = (tBTM_SEC_DEV_REC*)p_rec;
- uint8_t addr_type = BLE_ADDR_RANDOM;
- BD_ADDR bda;
- uint8_t* pp = (uint8_t*)p + 1;
- uint8_t evt_type;
-
- BTM_TRACE_EVENT("btm_ble_resolve_random_addr_on_adv ");
-
- STREAM_TO_UINT8(evt_type, pp);
- STREAM_TO_UINT8(addr_type, pp);
- STREAM_TO_BDADDR(bda, pp);
-
- if (match_rec) {
- BTM_TRACE_DEBUG("Random match");
- match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
- memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
-
- if (btm_ble_init_pseudo_addr(match_rec, bda)) {
- memcpy(bda, match_rec->bd_addr, BD_ADDR_LEN);
- } else {
- // Assign the original address to be the current report address
- memcpy(bda, match_rec->ble.pseudo_addr, BD_ADDR_LEN);
- }
- }
-
- btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, pp);
-
- return;
-}
-#endif
-
/*******************************************************************************
*
* Function BTM_BleLocalPrivacyEnabled
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
/* always do RRA resolution on host */
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
- btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv,
- p_data);
- } else
+ tBTM_SEC_DEV_REC* match_rec = btm_ble_resolve_random_addr(bda);
+ if (match_rec) {
+ BTM_TRACE_DEBUG("Random match");
+ match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
+ memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
+
+ if (btm_ble_init_pseudo_addr(match_rec, bda)) {
+ memcpy(bda, match_rec->bd_addr, BD_ADDR_LEN);
+ } else {
+ // Assign the original address to be the current report address
+ memcpy(bda, match_rec->ble.pseudo_addr, BD_ADDR_LEN);
+ }
+ }
+ }
#endif
- btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
+
+ btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
STREAM_TO_UINT8(data_len, p);