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

Commit 2570b7dd authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Remove legacy resolving list code am: e3d987d9 am: a88aac8d

parents 6eefbfcd a88aac8d
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -65,8 +65,6 @@ static bool acl_ble_common_connection(const tBLE_BD_ADDR& address_with_type,
    return false;
  }

  btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, true);

  /* Tell BTM Acl management about the link */
  btm_acl_created(address_with_type.bda, handle, role, BT_TRANSPORT_LE);

@@ -154,12 +152,10 @@ void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type,
  if (status != HCI_ERR_ADVERTISING_TIMEOUT) {
    btm_cb.ble_ctr_cb.set_connection_state_idle();
    btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
    btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, true);
    connection_manager::on_connection_timed_out_from_shim(
        address_with_type.bda);
  } else {
    btm_cb.ble_ctr_cb.inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
    btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, true);
  }
  btm_ble_update_mode_operation(HCI_ROLE_UNKNOWN, &address_with_type.bda,
                                status);
+0 −30
Original line number Diff line number Diff line
@@ -524,10 +524,6 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
      p_inq->scan_type = (p_inq->scan_type == BTM_BLE_SCAN_MODE_NONE)
                             ? BTM_BLE_SCAN_MODE_ACTI
                             : p_inq->scan_type;
      /* assume observe always not using acceptlist */
      /* enable resolving list */
      btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);

      btm_send_hci_set_scan_params(
          p_inq->scan_type, (uint16_t)scan_interval, (uint16_t)scan_window,
          btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, BTM_BLE_DEFAULT_SFP);
@@ -916,12 +912,6 @@ void btm_ble_start_sync_request(uint8_t sid, RawAddress addr, uint16_t skip,
    address_type = p_i->inq_info.results.ble_addr_type;  // Random
  }
  btm_random_pseudo_to_identity_addr(&addr, &address_type);
  if (address_type & BLE_ADDR_TYPE_ID_BIT) {
#if (BLE_PRIVACY_SPT == TRUE)
    LOG_INFO("Enable resolving list");
    btm_ble_enable_resolving_list(BTM_BLE_RL_SCAN);
#endif
  }
  address_type &= ~BLE_ADDR_TYPE_ID_BIT;
  uint8_t options = 0;
  uint8_t cte_type = 7;
@@ -1111,9 +1101,6 @@ void btm_ble_periodic_adv_sync_established(uint8_t status, uint16_t sync_handle,
  tBLE_ADDR_TYPE ble_addr_type = to_ble_addr_type(address_type);
  if (ble_addr_type & BLE_ADDR_TYPE_ID_BIT) {
    btm_identity_addr_to_random_pseudo(&bda, &ble_addr_type, true);
#if (BLE_PRIVACY_SPT == TRUE)
    btm_ble_disable_resolving_list(BTM_BLE_RL_SCAN, true);
#endif
  }
  int index = btm_ble_get_psync_index(adv_sid, bda);
  if (index == MAX_SYNC_TRANSACTION) {
@@ -1531,16 +1518,12 @@ static uint8_t btm_set_conn_mode_adv_init_addr(
        /* only do so for bonded device */
        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.identity_address_with_type.bda;
          *p_peer_addr_type = p_dev_rec->ble.identity_address_with_type.type;
          *p_own_addr_type = BLE_ADDR_RANDOM_ID;
          return evt_type;
        }
        /* otherwise fall though as normal directed adv */
        else {
          btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, true);
        }
      }
      /* direct adv mode does not have privacy, if privacy is not enabled  */
      *p_peer_addr_type = p_cb->direct_bda.type;
@@ -1833,8 +1816,6 @@ tBTM_STATUS btm_ble_set_discoverability(uint16_t combined_mode) {
    /* start initial GAP mode adv timer */
    alarm_set_on_mloop(p_cb->fast_adv_timer, BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS,
                       btm_ble_fast_adv_timer_timeout, NULL);
  } else {
    btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, true);
  }

  /* set up stop advertising timer */
