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

Commit 24b430cc authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "legacy: Re-log stack/bnep::" am: 47f0a16a

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1853871

Change-Id: If2fd77460ca586732e818c9a4de5be0d25bda270
parents c2286781 47f0a16a
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -226,8 +226,7 @@ tBNEP_RESULT BNEP_ConnectResp(uint16_t handle, tBNEP_RESULT resp) {
      (!(p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD)))
      (!(p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD)))
    return (BNEP_WRONG_STATE);
    return (BNEP_WRONG_STATE);


  BNEP_TRACE_API("BNEP_ConnectResp()  for handle %d, responce %d", handle,
  LOG_DEBUG("handle %d, responce %d", handle, resp);
                 resp);


  /* Form appropriate responce based on profile responce */
  /* Form appropriate responce based on profile responce */
  if (resp == BNEP_CONN_FAILED_SRC_UUID)
  if (resp == BNEP_CONN_FAILED_SRC_UUID)
+22 −26
Original line number Original line Diff line number Diff line
@@ -130,7 +130,7 @@ static void bnep_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
  alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
  alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
                     bnep_conn_timer_timeout, p_bcb);
                     bnep_conn_timer_timeout, p_bcb);


  BNEP_TRACE_EVENT("BNEP - Rcvd L2CAP conn ind, CID: 0x%x", p_bcb->l2cap_cid);
  LOG_DEBUG("BNEP - Rcvd L2CAP conn ind, CID: 0x%x", p_bcb->l2cap_cid);
}
}


static void bnep_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
static void bnep_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
@@ -165,7 +165,7 @@ static void bnep_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
  /* Find CCB based on CID */
  /* Find CCB based on CID */
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  if (p_bcb == NULL) {
  if (p_bcb == NULL) {
    BNEP_TRACE_WARNING("BNEP - Rcvd conn cnf for unknown CID 0x%x", l2cap_cid);
    LOG_WARN("BNEP - Rcvd conn cnf for unknown CID 0x%x", l2cap_cid);
    return;
    return;
  }
  }


@@ -179,8 +179,7 @@ static void bnep_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
    alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
    alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
                       bnep_conn_timer_timeout, p_bcb);
                       bnep_conn_timer_timeout, p_bcb);


    BNEP_TRACE_EVENT("BNEP - got conn cnf, sent cfg req, CID: 0x%x",
    LOG_DEBUG("BNEP - got conn cnf, sent cfg req, CID: 0x%x", p_bcb->l2cap_cid);
                     p_bcb->l2cap_cid);
  } else {
  } else {
    LOG(ERROR) << __func__ << ": invoked with non OK status";
    LOG(ERROR) << __func__ << ": invoked with non OK status";
  }
  }
