Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d93c32ac authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Use proper naming for Identity Address

During Bonding, devices exchange "Identity Address Information", which
include Identity Address, and Identity Address Type.

Identity Address is either Public Address, or Static Random Address.

Thorugh stack, we improperly use "static" where we should use
"identity" to refer to this address.

Bug: 109827460
Test: compilation, just renamed variables.
Change-Id: Iccee1e8ae881e9b9f480e0bf05eea440a905109a
parent ffecc8a5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -163,8 +163,8 @@ bool btm_ble_get_acl_remote_addr(tBTM_SEC_DEV_REC* p_dev_rec,
      break;

    case BTM_BLE_ADDR_STATIC:
      conn_addr = p_dev_rec->ble.static_addr;
      *p_addr_type = p_dev_rec->ble.static_addr_type;
      conn_addr = p_dev_rec->ble.identity_addr;
      *p_addr_type = p_dev_rec->ble.identity_addr_type;
      break;

    default:
+7 −6
Original line number Diff line number Diff line
@@ -1294,16 +1294,17 @@ void btm_sec_save_le_key(const RawAddress& bd_addr, tBTM_LE_KEY_TYPE key_type,

      case BTM_LE_KEY_PID:
        p_rec->ble.keys.irk = p_keys->pid_key.irk;
        p_rec->ble.static_addr = p_keys->pid_key.static_addr;
        p_rec->ble.static_addr_type = p_keys->pid_key.addr_type;
        p_rec->ble.identity_addr = p_keys->pid_key.identity_addr;
        p_rec->ble.identity_addr_type = p_keys->pid_key.identity_addr_type;
        p_rec->ble.key_type |= BTM_LE_KEY_PID;
        BTM_TRACE_DEBUG(
            "%s: BTM_LE_KEY_PID key_type=0x%x save peer IRK, change bd_addr=%s "
            "to static_addr=%s",
            "to id_addr=%s id_addr_type=0x%x",
            __func__, p_rec->ble.key_type, p_rec->bd_addr.ToString().c_str(),
            p_keys->pid_key.static_addr.ToString().c_str());
        /* update device record address as static address */
        p_rec->bd_addr = p_keys->pid_key.static_addr;
            p_keys->pid_key.identity_addr.ToString().c_str(),
            p_keys->pid_key.identity_addr_type);
        /* update device record address as identity address */
        p_rec->bd_addr = p_keys->pid_key.identity_addr;
        /* combine DUMO device security record if needed */
        btm_consolidate_dev(p_rec);
        break;
+11 −17
Original line number Diff line number Diff line
@@ -260,13 +260,7 @@ tBTM_SEC_DEV_REC* btm_ble_resolve_random_addr(const RawAddress& random_bda) {
/*******************************************************************************
 *  address mapping between pseudo address and real connection address
 ******************************************************************************/
/*******************************************************************************
 *
 * Function         btm_find_dev_by_identity_addr
 *
 * Description      find the security record whose LE static address is matching
 *
 ******************************************************************************/
/** Find the security record whose LE identity address is matching */
tBTM_SEC_DEV_REC* btm_find_dev_by_identity_addr(const RawAddress& bd_addr,
                                                uint8_t addr_type) {
#if (BLE_PRIVACY_SPT == TRUE)
@@ -275,12 +269,12 @@ tBTM_SEC_DEV_REC* btm_find_dev_by_identity_addr(const RawAddress& bd_addr,
       node = list_next(node)) {
    tBTM_SEC_DEV_REC* p_dev_rec =
        static_cast<tBTM_SEC_DEV_REC*>(list_node(node));
    if (p_dev_rec->ble.static_addr == bd_addr) {
      if ((p_dev_rec->ble.static_addr_type & (~BLE_ADDR_TYPE_ID_BIT)) !=
    if (p_dev_rec->ble.identity_addr == bd_addr) {
      if ((p_dev_rec->ble.identity_addr_type & (~BLE_ADDR_TYPE_ID_BIT)) !=
          (addr_type & (~BLE_ADDR_TYPE_ID_BIT)))
        BTM_TRACE_WARNING(
            "%s find pseudo->random match with diff addr type: %d vs %d",
            __func__, p_dev_rec->ble.static_addr_type, addr_type);
            __func__, p_dev_rec->ble.identity_addr_type, addr_type);

      /* found the match */
      return p_dev_rec;
@@ -333,16 +327,16 @@ bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
 *
 ******************************************************************************/
bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo,
                                        uint8_t* p_static_addr_type) {
                                        uint8_t* p_identity_addr_type) {
#if (BLE_PRIVACY_SPT == TRUE)
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(*random_pseudo);

  if (p_dev_rec != NULL) {
    if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) {
      *p_static_addr_type = p_dev_rec->ble.static_addr_type;
      *random_pseudo = p_dev_rec->ble.static_addr;
      *p_identity_addr_type = p_dev_rec->ble.identity_addr_type;
      *random_pseudo = p_dev_rec->ble.identity_addr;
      if (controller_get_interface()->supports_ble_privacy())
        *p_static_addr_type |= BLE_ADDR_TYPE_ID_BIT;
        *p_identity_addr_type |= BLE_ADDR_TYPE_ID_BIT;
      return true;
    }
  }
@@ -392,10 +386,10 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,

  if (p_acl != NULL) {
    if (rra_type == BTM_BLE_ADDR_PSEUDO) {
      /* use static address, resolvable_private_addr is empty */
      /* use identity address, resolvable_private_addr is empty */
      if (rra_dummy) {
        p_acl->active_remote_addr_type = p_sec_rec->ble.static_addr_type;
        p_acl->active_remote_addr = p_sec_rec->ble.static_addr;
        p_acl->active_remote_addr_type = p_sec_rec->ble.identity_addr_type;
        p_acl->active_remote_addr = p_sec_rec->ble.identity_addr;
      } else {
        p_acl->active_remote_addr_type = BLE_ADDR_RANDOM;
        p_acl->active_remote_addr = rpa;
+7 −7
Original line number Diff line number Diff line
@@ -171,10 +171,10 @@ bool btm_add_dev_to_controller(bool to_add, const RawAddress& bd_addr) {
        background_connection_add(p_dev_rec->ble.ble_addr_type, bd_addr);
        started = true;
        p_dev_rec->ble.in_controller_list |= BTM_WHITE_LIST_BIT;
      } else if (p_dev_rec->ble.static_addr != bd_addr &&
                 !p_dev_rec->ble.static_addr.IsEmpty()) {
        background_connection_add(p_dev_rec->ble.static_addr_type,
                                  p_dev_rec->ble.static_addr);
      } else if (p_dev_rec->ble.identity_addr != bd_addr &&
                 !p_dev_rec->ble.identity_addr.IsEmpty()) {
        background_connection_add(p_dev_rec->ble.identity_addr_type,
                                  p_dev_rec->ble.identity_addr);
        started = true;
        p_dev_rec->ble.in_controller_list |= BTM_WHITE_LIST_BIT;
      }
@@ -185,9 +185,9 @@ bool btm_add_dev_to_controller(bool to_add, const RawAddress& bd_addr) {
        started = true;
      }

      if (!p_dev_rec->ble.static_addr.IsEmpty() &&
          p_dev_rec->ble.static_addr != bd_addr) {
        background_connection_remove(p_dev_rec->ble.static_addr);
      if (!p_dev_rec->ble.identity_addr.IsEmpty() &&
          p_dev_rec->ble.identity_addr != bd_addr) {
        background_connection_remove(p_dev_rec->ble.identity_addr);
        started = true;
      }

+4 −4
Original line number Diff line number Diff line
@@ -822,8 +822,8 @@ static uint8_t btm_set_conn_mode_adv_init_addr(
        if ((p_dev_rec = btm_find_or_alloc_dev(p_cb->direct_bda.bda)) != NULL &&
            p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) {
          btm_ble_enable_resolving_list(BTM_BLE_RL_ADV);
          p_peer_addr_ptr = p_dev_rec->ble.static_addr;
          *p_peer_addr_type = p_dev_rec->ble.static_addr_type;
          p_peer_addr_ptr = p_dev_rec->ble.identity_addr;
          *p_peer_addr_type = p_dev_rec->ble.identity_addr_type;
          *p_own_addr_type = BLE_ADDR_RANDOM_ID;
          return evt_type;
        }
@@ -853,8 +853,8 @@ static uint8_t btm_set_conn_mode_adv_init_addr(
       * peer */
      tBTM_SEC_DEV_REC* p_dev_rec =
          static_cast<tBTM_SEC_DEV_REC*>(list_node(n));
      p_peer_addr_ptr = p_dev_rec->ble.static_addr;
      *p_peer_addr_type = p_dev_rec->ble.static_addr_type;
      p_peer_addr_ptr = p_dev_rec->ble.identity_addr;
      *p_peer_addr_type = p_dev_rec->ble.identity_addr_type;

      *p_own_addr_type = BLE_ADDR_RANDOM_ID;
    } else {
Loading