@@ -1918,8 +1899,6 @@ tBTM_STATUS btm_ble_set_connectability(uint16_t combined_mode) {
    /* start initial GAP mode adv timer */
    alarm_set_on_mloop(p_cb->fast_adv_timer, BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS,
                       btm_ble_fast_adv_timer_timeout, NULL);
  } else {
    btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, true);
  }
  return status;
}
@@ -2021,8 +2000,6 @@ tBTM_STATUS btm_ble_start_inquiry(uint8_t duration) {
        BTM_BLE_SCAN_MODE_ACTI, BTM_BLE_LOW_LATENCY_SCAN_INT,
        BTM_BLE_LOW_LATENCY_SCAN_WIN,
        btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, SP_ADV_ALL);
    /* enable IRK list */
    btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
    p_ble_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_ACTI;
    btm_ble_start_scan();
  } else if ((p_ble_cb->inq_var.scan_interval !=
@@ -3066,13 +3043,6 @@ tBTM_STATUS btm_ble_start_adv(void) {
  if (!btm_ble_adv_states_operation(btm_ble_topology_check, p_cb->evt_type))
    return BTM_WRONG_MODE;

  /* To relax resolving list,  always have resolving list enabled, unless
   * directed adv */
  if (p_cb->evt_type != BTM_BLE_CONNECT_LO_DUTY_DIR_EVT &&
      p_cb->evt_type != BTM_BLE_CONNECT_DIR_EVT)
    /* enable resolving list is desired */
    btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_ADV);

  btsnd_hcic_ble_set_adv_enable(BTM_BLE_ADV_ENABLE);
  p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
  btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
+0 −5
Original line number Diff line number Diff line
@@ -121,12 +121,7 @@ extern bool btm_ble_addr_resolvable(const RawAddress& rpa,
                                    tBTM_SEC_DEV_REC* p_dev_rec);

extern void btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC& p_dev_rec);
extern bool btm_ble_resolving_list_load_dev(
    tBTM_SEC_DEV_REC* p_dev_rec);  // DEPRECATED
extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec);
extern void btm_ble_enable_resolving_list(uint8_t);
extern bool btm_ble_disable_resolving_list(uint8_t rl_mask, bool to_resume);
extern void btm_ble_enable_resolving_list_for_platform(uint8_t rl_mask);
extern void btm_ble_resolving_list_init(uint8_t max_irk_list_sz);

extern void btm_ble_adv_init(void);
+0 −187
Original line number Diff line number Diff line
@@ -503,131 +503,6 @@ bool btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC* p_dev_rec) {
  return true;
}

/*******************************************************************************
 *
 * Function         btm_ble_disable_resolving_list
 *
 * Description      Disable LE Address resolution
 *
 * Returns          none
 *
 ******************************************************************************/
bool btm_ble_disable_resolving_list(uint8_t rl_mask, bool to_resume) {
  LOG_DEBUG("GD automatically disables Address Resolution list");
  return true;
}

/*******************************************************************************
 *
 * Function         btm_ble_resolving_list_load_dev
 *
 * Description      This function adds a device which is using RPA into the
 *                  acceptlist.
 *
 * Parameters       pointer to device security record
 *
 * Returns          true if device added, otherwise falase.
 *
 ******************************************************************************/
