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

Commit 84ff0696 authored by Myles Watson's avatar Myles Watson
Browse files

Security: Move parsing to HCI: sec requests

The security code should not have to parse packets.

Bug: 301661850
Test: mma -j32
Change-Id: Ib93760e92cfc432a7cb0927dc9c96bc00f813b70
parent 18e0f981
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -4120,10 +4120,7 @@ void btm_sec_link_key_notification(const RawAddress& p_bda,
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
void btm_sec_link_key_request(const uint8_t* p_event) {
  RawAddress bda;

  STREAM_TO_BDADDR(bda, p_event);
void btm_sec_link_key_request(const RawAddress bda) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bda);

  VLOG(2) << __func__ << " bda: " << ADDRESS_TO_LOGGABLE_STR(bda);
@@ -4271,12 +4268,9 @@ static void btm_sec_pairing_timeout(void* /* data */) {
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
void btm_sec_pin_code_request(const uint8_t* p_event) {
void btm_sec_pin_code_request(const RawAddress p_bda) {
  tBTM_SEC_DEV_REC* p_dev_rec;
  tBTM_SEC_CB* p_cb = &btm_sec_cb;
  RawAddress p_bda;

  STREAM_TO_BDADDR(p_bda, p_event);

  /* Tell L2CAP that there was a PIN code request,  */
  /* it may need to stretch timeouts                */
+2 −2
Original line number Diff line number Diff line
@@ -686,7 +686,7 @@ void btm_sec_link_key_notification(const RawAddress& p_bda,
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
void btm_sec_link_key_request(const uint8_t* p_event);
void btm_sec_link_key_request(const RawAddress bda);

/*******************************************************************************
 *
@@ -697,7 +697,7 @@ void btm_sec_link_key_request(const uint8_t* p_event);
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
void btm_sec_pin_code_request(const uint8_t* p_event);
void btm_sec_pin_code_request(const RawAddress bda);

/*******************************************************************************
 *
+15 −2
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ static void btu_hcif_esco_connection_chg_evt(uint8_t* p);

/* Parsing functions for btm functions */

static void btu_hcif_sec_pin_code_request(const uint8_t* p);
static void btu_hcif_sec_link_key_request(const uint8_t* p);
static void btu_hcif_rem_oob_req(const uint8_t* p);
static void btu_hcif_simple_pair_complete(const uint8_t* p);
static void btu_hcif_create_conn_cancel_complete(const uint8_t* p,
@@ -277,10 +279,10 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
      btu_hcif_mode_change_evt(p);
      break;
    case HCI_PIN_CODE_REQUEST_EVT:
      btm_sec_pin_code_request(p);
      btu_hcif_sec_pin_code_request(p);
      break;
    case HCI_LINK_KEY_REQUEST_EVT:
      btm_sec_link_key_request(p);
      btu_hcif_sec_link_key_request(p);
      break;
    case HCI_LINK_KEY_NOTIFICATION_EVT:
      btu_hcif_link_key_notification_evt(p);
@@ -1424,6 +1426,17 @@ static void btu_hcif_mode_change_evt(uint8_t* p) {

/* Parsing functions for btm functions */

void btu_hcif_sec_pin_code_request(const uint8_t* p) {
  RawAddress bda;

  STREAM_TO_BDADDR(bda, p);
  btm_sec_pin_code_request(bda);
}
void btu_hcif_sec_link_key_request(const uint8_t* p) {
  RawAddress bda;
  STREAM_TO_BDADDR(bda, p);
  btm_sec_link_key_request(bda);
}
void btu_hcif_rem_oob_req(const uint8_t* p) {
  RawAddress bda;
  STREAM_TO_BDADDR(bda, p);
+2 −2
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
                            uint8_t encr_enable);
void btm_sec_link_key_notification(const RawAddress& p_bda,
                                   const Octet16& link_key, uint8_t key_type);
void btm_sec_link_key_request(const uint8_t* p_event);
void btm_sec_pin_code_request(const uint8_t* p_event);
void btm_sec_link_key_request(const RawAddress bda);
void btm_sec_pin_code_request(const RawAddress p_bda);
void btm_sec_rmt_host_support_feat_evt(const uint8_t* p);
void btm_sec_rmt_name_request_complete(const RawAddress* bd_addr,
                                       const uint8_t* bd_name,
+4 −4
Original line number Diff line number Diff line
@@ -423,9 +423,9 @@ void btm_sec_link_key_notification(const RawAddress& p_bda,
  test::mock::stack_btm_sec::btm_sec_link_key_notification(p_bda, link_key,
                                                           key_type);
}
void btm_sec_link_key_request(const uint8_t* p_event) {
void btm_sec_link_key_request(const RawAddress bda) {
  inc_func_call_count(__func__);
  test::mock::stack_btm_sec::btm_sec_link_key_request(p_event);
  test::mock::stack_btm_sec::btm_sec_link_key_request(bda);
}
tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
                                      bool is_originator,
@@ -436,9 +436,9 @@ tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
  return test::mock::stack_btm_sec::btm_sec_mx_access_request(
      bd_addr, is_originator, security_required, p_callback, p_ref_data);
}
void btm_sec_pin_code_request(const uint8_t* p_event) {
void btm_sec_pin_code_request(const RawAddress bda) {
  inc_func_call_count(__func__);
  test::mock::stack_btm_sec::btm_sec_pin_code_request(p_event);
  test::mock::stack_btm_sec::btm_sec_pin_code_request(bda);
}
void btm_sec_rmt_host_support_feat_evt(const uint8_t* p) {
  inc_func_call_count(__func__);
Loading