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/12/08 22:52:22 UTC
[1/4] incubator-mynewt-core git commit: MYNEWT-383 BLE Host -
Deletion from ram store.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop f433a77ef -> 71503c55a
MYNEWT-383 BLE Host - Deletion from ram store.
Previously, deleting security material from the RAM store was not
implemented.
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/ed6b9c56
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ed6b9c56
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ed6b9c56
Branch: refs/heads/develop
Commit: ed6b9c56dbb5383daf83c8edff2dc25e36234926
Parents: f433a77
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Dec 8 10:28:18 2016 -0600
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Dec 8 10:28:18 2016 -0600
----------------------------------------------------------------------
net/nimble/host/include/host/ble_store.h | 2 +
net/nimble/host/src/ble_store.c | 63 +++++------
.../store/ram/include/store/ram/ble_store_ram.h | 1 +
net/nimble/host/store/ram/src/ble_store_ram.c | 113 ++++++++++++++++++-
4 files changed, 137 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ed6b9c56/net/nimble/host/include/host/ble_store.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_store.h b/net/nimble/host/include/host/ble_store.h
index 431721b..d953bfc 100644
--- a/net/nimble/host/include/host/ble_store.h
+++ b/net/nimble/host/include/host/ble_store.h
@@ -197,9 +197,11 @@ int ble_store_delete(int obj_type, union ble_store_key *key);
int ble_store_read_our_sec(struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec);
int ble_store_write_our_sec(struct ble_store_value_sec *value_sec);
+int ble_store_delete_our_sec(struct ble_store_key_sec *key_sec);
int ble_store_read_peer_sec(struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec);
int ble_store_write_peer_sec(struct ble_store_value_sec *value_sec);
+int ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec);
int ble_store_read_cccd(struct ble_store_key_cccd *key,
struct ble_store_value_cccd *out_value);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ed6b9c56/net/nimble/host/src/ble_store.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_store.c b/net/nimble/host/src/ble_store.c
index 5a26a2c..d042722 100644
--- a/net/nimble/host/src/ble_store.c
+++ b/net/nimble/host/src/ble_store.c
@@ -86,29 +86,17 @@ ble_store_read_our_sec(struct ble_store_key_sec *key_sec,
static int
ble_store_persist_sec(int obj_type, struct ble_store_value_sec *value_sec)
{
- struct ble_store_key_sec key_sec;
union ble_store_value *store_value;
- union ble_store_key *store_key;
int rc;
BLE_HS_DBG_ASSERT(value_sec->peer_addr_type == BLE_ADDR_TYPE_PUBLIC ||
value_sec->peer_addr_type == BLE_ADDR_TYPE_RANDOM);
+ BLE_HS_DBG_ASSERT(value_sec->ltk_present ||
+ value_sec->irk_present ||
+ value_sec->csrk_present);
- /* If the value contains no keys, delete the corresponding entry.
- * Otherwise, write it.
- */
- if (!value_sec->ltk_present &&
- !value_sec->irk_present &&
- !value_sec->csrk_present) {
-
- ble_store_key_from_value_sec(&key_sec, value_sec);
- store_key = (void *)&key_sec;
- rc = ble_store_delete(obj_type, store_key);
- } else {
- store_value = (void *)value_sec;
- rc = ble_store_write(obj_type, store_value);
- }
-
+ store_value = (void *)value_sec;
+ rc = ble_store_write(obj_type, store_value);
return rc;
}
@@ -122,6 +110,28 @@ ble_store_write_our_sec(struct ble_store_value_sec *value_sec)
}
int
+ble_store_delete_our_sec(struct ble_store_key_sec *key_sec)
+{
+ union ble_store_key *store_key;
+ int rc;
+
+ store_key = (void *)key_sec;
+ rc = ble_store_delete(BLE_STORE_OBJ_TYPE_OUR_SEC, store_key);
+ return rc;
+}
+
+int
+ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec)
+{
+ union ble_store_key *store_key;
+ int rc;
+
+ store_key = (void *)key_sec;
+ rc = ble_store_delete(BLE_STORE_OBJ_TYPE_PEER_SEC, store_key);
+ return rc;
+}
+
+int
ble_store_read_peer_sec(struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec)
{
@@ -171,25 +181,6 @@ ble_store_write_peer_sec(struct ble_store_value_sec *value_sec)
}
int
-ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec)
-{
- union ble_store_key *store_key;
- int rc;
-
- store_key = (void *)key_sec;
- rc = ble_store_delete(BLE_STORE_OBJ_TYPE_PEER_SEC, store_key);
-
- if(key_sec->peer_addr_type == BLE_STORE_ADDR_TYPE_NONE) {
- /* don't error check this since we don't know without looking up
- * the value whether it had a valid IRK */
- ble_hs_pvcy_remove_entry(key_sec->peer_addr_type,
- key_sec->peer_addr);
- }
-
- return rc;
-}
-
-int
ble_store_read_cccd(struct ble_store_key_cccd *key,
struct ble_store_value_cccd *out_value)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ed6b9c56/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h b/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
index f3c77d5..fc8375c 100644
--- a/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
+++ b/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
@@ -30,6 +30,7 @@ union ble_store_value;
int ble_store_ram_read(int obj_type, union ble_store_key *key,
union ble_store_value *value);
int ble_store_ram_write(int obj_type, union ble_store_value *val);
+int ble_store_ram_delete(int obj_type, union ble_store_key *key);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ed6b9c56/net/nimble/host/store/ram/src/ble_store_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/src/ble_store_ram.c b/net/nimble/host/store/ram/src/ble_store_ram.c
index e899a46..65a76cc 100644
--- a/net/nimble/host/store/ram/src/ble_store_ram.c
+++ b/net/nimble/host/store/ram/src/ble_store_ram.c
@@ -88,7 +88,8 @@ ble_store_ram_print_key_sec(struct ble_store_key_sec *key_sec)
static int
ble_store_ram_find_sec(struct ble_store_key_sec *key_sec,
- struct ble_store_value_sec *value_secs, int num_value_secs)
+ struct ble_store_value_sec *value_secs,
+ int num_value_secs)
{
struct ble_store_value_sec *cur;
int skipped;
@@ -133,7 +134,7 @@ ble_store_ram_find_sec(struct ble_store_key_sec *key_sec,
static int
ble_store_ram_read_our_sec(struct ble_store_key_sec *key_sec,
- struct ble_store_value_sec *value_sec)
+ struct ble_store_value_sec *value_sec)
{
int idx;
@@ -158,7 +159,7 @@ ble_store_ram_write_our_sec(struct ble_store_value_sec *value_sec)
ble_store_key_from_value_sec(&key_sec, value_sec);
idx = ble_store_ram_find_sec(&key_sec, ble_store_ram_our_secs,
- ble_store_ram_num_our_secs);
+ ble_store_ram_num_our_secs);
if (idx == -1) {
if (ble_store_ram_num_our_secs >= STORE_MAX_SLV_LTKS) {
BLE_HS_LOG(DEBUG, "error persisting our sec; too many entries "
@@ -175,8 +176,79 @@ ble_store_ram_write_our_sec(struct ble_store_value_sec *value_sec)
}
static int
+ble_store_ram_delete_obj(void *values, int value_size, int idx,
+ int *num_values)
+{
+ uint8_t *dst;
+ uint8_t *src;
+ int move_count;
+
+ (*num_values)--;
+ if (idx < *num_values) {
+ dst = values;
+ dst += idx * value_size;
+ src = dst + value_size;
+
+ move_count = *num_values - idx;
+ memmove(dst, src, move_count);
+ }
+
+ return 0;
+}
+
+static int
+ble_store_ram_delete_sec(struct ble_store_key_sec *key_sec,
+ struct ble_store_value_sec *value_secs,
+ int *num_value_secs)
+{
+ int idx;
+ int rc;
+
+ idx = ble_store_ram_find_sec(key_sec, value_secs, *num_value_secs);
+ if (idx == -1) {
+ return BLE_HS_ENOENT;
+ }
+
+ rc = ble_store_ram_delete_obj(value_secs, sizeof *value_secs, idx,
+ num_value_secs);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+static int
+ble_store_ram_delete_our_sec(struct ble_store_key_sec *key_sec)
+{
+ int rc;
+
+ rc = ble_store_ram_delete_sec(key_sec, ble_store_ram_our_secs,
+ &ble_store_ram_num_our_secs);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+static int
+ble_store_ram_delete_peer_sec(struct ble_store_key_sec *key_sec)
+{
+ int rc;
+
+ rc = ble_store_ram_delete_sec(key_sec, ble_store_ram_peer_secs,
+ &ble_store_ram_num_peer_secs);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+static int
ble_store_ram_read_peer_sec(struct ble_store_key_sec *key_sec,
- struct ble_store_value_sec *value_sec)
+ struct ble_store_value_sec *value_sec)
{
int idx;
@@ -201,7 +273,7 @@ ble_store_ram_write_peer_sec(struct ble_store_value_sec *value_sec)
ble_store_key_from_value_sec(&key_sec, value_sec);
idx = ble_store_ram_find_sec(&key_sec, ble_store_ram_peer_secs,
- ble_store_ram_num_peer_secs);
+ ble_store_ram_num_peer_secs);
if (idx == -1) {
if (ble_store_ram_num_peer_secs >= STORE_MAX_MST_LTKS) {
BLE_HS_LOG(DEBUG, "error persisting peer sec; too many entries "
@@ -308,7 +380,7 @@ ble_store_ram_write_cccd(struct ble_store_value_cccd *value_cccd)
*/
int
ble_store_ram_read(int obj_type, union ble_store_key *key,
- union ble_store_value *value)
+ union ble_store_value *value)
{
int rc;
@@ -373,6 +445,29 @@ ble_store_ram_write(int obj_type, union ble_store_value *val)
}
}
+int
+ble_store_ram_delete(int obj_type, union ble_store_key *key)
+{
+ int rc;
+
+ switch (obj_type) {
+ case BLE_STORE_OBJ_TYPE_PEER_SEC:
+ rc = ble_store_ram_delete_peer_sec(&key->sec);
+ return rc;
+
+ case BLE_STORE_OBJ_TYPE_OUR_SEC:
+ rc = ble_store_ram_delete_our_sec(&key->sec);
+ return rc;
+
+ case BLE_STORE_OBJ_TYPE_CCCD:
+ /* XXX: There is no good reason not to support this. */
+ return BLE_HS_ENOTSUP;
+
+ default:
+ return BLE_HS_ENOTSUP;
+ }
+}
+
void
ble_store_ram_init(void)
{
@@ -381,4 +476,10 @@ ble_store_ram_init(void)
ble_hs_cfg.store_read_cb = ble_store_ram_read;
ble_hs_cfg.store_write_cb = ble_store_ram_write;
+ ble_hs_cfg.store_delete_cb = ble_store_ram_delete;
+
+ /* Re-initialize BSS values in case of unit tests. */
+ ble_store_ram_num_our_secs = 0;
+ ble_store_ram_num_peer_secs = 0;
+ ble_store_ram_num_cccds = 0;
}
[4/4] incubator-mynewt-core git commit: bootutil - Fix incorrect
comment.
Posted by cc...@apache.org.
bootutil - Fix incorrect comment.
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/ea00890c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ea00890c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ea00890c
Branch: refs/heads/develop
Commit: ea00890c1196e61f7c98e87734056339914e628f
Parents: 1eef1ae
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Dec 8 14:52:40 2016 -0600
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Dec 8 16:21:13 2016 -0600
----------------------------------------------------------------------
boot/bootutil/src/bootutil_priv.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ea00890c/boot/bootutil/src/bootutil_priv.h
----------------------------------------------------------------------
diff --git a/boot/bootutil/src/bootutil_priv.h b/boot/bootutil/src/bootutil_priv.h
index a0f57c4..79885ae 100644
--- a/boot/bootutil/src/bootutil_priv.h
+++ b/boot/bootutil/src/bootutil_priv.h
@@ -63,9 +63,9 @@ struct boot_status {
* ~ Swap status (variable, aligned) ~
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Copy done | 0xff padding (up to min-write-sz) ~
+ * | Copy done | 0xff padding (up to min-write-sz - 1) ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Image OK | 0xff padding (up to min-write-sz) ~
+ * | Image OK | 0xff padding (up to min-write-sz - 1) ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
[2/4] incubator-mynewt-core git commit: MYNEWT-383 - BLE Host - use
ram store in unittests
Posted by cc...@apache.org.
MYNEWT-383 - BLE Host - use ram store in unittests
Previously, the unit tests were using a custom store implementation.
This resulted in needless code duplication. Now the tests use the
standard RAM store.
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/1eef1ae5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1eef1ae5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1eef1ae5
Branch: refs/heads/develop
Commit: 1eef1ae59f3c4a1e4670278b6901ffd425cf6185
Parents: ed6b9c5
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Dec 8 10:33:48 2016 -0600
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Dec 8 16:21:13 2016 -0600
----------------------------------------------------------------------
net/nimble/host/test/pkg.yml | 1 +
.../host/test/src/ble_gatts_notify_test.c | 18 +-
net/nimble/host/test/src/ble_hs_test_util.c | 72 ++++++
net/nimble/host/test/src/ble_hs_test_util.h | 2 +-
.../host/test/src/ble_hs_test_util_store.c | 248 -------------------
.../host/test/src/ble_hs_test_util_store.h | 44 ----
net/nimble/host/test/src/ble_sm_test_util.c | 34 +--
7 files changed, 83 insertions(+), 336 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/pkg.yml b/net/nimble/host/test/pkg.yml
index fe73f91..c8553ef 100644
--- a/net/nimble/host/test/pkg.yml
+++ b/net/nimble/host/test/pkg.yml
@@ -25,6 +25,7 @@ pkg.keywords:
pkg.deps:
- test/testutil
- net/nimble/host
+ - net/nimble/host/store/ram
pkg.deps.SELFTEST:
- sys/console/stub
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/src/ble_gatts_notify_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatts_notify_test.c b/net/nimble/host/test/src/ble_gatts_notify_test.c
index b86eac4..a1f1469 100644
--- a/net/nimble/host/test/src/ble_gatts_notify_test.c
+++ b/net/nimble/host/test/src/ble_gatts_notify_test.c
@@ -24,7 +24,6 @@
#include "host/ble_uuid.h"
#include "host/ble_hs_test.h"
#include "ble_hs_test_util.h"
-#include "ble_hs_test_util_store.h"
#define BLE_GATTS_NOTIFY_TEST_CHR_1_UUID 0x1111
#define BLE_GATTS_NOTIFY_TEST_CHR_2_UUID 0x2222
@@ -236,9 +235,6 @@ ble_gatts_notify_test_misc_init(uint16_t *out_conn_handle, int bonding,
ble_gatts_notify_test_num_events = 0;
- ble_hs_test_util_store_init(10, 10, 10);
- ble_hs_cfg.store_read_cb = ble_hs_test_util_store_read;
- ble_hs_cfg.store_write_cb = ble_hs_test_util_store_write;
rc = ble_gatts_register_svcs(ble_gatts_notify_test_svcs,
ble_gatts_notify_test_misc_reg_cb, NULL);
@@ -316,7 +312,7 @@ ble_gatts_notify_test_misc_init(uint16_t *out_conn_handle, int bonding,
} else {
exp_num_cccds = 0;
}
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == exp_num_cccds);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == exp_num_cccds);
}
static void
@@ -761,7 +757,7 @@ TEST_CASE(ble_gatts_notify_test_bonded_n)
BLE_GATTS_CLT_CFG_F_NOTIFY, 0);
/* Ensure both CCCDs still persisted. */
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == 2);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == 2);
/* Update characteristic 1's value. */
ble_gatts_notify_test_chr_1_len = 1;
@@ -807,7 +803,7 @@ TEST_CASE(ble_gatts_notify_test_bonded_n)
TEST_ASSERT(flags == BLE_GATTS_CLT_CFG_F_NOTIFY);
/* Ensure both CCCDs still persisted. */
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == 2);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == 2);
}
TEST_CASE(ble_gatts_notify_test_bonded_i)
@@ -825,7 +821,7 @@ TEST_CASE(ble_gatts_notify_test_bonded_i)
BLE_GATTS_CLT_CFG_F_INDICATE, 0);
/* Ensure both CCCDs still persisted. */
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == 2);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == 2);
/* Update characteristic 1's value. */
ble_gatts_notify_test_chr_1_len = 1;
@@ -897,7 +893,7 @@ TEST_CASE(ble_gatts_notify_test_bonded_i)
TEST_ASSERT(flags == BLE_GATTS_CLT_CFG_F_INDICATE);
/* Ensure both CCCDs still persisted. */
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == 2);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == 2);
}
TEST_CASE(ble_gatts_notify_test_bonded_i_no_ack)
@@ -938,7 +934,7 @@ TEST_CASE(ble_gatts_notify_test_bonded_i_no_ack)
BLE_GATTS_CLT_CFG_F_INDICATE, 1, 0, 0);
/* Ensure CCCD still persisted. */
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == 1);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == 1);
/* Reconnect. */
ble_hs_test_util_create_conn(conn_handle, ((uint8_t[]){2,3,4,5,6,7,8,9}),
@@ -966,7 +962,7 @@ TEST_CASE(ble_gatts_notify_test_bonded_i_no_ack)
TEST_ASSERT(flags == 0);
/* Ensure CCCD still persisted. */
- TEST_ASSERT(ble_hs_test_util_store_num_cccds == 1);
+ TEST_ASSERT(ble_hs_test_util_num_cccds() == 1);
/* Verify 'updated' state is no longer persisted. */
rc = ble_store_read_cccd(&key_cccd, &value_cccd);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/src/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c
index 9515e02..b0edcd3 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -26,6 +26,7 @@
#include "nimble/ble_hci_trans.h"
#include "host/ble_hs_adv.h"
#include "host/ble_hs_id.h"
+#include "store/ram/ble_store_ram.h"
#include "transport/ram/ble_hci_ram.h"
#include "ble_hs_test_util.h"
@@ -42,6 +43,10 @@ struct os_eventq ble_hs_test_util_evq;
static STAILQ_HEAD(, os_mbuf_pkthdr) ble_hs_test_util_prev_tx_queue;
struct os_mbuf *ble_hs_test_util_prev_tx_cur;
+int ble_sm_test_store_obj_type;
+union ble_store_key ble_sm_test_store_key;
+union ble_store_value ble_sm_test_store_value;
+
#define BLE_HS_TEST_UTIL_PREV_HCI_TX_CNT 64
static uint8_t
ble_hs_test_util_prev_hci_tx[BLE_HS_TEST_UTIL_PREV_HCI_TX_CNT][260];
@@ -2042,6 +2047,69 @@ ble_hs_test_util_hci_txed(uint8_t *cmdbuf, void *arg)
return 0;
}
+int
+ble_hs_test_util_num_cccds(void)
+{
+ struct ble_store_value_cccd val;
+ struct ble_store_key_cccd key = { 0 };
+ int rc;
+
+ key.peer_addr_type = BLE_STORE_ADDR_TYPE_NONE;
+ for (key.idx = 0; ; key.idx++) {
+ rc = ble_store_read_cccd(&key, &val);
+ switch (rc) {
+ case 0:
+ break;
+
+ case BLE_HS_ENOENT:
+ return key.idx;
+
+ default:
+ TEST_ASSERT_FATAL(0);
+ }
+ }
+}
+
+static int
+ble_hs_test_util_store_read(int obj_type, union ble_store_key *key,
+ union ble_store_value *value)
+{
+ int rc;
+
+ ble_sm_test_store_obj_type = obj_type;
+ ble_sm_test_store_key = *key;
+
+ rc = ble_store_ram_read(obj_type, key, value);
+ ble_sm_test_store_value = *value;
+
+ return rc;
+}
+
+static int
+ble_hs_test_util_store_write(int obj_type, union ble_store_value *value)
+{
+ int rc;
+
+ ble_sm_test_store_obj_type = obj_type;
+
+ rc = ble_store_ram_write(obj_type, value);
+ ble_sm_test_store_value = *value;
+
+ return rc;
+}
+
+static int
+ble_hs_test_util_store_delete(int obj_type, union ble_store_key *key)
+{
+ int rc;
+
+ ble_sm_test_store_obj_type = obj_type;
+ ble_sm_test_store_key = *key;
+
+ rc = ble_store_ram_delete(obj_type, key);
+ return rc;
+}
+
void
ble_hs_test_util_init_no_start(void)
{
@@ -2065,6 +2133,10 @@ ble_hs_test_util_init_no_start(void)
ble_hs_test_util_prev_hci_tx_clear();
ble_hs_evq_set(&ble_hs_test_util_evq);
+
+ ble_hs_cfg.store_read_cb = ble_hs_test_util_store_read;
+ ble_hs_cfg.store_write_cb = ble_hs_test_util_store_write;
+ ble_hs_cfg.store_delete_cb = ble_hs_test_util_store_delete;
}
void
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/src/ble_hs_test_util.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.h b/net/nimble/host/test/src/ble_hs_test_util.h
index 35fbd7a..b0f389c 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.h
+++ b/net/nimble/host/test/src/ble_hs_test_util.h
@@ -23,7 +23,6 @@
#include <inttypes.h>
#include "host/ble_gap.h"
#include "ble_hs_priv.h"
-#include "ble_hs_test_util_store.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -273,6 +272,7 @@ int ble_hs_test_util_mbuf_count(
void ble_hs_test_util_assert_mbufs_freed(
const struct ble_hs_test_util_mbuf_params *params);
void ble_hs_test_util_post_test(void *arg);
+int ble_hs_test_util_num_cccds(void);
void ble_hs_test_util_init_no_start(void);
void ble_hs_test_util_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/src/ble_hs_test_util_store.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util_store.c b/net/nimble/host/test/src/ble_hs_test_util_store.c
deleted file mode 100644
index e90f84a..0000000
--- a/net/nimble/host/test/src/ble_hs_test_util_store.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <string.h>
-#include "testutil/testutil.h"
-#include "nimble/ble.h"
-#include "ble_hs_test_util.h"
-#include "ble_hs_test_util_store.h"
-
-static int ble_hs_test_util_store_max_our_secs;
-static int ble_hs_test_util_store_max_peer_secs;
-static int ble_hs_test_util_store_max_cccds;
-
-static struct ble_store_value_sec *ble_hs_test_util_store_our_secs;
-static struct ble_store_value_sec *ble_hs_test_util_store_peer_secs;
-static struct ble_store_value_cccd *ble_hs_test_util_store_cccds;
-int ble_hs_test_util_store_num_our_secs;
-int ble_hs_test_util_store_num_peer_secs;
-int ble_hs_test_util_store_num_cccds;
-
-
-#define BLE_HS_TEST_UTIL_STORE_WRITE_GEN(store, num_vals, max_vals, \
- val, idx) do \
-{ \
- if ((idx) == -1) { \
- if ((num_vals) >= (max_vals)) { \
- return BLE_HS_ENOMEM; \
- } \
- store[(num_vals)] = (val); \
- (num_vals)++; \
- } else { \
- store[(idx)] = val; \
- } \
- return 0; \
-} while (0)
-
-void
-ble_hs_test_util_store_init(int max_our_secs, int max_peer_secs, int max_cccds)
-{
- free(ble_hs_test_util_store_our_secs);
- free(ble_hs_test_util_store_peer_secs);
- free(ble_hs_test_util_store_cccds);
-
- ble_hs_test_util_store_our_secs = malloc(
- ble_hs_test_util_store_max_our_secs *
- sizeof *ble_hs_test_util_store_our_secs);
- TEST_ASSERT_FATAL(ble_hs_test_util_store_our_secs != NULL);
-
- ble_hs_test_util_store_peer_secs = malloc(
- ble_hs_test_util_store_max_peer_secs *
- sizeof *ble_hs_test_util_store_peer_secs);
- TEST_ASSERT_FATAL(ble_hs_test_util_store_peer_secs != NULL);
-
- ble_hs_test_util_store_cccds = malloc(
- ble_hs_test_util_store_max_cccds *
- sizeof *ble_hs_test_util_store_cccds);
- TEST_ASSERT_FATAL(ble_hs_test_util_store_cccds != NULL);
-
- ble_hs_test_util_store_max_our_secs = max_our_secs;
- ble_hs_test_util_store_max_peer_secs = max_peer_secs;
- ble_hs_test_util_store_max_cccds = max_cccds;
- ble_hs_test_util_store_num_our_secs = 0;
- ble_hs_test_util_store_num_peer_secs = 0;
- ble_hs_test_util_store_num_cccds = 0;
-}
-
-static int
-ble_hs_test_util_store_read_sec(struct ble_store_value_sec *store,
- int num_values,
- struct ble_store_key_sec *key,
- struct ble_store_value_sec *value)
-{
- struct ble_store_value_sec *cur;
- int skipped;
- int i;
-
- skipped = 0;
-
- for (i = 0; i < num_values; i++) {
- cur = store + i;
-
- if (key->peer_addr_type != BLE_STORE_ADDR_TYPE_NONE) {
- if (cur->peer_addr_type != key->peer_addr_type) {
- continue;
- }
-
- if (memcmp(cur->peer_addr, key->peer_addr,
- sizeof cur->peer_addr) != 0) {
- continue;
- }
- }
-
- if (key->ediv_rand_present) {
- if (cur->ediv != key->ediv) {
- continue;
- }
-
- if (cur->rand_num != key->rand_num) {
- continue;
- }
- }
-
- if (key->idx > skipped) {
- skipped++;
- continue;
- }
-
- *value = *cur;
- return 0;
- }
-
- return BLE_HS_ENOENT;
-}
-
-static int
-ble_hs_test_util_store_find_cccd(struct ble_store_key_cccd *key)
-{
- struct ble_store_value_cccd *cur;
- int skipped;
- int i;
-
- skipped = 0;
- for (i = 0; i < ble_hs_test_util_store_num_cccds; i++) {
- cur = ble_hs_test_util_store_cccds + i;
-
- if (key->peer_addr_type != BLE_STORE_ADDR_TYPE_NONE) {
- if (cur->peer_addr_type != key->peer_addr_type) {
- continue;
- }
-
- if (memcmp(cur->peer_addr, key->peer_addr, 6) != 0) {
- continue;
- }
- }
-
- if (key->chr_val_handle != 0) {
- if (cur->chr_val_handle != key->chr_val_handle) {
- continue;
- }
- }
-
- if (key->idx > skipped) {
- skipped++;
- continue;
- }
-
- return i;
- }
-
- return -1;
-}
-
-static int
-ble_hs_test_util_store_read_cccd(struct ble_store_key_cccd *key,
- struct ble_store_value_cccd *value)
-{
- int idx;
-
- idx = ble_hs_test_util_store_find_cccd(key);
- if (idx == -1) {
- return BLE_HS_ENOENT;
- }
-
- *value = ble_hs_test_util_store_cccds[idx];
- return 0;
-}
-
-int
-ble_hs_test_util_store_read(int obj_type, union ble_store_key *key,
- union ble_store_value *dst)
-{
- switch (obj_type) {
- case BLE_STORE_OBJ_TYPE_PEER_SEC:
- return ble_hs_test_util_store_read_sec(
- ble_hs_test_util_store_peer_secs,
- ble_hs_test_util_store_num_peer_secs,
- &key->sec,
- &dst->sec);
-
- case BLE_STORE_OBJ_TYPE_OUR_SEC:
- return ble_hs_test_util_store_read_sec(
- ble_hs_test_util_store_our_secs,
- ble_hs_test_util_store_num_our_secs,
- &key->sec,
- &dst->sec);
-
- case BLE_STORE_OBJ_TYPE_CCCD:
- return ble_hs_test_util_store_read_cccd(&key->cccd, &dst->cccd);
-
- default:
- TEST_ASSERT_FATAL(0);
- return BLE_HS_EUNKNOWN;
- }
-}
-
-int
-ble_hs_test_util_store_write(int obj_type, union ble_store_value *value)
-{
- struct ble_store_key_cccd key_cccd;
- int idx;
-
- switch (obj_type) {
- case BLE_STORE_OBJ_TYPE_PEER_SEC:
- BLE_HS_TEST_UTIL_STORE_WRITE_GEN(
- ble_hs_test_util_store_peer_secs,
- ble_hs_test_util_store_num_peer_secs,
- ble_hs_test_util_store_max_peer_secs,
- value->sec, -1);
-
- case BLE_STORE_OBJ_TYPE_OUR_SEC:
- BLE_HS_TEST_UTIL_STORE_WRITE_GEN(
- ble_hs_test_util_store_our_secs,
- ble_hs_test_util_store_num_our_secs,
- ble_hs_test_util_store_max_our_secs,
- value->sec, -1);
-
- case BLE_STORE_OBJ_TYPE_CCCD:
- ble_store_key_from_value_cccd(&key_cccd, &value->cccd);
- idx = ble_hs_test_util_store_find_cccd(&key_cccd);
- BLE_HS_TEST_UTIL_STORE_WRITE_GEN(
- ble_hs_test_util_store_cccds,
- ble_hs_test_util_store_num_cccds,
- ble_hs_test_util_store_max_cccds,
- value->cccd, idx);
-
- default:
- TEST_ASSERT_FATAL(0);
- return BLE_HS_EUNKNOWN;
- }
-
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/src/ble_hs_test_util_store.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util_store.h b/net/nimble/host/test/src/ble_hs_test_util_store.h
deleted file mode 100644
index 0f82aa1..0000000
--- a/net/nimble/host/test/src/ble_hs_test_util_store.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_BLE_HS_TEST_UTIL_STORE_
-#define H_BLE_HS_TEST_UTIL_STORE_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-union ble_store_value;
-union ble_store_key;
-
-extern int ble_hs_test_util_store_num_our_ltks;
-extern int ble_hs_test_util_store_num_peer_ltks;
-extern int ble_hs_test_util_store_num_cccds;
-
-void ble_hs_test_util_store_init(int max_our_ltks, int max_peer_ltks,
- int max_cccds);
-int ble_hs_test_util_store_read(int obj_type, union ble_store_key *key,
- union ble_store_value *dst);
-int ble_hs_test_util_store_write(int obj_type, union ble_store_value *value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1eef1ae5/net/nimble/host/test/src/ble_sm_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_sm_test_util.c b/net/nimble/host/test/src/ble_sm_test_util.c
index b8f0dbc..d702ce6 100644
--- a/net/nimble/host/test/src/ble_sm_test_util.c
+++ b/net/nimble/host/test/src/ble_sm_test_util.c
@@ -26,6 +26,7 @@
#include "host/ble_sm.h"
#include "host/ble_hs_test.h"
#include "host/ble_hs_id.h"
+#include "store/ram/ble_store_ram.h"
#include "ble_hs_test_util.h"
#include "ble_sm_test_util.h"
@@ -34,13 +35,6 @@ int ble_sm_test_gap_status;
struct ble_gap_sec_state ble_sm_test_sec_state;
static struct ble_gap_passkey_params ble_sm_test_ioact;
-int ble_sm_test_store_obj_type;
-union ble_store_key ble_sm_test_store_key;
-union ble_store_value ble_sm_test_store_value;
-
-static ble_store_read_fn ble_sm_test_util_store_read;
-static ble_store_write_fn ble_sm_test_util_store_write;
-
struct ble_sm_test_util_entity {
uint8_t addr_type;
uint8_t id_addr_type;
@@ -75,34 +69,11 @@ struct ble_sm_test_util_entity {
.hdh_len = (len) \
})
-static int
-ble_sm_test_util_store_read(int obj_type, union ble_store_key *key,
- union ble_store_value *val)
-{
- ble_sm_test_store_obj_type = obj_type;
- ble_sm_test_store_key = *key;
-
- return ble_hs_test_util_store_read(obj_type, key, val);
-}
-
-static int
-ble_sm_test_util_store_write(int obj_type, union ble_store_value *val)
-{
- ble_sm_test_store_obj_type = obj_type;
- ble_sm_test_store_value = *val;
-
- return ble_hs_test_util_store_write(obj_type, val);
-}
-
void
ble_sm_test_util_init(void)
{
ble_hs_test_util_init();
- ble_hs_test_util_store_init(10, 10, 10);
- ble_hs_cfg.store_read_cb = ble_sm_test_util_store_read;
- ble_hs_cfg.store_write_cb = ble_sm_test_util_store_write;
- ble_sm_test_store_obj_type = -1;
ble_sm_test_gap_event_type = -1;
ble_sm_test_gap_status = -1;
@@ -1255,8 +1226,7 @@ ble_sm_test_util_peer_bonding_good(int send_enc_req,
TEST_ASSERT(!conn->bhc_sec_state.encrypted);
/* Ensure the LTK request event got sent to the application. */
- TEST_ASSERT(ble_sm_test_store_obj_type ==
- BLE_STORE_OBJ_TYPE_OUR_SEC);
+ TEST_ASSERT(ble_sm_test_store_obj_type == BLE_STORE_OBJ_TYPE_OUR_SEC);
TEST_ASSERT(ble_sm_test_store_key.sec.peer_addr_type ==
ble_hs_misc_addr_type_to_id(peer_addr_type));
TEST_ASSERT(ble_sm_test_store_key.sec.ediv_rand_present);
[3/4] incubator-mynewt-core git commit: MYNEWT-383 BLE Host - Allow
programmatic unbonding
Posted by cc...@apache.org.
MYNEWT-383 BLE Host - Allow programmatic unbonding
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/71503c55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/71503c55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/71503c55
Branch: refs/heads/develop
Commit: 71503c55a9f0e41ec8ba18c35be71c7a73aaded3
Parents: ea00890
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Dec 8 16:20:03 2016 -0600
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Dec 8 16:21:13 2016 -0600
----------------------------------------------------------------------
net/nimble/host/include/host/ble_sm.h | 1 +
net/nimble/host/src/ble_sm.c | 36 +++++++++++++++++++
net/nimble/host/test/src/ble_hs_test_util.c | 46 ++++++++++++++++++++++++
net/nimble/host/test/src/ble_hs_test_util.h | 2 ++
net/nimble/host/test/src/ble_sm_test_util.c | 44 +++++++++++++++++++++++
5 files changed, 129 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/71503c55/net/nimble/host/include/host/ble_sm.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_sm.h b/net/nimble/host/include/host/ble_sm.h
index 9bd25ad..ef4ec11 100644
--- a/net/nimble/host/include/host/ble_sm.h
+++ b/net/nimble/host/include/host/ble_sm.h
@@ -97,6 +97,7 @@ struct ble_sm_io {
#if NIMBLE_BLE_SM
int ble_sm_inject_io(uint16_t conn_handle, struct ble_sm_io *pkey);
+int ble_sm_unbond(uint8_t peer_id_addr_type, const uint8_t *peer_id_addr);
#else
#define ble_sm_inject_io(conn_handle, pkey) \
((void)(conn_handle), BLE_HS_ENOTSUP)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/71503c55/net/nimble/host/src/ble_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c
index 3421b06..76811ee 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -2155,6 +2155,42 @@ ble_sm_enc_initiate(uint16_t conn_handle, const uint8_t *ltk, uint16_t ediv,
return res.app_status;
}
+/**
+ * Deletes the bonding association with the specified peer. That is, this
+ * function erases the security material that was persisted when we paired with
+ * the specified peer.
+ *
+ * @param peer_id_addr_type The identity address type of the peer.
+ * @param peer_id_addr The peer's identity address.
+ *
+ * @return 0 on success;
+ * BLE_HS_ENOENT if there is no bond to the
+ * specified peer.
+ */
+int
+ble_sm_unbond(uint8_t peer_id_addr_type, const uint8_t *peer_id_addr)
+{
+ struct ble_store_key_sec key_sec = { 0 };
+ int peer_rc;
+ int our_rc;
+ int rc;
+
+ key_sec.peer_addr_type = peer_id_addr_type;
+ memcpy(key_sec.peer_addr, peer_id_addr, sizeof key_sec.peer_addr);
+
+ our_rc = ble_store_delete_our_sec(&key_sec);
+ peer_rc = ble_store_delete_peer_sec(&key_sec);
+
+ if (our_rc == BLE_HS_ENOENT && peer_rc == BLE_HS_ENOENT) {
+ rc = BLE_HS_ENOENT;
+ } else if (our_rc == 0) {
+ rc = peer_rc;
+ } else {
+ rc = our_rc;
+ }
+ return rc;
+}
+
static int
ble_sm_rx(uint16_t conn_handle, struct os_mbuf **om)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/71503c55/net/nimble/host/test/src/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c
index b0edcd3..ef4f9a1 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -2070,6 +2070,52 @@ ble_hs_test_util_num_cccds(void)
}
}
+int
+ble_hs_test_util_num_our_secs(void)
+{
+ struct ble_store_value_sec val;
+ struct ble_store_key_sec key = { 0 };
+ int rc;
+
+ key.peer_addr_type = BLE_STORE_ADDR_TYPE_NONE;
+ for (key.idx = 0; ; key.idx++) {
+ rc = ble_store_read_our_sec(&key, &val);
+ switch (rc) {
+ case 0:
+ break;
+
+ case BLE_HS_ENOENT:
+ return key.idx;
+
+ default:
+ TEST_ASSERT_FATAL(0);
+ }
+ }
+}
+
+int
+ble_hs_test_util_num_peer_secs(void)
+{
+ struct ble_store_value_sec val;
+ struct ble_store_key_sec key = { 0 };
+ int rc;
+
+ key.peer_addr_type = BLE_STORE_ADDR_TYPE_NONE;
+ for (key.idx = 0; ; key.idx++) {
+ rc = ble_store_read_peer_sec(&key, &val);
+ switch (rc) {
+ case 0:
+ break;
+
+ case BLE_HS_ENOENT:
+ return key.idx;
+
+ default:
+ TEST_ASSERT_FATAL(0);
+ }
+ }
+}
+
static int
ble_hs_test_util_store_read(int obj_type, union ble_store_key *key,
union ble_store_value *value)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/71503c55/net/nimble/host/test/src/ble_hs_test_util.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.h b/net/nimble/host/test/src/ble_hs_test_util.h
index b0f389c..75865e2 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.h
+++ b/net/nimble/host/test/src/ble_hs_test_util.h
@@ -273,6 +273,8 @@ void ble_hs_test_util_assert_mbufs_freed(
const struct ble_hs_test_util_mbuf_params *params);
void ble_hs_test_util_post_test(void *arg);
int ble_hs_test_util_num_cccds(void);
+int ble_hs_test_util_num_our_secs(void);
+int ble_hs_test_util_num_peer_secs(void);
void ble_hs_test_util_init_no_start(void);
void ble_hs_test_util_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/71503c55/net/nimble/host/test/src/ble_sm_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_sm_test_util.c b/net/nimble/host/test/src/ble_sm_test_util.c
index d702ce6..7f40ff9 100644
--- a/net/nimble/host/test/src/ble_sm_test_util.c
+++ b/net/nimble/host/test/src/ble_sm_test_util.c
@@ -1797,6 +1797,9 @@ ble_sm_test_util_us_lgcy_good_once(struct ble_sm_test_params *params)
void
ble_sm_test_util_us_lgcy_good(struct ble_sm_test_params *params)
{
+ uint8_t id_addr_type;
+ int rc;
+
/*** We are master. */
/* We initiate pairing. */
@@ -1809,6 +1812,14 @@ ble_sm_test_util_us_lgcy_good(struct ble_sm_test_params *params)
/* Verify link can be restored via the encryption procedure. */
ble_sm_test_util_bonding_all(params, 1);
+
+ /* Verify programmatic unbonding. */
+ id_addr_type = ble_hs_misc_addr_type_to_id(params->resp_addr_type);
+ rc = ble_sm_unbond(id_addr_type, params->resp_id_addr);
+ TEST_ASSERT(rc == 0);
+
+ TEST_ASSERT(ble_hs_test_util_num_our_secs() == 0);
+ TEST_ASSERT(ble_hs_test_util_num_peer_secs() == 0);
}
static void
@@ -1924,6 +1935,9 @@ ble_sm_test_util_peer_lgcy_good_once(struct ble_sm_test_params *params)
void
ble_sm_test_util_peer_lgcy_good(struct ble_sm_test_params *params)
{
+ uint8_t id_addr_type;
+ int rc;
+
/*** Peer is master. */
/* Peer performs IO first; peer initiates pairing. */
@@ -1948,6 +1962,14 @@ ble_sm_test_util_peer_lgcy_good(struct ble_sm_test_params *params)
/* Verify link can be restored via the encryption procedure. */
ble_sm_test_util_bonding_all(params, 0);
+
+ /* Verify programmatic unbonding. */
+ id_addr_type = ble_hs_misc_addr_type_to_id(params->init_addr_type);
+ rc = ble_sm_unbond(id_addr_type, params->init_id_addr);
+ TEST_ASSERT(rc == 0);
+
+ TEST_ASSERT(ble_hs_test_util_num_our_secs() == 0);
+ TEST_ASSERT(ble_hs_test_util_num_peer_secs() == 0);
}
static void
@@ -2110,6 +2132,9 @@ ble_sm_test_util_us_sc_good_once(struct ble_sm_test_params *params)
void
ble_sm_test_util_us_sc_good(struct ble_sm_test_params *params)
{
+ uint8_t id_addr_type;
+ int rc;
+
/*** We are master. */
/* We initiate pairing. */
@@ -2124,6 +2149,14 @@ ble_sm_test_util_us_sc_good(struct ble_sm_test_params *params)
/* Verify link can be restored via the encryption procedure. */
ble_sm_test_util_bonding_all(params, 1);
+
+ /* Verify programmatic unbonding. */
+ id_addr_type = ble_hs_misc_addr_type_to_id(params->resp_addr_type);
+ rc = ble_sm_unbond(id_addr_type, params->resp_id_addr);
+ TEST_ASSERT(rc == 0);
+
+ TEST_ASSERT(ble_hs_test_util_num_our_secs() == 0);
+ TEST_ASSERT(ble_hs_test_util_num_peer_secs() == 0);
}
static void
@@ -2298,6 +2331,9 @@ ble_sm_test_util_peer_sc_good_once(struct ble_sm_test_params *params)
void
ble_sm_test_util_peer_sc_good(struct ble_sm_test_params *params)
{
+ uint8_t id_addr_type;
+ int rc;
+
/*** Peer is master. */
/* Peer performs IO first; peer initiates pairing. */
@@ -2322,6 +2358,14 @@ ble_sm_test_util_peer_sc_good(struct ble_sm_test_params *params)
/* Verify link can be restored via the encryption procedure. */
ble_sm_test_util_bonding_all(params, 0);
+
+ /* Verify programmatic unbonding. */
+ id_addr_type = ble_hs_misc_addr_type_to_id(params->init_addr_type);
+ rc = ble_sm_unbond(id_addr_type, params->init_id_addr);
+ TEST_ASSERT(rc == 0);
+
+ TEST_ASSERT(ble_hs_test_util_num_our_secs() == 0);
+ TEST_ASSERT(ble_hs_test_util_num_peer_secs() == 0);
}
void