bool btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC* p_dev_rec) {
  ASSERT_LOG(false,
             "API is disabled...use signature <void(tBTM_SEC_DEV_REC&)>");

  const uint8_t rl_state = btm_cb.ble_ctr_cb.rl_state;

  if (controller_get_interface()->get_ble_resolving_list_max_size() == 0) {
    BTM_TRACE_DEBUG(
        "%s: Controller does not support RPA offloading or privacy 1.2",
        __func__);
    return false;
  }

  BTM_TRACE_DEBUG("%s: btm_cb.ble_ctr_cb.privacy_mode = %d", __func__,
                  btm_cb.ble_ctr_cb.privacy_mode);

  if (!p_dev_rec) {
    BTM_TRACE_DEBUG("%s: No device security record", __func__);
    return false;
  }

  /* only add RPA enabled device into resolving list */
  if (controller_get_interface()->supports_ble_privacy()) {
    if ((p_dev_rec->ble.key_type & (BTM_LE_KEY_PID | BTM_LE_KEY_LID)) == 0) {
      BTM_TRACE_DEBUG("%s: privacy 1.2: Device not a RPA enabled device",
                      __func__);
      return false;
    }
  } else if ((p_dev_rec->ble.key_type & BTM_LE_KEY_PID) == 0) {
    BTM_TRACE_DEBUG("%s: RPA offloading: Device not a RPA enabled device",
                    __func__);
    return false;
  }

  if ((p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) ||
      btm_ble_brcm_find_resolving_pending_entry(p_dev_rec->bd_addr,
                                                BTM_BLE_META_ADD_IRK_ENTRY)) {
    BTM_TRACE_ERROR("%s: Device already in Resolving list", __func__);
    return true;
  }

  if (btm_cb.ble_ctr_cb.resolving_list_avail_size == 0) {
    return false;
  }

  if (rl_state && !btm_ble_disable_resolving_list(rl_state, false)) {
    return false;
  }

  if (controller_get_interface()->supports_ble_privacy()) {
    const Octet16& peer_irk = p_dev_rec->ble.keys.irk;
    const Octet16& local_irk = btm_cb.devcb.id_keys.irk;

    if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) {
      p_dev_rec->ble.identity_address_with_type.bda = p_dev_rec->bd_addr;
      p_dev_rec->ble.identity_address_with_type.type =
          p_dev_rec->ble.AddressType();
    }

    BTM_TRACE_DEBUG(
        "%s: adding device %s to controller resolving list", __func__,
        p_dev_rec->ble.identity_address_with_type.bda.ToString().c_str());

    // use identical IRK for now
    btsnd_hcic_ble_add_device_resolving_list(
        p_dev_rec->ble.identity_address_with_type.type,
        p_dev_rec->ble.identity_address_with_type.bda, peer_irk, local_irk);

    if (controller_get_interface()->supports_ble_set_privacy_mode()) {
      BTM_TRACE_DEBUG("%s: adding device privacy mode", __func__);
      btsnd_hcic_ble_set_privacy_mode(
          p_dev_rec->ble.identity_address_with_type.type,
          p_dev_rec->ble.identity_address_with_type.bda, 0x01);
    }
  } else {
    uint8_t param[40] = {0};
    uint8_t* p = param;

    UINT8_TO_STREAM(p, BTM_BLE_META_ADD_IRK_ENTRY);
    ARRAY_TO_STREAM(p, p_dev_rec->ble.keys.irk, OCTET16_LEN);
    UINT8_TO_STREAM(p, p_dev_rec->ble.identity_address_with_type.type);
    BDADDR_TO_STREAM(p, p_dev_rec->ble.identity_address_with_type.bda);

    BTM_VendorSpecificCommand(HCI_VENDOR_BLE_RPA_VSC, BTM_BLE_META_ADD_IRK_LEN,
                              param, btm_ble_resolving_list_vsc_op_cmpl);
  }

  btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
                                     BTM_BLE_META_ADD_IRK_ENTRY);

  /* if resolving list has been turned on, re-enable it */
  if (rl_state)
    btm_ble_enable_resolving_list(rl_state);
  else
    btm_ble_enable_resolving_list(BTM_BLE_RL_INIT);

  return true;
}

