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

Commit a18fee4c authored by jruthe's avatar jruthe Committed by android-build-merger
Browse files

test_vendor: Add LOG_DEBUG to L2cap::assemble am: 5f41ce69

am: 7a71f36b

Change-Id: Ifc9cacb3da6cf8f5a45c5e7ead50e01f23d5b774
parents c1252798 7a71f36b
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 *  limitations under the License.
 *
 ******************************************************************************/
#define LOG_TAG "l2cap_assemble"
#define LOG_TAG "l2cap_packet"

#include "l2cap_packet.h"

@@ -39,9 +39,11 @@ std::unique_ptr<L2capPacket> L2capPacket::assemble(
  uint8_t txseq_start;

  if (sdu_packets.size() == 0) {
    LOG_DEBUG(LOG_TAG, "%s: No SDU received.", __func__);
    return nullptr;
  }
  if (sdu_packets.size() == 1 && !L2capSdu::is_complete_l2cap(sdu_packets[0])) {
    LOG_DEBUG(LOG_TAG, "%s: Unsegmented SDU has incorrect SAR bits.", __func__);
    return nullptr;
  }

@@ -57,21 +59,24 @@ std::unique_ptr<L2capPacket> L2capPacket::assemble(
    // L2capSdu objects and these checks will be moved there instead.
    //
    // Check the integrity of the packet length, if it is zero, it is invalid.
    // The maximum size of a single, partial L2CAP payload is 1016 bytes.
    // The maximum size of a single, segmented L2CAP payload is 1016 bytes.
    if ((payload_length <= 0) ||
        (payload_length != sdu_packets[i].get_vector_size() - 4)) {
      LOG_DEBUG(LOG_TAG, "%s: SDU payload length incorrect.", __func__);
      return nullptr;
    }

    uint16_t fcs_check = sdu_packets[i].get_fcs();

    if (sdu_packets[i].calculate_fcs() != fcs_check) {
      LOG_DEBUG(LOG_TAG, "%s: SDU fcs is incorrect.", __func__);
      return nullptr;
    }

    uint16_t controls = sdu_packets[i].get_controls();

    if (sdu_packets[i].get_channel_id() != first_packet_channel_id) {
      LOG_DEBUG(LOG_TAG, "%s: SDU CID does not match expected.", __func__);
      return nullptr;
    }

@@ -88,16 +93,25 @@ std::unique_ptr<L2capPacket> L2capPacket::assemble(
    uint8_t txseq = controls & kSduTxSeqBits;
    if (sdu_packets.size() > 1 && i == 0 &&
        !L2capSdu::is_starting_sdu(sdu_packets[i])) {
      LOG_DEBUG(LOG_TAG, "%s: First segmented SDU has incorrect SAR bits.",
                __func__);
      return nullptr;
    }
    if (i != 0 && L2capSdu::is_starting_sdu(sdu_packets[i])) {
      LOG_DEBUG(LOG_TAG,
                "%s: SAR bits set to first segmented SDU on "
                "non-starting SDU.",
                __func__);
      return nullptr;
    }
    if (txseq != (txseq_start + (static_cast<uint8_t>(i) << 1))) {
      LOG_DEBUG(LOG_TAG, "%s: TxSeq incorrect.", __func__);
      return nullptr;
    }
    if (sdu_packets.size() > 1 && i == sdu_packets.size() - 1 &&
        !L2capSdu::is_ending_sdu(sdu_packets[i])) {
      LOG_DEBUG(LOG_TAG, "%s: Final segmented SDU has incorrect SAR bits.",
                __func__);
      return nullptr;
    }

@@ -124,6 +138,8 @@ std::unique_ptr<L2capPacket> L2capPacket::assemble(

  if (l2cap_payload_length != total_expected_l2cap_length &&
      sdu_packets.size() > 1) {
    LOG_DEBUG(LOG_TAG, "%s: Total expected L2CAP payload length incorrect.",
              __func__);
    return nullptr;
  }