You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2019/12/03 22:37:20 UTC
[mynewt-nimble] 02/08: nimble/ll: Add api for resolving peer RPA to
any IRK on list
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
commit 1e0b0948c3aa542adb925a663b0eec501bd0bf64
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Thu Nov 7 15:29:16 2019 +0100
nimble/ll: Add api for resolving peer RPA to any IRK on list
This is needed to properly report periodic sync transfers received
since address in LL_SYNC_TRANSFER_IND is always RPA.
---
nimble/controller/include/controller/ble_ll_resolv.h | 5 ++++-
nimble/controller/src/ble_ll_resolv.c | 20 +++++++++++++++++---
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/nimble/controller/include/controller/ble_ll_resolv.h b/nimble/controller/include/controller/ble_ll_resolv.h
index 17228d6..f9dc397 100644
--- a/nimble/controller/include/controller/ble_ll_resolv.h
+++ b/nimble/controller/include/controller/ble_ll_resolv.h
@@ -98,7 +98,10 @@ int ble_ll_resolve_set_priv_mode(const uint8_t *cmdbuf, uint8_t len);
uint32_t ble_ll_resolv_get_rpa_tmo(void);
/* Resolve a resolvable private address */
-int ble_ll_resolv_rpa(uint8_t *rpa, uint8_t *irk);
+int ble_ll_resolv_rpa(const uint8_t *rpa, const uint8_t *irk);
+
+/* Try to resolve peer RPA and return index on RL if matched */
+int ble_ll_resolv_peer_rpa_any(const uint8_t *rpa);
/* Initialize resolv*/
void ble_ll_resolv_init(void);
diff --git a/nimble/controller/src/ble_ll_resolv.c b/nimble/controller/src/ble_ll_resolv.c
index abf3986..c35cc33 100644
--- a/nimble/controller/src/ble_ll_resolv.c
+++ b/nimble/controller/src/ble_ll_resolv.c
@@ -641,15 +641,15 @@ ble_ll_resolv_gen_rpa(uint8_t *addr, uint8_t addr_type, uint8_t *rpa, int local)
* @return int
*/
int
-ble_ll_resolv_rpa(uint8_t *rpa, uint8_t *irk)
+ble_ll_resolv_rpa(const uint8_t *rpa, const uint8_t *irk)
{
int rc;
- uint32_t *irk32;
+ const uint32_t *irk32;
uint32_t *key32;
uint32_t *pt32;
struct ble_encryption_block ecb;
- irk32 = (uint32_t *)irk;
+ irk32 = (const uint32_t *)irk;
key32 = (uint32_t *)&ecb.key[0];
key32[0] = irk32[0];
@@ -678,6 +678,20 @@ ble_ll_resolv_rpa(uint8_t *rpa, uint8_t *irk)
return rc;
}
+int
+ble_ll_resolv_peer_rpa_any(const uint8_t *rpa)
+{
+ int i;
+
+ for (i = 0; i < g_ble_ll_resolv_data.rl_cnt_hw; i++) {
+ if (ble_ll_resolv_rpa(rpa, g_ble_ll_resolv_list[i].rl_peer_irk)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
/**
* Returns whether or not address resolution is enabled.
*