You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2019/07/12 11:24:18 UTC

[mynewt-nimble] branch master updated: nimble/ll: Use a different RPA when initiating Directed Connection

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

naraj 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 e138127  nimble/ll: Use a different RPA when initiating Directed Connection
e138127 is described below

commit e138127e3f9855e518086be2e1628af09fd4d6af
Author: MichaƂ Narajowski <mi...@codecoup.pl>
AuthorDate: Thu Jul 11 14:43:01 2019 +0200

    nimble/ll: Use a different RPA when initiating Directed Connection
    
    Core Specification Vol 6, Part B, Section 6.4:
    "The Link Layer should not set the InitA field to the same
    value as the TargetA field in the received advertising PDU."
---
 nimble/controller/src/ble_ll_conn.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 61f8a66..c7ea56e 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -3076,10 +3076,20 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok,
              * If the InitA is a RPA, we must see if it resolves based on the
              * identity address of the resolved ADVA.
              */
-            if (init_addr && inita_is_rpa &&
-                            !ble_ll_resolv_rpa(init_addr,
-                                               g_ble_ll_resolv_list[index].rl_local_irk)) {
-                goto init_rx_isr_exit;
+            if (init_addr && inita_is_rpa) {
+                if (!ble_ll_resolv_rpa(init_addr,
+                                       g_ble_ll_resolv_list[index].rl_local_irk)) {
+                    goto init_rx_isr_exit;
+                }
+
+                /* Core Specification Vol 6, Part B, Section 6.4:
+                 * "The Link Layer should not set the InitA field to the same
+                 * value as the TargetA field in the received advertising PDU."
+                 *
+                 * We update the received PDU directly here, so ble_ll_init_rx_pkt_in
+                 * can process it as is.
+                 */
+                memcpy(init_addr, rl->rl_local_rpa, BLE_DEV_ADDR_LEN);
             }
 
         } else {
@@ -3119,6 +3129,15 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok,
             if (!rl || !ble_ll_resolv_rpa(init_addr, rl->rl_local_irk)) {
                 goto init_rx_isr_exit;
             }
+
+            /* Core Specification Vol 6, Part B, Section 6.4:
+             * "The Link Layer should not set the InitA field to the same
+             * value as the TargetA field in the received advertising PDU."
+             *
+             * We update the received PDU directly here, so ble_ll_init_rx_pkt_in
+             * can process it as is.
+             */
+            memcpy(init_addr, rl->rl_local_rpa, BLE_DEV_ADDR_LEN);
         }
     }
 #endif