You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/06 21:19:09 UTC
[33/50] incubator-mynewt-core git commit: nimble/l2cap: Improve L2CAP
LE CoC connection handling
nimble/l2cap: Improve L2CAP LE CoC connection handling
With this patch we make sure remote does not use already used CID
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6963daf8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6963daf8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6963daf8
Branch: refs/heads/master
Commit: 6963daf878259509b367e9a538302429bb5da0da
Parents: 38ae570
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Wed Mar 1 11:42:43 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Fri Mar 3 12:40:42 2017 +0100
----------------------------------------------------------------------
net/nimble/host/src/ble_l2cap_sig.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6963daf8/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index 439acfe..1840b0a 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -658,14 +658,19 @@ ble_l2cap_sig_coc_req_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr,
ble_hs_lock();
conn = ble_hs_conn_find_assert(conn_handle);
- /* Verify CID */
+ /* Verify CID. Note, scid in the request is dcid for out local channel */
scid = le16toh(req->scid);
if (scid < BLE_L2CAP_COC_CID_START || scid > BLE_L2CAP_COC_CID_END) {
- /*FIXME: Check if SCID is not already used */
rsp->result = htole16(BLE_L2CAP_COC_ERR_INVALID_SOURCE_CID);
goto failed;
}
+ chan = ble_hs_conn_chan_find_by_dcid(conn, scid);
+ if (chan) {
+ rsp->result = htole16(BLE_L2CAP_COC_ERR_SOURCE_CID_ALREADY_USED);
+ goto failed;
+ }
+
rc = ble_l2cap_coc_create_srv_chan(conn_handle, le16toh(req->psm), &chan);
if (rc != 0) {
uint16_t coc_err = ble_l2cap_sig_ble_hs_err2coc_err(rc);