Bluetooth: L2CAP: Add configuration response handler
Adds L2CAP configuration response protocol definitions to be able handle response from remote in reaction to issued local request to exchange MTU. Current optimistic path of configuration initiated from local assumes to set MTU contract in one iteration. Change-Id: If86d96b37e9cd888ad10a624a79c864a137e027d Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
69882759b8
commit
2178fc5ab3
2 changed files with 56 additions and 0 deletions
|
@ -534,6 +534,48 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
static void l2cap_br_conf_rsp(struct bt_l2cap_br *l2cap, uint8_t ident,
|
||||
uint16_t len, struct net_buf *buf)
|
||||
{
|
||||
struct bt_conn *conn = l2cap->chan.chan.conn;
|
||||
struct bt_l2cap_chan *chan;
|
||||
struct bt_l2cap_conf_rsp *rsp = (void *)buf->data;
|
||||
uint16_t flags, scid, result, opt_len;
|
||||
|
||||
if (buf->len < sizeof(*rsp)) {
|
||||
BT_ERR("Too small L2CAP conf rsp packet size");
|
||||
return;
|
||||
}
|
||||
|
||||
flags = sys_le16_to_cpu(rsp->flags);
|
||||
scid = sys_le16_to_cpu(rsp->scid);
|
||||
result = sys_le16_to_cpu(rsp->result);
|
||||
opt_len = len - sizeof(*rsp);
|
||||
|
||||
BT_DBG("scid 0x%04x flags 0x%02x result 0x%02x len %u", scid, flags,
|
||||
result, opt_len);
|
||||
|
||||
chan = bt_l2cap_br_lookup_rx_cid(conn, scid);
|
||||
if (!chan) {
|
||||
BT_ERR("channel mismatch!");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: handle other results than success and parse response data if
|
||||
* available
|
||||
*/
|
||||
switch (result) {
|
||||
case BT_L2CAP_CONF_SUCCESS:
|
||||
BT_DBG("local MTU %u", BR_CHAN(chan)->rx.mtu);
|
||||
break;
|
||||
default:
|
||||
/* currently disconnect channel on non success result */
|
||||
bt_l2cap_chan_disconnect(chan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int bt_l2cap_br_server_register(struct bt_l2cap_server *server)
|
||||
{
|
||||
if (server->psm < L2CAP_BR_PSM_START || !server->accept) {
|
||||
|
@ -745,6 +787,10 @@ static void l2cap_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
case BT_L2CAP_CONN_REQ:
|
||||
l2cap_br_conn_req(l2cap, hdr->ident, buf);
|
||||
break;
|
||||
case BT_L2CAP_CONF_RSP:
|
||||
l2cap_br_conf_rsp(l2cap, hdr->ident, sys_le16_to_cpu(hdr->len),
|
||||
buf);
|
||||
break;
|
||||
default:
|
||||
BT_WARN("Unknown/Unsupported L2CAP PDU code 0x%02x", hdr->code);
|
||||
l2cap_br_send_reject(chan->conn, hdr->ident,
|
||||
|
|
|
@ -69,6 +69,8 @@ struct bt_l2cap_conn_rsp {
|
|||
uint16_t status;
|
||||
} __packed;
|
||||
|
||||
#define BT_L2CAP_CONF_SUCCESS 0x0000
|
||||
|
||||
#define BT_L2CAP_CONF_REQ 0x04
|
||||
struct bt_l2cap_conf_req {
|
||||
uint16_t dcid;
|
||||
|
@ -76,6 +78,14 @@ struct bt_l2cap_conf_req {
|
|||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BT_L2CAP_CONF_RSP 0x05
|
||||
struct bt_l2cap_conf_rsp {
|
||||
uint16_t scid;
|
||||
uint16_t flags;
|
||||
uint16_t result;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
/* Option type used by MTU config request data */
|
||||
#define BT_L2CAP_CONF_OPT_MTU 0x01
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue