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

Commit 69707252 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Get rid of L2CAP_MAX_BUF_SIZE, use variable-size buffers instead

This is step towards increasing L2CAP_MAX_SDU_LENGTH value.

Test: transfer file using OPP, send data using CoC
Bug: 68359837
Change-Id: Ia4fb6b2325cb92db9c90c6a4d2ab17f271640ea8
parent 4e27c0bc
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <vector>

#include <mutex>

@@ -675,13 +676,13 @@ static void on_l2cap_data_ind(tBTA_JV* evt, uint32_t id) {
    }

  } else {
    uint8_t buffer[L2CAP_MAX_SDU_LENGTH];
    uint32_t count;

    if (BTA_JvL2capReady(sock->handle, &count) == BTA_JV_SUCCESS) {
      if (BTA_JvL2capRead(sock->handle, sock->id, buffer, count) ==
      std::vector<uint8_t> buffer(count);
      if (BTA_JvL2capRead(sock->handle, sock->id, buffer.data(), count) ==
          BTA_JV_SUCCESS) {
        if (packet_put_tail_l(sock, buffer, count)) {
        if (packet_put_tail_l(sock, buffer.data(), count)) {
          bytes_read = count;
          btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP,
                               SOCK_THREAD_FD_WR, sock->id);
+0 −1
Original line number Diff line number Diff line
@@ -328,7 +328,6 @@
 * Changed it to  8087 to have same value between BTIF and L2cap layers
 */
#define L2CAP_MAX_SDU_LENGTH (8080 + 26 - (L2CAP_MIN_OFFSET + 6))
#define L2CAP_MAX_BUF_SIZE (10240 + 24)

/* Part of L2CAP_MIN_OFFSET that is not part of L2CAP
*/
+3 −2
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ void l2c_lcc_proc_pdu(tL2C_CCB* p_ccb, BT_HDR* p_buf) {
      return;
    }

    p_data = (BT_HDR*)osi_malloc(L2CAP_MAX_BUF_SIZE);
    p_data = (BT_HDR*)osi_malloc(BT_HDR_SIZE + sdu_length);
    if (p_data == NULL) {
      osi_free(p_buf);
      return;
@@ -1452,7 +1452,8 @@ static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf,
                            p_fcrb->rx_sdu_len, p_fcrb->rx_sdu_len);
        packet_ok = false;
      } else {
        p_fcrb->p_rx_sdu = (BT_HDR*)osi_malloc(L2CAP_MAX_BUF_SIZE);
        p_fcrb->p_rx_sdu = (BT_HDR*)osi_malloc(
            BT_HDR_SIZE + OBX_BUF_MIN_OFFSET + p_fcrb->rx_sdu_len);
        p_fcrb->p_rx_sdu->offset = OBX_BUF_MIN_OFFSET;
        p_fcrb->p_rx_sdu->len = 0;
      }