static void btm_ble_ble_unsupported_resolving_list_load_dev(
    tBTM_SEC_DEV_REC* p_dev_rec) {
  LOG_INFO("Controller does not support BLE privacy");
@@ -707,12 +582,7 @@ void btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC& dev_rec) {
 *
 ******************************************************************************/
void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec) {
  uint8_t rl_mask = btm_cb.ble_ctr_cb.rl_state;

  BTM_TRACE_EVENT("%s", __func__);
  if (rl_mask) {
    if (!btm_ble_disable_resolving_list(rl_mask, false)) return;
  }

  if ((p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) &&
      !btm_ble_brcm_find_resolving_pending_entry(
@@ -722,63 +592,6 @@ void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec) {
  } else {
    BTM_TRACE_DEBUG("Device not in resolving list");
  }

  /* if resolving list has been turned on, re-enable it */
  if (rl_mask) btm_ble_enable_resolving_list(rl_mask);
}

/*******************************************************************************
 *
 * Function         btm_ble_enable_resolving_list
 *
 * Description      enable LE resolve address list
 *
 * Returns          none
 *
 ******************************************************************************/
void btm_ble_enable_resolving_list(uint8_t rl_mask) {
  LOG_DEBUG("GD automatically enables Address Resolution list");
}

static bool is_on_resolving_list(void* data, void* context) {
  tBTM_SEC_DEV_REC* p_dev = static_cast<tBTM_SEC_DEV_REC*>(data);
  if ((p_dev->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) &&
      (p_dev->ble.in_controller_list & BTM_ACCEPTLIST_BIT))
    return false;

  return true;
}

/*******************************************************************************
 *
 * Function         btm_ble_enable_resolving_list_for_platform
 *
 * Description      enable/disable resolving list feature depending on if any
 *                  resolving list is empty and acceptlist is involoved in the
 *                  operation.
 *
 * Returns          none
 *
 ******************************************************************************/
void btm_ble_enable_resolving_list_for_platform(uint8_t rl_mask) {
  /* if controller does not support, skip */
  if (controller_get_interface()->get_ble_resolving_list_max_size() == 0)
    return;

  if (btm_cb.ble_ctr_cb.wl_state == BTM_BLE_WL_IDLE) {
    if (controller_get_interface()->get_ble_resolving_list_max_size() >
        btm_cb.ble_ctr_cb.resolving_list_avail_size)
      btm_ble_enable_resolving_list(rl_mask);
    else
      btm_ble_disable_resolving_list(rl_mask, true);
    return;
  }

  list_node_t* n = list_foreach(btm_cb.sec_dev_rec, is_on_resolving_list, NULL);
  if (n)
    btm_ble_enable_resolving_list(rl_mask);
  else
    btm_ble_disable_resolving_list(rl_mask, true);
}

/*******************************************************************************
+0 −67
Original line number Diff line number Diff line
@@ -593,73 +593,6 @@ void btsnd_hcic_ble_rc_param_req_neg_reply(uint16_t handle, uint8_t reason) {
  btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}

void btsnd_hcic_ble_add_device_resolving_list(uint8_t addr_type_peer,
                                              const RawAddress& bda_peer,
                                              const Octet16& irk_peer,
                                              const Octet16& irk_local) {
  BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
  uint8_t* pp = (uint8_t*)(p + 1);

  p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST;
  p->offset = 0;

  UINT16_TO_STREAM(pp, HCI_BLE_ADD_DEV_RESOLVING_LIST);
  UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST);
  UINT8_TO_STREAM(pp, addr_type_peer);
  BDADDR_TO_STREAM(pp, bda_peer);
  ARRAY_TO_STREAM(pp, irk_peer.data(), HCIC_BLE_ENCRYPT_KEY_SIZE);
  ARRAY_TO_STREAM(pp, irk_local.data(), HCIC_BLE_ENCRYPT_KEY_SIZE);

  btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}

void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer,
                                             const RawAddress& bda_peer) {
  BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
  uint8_t* pp = (uint8_t*)(p + 1);

  p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST;
  p->offset = 0;

  UINT16_TO_STREAM(pp, HCI_BLE_RM_DEV_RESOLVING_LIST);
  UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST);
  UINT8_TO_STREAM(pp, addr_type_peer);
  BDADDR_TO_STREAM(pp, bda_peer);

  btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}

void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer,
                                     const RawAddress& bda_peer,
                                     uint8_t privacy_type) {
  BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
  uint8_t* pp = (uint8_t*)(p + 1);

  p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE;
  p->offset = 0;

  UINT16_TO_STREAM(pp, HCI_BLE_SET_PRIVACY_MODE);
  UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE);
  UINT8_TO_STREAM(pp, addr_type_peer);
  BDADDR_TO_STREAM(pp, bda_peer);
  UINT8_TO_STREAM(pp, privacy_type);

  btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}

void btsnd_hcic_ble_clear_resolving_list(void) {
  BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
  uint8_t* pp = (uint8_t*)(p + 1);

  p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST;
  p->offset = 0;

  UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_RESOLVING_LIST);
  UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST);

  btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}

void btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer,
                                              const RawAddress& bda_peer) {
  BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
Loading