You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/05/09 04:54:05 UTC
[3/4] incubator-mynewt-core git commit: BLE host - Ensure pair-req
sender is master.
BLE host - Ensure pair-req sender is master.
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/2a6cf993
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2a6cf993
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2a6cf993
Branch: refs/heads/develop
Commit: 2a6cf9936308255fa76bcba744cd461781628fda
Parents: 7a3a946
Author: Christopher Collins <cc...@apache.org>
Authored: Sat May 7 13:12:58 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sun May 8 21:53:49 2016 -0700
----------------------------------------------------------------------
net/nimble/host/src/ble_l2cap_sm.c | 14 ++++++++++++--
net/nimble/host/src/test/ble_l2cap_sm_test.c | 6 ++++++
2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2a6cf993/net/nimble/host/src/ble_l2cap_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sm.c b/net/nimble/host/src/ble_l2cap_sm.c
index 1b2eea0..60cbae8 100644
--- a/net/nimble/host/src/ble_l2cap_sm.c
+++ b/net/nimble/host/src/ble_l2cap_sm.c
@@ -1025,17 +1025,27 @@ ble_l2cap_sm_pair_req_handle(struct ble_l2cap_sm_proc *proc,
uint8_t *out_sm_status,
uint8_t *passkey_action)
{
+ struct ble_hs_conn *conn;
int rc;
proc->pair_req = *req;
+ conn = ble_hs_conn_find(proc->conn_handle);
+ if (conn == NULL) {
+ *out_sm_status = BLE_L2CAP_SM_ERR_UNSPECIFIED;
+ return BLE_HS_ENOTCONN;
+ }
+ if (conn->bhc_flags & BLE_HS_CONN_F_MASTER) {
+ *out_sm_status = BLE_L2CAP_SM_ERR_CMD_NOT_SUPP;
+ return BLE_HS_EROLE;
+ }
+
if (!ble_l2cap_sm_pair_cmd_is_valid(req)) {
*out_sm_status = BLE_L2CAP_SM_ERR_INVAL;
- return BLE_HS_EBADDATA;
+ return BLE_HS_SM_US_ERR(BLE_L2CAP_SM_ERR_INVAL);
}
rc = ble_l2cap_sm_pair_go(proc);
-
if (rc != 0) {
*out_sm_status = BLE_L2CAP_SM_ERR_UNSPECIFIED;
return rc;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2a6cf993/net/nimble/host/src/test/ble_l2cap_sm_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_l2cap_sm_test.c b/net/nimble/host/src/test/ble_l2cap_sm_test.c
index 409cfc9..dd22a73 100644
--- a/net/nimble/host/src/test/ble_l2cap_sm_test.c
+++ b/net/nimble/host/src/test/ble_l2cap_sm_test.c
@@ -417,6 +417,9 @@ ble_l2cap_sm_test_util_peer_lgcy_good(
ble_l2cap_sm_test_util_conn_cb,
NULL);
+ /* Peer is the initiator so we must be the slave. */
+ conn->bhc_flags &= ~BLE_HS_CONN_F_MASTER;
+
TEST_ASSERT(!conn->bhc_sec_state.enc_enabled);
TEST_ASSERT(ble_l2cap_sm_dbg_num_procs() == 0);
@@ -508,6 +511,9 @@ ble_l2cap_sm_test_util_peer_lgcy_fail(
ble_l2cap_sm_test_util_conn_cb,
NULL);
+ /* Peer is the initiator so we must be the slave. */
+ conn->bhc_flags &= ~BLE_HS_CONN_F_MASTER;
+
TEST_ASSERT(ble_l2cap_sm_dbg_num_procs() == 0);
/* Receive a pair request from the peer. */