|
@@ -48,19 +48,20 @@ static LIST_HEAD(chan_list);
|
|
|
static DEFINE_RWLOCK(chan_list_lock);
|
|
|
|
|
|
static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
|
|
|
- u8 code, u8 ident, u16 dlen, void *data);
|
|
|
+ u8 code, u8 ident, u16 dlen, void *data);
|
|
|
static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
|
|
|
- void *data);
|
|
|
+ void *data);
|
|
|
static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data);
|
|
|
static void l2cap_send_disconn_req(struct l2cap_conn *conn,
|
|
|
struct l2cap_chan *chan, int err);
|
|
|
|
|
|
static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
|
|
|
- struct sk_buff_head *skbs, u8 event);
|
|
|
+ struct sk_buff_head *skbs, u8 event);
|
|
|
|
|
|
/* ---- L2CAP channels ---- */
|
|
|
|
|
|
-static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid)
|
|
|
+static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn,
|
|
|
+ u16 cid)
|
|
|
{
|
|
|
struct l2cap_chan *c;
|
|
|
|
|
@@ -71,7 +72,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid)
|
|
|
+static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn,
|
|
|
+ u16 cid)
|
|
|
{
|
|
|
struct l2cap_chan *c;
|
|
|
|
|
@@ -84,7 +86,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16
|
|
|
|
|
|
/* Find channel with given SCID.
|
|
|
* Returns locked channel. */
|
|
|
-static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid)
|
|
|
+static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn,
|
|
|
+ u16 cid)
|
|
|
{
|
|
|
struct l2cap_chan *c;
|
|
|
|
|
@@ -97,7 +100,8 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci
|
|
|
return c;
|
|
|
}
|
|
|
|
|
|
-static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident)
|
|
|
+static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn,
|
|
|
+ u8 ident)
|
|
|
{
|
|
|
struct l2cap_chan *c;
|
|
|
|
|
@@ -178,7 +182,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn)
|
|
|
static void __l2cap_state_change(struct l2cap_chan *chan, int state)
|
|
|
{
|
|
|
BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state),
|
|
|
- state_to_string(state));
|
|
|
+ state_to_string(state));
|
|
|
|
|
|
chan->state = state;
|
|
|
chan->ops->state_change(chan, state);
|
|
@@ -361,7 +365,7 @@ static void l2cap_seq_list_append(struct l2cap_seq_list *seq_list, u16 seq)
|
|
|
static void l2cap_chan_timeout(struct work_struct *work)
|
|
|
{
|
|
|
struct l2cap_chan *chan = container_of(work, struct l2cap_chan,
|
|
|
- chan_timer.work);
|
|
|
+ chan_timer.work);
|
|
|
struct l2cap_conn *conn = chan->conn;
|
|
|
int reason;
|
|
|
|
|
@@ -373,7 +377,7 @@ static void l2cap_chan_timeout(struct work_struct *work)
|
|
|
if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG)
|
|
|
reason = ECONNREFUSED;
|
|
|
else if (chan->state == BT_CONNECT &&
|
|
|
- chan->sec_level != BT_SECURITY_SDP)
|
|
|
+ chan->sec_level != BT_SECURITY_SDP)
|
|
|
reason = ECONNREFUSED;
|
|
|
else
|
|
|
reason = ETIMEDOUT;
|
|
@@ -455,7 +459,7 @@ void l2cap_chan_set_defaults(struct l2cap_chan *chan)
|
|
|
set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
|
|
|
}
|
|
|
|
|
|
-static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
|
|
|
+void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
|
|
|
{
|
|
|
BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn,
|
|
|
__le16_to_cpu(chan->psm), chan->dcid);
|
|
@@ -504,7 +508,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
|
|
|
chan->local_msdu = L2CAP_DEFAULT_MAX_SDU_SIZE;
|
|
|
chan->local_sdu_itime = L2CAP_DEFAULT_SDU_ITIME;
|
|
|
chan->local_acc_lat = L2CAP_DEFAULT_ACC_LAT;
|
|
|
- chan->local_flush_to = L2CAP_DEFAULT_FLUSH_TO;
|
|
|
+ chan->local_flush_to = L2CAP_EFS_DEFAULT_FLUSH_TO;
|
|
|
|
|
|
l2cap_chan_hold(chan);
|
|
|
|
|
@@ -527,6 +531,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
|
|
|
BT_DBG("chan %p, conn %p, err %d", chan, conn, err);
|
|
|
|
|
|
if (conn) {
|
|
|
+ struct amp_mgr *mgr = conn->hcon->amp_mgr;
|
|
|
/* Delete from channel list */
|
|
|
list_del(&chan->list);
|
|
|
|
|
@@ -536,10 +541,12 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
|
|
|
|
|
|
if (chan->chan_type != L2CAP_CHAN_CONN_FIX_A2MP)
|
|
|
hci_conn_put(conn->hcon);
|
|
|
+
|
|
|
+ if (mgr && mgr->bredr_chan == chan)
|
|
|
+ mgr->bredr_chan = NULL;
|
|
|
}
|
|
|
|
|
|
- if (chan->ops->teardown)
|
|
|
- chan->ops->teardown(chan, err);
|
|
|
+ chan->ops->teardown(chan, err);
|
|
|
|
|
|
if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
|
|
|
return;
|
|
@@ -573,19 +580,18 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
|
|
|
struct l2cap_conn *conn = chan->conn;
|
|
|
struct sock *sk = chan->sk;
|
|
|
|
|
|
- BT_DBG("chan %p state %s sk %p", chan,
|
|
|
- state_to_string(chan->state), sk);
|
|
|
+ BT_DBG("chan %p state %s sk %p", chan, state_to_string(chan->state),
|
|
|
+ sk);
|
|
|
|
|
|
switch (chan->state) {
|
|
|
case BT_LISTEN:
|
|
|
- if (chan->ops->teardown)
|
|
|
- chan->ops->teardown(chan, 0);
|
|
|
+ chan->ops->teardown(chan, 0);
|
|
|
break;
|
|
|
|
|
|
case BT_CONNECTED:
|
|
|
case BT_CONFIG:
|
|
|
if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED &&
|
|
|
- conn->hcon->type == ACL_LINK) {
|
|
|
+ conn->hcon->type == ACL_LINK) {
|
|
|
__set_chan_timer(chan, sk->sk_sndtimeo);
|
|
|
l2cap_send_disconn_req(conn, chan, reason);
|
|
|
} else
|
|
@@ -594,7 +600,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
|
|
|
|
|
|
case BT_CONNECT2:
|
|
|
if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED &&
|
|
|
- conn->hcon->type == ACL_LINK) {
|
|
|
+ conn->hcon->type == ACL_LINK) {
|
|
|
struct l2cap_conn_rsp rsp;
|
|
|
__u16 result;
|
|
|
|
|
@@ -609,7 +615,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
|
|
|
rsp.result = cpu_to_le16(result);
|
|
|
rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
|
|
|
l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP,
|
|
|
- sizeof(rsp), &rsp);
|
|
|
+ sizeof(rsp), &rsp);
|
|
|
}
|
|
|
|
|
|
l2cap_chan_del(chan, reason);
|
|
@@ -621,8 +627,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- if (chan->ops->teardown)
|
|
|
- chan->ops->teardown(chan, 0);
|
|
|
+ chan->ops->teardown(chan, 0);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -691,7 +696,8 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn)
|
|
|
return id;
|
|
|
}
|
|
|
|
|
|
-static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
|
|
|
+static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
|
|
|
+ void *data)
|
|
|
{
|
|
|
struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
|
|
|
u8 flags;
|
|
@@ -718,10 +724,10 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
|
|
|
u16 flags;
|
|
|
|
|
|
BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len,
|
|
|
- skb->priority);
|
|
|
+ skb->priority);
|
|
|
|
|
|
if (!test_bit(FLAG_FLUSHABLE, &chan->flags) &&
|
|
|
- lmp_no_flush_capable(hcon->hdev))
|
|
|
+ lmp_no_flush_capable(hcon->hdev))
|
|
|
flags = ACL_START_NO_FLUSH;
|
|
|
else
|
|
|
flags = ACL_START;
|
|
@@ -946,7 +952,19 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan)
|
|
|
return !test_bit(CONF_CONNECT_PEND, &chan->conf_state);
|
|
|
}
|
|
|
|
|
|
-static void l2cap_send_conn_req(struct l2cap_chan *chan)
|
|
|
+static bool __amp_capable(struct l2cap_chan *chan)
|
|
|
+{
|
|
|
+ struct l2cap_conn *conn = chan->conn;
|
|
|
+
|
|
|
+ if (enable_hs &&
|
|
|
+ chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED &&
|
|
|
+ conn->fixed_chan_mask & L2CAP_FC_A2MP)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+void l2cap_send_conn_req(struct l2cap_chan *chan)
|
|
|
{
|
|
|
struct l2cap_conn *conn = chan->conn;
|
|
|
struct l2cap_conn_req req;
|
|
@@ -972,6 +990,16 @@ static void l2cap_chan_ready(struct l2cap_chan *chan)
|
|
|
chan->ops->ready(chan);
|
|
|
}
|
|
|
|
|
|
+static void l2cap_start_connection(struct l2cap_chan *chan)
|
|
|
+{
|
|
|
+ if (__amp_capable(chan)) {
|
|
|
+ BT_DBG("chan %p AMP capable: discover AMPs", chan);
|
|
|
+ a2mp_discover_amp(chan);
|
|
|
+ } else {
|
|
|
+ l2cap_send_conn_req(chan);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static void l2cap_do_start(struct l2cap_chan *chan)
|
|
|
{
|
|
|
struct l2cap_conn *conn = chan->conn;
|
|
@@ -986,8 +1014,9 @@ static void l2cap_do_start(struct l2cap_chan *chan)
|
|
|
return;
|
|
|
|
|
|
if (l2cap_chan_check_security(chan) &&
|
|
|
- __l2cap_no_conn_pending(chan))
|
|
|
- l2cap_send_conn_req(chan);
|
|
|
+ __l2cap_no_conn_pending(chan)) {
|
|
|
+ l2cap_start_connection(chan);
|
|
|
+ }
|
|
|
} else {
|
|
|
struct l2cap_info_req req;
|
|
|
req.type = __constant_cpu_to_le16(L2CAP_IT_FEAT_MASK);
|
|
@@ -997,8 +1026,8 @@ static void l2cap_do_start(struct l2cap_chan *chan)
|
|
|
|
|
|
schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT);
|
|
|
|
|
|
- l2cap_send_cmd(conn, conn->info_ident,
|
|
|
- L2CAP_INFO_REQ, sizeof(req), &req);
|
|
|
+ l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ,
|
|
|
+ sizeof(req), &req);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1018,7 +1047,8 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err)
|
|
|
+static void l2cap_send_disconn_req(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_chan *chan, int err)
|
|
|
{
|
|
|
struct sock *sk = chan->sk;
|
|
|
struct l2cap_disconn_req req;
|
|
@@ -1033,14 +1063,14 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c
|
|
|
}
|
|
|
|
|
|
if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP) {
|
|
|
- __l2cap_state_change(chan, BT_DISCONN);
|
|
|
+ l2cap_state_change(chan, BT_DISCONN);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
req.dcid = cpu_to_le16(chan->dcid);
|
|
|
req.scid = cpu_to_le16(chan->scid);
|
|
|
- l2cap_send_cmd(conn, l2cap_get_ident(conn),
|
|
|
- L2CAP_DISCONN_REQ, sizeof(req), &req);
|
|
|
+ l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ,
|
|
|
+ sizeof(req), &req);
|
|
|
|
|
|
lock_sock(sk);
|
|
|
__l2cap_state_change(chan, BT_DISCONN);
|
|
@@ -1069,20 +1099,20 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
|
|
|
|
|
|
if (chan->state == BT_CONNECT) {
|
|
|
if (!l2cap_chan_check_security(chan) ||
|
|
|
- !__l2cap_no_conn_pending(chan)) {
|
|
|
+ !__l2cap_no_conn_pending(chan)) {
|
|
|
l2cap_chan_unlock(chan);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (!l2cap_mode_supported(chan->mode, conn->feat_mask)
|
|
|
- && test_bit(CONF_STATE2_DEVICE,
|
|
|
+ && test_bit(CONF_STATE2_DEVICE,
|
|
|
&chan->conf_state)) {
|
|
|
l2cap_chan_close(chan, ECONNRESET);
|
|
|
l2cap_chan_unlock(chan);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- l2cap_send_conn_req(chan);
|
|
|
+ l2cap_start_connection(chan);
|
|
|
|
|
|
} else if (chan->state == BT_CONNECT2) {
|
|
|
struct l2cap_conn_rsp rsp;
|
|
@@ -1094,11 +1124,9 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
|
|
|
lock_sock(sk);
|
|
|
if (test_bit(BT_SK_DEFER_SETUP,
|
|
|
&bt_sk(sk)->flags)) {
|
|
|
- struct sock *parent = bt_sk(sk)->parent;
|
|
|
rsp.result = __constant_cpu_to_le16(L2CAP_CR_PEND);
|
|
|
rsp.status = __constant_cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
|
|
|
- if (parent)
|
|
|
- parent->sk_data_ready(parent, 0);
|
|
|
+ chan->ops->defer(chan);
|
|
|
|
|
|
} else {
|
|
|
__l2cap_state_change(chan, BT_CONFIG);
|
|
@@ -1112,17 +1140,17 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
|
|
|
}
|
|
|
|
|
|
l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP,
|
|
|
- sizeof(rsp), &rsp);
|
|
|
+ sizeof(rsp), &rsp);
|
|
|
|
|
|
if (test_bit(CONF_REQ_SENT, &chan->conf_state) ||
|
|
|
- rsp.result != L2CAP_CR_SUCCESS) {
|
|
|
+ rsp.result != L2CAP_CR_SUCCESS) {
|
|
|
l2cap_chan_unlock(chan);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
set_bit(CONF_REQ_SENT, &chan->conf_state);
|
|
|
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
|
|
|
- l2cap_build_conf_req(chan, buf), buf);
|
|
|
+ l2cap_build_conf_req(chan, buf), buf);
|
|
|
chan->num_conf_req++;
|
|
|
}
|
|
|
|
|
@@ -1204,8 +1232,6 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
|
|
|
bacpy(&bt_sk(sk)->src, conn->src);
|
|
|
bacpy(&bt_sk(sk)->dst, conn->dst);
|
|
|
|
|
|
- bt_accept_enqueue(parent, sk);
|
|
|
-
|
|
|
l2cap_chan_add(conn, chan);
|
|
|
|
|
|
l2cap_chan_ready(chan);
|
|
@@ -1270,7 +1296,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
|
|
|
|
|
|
list_for_each_entry(chan, &conn->chan_l, list) {
|
|
|
if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags))
|
|
|
- __l2cap_chan_set_err(chan, err);
|
|
|
+ l2cap_chan_set_err(chan, err);
|
|
|
}
|
|
|
|
|
|
mutex_unlock(&conn->chan_lock);
|
|
@@ -1279,7 +1305,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
|
|
|
static void l2cap_info_timeout(struct work_struct *work)
|
|
|
{
|
|
|
struct l2cap_conn *conn = container_of(work, struct l2cap_conn,
|
|
|
- info_timer.work);
|
|
|
+ info_timer.work);
|
|
|
|
|
|
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
|
|
|
conn->info_ident = 0;
|
|
@@ -1333,7 +1359,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
|
|
|
static void security_timeout(struct work_struct *work)
|
|
|
{
|
|
|
struct l2cap_conn *conn = container_of(work, struct l2cap_conn,
|
|
|
- security_timer.work);
|
|
|
+ security_timer.work);
|
|
|
|
|
|
BT_DBG("conn %p", conn);
|
|
|
|
|
@@ -1355,7 +1381,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
|
|
|
if (!hchan)
|
|
|
return NULL;
|
|
|
|
|
|
- conn = kzalloc(sizeof(struct l2cap_conn), GFP_ATOMIC);
|
|
|
+ conn = kzalloc(sizeof(struct l2cap_conn), GFP_KERNEL);
|
|
|
if (!conn) {
|
|
|
hci_chan_del(hchan);
|
|
|
return NULL;
|
|
@@ -1367,10 +1393,22 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
|
|
|
|
|
|
BT_DBG("hcon %p conn %p hchan %p", hcon, conn, hchan);
|
|
|
|
|
|
- if (hcon->hdev->le_mtu && hcon->type == LE_LINK)
|
|
|
- conn->mtu = hcon->hdev->le_mtu;
|
|
|
- else
|
|
|
+ switch (hcon->type) {
|
|
|
+ case AMP_LINK:
|
|
|
+ conn->mtu = hcon->hdev->block_mtu;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LE_LINK:
|
|
|
+ if (hcon->hdev->le_mtu) {
|
|
|
+ conn->mtu = hcon->hdev->le_mtu;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ /* fall through */
|
|
|
+
|
|
|
+ default:
|
|
|
conn->mtu = hcon->hdev->acl_mtu;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
conn->src = &hcon->hdev->bdaddr;
|
|
|
conn->dst = &hcon->dst;
|
|
@@ -1448,7 +1486,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
|
|
|
__u8 auth_type;
|
|
|
int err;
|
|
|
|
|
|
- BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
|
|
|
+ BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", src, dst,
|
|
|
dst_type, __le16_to_cpu(psm));
|
|
|
|
|
|
hdev = hci_get_route(dst, src);
|
|
@@ -1461,7 +1499,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
|
|
|
|
|
|
/* PSM must be odd and lsb of upper byte must be 0 */
|
|
|
if ((__le16_to_cpu(psm) & 0x0101) != 0x0001 && !cid &&
|
|
|
- chan->chan_type != L2CAP_CHAN_RAW) {
|
|
|
+ chan->chan_type != L2CAP_CHAN_RAW) {
|
|
|
err = -EINVAL;
|
|
|
goto done;
|
|
|
}
|
|
@@ -1770,7 +1808,7 @@ static void l2cap_ertm_resend(struct l2cap_chan *chan)
|
|
|
skb = l2cap_ertm_seq_in_queue(&chan->tx_q, seq);
|
|
|
if (!skb) {
|
|
|
BT_DBG("Error: Can't retransmit seq %d, frame missing",
|
|
|
- seq);
|
|
|
+ seq);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -1795,9 +1833,9 @@ static void l2cap_ertm_resend(struct l2cap_chan *chan)
|
|
|
/* Cloned sk_buffs are read-only, so we need a
|
|
|
* writeable copy
|
|
|
*/
|
|
|
- tx_skb = skb_copy(skb, GFP_ATOMIC);
|
|
|
+ tx_skb = skb_copy(skb, GFP_KERNEL);
|
|
|
} else {
|
|
|
- tx_skb = skb_clone(skb, GFP_ATOMIC);
|
|
|
+ tx_skb = skb_clone(skb, GFP_KERNEL);
|
|
|
}
|
|
|
|
|
|
if (!tx_skb) {
|
|
@@ -1855,7 +1893,7 @@ static void l2cap_retransmit_all(struct l2cap_chan *chan,
|
|
|
if (chan->unacked_frames) {
|
|
|
skb_queue_walk(&chan->tx_q, skb) {
|
|
|
if (bt_cb(skb)->control.txseq == control->reqseq ||
|
|
|
- skb == chan->tx_send_head)
|
|
|
+ skb == chan->tx_send_head)
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -2156,7 +2194,7 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
|
|
|
}
|
|
|
|
|
|
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
|
|
|
- u32 priority)
|
|
|
+ u32 priority)
|
|
|
{
|
|
|
struct sk_buff *skb;
|
|
|
int err;
|
|
@@ -2543,7 +2581,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
|
|
|
/* Don't send frame to the socket it came from */
|
|
|
if (skb->sk == sk)
|
|
|
continue;
|
|
|
- nskb = skb_clone(skb, GFP_ATOMIC);
|
|
|
+ nskb = skb_clone(skb, GFP_KERNEL);
|
|
|
if (!nskb)
|
|
|
continue;
|
|
|
|
|
@@ -2569,7 +2607,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code,
|
|
|
len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
|
|
|
count = min_t(unsigned int, conn->mtu, len);
|
|
|
|
|
|
- skb = bt_skb_alloc(count, GFP_ATOMIC);
|
|
|
+ skb = bt_skb_alloc(count, GFP_KERNEL);
|
|
|
if (!skb)
|
|
|
return NULL;
|
|
|
|
|
@@ -2599,7 +2637,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code,
|
|
|
while (len) {
|
|
|
count = min_t(unsigned int, conn->mtu, len);
|
|
|
|
|
|
- *frag = bt_skb_alloc(count, GFP_ATOMIC);
|
|
|
+ *frag = bt_skb_alloc(count, GFP_KERNEL);
|
|
|
if (!*frag)
|
|
|
goto fail;
|
|
|
|
|
@@ -2618,7 +2656,8 @@ fail:
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned long *val)
|
|
|
+static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen,
|
|
|
+ unsigned long *val)
|
|
|
{
|
|
|
struct l2cap_conf_opt *opt = *ptr;
|
|
|
int len;
|
|
@@ -2692,7 +2731,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
|
|
|
efs.msdu = cpu_to_le16(chan->local_msdu);
|
|
|
efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime);
|
|
|
efs.acc_lat = __constant_cpu_to_le32(L2CAP_DEFAULT_ACC_LAT);
|
|
|
- efs.flush_to = __constant_cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO);
|
|
|
+ efs.flush_to = __constant_cpu_to_le32(L2CAP_EFS_DEFAULT_FLUSH_TO);
|
|
|
break;
|
|
|
|
|
|
case L2CAP_MODE_STREAMING:
|
|
@@ -2709,7 +2748,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
|
|
|
}
|
|
|
|
|
|
l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs),
|
|
|
- (unsigned long) &efs);
|
|
|
+ (unsigned long) &efs);
|
|
|
}
|
|
|
|
|
|
static void l2cap_ack_timeout(struct work_struct *work)
|
|
@@ -2798,13 +2837,13 @@ static inline bool __l2cap_efs_supported(struct l2cap_chan *chan)
|
|
|
static inline void l2cap_txwin_setup(struct l2cap_chan *chan)
|
|
|
{
|
|
|
if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW &&
|
|
|
- __l2cap_ews_supported(chan)) {
|
|
|
+ __l2cap_ews_supported(chan)) {
|
|
|
/* use extended control field */
|
|
|
set_bit(FLAG_EXT_CTRL, &chan->flags);
|
|
|
chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW;
|
|
|
} else {
|
|
|
chan->tx_win = min_t(u16, chan->tx_win,
|
|
|
- L2CAP_DEFAULT_TX_WINDOW);
|
|
|
+ L2CAP_DEFAULT_TX_WINDOW);
|
|
|
chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW;
|
|
|
}
|
|
|
chan->ack_win = chan->tx_win;
|
|
@@ -2844,7 +2883,7 @@ done:
|
|
|
switch (chan->mode) {
|
|
|
case L2CAP_MODE_BASIC:
|
|
|
if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) &&
|
|
|
- !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING))
|
|
|
+ !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING))
|
|
|
break;
|
|
|
|
|
|
rfc.mode = L2CAP_MODE_BASIC;
|
|
@@ -2855,7 +2894,7 @@ done:
|
|
|
rfc.max_pdu_size = 0;
|
|
|
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
|
|
|
- (unsigned long) &rfc);
|
|
|
+ (unsigned long) &rfc);
|
|
|
break;
|
|
|
|
|
|
case L2CAP_MODE_ERTM:
|
|
@@ -2865,18 +2904,17 @@ done:
|
|
|
rfc.monitor_timeout = 0;
|
|
|
|
|
|
size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu -
|
|
|
- L2CAP_EXT_HDR_SIZE -
|
|
|
- L2CAP_SDULEN_SIZE -
|
|
|
- L2CAP_FCS_SIZE);
|
|
|
+ L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE -
|
|
|
+ L2CAP_FCS_SIZE);
|
|
|
rfc.max_pdu_size = cpu_to_le16(size);
|
|
|
|
|
|
l2cap_txwin_setup(chan);
|
|
|
|
|
|
rfc.txwin_size = min_t(u16, chan->tx_win,
|
|
|
- L2CAP_DEFAULT_TX_WINDOW);
|
|
|
+ L2CAP_DEFAULT_TX_WINDOW);
|
|
|
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
|
|
|
- (unsigned long) &rfc);
|
|
|
+ (unsigned long) &rfc);
|
|
|
|
|
|
if (test_bit(FLAG_EFS_ENABLE, &chan->flags))
|
|
|
l2cap_add_opt_efs(&ptr, chan);
|
|
@@ -2885,14 +2923,14 @@ done:
|
|
|
break;
|
|
|
|
|
|
if (chan->fcs == L2CAP_FCS_NONE ||
|
|
|
- test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
|
|
|
+ test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
|
|
|
chan->fcs = L2CAP_FCS_NONE;
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs);
|
|
|
}
|
|
|
|
|
|
if (test_bit(FLAG_EXT_CTRL, &chan->flags))
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2,
|
|
|
- chan->tx_win);
|
|
|
+ chan->tx_win);
|
|
|
break;
|
|
|
|
|
|
case L2CAP_MODE_STREAMING:
|
|
@@ -2904,13 +2942,12 @@ done:
|
|
|
rfc.monitor_timeout = 0;
|
|
|
|
|
|
size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu -
|
|
|
- L2CAP_EXT_HDR_SIZE -
|
|
|
- L2CAP_SDULEN_SIZE -
|
|
|
- L2CAP_FCS_SIZE);
|
|
|
+ L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE -
|
|
|
+ L2CAP_FCS_SIZE);
|
|
|
rfc.max_pdu_size = cpu_to_le16(size);
|
|
|
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
|
|
|
- (unsigned long) &rfc);
|
|
|
+ (unsigned long) &rfc);
|
|
|
|
|
|
if (test_bit(FLAG_EFS_ENABLE, &chan->flags))
|
|
|
l2cap_add_opt_efs(&ptr, chan);
|
|
@@ -2919,7 +2956,7 @@ done:
|
|
|
break;
|
|
|
|
|
|
if (chan->fcs == L2CAP_FCS_NONE ||
|
|
|
- test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
|
|
|
+ test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
|
|
|
chan->fcs = L2CAP_FCS_NONE;
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs);
|
|
|
}
|
|
@@ -3011,7 +3048,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
|
|
|
case L2CAP_MODE_ERTM:
|
|
|
if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) {
|
|
|
chan->mode = l2cap_select_mode(rfc.mode,
|
|
|
- chan->conn->feat_mask);
|
|
|
+ chan->conn->feat_mask);
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -3036,8 +3073,8 @@ done:
|
|
|
if (chan->num_conf_rsp == 1)
|
|
|
return -ECONNREFUSED;
|
|
|
|
|
|
- l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
|
|
|
- sizeof(rfc), (unsigned long) &rfc);
|
|
|
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
|
|
|
+ (unsigned long) &rfc);
|
|
|
}
|
|
|
|
|
|
if (result == L2CAP_CONF_SUCCESS) {
|
|
@@ -3054,8 +3091,8 @@ done:
|
|
|
|
|
|
if (remote_efs) {
|
|
|
if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
|
|
|
- efs.stype != L2CAP_SERV_NOTRAFIC &&
|
|
|
- efs.stype != chan->local_stype) {
|
|
|
+ efs.stype != L2CAP_SERV_NOTRAFIC &&
|
|
|
+ efs.stype != chan->local_stype) {
|
|
|
|
|
|
result = L2CAP_CONF_UNACCEPT;
|
|
|
|
|
@@ -3063,8 +3100,8 @@ done:
|
|
|
return -ECONNREFUSED;
|
|
|
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
|
|
|
- sizeof(efs),
|
|
|
- (unsigned long) &efs);
|
|
|
+ sizeof(efs),
|
|
|
+ (unsigned long) &efs);
|
|
|
} else {
|
|
|
/* Send PENDING Conf Rsp */
|
|
|
result = L2CAP_CONF_PENDING;
|
|
@@ -3087,10 +3124,8 @@ done:
|
|
|
chan->remote_max_tx = rfc.max_transmit;
|
|
|
|
|
|
size = min_t(u16, le16_to_cpu(rfc.max_pdu_size),
|
|
|
- chan->conn->mtu -
|
|
|
- L2CAP_EXT_HDR_SIZE -
|
|
|
- L2CAP_SDULEN_SIZE -
|
|
|
- L2CAP_FCS_SIZE);
|
|
|
+ chan->conn->mtu - L2CAP_EXT_HDR_SIZE -
|
|
|
+ L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE);
|
|
|
rfc.max_pdu_size = cpu_to_le16(size);
|
|
|
chan->remote_mps = size;
|
|
|
|
|
@@ -3102,36 +3137,35 @@ done:
|
|
|
set_bit(CONF_MODE_DONE, &chan->conf_state);
|
|
|
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
|
|
|
- sizeof(rfc), (unsigned long) &rfc);
|
|
|
+ sizeof(rfc), (unsigned long) &rfc);
|
|
|
|
|
|
if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
|
|
|
chan->remote_id = efs.id;
|
|
|
chan->remote_stype = efs.stype;
|
|
|
chan->remote_msdu = le16_to_cpu(efs.msdu);
|
|
|
chan->remote_flush_to =
|
|
|
- le32_to_cpu(efs.flush_to);
|
|
|
+ le32_to_cpu(efs.flush_to);
|
|
|
chan->remote_acc_lat =
|
|
|
- le32_to_cpu(efs.acc_lat);
|
|
|
+ le32_to_cpu(efs.acc_lat);
|
|
|
chan->remote_sdu_itime =
|
|
|
le32_to_cpu(efs.sdu_itime);
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
|
|
|
- sizeof(efs), (unsigned long) &efs);
|
|
|
+ sizeof(efs),
|
|
|
+ (unsigned long) &efs);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case L2CAP_MODE_STREAMING:
|
|
|
size = min_t(u16, le16_to_cpu(rfc.max_pdu_size),
|
|
|
- chan->conn->mtu -
|
|
|
- L2CAP_EXT_HDR_SIZE -
|
|
|
- L2CAP_SDULEN_SIZE -
|
|
|
- L2CAP_FCS_SIZE);
|
|
|
+ chan->conn->mtu - L2CAP_EXT_HDR_SIZE -
|
|
|
+ L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE);
|
|
|
rfc.max_pdu_size = cpu_to_le16(size);
|
|
|
chan->remote_mps = size;
|
|
|
|
|
|
set_bit(CONF_MODE_DONE, &chan->conf_state);
|
|
|
|
|
|
- l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
|
|
|
- sizeof(rfc), (unsigned long) &rfc);
|
|
|
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
|
|
|
+ (unsigned long) &rfc);
|
|
|
|
|
|
break;
|
|
|
|
|
@@ -3152,7 +3186,8 @@ done:
|
|
|
return ptr - data;
|
|
|
}
|
|
|
|
|
|
-static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, void *data, u16 *result)
|
|
|
+static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
|
|
|
+ void *data, u16 *result)
|
|
|
{
|
|
|
struct l2cap_conf_req *req = data;
|
|
|
void *ptr = req->data;
|
|
@@ -3179,7 +3214,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
|
|
|
case L2CAP_CONF_FLUSH_TO:
|
|
|
chan->flush_to = val;
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO,
|
|
|
- 2, chan->flush_to);
|
|
|
+ 2, chan->flush_to);
|
|
|
break;
|
|
|
|
|
|
case L2CAP_CONF_RFC:
|
|
@@ -3187,13 +3222,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
|
|
|
memcpy(&rfc, (void *)val, olen);
|
|
|
|
|
|
if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
|
|
|
- rfc.mode != chan->mode)
|
|
|
+ rfc.mode != chan->mode)
|
|
|
return -ECONNREFUSED;
|
|
|
|
|
|
chan->fcs = 0;
|
|
|
|
|
|
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
|
|
|
- sizeof(rfc), (unsigned long) &rfc);
|
|
|
+ sizeof(rfc), (unsigned long) &rfc);
|
|
|
break;
|
|
|
|
|
|
case L2CAP_CONF_EWS:
|
|
@@ -3207,12 +3242,12 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
|
|
|
memcpy(&efs, (void *)val, olen);
|
|
|
|
|
|
if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
|
|
|
- efs.stype != L2CAP_SERV_NOTRAFIC &&
|
|
|
- efs.stype != chan->local_stype)
|
|
|
+ efs.stype != L2CAP_SERV_NOTRAFIC &&
|
|
|
+ efs.stype != chan->local_stype)
|
|
|
return -ECONNREFUSED;
|
|
|
|
|
|
- l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
|
|
|
- sizeof(efs), (unsigned long) &efs);
|
|
|
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs),
|
|
|
+ (unsigned long) &efs);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -3235,10 +3270,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
|
|
|
if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
|
|
|
chan->local_msdu = le16_to_cpu(efs.msdu);
|
|
|
chan->local_sdu_itime =
|
|
|
- le32_to_cpu(efs.sdu_itime);
|
|
|
+ le32_to_cpu(efs.sdu_itime);
|
|
|
chan->local_acc_lat = le32_to_cpu(efs.acc_lat);
|
|
|
chan->local_flush_to =
|
|
|
- le32_to_cpu(efs.flush_to);
|
|
|
+ le32_to_cpu(efs.flush_to);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -3253,7 +3288,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
|
|
|
return ptr - data;
|
|
|
}
|
|
|
|
|
|
-static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result, u16 flags)
|
|
|
+static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data,
|
|
|
+ u16 result, u16 flags)
|
|
|
{
|
|
|
struct l2cap_conf_rsp *rsp = data;
|
|
|
void *ptr = rsp->data;
|
|
@@ -3277,14 +3313,13 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
|
|
|
rsp.dcid = cpu_to_le16(chan->scid);
|
|
|
rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS);
|
|
|
rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
|
|
|
- l2cap_send_cmd(conn, chan->ident,
|
|
|
- L2CAP_CONN_RSP, sizeof(rsp), &rsp);
|
|
|
+ l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
|
|
|
|
|
|
if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state))
|
|
|
return;
|
|
|
|
|
|
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
|
|
|
- l2cap_build_conf_req(chan, buf), buf);
|
|
|
+ l2cap_build_conf_req(chan, buf), buf);
|
|
|
chan->num_conf_req++;
|
|
|
}
|
|
|
|
|
@@ -3339,7 +3374,8 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_command_rej(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
|
|
|
|
|
@@ -3347,7 +3383,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
return 0;
|
|
|
|
|
|
if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) &&
|
|
|
- cmd->ident == conn->info_ident) {
|
|
|
+ cmd->ident == conn->info_ident) {
|
|
|
cancel_delayed_work(&conn->info_timer);
|
|
|
|
|
|
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
|
|
@@ -3359,7 +3395,8 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
|
|
|
+ u8 *data, u8 rsp_code, u8 amp_id)
|
|
|
{
|
|
|
struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
|
|
|
struct l2cap_conn_rsp rsp;
|
|
@@ -3386,7 +3423,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
|
|
|
/* Check if the ACL is secure enough (if not SDP) */
|
|
|
if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) &&
|
|
|
- !hci_conn_check_link_mode(conn->hcon)) {
|
|
|
+ !hci_conn_check_link_mode(conn->hcon)) {
|
|
|
conn->disc_reason = HCI_ERROR_AUTH_FAILURE;
|
|
|
result = L2CAP_CR_SEC_BLOCK;
|
|
|
goto response;
|
|
@@ -3411,8 +3448,6 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
chan->psm = psm;
|
|
|
chan->dcid = scid;
|
|
|
|
|
|
- bt_accept_enqueue(parent, sk);
|
|
|
-
|
|
|
__l2cap_chan_add(conn, chan);
|
|
|
|
|
|
dcid = chan->scid;
|
|
@@ -3427,7 +3462,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
__l2cap_state_change(chan, BT_CONNECT2);
|
|
|
result = L2CAP_CR_PEND;
|
|
|
status = L2CAP_CS_AUTHOR_PEND;
|
|
|
- parent->sk_data_ready(parent, 0);
|
|
|
+ chan->ops->defer(chan);
|
|
|
} else {
|
|
|
__l2cap_state_change(chan, BT_CONFIG);
|
|
|
result = L2CAP_CR_SUCCESS;
|
|
@@ -3453,7 +3488,7 @@ sendresp:
|
|
|
rsp.dcid = cpu_to_le16(dcid);
|
|
|
rsp.result = cpu_to_le16(result);
|
|
|
rsp.status = cpu_to_le16(status);
|
|
|
- l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
|
|
|
+ l2cap_send_cmd(conn, cmd->ident, rsp_code, sizeof(rsp), &rsp);
|
|
|
|
|
|
if (result == L2CAP_CR_PEND && status == L2CAP_CS_NO_INFO) {
|
|
|
struct l2cap_info_req info;
|
|
@@ -3464,23 +3499,29 @@ sendresp:
|
|
|
|
|
|
schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT);
|
|
|
|
|
|
- l2cap_send_cmd(conn, conn->info_ident,
|
|
|
- L2CAP_INFO_REQ, sizeof(info), &info);
|
|
|
+ l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ,
|
|
|
+ sizeof(info), &info);
|
|
|
}
|
|
|
|
|
|
if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) &&
|
|
|
- result == L2CAP_CR_SUCCESS) {
|
|
|
+ result == L2CAP_CR_SUCCESS) {
|
|
|
u8 buf[128];
|
|
|
set_bit(CONF_REQ_SENT, &chan->conf_state);
|
|
|
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
|
|
|
- l2cap_build_conf_req(chan, buf), buf);
|
|
|
+ l2cap_build_conf_req(chan, buf), buf);
|
|
|
chan->num_conf_req++;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
+static int l2cap_connect_req(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+{
|
|
|
+ l2cap_connect(conn, cmd, data, L2CAP_CONN_RSP, 0);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_connect_rsp(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data;
|
|
|
u16 scid, dcid, result, status;
|
|
@@ -3494,7 +3535,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
status = __le16_to_cpu(rsp->status);
|
|
|
|
|
|
BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x",
|
|
|
- dcid, scid, result, status);
|
|
|
+ dcid, scid, result, status);
|
|
|
|
|
|
mutex_lock(&conn->chan_lock);
|
|
|
|
|
@@ -3527,7 +3568,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
|
|
|
break;
|
|
|
|
|
|
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
|
|
|
- l2cap_build_conf_req(chan, req), req);
|
|
|
+ l2cap_build_conf_req(chan, req), req);
|
|
|
chan->num_conf_req++;
|
|
|
break;
|
|
|
|
|
@@ -3559,7 +3600,25 @@ static inline void set_default_fcs(struct l2cap_chan *chan)
|
|
|
chan->fcs = L2CAP_FCS_CRC16;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
|
|
|
+static void l2cap_send_efs_conf_rsp(struct l2cap_chan *chan, void *data,
|
|
|
+ u8 ident, u16 flags)
|
|
|
+{
|
|
|
+ struct l2cap_conn *conn = chan->conn;
|
|
|
+
|
|
|
+ BT_DBG("conn %p chan %p ident %d flags 0x%4.4x", conn, chan, ident,
|
|
|
+ flags);
|
|
|
+
|
|
|
+ clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state);
|
|
|
+ set_bit(CONF_OUTPUT_DONE, &chan->conf_state);
|
|
|
+
|
|
|
+ l2cap_send_cmd(conn, ident, L2CAP_CONF_RSP,
|
|
|
+ l2cap_build_conf_rsp(chan, data,
|
|
|
+ L2CAP_CONF_SUCCESS, flags), data);
|
|
|
+}
|
|
|
+
|
|
|
+static inline int l2cap_config_req(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u16 cmd_len,
|
|
|
+ u8 *data)
|
|
|
{
|
|
|
struct l2cap_conf_req *req = (struct l2cap_conf_req *) data;
|
|
|
u16 dcid, flags;
|
|
@@ -3584,7 +3643,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
rej.dcid = cpu_to_le16(chan->dcid);
|
|
|
|
|
|
l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ,
|
|
|
- sizeof(rej), &rej);
|
|
|
+ sizeof(rej), &rej);
|
|
|
goto unlock;
|
|
|
}
|
|
|
|
|
@@ -3592,8 +3651,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
len = cmd_len - sizeof(*req);
|
|
|
if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) {
|
|
|
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
|
|
|
- l2cap_build_conf_rsp(chan, rsp,
|
|
|
- L2CAP_CONF_REJECT, flags), rsp);
|
|
|
+ l2cap_build_conf_rsp(chan, rsp,
|
|
|
+ L2CAP_CONF_REJECT, flags), rsp);
|
|
|
goto unlock;
|
|
|
}
|
|
|
|
|
@@ -3604,8 +3663,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
if (flags & L2CAP_CONF_FLAG_CONTINUATION) {
|
|
|
/* Incomplete config. Send empty response. */
|
|
|
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
|
|
|
- l2cap_build_conf_rsp(chan, rsp,
|
|
|
- L2CAP_CONF_SUCCESS, flags), rsp);
|
|
|
+ l2cap_build_conf_rsp(chan, rsp,
|
|
|
+ L2CAP_CONF_SUCCESS, flags), rsp);
|
|
|
goto unlock;
|
|
|
}
|
|
|
|
|
@@ -3643,23 +3702,22 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) {
|
|
|
u8 buf[64];
|
|
|
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
|
|
|
- l2cap_build_conf_req(chan, buf), buf);
|
|
|
+ l2cap_build_conf_req(chan, buf), buf);
|
|
|
chan->num_conf_req++;
|
|
|
}
|
|
|
|
|
|
/* Got Conf Rsp PENDING from remote side and asume we sent
|
|
|
Conf Rsp PENDING in the code above */
|
|
|
if (test_bit(CONF_REM_CONF_PEND, &chan->conf_state) &&
|
|
|
- test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) {
|
|
|
+ test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) {
|
|
|
|
|
|
/* check compatibility */
|
|
|
|
|
|
- clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state);
|
|
|
- set_bit(CONF_OUTPUT_DONE, &chan->conf_state);
|
|
|
-
|
|
|
- l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
|
|
|
- l2cap_build_conf_rsp(chan, rsp,
|
|
|
- L2CAP_CONF_SUCCESS, flags), rsp);
|
|
|
+ /* Send rsp for BR/EDR channel */
|
|
|
+ if (!chan->ctrl_id)
|
|
|
+ l2cap_send_efs_conf_rsp(chan, rsp, cmd->ident, flags);
|
|
|
+ else
|
|
|
+ chan->ident = cmd->ident;
|
|
|
}
|
|
|
|
|
|
unlock:
|
|
@@ -3667,7 +3725,8 @@ unlock:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_config_rsp(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data;
|
|
|
u16 scid, flags, result;
|
|
@@ -3699,7 +3758,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
char buf[64];
|
|
|
|
|
|
len = l2cap_parse_conf_rsp(chan, rsp->data, len,
|
|
|
- buf, &result);
|
|
|
+ buf, &result);
|
|
|
if (len < 0) {
|
|
|
l2cap_send_disconn_req(conn, chan, ECONNRESET);
|
|
|
goto done;
|
|
@@ -3707,12 +3766,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
|
|
|
/* check compatibility */
|
|
|
|
|
|
- clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state);
|
|
|
- set_bit(CONF_OUTPUT_DONE, &chan->conf_state);
|
|
|
-
|
|
|
- l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
|
|
|
- l2cap_build_conf_rsp(chan, buf,
|
|
|
- L2CAP_CONF_SUCCESS, 0x0000), buf);
|
|
|
+ if (!chan->ctrl_id)
|
|
|
+ l2cap_send_efs_conf_rsp(chan, buf, cmd->ident,
|
|
|
+ 0);
|
|
|
+ else
|
|
|
+ chan->ident = cmd->ident;
|
|
|
}
|
|
|
goto done;
|
|
|
|
|
@@ -3728,14 +3786,14 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
|
|
|
/* throw out any old stored conf requests */
|
|
|
result = L2CAP_CONF_SUCCESS;
|
|
|
len = l2cap_parse_conf_rsp(chan, rsp->data, len,
|
|
|
- req, &result);
|
|
|
+ req, &result);
|
|
|
if (len < 0) {
|
|
|
l2cap_send_disconn_req(conn, chan, ECONNRESET);
|
|
|
goto done;
|
|
|
}
|
|
|
|
|
|
l2cap_send_cmd(conn, l2cap_get_ident(conn),
|
|
|
- L2CAP_CONF_REQ, len, req);
|
|
|
+ L2CAP_CONF_REQ, len, req);
|
|
|
chan->num_conf_req++;
|
|
|
if (result != L2CAP_CONF_SUCCESS)
|
|
|
goto done;
|
|
@@ -3773,7 +3831,8 @@ done:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data;
|
|
|
struct l2cap_disconn_rsp rsp;
|
|
@@ -3819,7 +3878,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data;
|
|
|
u16 dcid, scid;
|
|
@@ -3853,7 +3913,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_information_req(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_info_req *req = (struct l2cap_info_req *) data;
|
|
|
u16 type;
|
|
@@ -3870,14 +3931,14 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm
|
|
|
rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS);
|
|
|
if (!disable_ertm)
|
|
|
feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING
|
|
|
- | L2CAP_FEAT_FCS;
|
|
|
+ | L2CAP_FEAT_FCS;
|
|
|
if (enable_hs)
|
|
|
feat_mask |= L2CAP_FEAT_EXT_FLOW
|
|
|
- | L2CAP_FEAT_EXT_WINDOW;
|
|
|
+ | L2CAP_FEAT_EXT_WINDOW;
|
|
|
|
|
|
put_unaligned_le32(feat_mask, rsp->data);
|
|
|
- l2cap_send_cmd(conn, cmd->ident,
|
|
|
- L2CAP_INFO_RSP, sizeof(buf), buf);
|
|
|
+ l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf),
|
|
|
+ buf);
|
|
|
} else if (type == L2CAP_IT_FIXED_CHAN) {
|
|
|
u8 buf[12];
|
|
|
struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf;
|
|
@@ -3890,20 +3951,21 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm
|
|
|
rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN);
|
|
|
rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS);
|
|
|
memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan));
|
|
|
- l2cap_send_cmd(conn, cmd->ident,
|
|
|
- L2CAP_INFO_RSP, sizeof(buf), buf);
|
|
|
+ l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf),
|
|
|
+ buf);
|
|
|
} else {
|
|
|
struct l2cap_info_rsp rsp;
|
|
|
rsp.type = cpu_to_le16(type);
|
|
|
rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP);
|
|
|
- l2cap_send_cmd(conn, cmd->ident,
|
|
|
- L2CAP_INFO_RSP, sizeof(rsp), &rsp);
|
|
|
+ l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp),
|
|
|
+ &rsp);
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+static inline int l2cap_information_rsp(struct l2cap_conn *conn,
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data;
|
|
|
u16 type, result;
|
|
@@ -3915,7 +3977,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
|
|
|
|
|
|
/* L2CAP Info req/rsp are unbound to channels, add extra checks */
|
|
|
if (cmd->ident != conn->info_ident ||
|
|
|
- conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)
|
|
|
+ conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)
|
|
|
return 0;
|
|
|
|
|
|
cancel_delayed_work(&conn->info_timer);
|
|
@@ -3940,7 +4002,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
|
|
|
conn->info_ident = l2cap_get_ident(conn);
|
|
|
|
|
|
l2cap_send_cmd(conn, conn->info_ident,
|
|
|
- L2CAP_INFO_REQ, sizeof(req), &req);
|
|
|
+ L2CAP_INFO_REQ, sizeof(req), &req);
|
|
|
} else {
|
|
|
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
|
|
|
conn->info_ident = 0;
|
|
@@ -3962,8 +4024,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
|
|
|
}
|
|
|
|
|
|
static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
|
|
|
- struct l2cap_cmd_hdr *cmd, u16 cmd_len,
|
|
|
- void *data)
|
|
|
+ struct l2cap_cmd_hdr *cmd,
|
|
|
+ u16 cmd_len, void *data)
|
|
|
{
|
|
|
struct l2cap_create_chan_req *req = data;
|
|
|
struct l2cap_create_chan_rsp rsp;
|
|
@@ -3993,7 +4055,8 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
|
|
|
}
|
|
|
|
|
|
static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn,
|
|
|
- struct l2cap_cmd_hdr *cmd, void *data)
|
|
|
+ struct l2cap_cmd_hdr *cmd,
|
|
|
+ void *data)
|
|
|
{
|
|
|
BT_DBG("conn %p", conn);
|
|
|
|
|
@@ -4126,7 +4189,7 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn,
|
|
|
}
|
|
|
|
|
|
static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency,
|
|
|
- u16 to_multiplier)
|
|
|
+ u16 to_multiplier)
|
|
|
{
|
|
|
u16 max_latency;
|
|
|
|
|
@@ -4147,7 +4210,8 @@ static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency,
|
|
|
}
|
|
|
|
|
|
static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
|
|
|
- struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+ struct l2cap_cmd_hdr *cmd,
|
|
|
+ u8 *data)
|
|
|
{
|
|
|
struct hci_conn *hcon = conn->hcon;
|
|
|
struct l2cap_conn_param_update_req *req;
|
|
@@ -4169,7 +4233,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
|
|
|
to_multiplier = __le16_to_cpu(req->to_multiplier);
|
|
|
|
|
|
BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x",
|
|
|
- min, max, latency, to_multiplier);
|
|
|
+ min, max, latency, to_multiplier);
|
|
|
|
|
|
memset(&rsp, 0, sizeof(rsp));
|
|
|
|
|
@@ -4180,7 +4244,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
|
|
|
rsp.result = __constant_cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED);
|
|
|
|
|
|
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
|
|
|
- sizeof(rsp), &rsp);
|
|
|
+ sizeof(rsp), &rsp);
|
|
|
|
|
|
if (!err)
|
|
|
hci_le_conn_update(hcon, min, max, latency, to_multiplier);
|
|
@@ -4189,7 +4253,8 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
|
|
|
}
|
|
|
|
|
|
static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
|
|
|
- struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
|
|
|
+ struct l2cap_cmd_hdr *cmd, u16 cmd_len,
|
|
|
+ u8 *data)
|
|
|
{
|
|
|
int err = 0;
|
|
|
|
|
@@ -4203,6 +4268,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
|
|
|
break;
|
|
|
|
|
|
case L2CAP_CONN_RSP:
|
|
|
+ case L2CAP_CREATE_CHAN_RSP:
|
|
|
err = l2cap_connect_rsp(conn, cmd, data);
|
|
|
break;
|
|
|
|
|
@@ -4241,10 +4307,6 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
|
|
|
err = l2cap_create_channel_req(conn, cmd, cmd_len, data);
|
|
|
break;
|
|
|
|
|
|
- case L2CAP_CREATE_CHAN_RSP:
|
|
|
- err = l2cap_create_channel_rsp(conn, cmd, data);
|
|
|
- break;
|
|
|
-
|
|
|
case L2CAP_MOVE_CHAN_REQ:
|
|
|
err = l2cap_move_channel_req(conn, cmd, cmd_len, data);
|
|
|
break;
|
|
@@ -4271,7 +4333,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
|
|
|
}
|
|
|
|
|
|
static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
|
|
|
- struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
+ struct l2cap_cmd_hdr *cmd, u8 *data)
|
|
|
{
|
|
|
switch (cmd->code) {
|
|
|
case L2CAP_COMMAND_REJ:
|
|
@@ -4290,7 +4352,7 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
|
|
|
}
|
|
|
|
|
|
static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
|
|
- struct sk_buff *skb)
|
|
|
+ struct sk_buff *skb)
|
|
|
{
|
|
|
u8 *data = skb->data;
|
|
|
int len = skb->len;
|
|
@@ -4307,7 +4369,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
|
|
|
|
|
cmd_len = le16_to_cpu(cmd.len);
|
|
|
|
|
|
- BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident);
|
|
|
+ BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len,
|
|
|
+ cmd.ident);
|
|
|
|
|
|
if (cmd_len > len || !cmd.ident) {
|
|
|
BT_DBG("corrupted command");
|
|
@@ -4326,7 +4389,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
|
|
|
|
|
/* FIXME: Map err to a valid reason */
|
|
|
rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
|
|
|
- l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
|
|
|
+ l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ,
|
|
|
+ sizeof(rej), &rej);
|
|
|
}
|
|
|
|
|
|
data += cmd_len;
|
|
@@ -4391,8 +4455,8 @@ static void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void append_skb_frag(struct sk_buff *skb,
|
|
|
- struct sk_buff *new_frag, struct sk_buff **last_frag)
|
|
|
+static void append_skb_frag(struct sk_buff *skb, struct sk_buff *new_frag,
|
|
|
+ struct sk_buff **last_frag)
|
|
|
{
|
|
|
/* skb->len reflects data in skb as well as all fragments
|
|
|
* skb->data_len reflects only data in fragments
|
|
@@ -4641,7 +4705,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq)
|
|
|
|
|
|
if (chan->rx_state == L2CAP_RX_STATE_SREJ_SENT) {
|
|
|
if (__seq_offset(chan, txseq, chan->last_acked_seq) >=
|
|
|
- chan->tx_win) {
|
|
|
+ chan->tx_win) {
|
|
|
/* See notes below regarding "double poll" and
|
|
|
* invalid packets.
|
|
|
*/
|
|
@@ -4682,8 +4746,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq)
|
|
|
}
|
|
|
|
|
|
if (__seq_offset(chan, txseq, chan->last_acked_seq) <
|
|
|
- __seq_offset(chan, chan->expected_tx_seq,
|
|
|
- chan->last_acked_seq)){
|
|
|
+ __seq_offset(chan, chan->expected_tx_seq, chan->last_acked_seq)) {
|
|
|
BT_DBG("Duplicate - expected_tx_seq later than txseq");
|
|
|
return L2CAP_TXSEQ_DUPLICATE;
|
|
|
}
|
|
@@ -5323,7 +5386,7 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
|
|
|
int exact = 0, lm1 = 0, lm2 = 0;
|
|
|
struct l2cap_chan *c;
|
|
|
|
|
|
- BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
|
|
|
+ BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr);
|
|
|
|
|
|
/* Find listening sockets and check their link_mode */
|
|
|
read_lock(&chan_list_lock);
|
|
@@ -5353,7 +5416,7 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
|
|
|
{
|
|
|
struct l2cap_conn *conn;
|
|
|
|
|
|
- BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
|
|
|
+ BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
|
|
|
|
|
|
if (!status) {
|
|
|
conn = l2cap_conn_add(hcon, status);
|
|
@@ -5443,7 +5506,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
|
|
|
}
|
|
|
|
|
|
if (!status && (chan->state == BT_CONNECTED ||
|
|
|
- chan->state == BT_CONFIG)) {
|
|
|
+ chan->state == BT_CONFIG)) {
|
|
|
struct sock *sk = chan->sk;
|
|
|
|
|
|
clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
|
|
@@ -5456,7 +5519,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
|
|
|
|
|
|
if (chan->state == BT_CONNECT) {
|
|
|
if (!status) {
|
|
|
- l2cap_send_conn_req(chan);
|
|
|
+ l2cap_start_connection(chan);
|
|
|
} else {
|
|
|
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
|
|
|
}
|
|
@@ -5470,11 +5533,9 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
|
|
|
if (!status) {
|
|
|
if (test_bit(BT_SK_DEFER_SETUP,
|
|
|
&bt_sk(sk)->flags)) {
|
|
|
- struct sock *parent = bt_sk(sk)->parent;
|
|
|
res = L2CAP_CR_PEND;
|
|
|
stat = L2CAP_CS_AUTHOR_PEND;
|
|
|
- if (parent)
|
|
|
- parent->sk_data_ready(parent, 0);
|
|
|
+ chan->ops->defer(chan);
|
|
|
} else {
|
|
|
__l2cap_state_change(chan, BT_CONFIG);
|
|
|
res = L2CAP_CR_SUCCESS;
|
|
@@ -5494,7 +5555,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
|
|
|
rsp.result = cpu_to_le16(res);
|
|
|
rsp.status = cpu_to_le16(stat);
|
|
|
l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP,
|
|
|
- sizeof(rsp), &rsp);
|
|
|
+ sizeof(rsp), &rsp);
|
|
|
|
|
|
if (!test_bit(CONF_REQ_SENT, &chan->conf_state) &&
|
|
|
res == L2CAP_CR_SUCCESS) {
|
|
@@ -5519,6 +5580,12 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
|
|
|
int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
|
|
|
{
|
|
|
struct l2cap_conn *conn = hcon->l2cap_data;
|
|
|
+ struct l2cap_hdr *hdr;
|
|
|
+ int len;
|
|
|
+
|
|
|
+ /* For AMP controller do not create l2cap conn */
|
|
|
+ if (!conn && hcon->hdev->dev_type != HCI_BREDR)
|
|
|
+ goto drop;
|
|
|
|
|
|
if (!conn)
|
|
|
conn = l2cap_conn_add(hcon, 0);
|
|
@@ -5528,10 +5595,10 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
|
|
|
|
|
|
BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags);
|
|
|
|
|
|
- if (!(flags & ACL_CONT)) {
|
|
|
- struct l2cap_hdr *hdr;
|
|
|
- int len;
|
|
|
-
|
|
|
+ switch (flags) {
|
|
|
+ case ACL_START:
|
|
|
+ case ACL_START_NO_FLUSH:
|
|
|
+ case ACL_COMPLETE:
|
|
|
if (conn->rx_len) {
|
|
|
BT_ERR("Unexpected start frame (len %d)", skb->len);
|
|
|
kfree_skb(conn->rx_skb);
|
|
@@ -5560,20 +5627,22 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
|
|
|
|
|
|
if (skb->len > len) {
|
|
|
BT_ERR("Frame is too long (len %d, expected len %d)",
|
|
|
- skb->len, len);
|
|
|
+ skb->len, len);
|
|
|
l2cap_conn_unreliable(conn, ECOMM);
|
|
|
goto drop;
|
|
|
}
|
|
|
|
|
|
/* Allocate skb for the complete frame (with header) */
|
|
|
- conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC);
|
|
|
+ conn->rx_skb = bt_skb_alloc(len, GFP_KERNEL);
|
|
|
if (!conn->rx_skb)
|
|
|
goto drop;
|
|
|
|
|
|
skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len),
|
|
|
- skb->len);
|
|
|
+ skb->len);
|
|
|
conn->rx_len = len - skb->len;
|
|
|
- } else {
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ACL_CONT:
|
|
|
BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len);
|
|
|
|
|
|
if (!conn->rx_len) {
|
|
@@ -5584,7 +5653,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
|
|
|
|
|
|
if (skb->len > conn->rx_len) {
|
|
|
BT_ERR("Fragment is too long (len %d, expected %d)",
|
|
|
- skb->len, conn->rx_len);
|
|
|
+ skb->len, conn->rx_len);
|
|
|
kfree_skb(conn->rx_skb);
|
|
|
conn->rx_skb = NULL;
|
|
|
conn->rx_len = 0;
|
|
@@ -5593,7 +5662,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
|
|
|
}
|
|
|
|
|
|
skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len),
|
|
|
- skb->len);
|
|
|
+ skb->len);
|
|
|
conn->rx_len -= skb->len;
|
|
|
|
|
|
if (!conn->rx_len) {
|
|
@@ -5601,6 +5670,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
|
|
|
l2cap_recv_frame(conn, conn->rx_skb);
|
|
|
conn->rx_skb = NULL;
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
drop:
|
|
@@ -5617,12 +5687,11 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
|
|
|
list_for_each_entry(c, &chan_list, global_l) {
|
|
|
struct sock *sk = c->sk;
|
|
|
|
|
|
- seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
|
|
|
- batostr(&bt_sk(sk)->src),
|
|
|
- batostr(&bt_sk(sk)->dst),
|
|
|
- c->state, __le16_to_cpu(c->psm),
|
|
|
- c->scid, c->dcid, c->imtu, c->omtu,
|
|
|
- c->sec_level, c->mode);
|
|
|
+ seq_printf(f, "%pMR %pMR %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
|
|
|
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
|
|
|
+ c->state, __le16_to_cpu(c->psm),
|
|
|
+ c->scid, c->dcid, c->imtu, c->omtu,
|
|
|
+ c->sec_level, c->mode);
|
|
|
}
|
|
|
|
|
|
read_unlock(&chan_list_lock);
|
|
@@ -5653,8 +5722,8 @@ int __init l2cap_init(void)
|
|
|
return err;
|
|
|
|
|
|
if (bt_debugfs) {
|
|
|
- l2cap_debugfs = debugfs_create_file("l2cap", 0444,
|
|
|
- bt_debugfs, NULL, &l2cap_debugfs_fops);
|
|
|
+ l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs,
|
|
|
+ NULL, &l2cap_debugfs_fops);
|
|
|
if (!l2cap_debugfs)
|
|
|
BT_ERR("Failed to create L2CAP debug file");
|
|
|
}
|