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

Commit 37229509 authored by Chris Manton's avatar Chris Manton
Browse files

Provide more suitable API to rotate le address

stack/acl/btm_acl.cc:: acl_refresh_remote_address()

Working towards encapsulation of tACL_CONN

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions workingcompiles

Change-Id: I1596a245a46c8d78a4c35a0d1e81a57b0eb77e85
parent be6ac81e
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -2410,3 +2410,30 @@ bool acl_is_role_master(const RawAddress& bda, tBT_TRANSPORT transport) {
bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x) {
  return ((x.address)[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB;
}

bool acl_refresh_remote_address(const tBTM_SEC_DEV_REC* p_sec_rec,
                                const RawAddress& bda, tBT_TRANSPORT transport,
                                uint8_t rra_type, const RawAddress& rpa) {
  tACL_CONN* p_acl = btm_bda_to_acl(bda, transport);
  if (p_acl == nullptr) {
    return false;
  }

  if (rra_type == BTM_BLE_ADDR_PSEUDO) {
    /* use identity address, resolvable_private_addr is empty */
    if (rpa.IsEmpty()) {
      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;
    }
  } else {
    p_acl->active_remote_addr_type = rra_type;
    p_acl->active_remote_addr = rpa;
  }

  BTM_TRACE_DEBUG("%s active_remote_addr_type: %d ", __func__,
                  p_acl->active_remote_addr_type);
  return true;
}
+6 −21
Original line number Diff line number Diff line
@@ -335,28 +335,13 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,
                  p_sec_rec->ble.active_addr_type);

  /* connection refresh remote address */
  tACL_CONN* p_acl = btm_bda_to_acl(p_sec_rec->bd_addr, BT_TRANSPORT_LE);
  if (p_acl == NULL)
    p_acl = btm_bda_to_acl(p_sec_rec->ble.pseudo_addr, BT_TRANSPORT_LE);

  if (p_acl != NULL) {
    if (rra_type == BTM_BLE_ADDR_PSEUDO) {
      /* use identity address, resolvable_private_addr is empty */
      if (rpa.IsEmpty()) {
        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;
      }
    } else {
      p_acl->active_remote_addr_type = rra_type;
      p_acl->active_remote_addr = rpa;
  if (!acl_refresh_remote_address(p_sec_rec, p_sec_rec->bd_addr,
                                  BT_TRANSPORT_LE, rra_type, rpa)) {
    // Try looking up the pseudo random address
    if (!acl_refresh_remote_address(p_sec_rec, p_sec_rec->ble.pseudo_addr,
                                    BT_TRANSPORT_LE, rra_type, rpa)) {
      BTM_TRACE_ERROR("%s Unknown device to refresh remote device", __func__);
    }

    BTM_TRACE_DEBUG("p_acl->active_remote_addr_type: %d ",
                    p_acl->active_remote_addr_type);
    VLOG(1) << __func__ << " conn_addr: " << p_acl->active_remote_addr;
  }
#endif
}
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <cstdint>

#include "stack/acl/acl.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/acl_api_types.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_status.h"
@@ -244,3 +245,8 @@ bool acl_is_role_master(const RawAddress& remote_bda, tBT_TRANSPORT transport);
#define BLE_RESOLVE_ADDR_MSB 0x40

bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x);

bool acl_refresh_remote_address(const tBTM_SEC_DEV_REC* p_dev_rec,
                                const RawAddress& remote_bda,
                                tBT_TRANSPORT transport, uint8_t rra_type,
                                const RawAddress& rpa);