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

Commit 256d1ede authored by William Escande's avatar William Escande
Browse files

SDP: split the sdpu_process_pend_ccb

Two method are clearer than one with parameter

Bug: 246022810
Test: atest net_test_stack_sdp
Tag: #refactor
Merged-In: I3da1c52575277308f1bd82ce075c7751ab7e9e14
Change-Id: I3da1c52575277308f1bd82ce075c7751ab7e9e14
(cherry picked from commit 9bb77245)
parent 4af4e092
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ static void sdp_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) {
  if (ack_needed) {
    SDP_TRACE_WARNING("SDP - Rcvd L2CAP disc, process pend sdp ccb: 0x%x",
                      l2cap_cid);
    sdpu_process_pend_ccb(ccb, false);
    sdpu_process_pend_ccb_new_cid(ccb);
  } else {
    SDP_TRACE_WARNING("SDP - Rcvd L2CAP disc, clear pend sdp ccb: 0x%x",
                      l2cap_cid);
@@ -387,7 +387,7 @@ void sdp_disconnect(tCONN_CB* p_ccb, tSDP_REASON reason) {
  /* Check if we have a connection ID */
  if (ccb.connection_id != 0) {
    ccb.disconnect_reason = reason;
    if (SDP_SUCCESS == reason && sdpu_process_pend_ccb(ccb, true)) {
    if (SDP_SUCCESS == reason && sdpu_process_pend_ccb_same_cid(*p_ccb)) {
      sdpu_callback(ccb, reason);
      sdpu_release_ccb(ccb);
      return;
@@ -429,7 +429,7 @@ static void sdp_disconnect_cfm(uint16_t l2cap_cid,
  SDP_TRACE_EVENT("SDP - Rcvd L2CAP disc cfm, CID: 0x%x", l2cap_cid);

  sdpu_callback(ccb, static_cast<tSDP_STATUS>(ccb.disconnect_reason));
  sdpu_process_pend_ccb(ccb, false);
  sdpu_process_pend_ccb_new_cid(ccb);
  sdpu_release_ccb(ccb);
}

+33 −16
Original line number Diff line number Diff line
@@ -460,19 +460,17 @@ uint16_t sdpu_get_active_ccb_cid(const RawAddress& remote_bd_addr) {
 * Function         sdpu_process_pend_ccb
 *
 * Description      This function process if any sdp ccb pending for connection
 *                  and reuse the same connection id
 *
 *                  uint16_t : Remote CID
 *                  bool: if true will reuse current channel else will create a
 *                         new L2CAP connection
 *                  tCONN_CB&: connection control block that trigget the process
 *
 * Returns          returns true if any pending ccb, else false.
 *
 ******************************************************************************/
bool sdpu_process_pend_ccb(tCONN_CB& ccb, bool use_cur_chnl) {
bool sdpu_process_pend_ccb_same_cid(tCONN_CB& ccb) {
  uint16_t xx;
  tCONN_CB* p_ccb;

  if (use_cur_chnl) {
  // Look through each connection control block for active sdp on given remote
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
    if ((p_ccb->con_state == SDP_STATE_CONN_PEND) &&
@@ -487,13 +485,31 @@ bool sdpu_process_pend_ccb(tCONN_CB& ccb, bool use_cur_chnl) {
  return false;
}

/*******************************************************************************
 *
 * Function         sdpu_process_pend_ccb_new_cid
 *
 * Description      This function process if any sdp ccb pending for connection
 *                  and update their connection id with a new L2CA connection
 *
 *                  tCONN_CB&: connection control block that trigget the process
 *
 * Returns          returns true if any pending ccb, else false.
 *
 ******************************************************************************/
bool sdpu_process_pend_ccb_new_cid(tCONN_CB& ccb) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  uint16_t new_cid = 0;
  bool new_conn = false;

  // Look through each ccb to replace the obsolete cid with a new one.
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
    if ((p_ccb->con_state == SDP_STATE_CONN_PEND) &&
        (p_ccb->connection_id == ccb.connection_id) &&
        (p_ccb->con_flags & SDP_FLAGS_IS_ORIG)) {
      if (!new_conn) {
        // Only change state of the first ccb
        p_ccb->con_state = SDP_STATE_CONN_SETUP;
        new_cid =
            L2CA_ConnectReq2(BT_PSM_SDP, p_ccb->device_address, BTM_SEC_NONE);
@@ -501,6 +517,7 @@ bool sdpu_process_pend_ccb(tCONN_CB& ccb, bool use_cur_chnl) {
      }
      // Check if L2CAP started the connection process
      if (new_cid != 0) {
        // update alls cid to the new one for future reference
        p_ccb->connection_id = new_cid;
      } else {
        sdpu_callback(*p_ccb, SDP_CONN_FAILED);
+2 −1
Original line number Diff line number Diff line
@@ -241,7 +241,8 @@ extern bool spdu_is_avrcp_version_valid(const uint16_t version);
extern void sdpu_set_avrc_target_version(const tSDP_ATTRIBUTE* p_attr,
                                         const RawAddress* bdaddr);
extern uint16_t sdpu_get_active_ccb_cid(const RawAddress& remote_bd_addr);
extern bool sdpu_process_pend_ccb(tCONN_CB& ccb, bool use_cur_chnl);
extern bool sdpu_process_pend_ccb_same_cid(tCONN_CB& ccb);
extern bool sdpu_process_pend_ccb_new_cid(tCONN_CB& ccb);
extern void sdpu_clear_pend_ccb(tCONN_CB& ccb);
extern void sdpu_callback(tCONN_CB& ccb, tSDP_REASON reason);