Skip to content

Commit 63dbc4c

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: L2CAP: Support zero-length SDU in none basic mode
Support zero-length SDU sending if the L2CAP channel connection is not in basic mode. Flag the zero-length SDU buffer and clear it if it has been processed. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
1 parent cad801a commit 63dbc4c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

subsys/bluetooth/host/classic/l2cap_br.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ LOG_MODULE_REGISTER(bt_l2cap_br, CONFIG_BT_L2CAP_LOG_LEVEL);
6060

6161
#define L2CAP_BR_PSM_SDP 0x0001
6262

63+
#define L2CAP_BR_ZL_I_FRAME_FLAG_MASK 0xfffffeffU
64+
#define L2CAP_BR_ZL_I_FRAME_UD_FLAG 0xfffffeff
65+
#define L2CAP_BR_IS_ZERO_LEN_I_FRAME(flag) \
66+
((POINTER_TO_UINT(flag) & L2CAP_BR_ZL_I_FRAME_FLAG_MASK) == L2CAP_BR_ZL_I_FRAME_UD_FLAG)
67+
6368
#define L2CAP_BR_S_FRAME_FLAG_MASK 0xffffff00U
6469
#define L2CAP_BR_S_FRAME_UD_FLAG 0xffffff00
6570
#define L2CAP_BR_IS_S_FRAME(flag) \
@@ -892,6 +897,11 @@ int bt_l2cap_br_send_cb(struct bt_conn *conn, uint16_t cid, struct net_buf *buf,
892897
hdr = net_buf_push(buf, sizeof(*hdr));
893898
hdr->len = sys_cpu_to_le16(buf->len - sizeof(*hdr));
894899
hdr->cid = sys_cpu_to_le16(cid);
900+
} else {
901+
if ((cb == NULL) && (user_data == NULL) && (buf->len == 0)) {
902+
/* Mask it is a zero-length I-frame */
903+
user_data = UINT_TO_POINTER(L2CAP_BR_ZL_I_FRAME_UD_FLAG);
904+
}
895905
}
896906
#else
897907
hdr = net_buf_push(buf, sizeof(*hdr));
@@ -1139,6 +1149,10 @@ static struct net_buf *l2cap_br_get_next_sdu(struct bt_l2cap_br_chan *br_chan)
11391149
if (L2CAP_BR_IS_S_FRAME(closure_data(sdu->user_data))) {
11401150
return sdu;
11411151
}
1152+
1153+
if (L2CAP_BR_IS_ZERO_LEN_I_FRAME(closure_data(sdu->user_data))) {
1154+
return sdu;
1155+
}
11421156
}
11431157

11441158
return NULL;
@@ -1501,6 +1515,10 @@ static struct net_buf *l2cap_br_ret_fc_data_pull(struct bt_conn *conn, size_t am
15011515
br_chan->next_tx_seq =
15021516
bt_l2cap_br_update_seq(br_chan, br_chan->next_tx_seq + 1);
15031517

1518+
if (L2CAP_BR_IS_ZERO_LEN_I_FRAME(closure_data(pdu->user_data))) {
1519+
make_closure(pdu->user_data, NULL, NULL);
1520+
}
1521+
15041522
net_buf_pull(pdu, pdu_len);
15051523

15061524
if (br_chan->rx.mode != BT_L2CAP_BR_LINK_MODE_STREAM) {

0 commit comments

Comments
 (0)