You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2018/11/05 11:31:11 UTC

[mynewt-nimble] 02/04: nimble/ll: Fix handling LL_CTRL is not used for given role

This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 5638692fb63c4b135cd1b2a24ddb7dc93bc1647b
Author: Ɓukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Oct 19 00:35:54 2018 +0200

    nimble/ll: Fix handling LL_CTRL is not used for given role
    
    In such a case we should reply with LL_UNKNOWN_RSP
---
 nimble/controller/src/ble_ll_ctrl.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c
index 0f0a29b..108fb15 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -874,6 +874,8 @@ ble_ll_ctrl_rx_phy_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
          *
          * XXX: TODO count some stat?
          */
+    } else {
+        rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
     }
 
     /* NOTE: slave should never receive one of these */
@@ -1261,7 +1263,7 @@ ble_ll_ctrl_rx_enc_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
                        uint8_t *rspdata)
 {
     if (connsm->conn_role != BLE_LL_CONN_ROLE_SLAVE) {
-        return BLE_ERR_MAX;
+        return BLE_LL_CTRL_UNKNOWN_RSP;
     }
 
     /* In case we were already encrypted we need to reset packet counters */
@@ -1309,6 +1311,8 @@ ble_ll_ctrl_rx_start_enc_req(struct ble_ll_conn_sm *connsm)
             connsm->enc_data.enc_state = CONN_ENC_S_START_ENC_RSP_WAIT;
             rc = BLE_LL_CTRL_START_ENC_RSP;
         }
+    } else {
+        rc = BLE_LL_CTRL_UNKNOWN_RSP;
     }
     return rc;
 }
@@ -1327,6 +1331,8 @@ ble_ll_ctrl_rx_pause_enc_req(struct ble_ll_conn_sm *connsm)
     if ((connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) &&
         (connsm->enc_data.enc_state == CONN_ENC_S_ENCRYPTED)) {
         rc = BLE_LL_CTRL_PAUSE_ENC_RSP;
+    } else {
+        rc = BLE_LL_CTRL_UNKNOWN_RSP;
     }
 
     return rc;
@@ -1345,9 +1351,10 @@ ble_ll_ctrl_rx_pause_enc_rsp(struct ble_ll_conn_sm *connsm)
 {
     int rc;
 
-    rc = BLE_ERR_MAX;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
         rc = BLE_LL_CTRL_PAUSE_ENC_RSP;
+    } else {
+        rc = BLE_LL_CTRL_UNKNOWN_RSP;
     }
 
     return rc;
@@ -1789,7 +1796,7 @@ ble_ll_ctrl_rx_conn_param_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 
     /* A slave should never receive this response */
     if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
-        return BLE_ERR_MAX;
+        return BLE_LL_CTRL_UNKNOWN_RSP;
     }
 
     /*