Skip to content

Commit c564804

Browse files
lylezhu2012nashif
authored andcommitted
Bluetooth: L2CAP_BR: incorrect result returned if config opt unsupported
The `BT_L2CAP_CONF_SUCCESS` is returned as result for the config req with supported opt. Result `BT_L2CAP_CONF_UNKNOWN_OPT` should be returned for this case. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
1 parent 9c5fda3 commit c564804

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

subsys/bluetooth/host/classic/l2cap_br.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,13 @@ static void l2cap_br_conf_add_mtu(struct net_buf *buf, const uint16_t mtu)
707707
net_buf_add_le16(buf, mtu);
708708
}
709709

710+
static void l2cap_br_conf_add_opt(struct net_buf *buf, const struct bt_l2cap_conf_opt *opt)
711+
{
712+
net_buf_add_u8(buf, opt->type & BT_L2CAP_CONF_MASK);
713+
net_buf_add_u8(buf, opt->len);
714+
net_buf_add_mem(buf, opt->data, opt->len);
715+
}
716+
710717
static void l2cap_br_conf(struct bt_l2cap_chan *chan)
711718
{
712719
struct bt_l2cap_sig_hdr *hdr;
@@ -1235,7 +1242,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident,
12351242
struct bt_l2cap_conf_req *req;
12361243
struct bt_l2cap_sig_hdr *hdr;
12371244
struct bt_l2cap_conf_rsp *rsp;
1238-
struct bt_l2cap_conf_opt *opt;
1245+
struct bt_l2cap_conf_opt *opt = NULL;
12391246
uint16_t flags, dcid, opt_len, hint, result = BT_L2CAP_CONF_SUCCESS;
12401247

12411248
if (buf->len < sizeof(*req)) {
@@ -1294,6 +1301,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident,
12941301
default:
12951302
if (!hint) {
12961303
LOG_DBG("option %u not handled", opt->type);
1304+
result = BT_L2CAP_CONF_UNKNOWN_OPT;
12971305
goto send_rsp;
12981306
}
12991307

@@ -1322,6 +1330,10 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident,
13221330
*/
13231331
if (result == BT_L2CAP_CONF_UNACCEPT) {
13241332
l2cap_br_conf_add_mtu(buf, BR_CHAN(chan)->tx.mtu);
1333+
} else if (result == BT_L2CAP_CONF_UNKNOWN_OPT) {
1334+
if (opt) {
1335+
l2cap_br_conf_add_opt(buf, opt);
1336+
}
13251337
}
13261338

13271339
hdr->len = sys_cpu_to_le16(buf->len - sizeof(*hdr));

subsys/bluetooth/host/classic/l2cap_br_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ struct bt_l2cap_conn_rsp {
7272
#define BT_L2CAP_CONF_SUCCESS 0x0000
7373
#define BT_L2CAP_CONF_UNACCEPT 0x0001
7474
#define BT_L2CAP_CONF_REJECT 0x0002
75+
#define BT_L2CAP_CONF_UNKNOWN_OPT 0x0003
76+
#define BT_L2CAP_CONF_PENDING 0x0004
77+
#define BT_L2CAP_CONF_FLOW_SPEC_REJECT 0x0005
7578

7679
#define BT_L2CAP_CONF_REQ 0x04
7780
struct bt_l2cap_conf_req {

0 commit comments

Comments
 (0)