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

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


The following commit(s) were added to refs/heads/master by this push:
     new 89db9ca2 host/sm: do not send Pairing Failed after receiving Pairing 
Failed
89db9ca2 is described below

commit 89db9ca298a0ec238109c881933598e4445d2f7e
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Tue Jun 13 08:30:30 2023 +0200

    host/sm: do not send Pairing Failed after receiving Pairing Failed
    
    When device receives Pairing Failed message, according to Core v5.4,
    Vol 3, Part H, 3.5.5: This is used when there has been a failure during 
pairing
    and reports that the pairing procedure has been stopped and no further
    communication for the current pairing procedure is to occur.
    
    Sending our own Pairing Failed is further communication.
    
    This affects SM/CEN/PKE/BI-02-C
---
 nimble/host/src/ble_sm.c      | 22 ++++++++++++----------
 nimble/host/src/ble_sm_priv.h |  3 ++-
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/nimble/host/src/ble_sm.c b/nimble/host/src/ble_sm.c
index dbea8b70..831cf0fc 100644
--- a/nimble/host/src/ble_sm.c
+++ b/nimble/host/src/ble_sm.c
@@ -904,7 +904,8 @@ ble_sm_chk_repeat_pairing(uint16_t conn_handle,
 }
 
 void
-ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res)
+ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res,
+                      bool tx_fail)
 {
     struct ble_sm_proc *prev;
     struct ble_sm_proc *proc;
@@ -937,7 +938,7 @@ ble_sm_process_result(uint16_t conn_handle, struct 
ble_sm_result *res)
             }
         }
 
-        if (res->sm_err != 0) {
+        if (res->sm_err != 0 && tx_fail) {
             ble_sm_pair_fail_tx(conn_handle, res->sm_err);
         }
 
@@ -1208,7 +1209,7 @@ ble_sm_enc_event_rx(uint16_t conn_handle, uint8_t 
evt_status, int encrypted)
     ble_hs_unlock();
 
     res.bonded = bonded;
-    ble_sm_process_result(conn_handle, &res);
+    ble_sm_process_result(conn_handle, &res, true);
 }
 
 void
@@ -1429,7 +1430,7 @@ ble_sm_ltk_req_rx(const struct 
ble_hci_ev_le_subev_lt_key_req *ev)
         }
     }
 
-    ble_sm_process_result(conn_handle, &res);
+    ble_sm_process_result(conn_handle, &res, true);
 
     return 0;
 }
@@ -2576,7 +2577,7 @@ ble_sm_pair_initiate(uint16_t conn_handle)
     }
 
     if (proc != NULL) {
-        ble_sm_process_result(conn_handle, &res);
+        ble_sm_process_result(conn_handle, &res, true);
     }
 
     return res.app_status;
@@ -2615,7 +2616,7 @@ ble_sm_slave_initiate(uint16_t conn_handle)
     ble_hs_unlock();
 
     if (proc != NULL) {
-        ble_sm_process_result(conn_handle, &res);
+        ble_sm_process_result(conn_handle, &res, true);
     }
 
     return res.app_status;
@@ -2669,7 +2670,7 @@ ble_sm_enc_initiate(uint16_t conn_handle, uint8_t 
key_size,
 
     ble_hs_unlock();
 
-    ble_sm_process_result(conn_handle, &res);
+    ble_sm_process_result(conn_handle, &res, true);
 
     return res.app_status;
 }
@@ -2707,7 +2708,8 @@ ble_sm_rx(struct ble_l2cap_chan *chan)
         memset(&res, 0, sizeof res);
 
         rx_cb(conn_handle, om, &res);
-        ble_sm_process_result(conn_handle, &res);
+        ble_sm_process_result(conn_handle, &res, op == BLE_SM_OP_PAIR_FAIL ?
+                              false : true);
         rc = res.app_status;
     } else {
         rc = BLE_HS_ENOTSUP;
@@ -2821,7 +2823,7 @@ ble_sm_inject_io(uint16_t conn_handle, struct ble_sm_io 
*pkey)
         return rc;
     }
 
-    ble_sm_process_result(conn_handle, &res);
+    ble_sm_process_result(conn_handle, &res, true);
     return res.app_status;
 }
 
@@ -2834,7 +2836,7 @@ ble_sm_connection_broken(uint16_t conn_handle)
     res.app_status = BLE_HS_ENOTCONN;
     res.enc_cb = 1;
 
-    ble_sm_process_result(conn_handle, &res);
+    ble_sm_process_result(conn_handle, &res, true);
 }
 
 int
diff --git a/nimble/host/src/ble_sm_priv.h b/nimble/host/src/ble_sm_priv.h
index 27e75aa1..5e761c1e 100644
--- a/nimble/host/src/ble_sm_priv.h
+++ b/nimble/host/src/ble_sm_priv.h
@@ -381,7 +381,8 @@ uint8_t *ble_sm_our_pair_rand(struct ble_sm_proc *proc);
 uint8_t *ble_sm_peer_pair_rand(struct ble_sm_proc *proc);
 int ble_sm_ioact_state(uint8_t action);
 int ble_sm_proc_can_advance(struct ble_sm_proc *proc);
-void ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res);
+void ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res,
+                           bool tx_fail);
 void ble_sm_confirm_advance(struct ble_sm_proc *proc);
 void ble_sm_ia_ra(struct ble_sm_proc *proc,
                   uint8_t *out_iat, uint8_t *out_ia,

Reply via email to