@@ -200,13 +199,12 @@ static void bnep_config_cfm(uint16_t l2cap_cid, uint16_t initiator,
                            tL2CAP_CFG_INFO* p_cfg) {
                            tL2CAP_CFG_INFO* p_cfg) {
  tBNEP_CONN* p_bcb;
  tBNEP_CONN* p_bcb;


  BNEP_TRACE_EVENT("BNEP - Rcvd cfg cfm, CID: 0x%x", l2cap_cid);
  LOG_DEBUG("BNEP - Rcvd cfg cfm, CID: 0x%x", l2cap_cid);


  /* Find CCB based on CID */
  /* Find CCB based on CID */
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  if (p_bcb == NULL) {
  if (p_bcb == NULL) {
    BNEP_TRACE_WARNING("BNEP - Rcvd L2CAP cfg ind, unknown CID: 0x%x",
    LOG_WARN("BNEP - Rcvd L2CAP cfg ind, unknown CID: 0x%x", l2cap_cid);
                       l2cap_cid);
    return;
    return;
  }
  }


@@ -238,11 +236,11 @@ static void bnep_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) {
  /* Find CCB based on CID */
  /* Find CCB based on CID */
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  if (p_bcb == NULL) {
  if (p_bcb == NULL) {
    BNEP_TRACE_WARNING("BNEP - Rcvd L2CAP disc, unknown CID: 0x%x", l2cap_cid);
    LOG_WARN("BNEP - Rcvd L2CAP disc, unknown CID: 0x%x", l2cap_cid);
    return;
    return;
  }
  }


  BNEP_TRACE_EVENT("BNEP - Rcvd L2CAP disc, CID: 0x%x", l2cap_cid);
  LOG_DEBUG("BNEP - Rcvd L2CAP disc, CID: 0x%x", l2cap_cid);


  /* Tell the user if there is a callback */
  /* Tell the user if there is a callback */
  if (p_bcb->con_state == BNEP_STATE_CONNECTED) {
  if (p_bcb->con_state == BNEP_STATE_CONNECTED) {
@@ -274,7 +272,7 @@ static void bnep_congestion_ind(uint16_t l2cap_cid, bool is_congested) {
  /* Find BCB based on CID */
  /* Find BCB based on CID */
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  if (p_bcb == NULL) {
  if (p_bcb == NULL) {
    BNEP_TRACE_WARNING("BNEP - Rcvd L2CAP cong, unknown CID: 0x%x", l2cap_cid);
    LOG_WARN("BNEP - Rcvd L2CAP cong, unknown CID: 0x%x", l2cap_cid);
    return;
    return;
  }
  }


@@ -332,7 +330,7 @@ static void bnep_data_ind(uint16_t l2cap_cid, BT_HDR* p_buf) {
  /* Find CCB based on CID */
  /* Find CCB based on CID */
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
  if (p_bcb == NULL) {
  if (p_bcb == NULL) {
    BNEP_TRACE_WARNING("BNEP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
    LOG_WARN("BNEP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
    osi_free(p_buf);
    osi_free(p_buf);
    return;
    return;
  }
  }
@@ -342,14 +340,13 @@ static void bnep_data_ind(uint16_t l2cap_cid, BT_HDR* p_buf) {
  extension_present = type >> 7;
  extension_present = type >> 7;
  type &= 0x7f;
  type &= 0x7f;
  if (type >= sizeof(bnep_frame_hdr_sizes) / sizeof(bnep_frame_hdr_sizes[0])) {
  if (type >= sizeof(bnep_frame_hdr_sizes) / sizeof(bnep_frame_hdr_sizes[0])) {
    BNEP_TRACE_EVENT("BNEP - rcvd frame, bad type: 0x%02x", type);
    LOG_INFO("BNEP - rcvd frame, bad type: 0x%02x", type);
    android_errorWriteLog(0x534e4554, "68818034");
    android_errorWriteLog(0x534e4554, "68818034");
    osi_free(p_buf);
    osi_free(p_buf);
    return;
    return;
  }
  }
  if ((rem_len <= bnep_frame_hdr_sizes[type]) || (rem_len > BNEP_MTU_SIZE)) {
  if ((rem_len <= bnep_frame_hdr_sizes[type]) || (rem_len > BNEP_MTU_SIZE)) {
    BNEP_TRACE_EVENT("BNEP - rcvd frame, bad len: %d  type: 0x%02x", p_buf->len,
    LOG_DEBUG("BNEP - rcvd frame, bad len: %d  type: 0x%02x", p_buf->len, type);
                     type);
    osi_free(p_buf);
    osi_free(p_buf);
    return;
    return;
  }
  }
@@ -359,8 +356,7 @@ static void bnep_data_ind(uint16_t l2cap_cid, BT_HDR* p_buf) {
  if ((p_bcb->con_state != BNEP_STATE_CONNECTED) &&
  if ((p_bcb->con_state != BNEP_STATE_CONNECTED) &&
      (!(p_bcb->con_flags & BNEP_FLAGS_CONN_COMPLETED)) &&
      (!(p_bcb->con_flags & BNEP_FLAGS_CONN_COMPLETED)) &&
      (type != BNEP_FRAME_CONTROL)) {
      (type != BNEP_FRAME_CONTROL)) {
    BNEP_TRACE_WARNING(
    LOG_WARN("BNEP - Ignored L2CAP data while in state: %d, CID: 0x%x",
        "BNEP - Ignored L2CAP data while in state: %d, CID: 0x%x",
             p_bcb->con_state, l2cap_cid);
             p_bcb->con_state, l2cap_cid);


    if (extension_present) {
    if (extension_present) {
@@ -407,13 +403,13 @@ static void bnep_data_ind(uint16_t l2cap_cid, BT_HDR* p_buf) {
  }
  }


  if (type > BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY) {
  if (type > BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY) {
    BNEP_TRACE_EVENT("BNEP - rcvd frame, unknown type: 0x%02x", type);
    LOG_DEBUG("BNEP - rcvd frame, unknown type: 0x%02x", type);
    osi_free(p_buf);
    osi_free(p_buf);
    return;
    return;
  }
  }


  BNEP_TRACE_DEBUG("BNEP - rcv frame, type: %d len: %d Ext: %d", type,
  LOG_DEBUG("BNEP - rcv frame, type: %d len: %d Ext: %d", type, p_buf->len,
                   p_buf->len, extension_present);
            extension_present);


  /* Initialize addresses to 'not supplied' */
  /* Initialize addresses to 'not supplied' */
  const RawAddress *p_src_addr, *p_dst_addr;
  const RawAddress *p_src_addr, *p_dst_addr;
@@ -486,7 +482,7 @@ static void bnep_data_ind(uint16_t l2cap_cid, BT_HDR* p_buf) {


    /* if unknown extension present stop processing */
    /* if unknown extension present stop processing */
    if (ext_type) {
    if (ext_type) {
      BNEP_TRACE_EVENT("Data extension type 0x%x found", ext_type);
      LOG_DEBUG("Data extension type 0x%x found", ext_type);
      break;
      break;
    }
    }


@@ -533,14 +529,14 @@ static void bnep_data_ind(uint16_t l2cap_cid, BT_HDR* p_buf) {
void bnep_conn_timer_timeout(void* data) {
void bnep_conn_timer_timeout(void* data) {
  tBNEP_CONN* p_bcb = (tBNEP_CONN*)data;
  tBNEP_CONN* p_bcb = (tBNEP_CONN*)data;


  BNEP_TRACE_EVENT(
  LOG_DEBUG(
      "BNEP - CCB timeout in state: %d  CID: 0x%x flags %x, re_transmit %d",
      "BNEP - CCB timeout in state: %d  CID: 0x%x flags %x, re_transmit %d",
      p_bcb->con_state, p_bcb->l2cap_cid, p_bcb->con_flags,
      p_bcb->con_state, p_bcb->l2cap_cid, p_bcb->con_flags,
      p_bcb->re_transmits);
      p_bcb->re_transmits);


  if (p_bcb->con_state == BNEP_STATE_CONN_SETUP) {
  if (p_bcb->con_state == BNEP_STATE_CONN_SETUP) {
    BNEP_TRACE_EVENT("BNEP - CCB timeout in state: %d  CID: 0x%x",
    LOG_DEBUG("BNEP - CCB timeout in state: %d  CID: 0x%x", p_bcb->con_state,
                     p_bcb->con_state, p_bcb->l2cap_cid);
              p_bcb->l2cap_cid);


    if (!(p_bcb->con_flags & BNEP_FLAGS_IS_ORIG)) {
    if (!(p_bcb->con_flags & BNEP_FLAGS_IS_ORIG)) {
      L2CA_DisconnectReq(p_bcb->l2cap_cid);
      L2CA_DisconnectReq(p_bcb->l2cap_cid);
@@ -564,8 +560,8 @@ void bnep_conn_timer_timeout(void* data) {
      return;
      return;
    }
    }
  } else if (p_bcb->con_state != BNEP_STATE_CONNECTED) {
  } else if (p_bcb->con_state != BNEP_STATE_CONNECTED) {
    BNEP_TRACE_EVENT("BNEP - CCB timeout in state: %d  CID: 0x%x",
    LOG_DEBUG("BNEP - CCB timeout in state: %d  CID: 0x%x", p_bcb->con_state,
                     p_bcb->con_state, p_bcb->l2cap_cid);
              p_bcb->l2cap_cid);


    L2CA_DisconnectReq(p_bcb->l2cap_cid);
    L2CA_DisconnectReq(p_bcb->l2cap_cid);


+11 −15
Original line number Original line Diff line number Diff line
@@ -223,8 +223,7 @@ void bnep_send_conn_responce(tBNEP_CONN* p_bcb, uint16_t resp_code) {
  BT_HDR* p_buf = (BT_HDR*)osi_malloc(BNEP_BUF_SIZE);
  BT_HDR* p_buf = (BT_HDR*)osi_malloc(BNEP_BUF_SIZE);
  uint8_t* p;
  uint8_t* p;


  BNEP_TRACE_EVENT("BNEP - bnep_send_conn_responce for CID: 0x%x",
  LOG_DEBUG("BNEP - bnep_send_conn_responce for CID: 0x%x", p_bcb->l2cap_cid);
                   p_bcb->l2cap_cid);


  p_buf->offset = L2CAP_MIN_OFFSET;
  p_buf->offset = L2CAP_MIN_OFFSET;
  p = (uint8_t*)(p_buf + 1) + L2CAP_MIN_OFFSET;
  p = (uint8_t*)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -404,12 +403,10 @@ void bnep_send_command_not_understood(tBNEP_CONN* p_bcb, uint8_t cmd_code) {
 *
 *
 ******************************************************************************/
 ******************************************************************************/
void bnepu_check_send_packet(tBNEP_CONN* p_bcb, BT_HDR* p_buf) {
void bnepu_check_send_packet(tBNEP_CONN* p_bcb, BT_HDR* p_buf) {
  BNEP_TRACE_EVENT("BNEP - bnepu_check_send_packet for CID: 0x%x",
  LOG_DEBUG("BNEP - bnepu_check_send_packet for CID: 0x%x", p_bcb->l2cap_cid);
                   p_bcb->l2cap_cid);
  if (p_bcb->con_flags & BNEP_FLAGS_L2CAP_CONGESTED) {
  if (p_bcb->con_flags & BNEP_FLAGS_L2CAP_CONGESTED) {
    if (fixed_queue_length(p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH) {
    if (fixed_queue_length(p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH) {
      BNEP_TRACE_EVENT("BNEP - congested, dropping buf, CID: 0x%x",
      LOG_WARN("BNEP - congested, dropping buf, CID: 0x%x", p_bcb->l2cap_cid);
                       p_bcb->l2cap_cid);


      osi_free(p_buf);
      osi_free(p_buf);
    } else {
    } else {
@@ -534,12 +531,12 @@ static uint8_t* bnepu_init_hdr(BT_HDR* p_buf, uint16_t hdr_len,
 ******************************************************************************/
 ******************************************************************************/
void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup,
void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup,
                                 uint8_t len) {
                                 uint8_t len) {
  BNEP_TRACE_EVENT("BNEP - %s for CID: 0x%x", __func__, p_bcb->l2cap_cid);
  LOG_DEBUG("BNEP - for CID: 0x%x", p_bcb->l2cap_cid);


  if (p_bcb->con_state != BNEP_STATE_CONN_SETUP &&
  if (p_bcb->con_state != BNEP_STATE_CONN_SETUP &&
      p_bcb->con_state != BNEP_STATE_SEC_CHECKING &&
      p_bcb->con_state != BNEP_STATE_SEC_CHECKING &&
      p_bcb->con_state != BNEP_STATE_CONNECTED) {
      p_bcb->con_state != BNEP_STATE_CONNECTED) {
    BNEP_TRACE_ERROR("BNEP - setup request in bad state %d", p_bcb->con_state);
    LOG_ERROR("BNEP - setup request in bad state %d", p_bcb->con_state);
    bnep_send_conn_responce(p_bcb, BNEP_SETUP_CONN_NOT_ALLOWED);
    bnep_send_conn_responce(p_bcb, BNEP_SETUP_CONN_NOT_ALLOWED);
    return;
    return;
  }
  }
@@ -547,7 +544,7 @@ void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup,
  /* Check if we already initiated security check or if waiting for user
  /* Check if we already initiated security check or if waiting for user
   * responce */
   * responce */
  if (p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD) {
  if (p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD) {
    BNEP_TRACE_EVENT(
    LOG_WARN(
        "BNEP - Duplicate Setup message received while doing security check");
        "BNEP - Duplicate Setup message received while doing security check");
    return;
    return;
  }
  }
@@ -556,7 +553,7 @@ void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup,
  if (p_bcb->con_state != BNEP_STATE_CONNECTED &&
  if (p_bcb->con_state != BNEP_STATE_CONNECTED &&
      (!(p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD)) &&
      (!(p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD)) &&
      (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG)) {
      (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG)) {
    BNEP_TRACE_ERROR("BNEP - setup request when we are originator",
    LOG_ERROR("BNEP - setup request when we are originator state:%hu",
              p_bcb->con_state);
              p_bcb->con_state);
    bnep_send_conn_responce(p_bcb, BNEP_SETUP_CONN_NOT_ALLOWED);
    bnep_send_conn_responce(p_bcb, BNEP_SETUP_CONN_NOT_ALLOWED);
    return;
    return;
@@ -599,7 +596,7 @@ void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup,
    p_bcb->dst_uuid = Uuid::From128BitBE(p_setup);
    p_bcb->dst_uuid = Uuid::From128BitBE(p_setup);
    p_setup += len;
    p_setup += len;
  } else {
  } else {
    BNEP_TRACE_ERROR("BNEP - Bad UID len %d in ConnReq", len);
    LOG_ERROR("BNEP - Bad UID len %d in ConnReq", len);
    bnep_send_conn_responce(p_bcb, BNEP_SETUP_INVALID_UUID_SIZE);
    bnep_send_conn_responce(p_bcb, BNEP_SETUP_INVALID_UUID_SIZE);
    return;
    return;
  }
  }
@@ -607,8 +604,7 @@ void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup,
  p_bcb->con_state = BNEP_STATE_SEC_CHECKING;
  p_bcb->con_state = BNEP_STATE_SEC_CHECKING;
  p_bcb->con_flags |= BNEP_FLAGS_SETUP_RCVD;
  p_bcb->con_flags |= BNEP_FLAGS_SETUP_RCVD;


  BNEP_TRACE_EVENT(
  LOG_DEBUG("BNEP initiating security check for incoming call for uuid %s",
      "BNEP initiating security check for incoming call for uuid %s",
            p_bcb->src_uuid.ToString().c_str());
            p_bcb->src_uuid.ToString().c_str());
  bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb);
  bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb);
}
}