提交 571f7390 编写于 作者: M Mallikarjun Phulari 提交者: Marcel Holtmann

Bluetooth: Use separate L2CAP LE credit based connection result values

Add the result values specific to L2CAP LE credit based connections
and change the old result values wherever they were used.
Signed-off-by: NMallikarjun Phulari <mallikarjun.phulari@intel.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 70ecdd3d
...@@ -277,12 +277,17 @@ struct l2cap_conn_rsp { ...@@ -277,12 +277,17 @@ struct l2cap_conn_rsp {
#define L2CAP_CR_SEC_BLOCK 0x0003 #define L2CAP_CR_SEC_BLOCK 0x0003
#define L2CAP_CR_NO_MEM 0x0004 #define L2CAP_CR_NO_MEM 0x0004
#define L2CAP_CR_BAD_AMP 0x0005 #define L2CAP_CR_BAD_AMP 0x0005
#define L2CAP_CR_AUTHENTICATION 0x0005
#define L2CAP_CR_AUTHORIZATION 0x0006 /* credit based connect results */
#define L2CAP_CR_BAD_KEY_SIZE 0x0007 #define L2CAP_CR_LE_SUCCESS 0x0000
#define L2CAP_CR_ENCRYPTION 0x0008 #define L2CAP_CR_LE_BAD_PSM 0x0002
#define L2CAP_CR_INVALID_SCID 0x0009 #define L2CAP_CR_LE_NO_MEM 0x0004
#define L2CAP_CR_SCID_IN_USE 0x000A #define L2CAP_CR_LE_AUTHENTICATION 0x0005
#define L2CAP_CR_LE_AUTHORIZATION 0x0006
#define L2CAP_CR_LE_BAD_KEY_SIZE 0x0007
#define L2CAP_CR_LE_ENCRYPTION 0x0008
#define L2CAP_CR_LE_INVALID_SCID 0x0009
#define L2CAP_CR_LE_SCID_IN_USE 0X000A
/* connect/create channel status */ /* connect/create channel status */
#define L2CAP_CS_NO_INFO 0x0000 #define L2CAP_CS_NO_INFO 0x0000
......
...@@ -680,9 +680,9 @@ static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan) ...@@ -680,9 +680,9 @@ static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan)
u16 result; u16 result;
if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) if (test_bit(FLAG_DEFER_SETUP, &chan->flags))
result = L2CAP_CR_AUTHORIZATION; result = L2CAP_CR_LE_AUTHORIZATION;
else else
result = L2CAP_CR_BAD_PSM; result = L2CAP_CR_LE_BAD_PSM;
l2cap_state_change(chan, BT_DISCONN); l2cap_state_change(chan, BT_DISCONN);
...@@ -3670,7 +3670,7 @@ void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan) ...@@ -3670,7 +3670,7 @@ void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan)
rsp.mtu = cpu_to_le16(chan->imtu); rsp.mtu = cpu_to_le16(chan->imtu);
rsp.mps = cpu_to_le16(chan->mps); rsp.mps = cpu_to_le16(chan->mps);
rsp.credits = cpu_to_le16(chan->rx_credits); rsp.credits = cpu_to_le16(chan->rx_credits);
rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); rsp.result = cpu_to_le16(L2CAP_CR_LE_SUCCESS);
l2cap_send_cmd(conn, chan->ident, L2CAP_LE_CONN_RSP, sizeof(rsp), l2cap_send_cmd(conn, chan->ident, L2CAP_LE_CONN_RSP, sizeof(rsp),
&rsp); &rsp);
...@@ -5280,7 +5280,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, ...@@ -5280,7 +5280,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
credits = __le16_to_cpu(rsp->credits); credits = __le16_to_cpu(rsp->credits);
result = __le16_to_cpu(rsp->result); result = __le16_to_cpu(rsp->result);
if (result == L2CAP_CR_SUCCESS && (mtu < 23 || mps < 23 || if (result == L2CAP_CR_LE_SUCCESS && (mtu < 23 || mps < 23 ||
dcid < L2CAP_CID_DYN_START || dcid < L2CAP_CID_DYN_START ||
dcid > L2CAP_CID_LE_DYN_END)) dcid > L2CAP_CID_LE_DYN_END))
return -EPROTO; return -EPROTO;
...@@ -5301,7 +5301,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, ...@@ -5301,7 +5301,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
l2cap_chan_lock(chan); l2cap_chan_lock(chan);
switch (result) { switch (result) {
case L2CAP_CR_SUCCESS: case L2CAP_CR_LE_SUCCESS:
if (__l2cap_get_chan_by_dcid(conn, dcid)) { if (__l2cap_get_chan_by_dcid(conn, dcid)) {
err = -EBADSLT; err = -EBADSLT;
break; break;
...@@ -5315,8 +5315,8 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, ...@@ -5315,8 +5315,8 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
l2cap_chan_ready(chan); l2cap_chan_ready(chan);
break; break;
case L2CAP_CR_AUTHENTICATION: case L2CAP_CR_LE_AUTHENTICATION:
case L2CAP_CR_ENCRYPTION: case L2CAP_CR_LE_ENCRYPTION:
/* If we already have MITM protection we can't do /* If we already have MITM protection we can't do
* anything. * anything.
*/ */
...@@ -5459,7 +5459,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, ...@@ -5459,7 +5459,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src, pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src,
&conn->hcon->dst, LE_LINK); &conn->hcon->dst, LE_LINK);
if (!pchan) { if (!pchan) {
result = L2CAP_CR_BAD_PSM; result = L2CAP_CR_LE_BAD_PSM;
chan = NULL; chan = NULL;
goto response; goto response;
} }
...@@ -5469,28 +5469,28 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, ...@@ -5469,28 +5469,28 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
if (!smp_sufficient_security(conn->hcon, pchan->sec_level, if (!smp_sufficient_security(conn->hcon, pchan->sec_level,
SMP_ALLOW_STK)) { SMP_ALLOW_STK)) {
result = L2CAP_CR_AUTHENTICATION; result = L2CAP_CR_LE_AUTHENTICATION;
chan = NULL; chan = NULL;
goto response_unlock; goto response_unlock;
} }
/* Check for valid dynamic CID range */ /* Check for valid dynamic CID range */
if (scid < L2CAP_CID_DYN_START || scid > L2CAP_CID_LE_DYN_END) { if (scid < L2CAP_CID_DYN_START || scid > L2CAP_CID_LE_DYN_END) {
result = L2CAP_CR_INVALID_SCID; result = L2CAP_CR_LE_INVALID_SCID;
chan = NULL; chan = NULL;
goto response_unlock; goto response_unlock;
} }
/* Check if we already have channel with that dcid */ /* Check if we already have channel with that dcid */
if (__l2cap_get_chan_by_dcid(conn, scid)) { if (__l2cap_get_chan_by_dcid(conn, scid)) {
result = L2CAP_CR_SCID_IN_USE; result = L2CAP_CR_LE_SCID_IN_USE;
chan = NULL; chan = NULL;
goto response_unlock; goto response_unlock;
} }
chan = pchan->ops->new_connection(pchan); chan = pchan->ops->new_connection(pchan);
if (!chan) { if (!chan) {
result = L2CAP_CR_NO_MEM; result = L2CAP_CR_LE_NO_MEM;
goto response_unlock; goto response_unlock;
} }
...@@ -5526,7 +5526,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, ...@@ -5526,7 +5526,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
chan->ops->defer(chan); chan->ops->defer(chan);
} else { } else {
l2cap_chan_ready(chan); l2cap_chan_ready(chan);
result = L2CAP_CR_SUCCESS; result = L2CAP_CR_LE_SUCCESS;
} }
response_unlock: response_unlock:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册