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/09/26 22:59:29 UTC

[1/2] incubator-mynewt-core git commit: BLE Host - Move SC-specific functions into SC file

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 7b78fafdc -> fdc06afc6


BLE Host - Move SC-specific functions into SC file


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/1cf40bb0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1cf40bb0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1cf40bb0

Branch: refs/heads/develop
Commit: 1cf40bb047cdd3ada46bd64878d14f9762a5044b
Parents: 7b78faf
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Sep 26 15:16:08 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Sep 26 15:51:07 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_sm.c      | 35 -----------------------------
 net/nimble/host/src/ble_sm_priv.h |  1 -
 net/nimble/host/src/ble_sm_sc.c   | 40 ++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1cf40bb0/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 ee848fc..1156b77 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -156,9 +156,6 @@ static uint8_t ble_sm_dbg_next_ltk[16];
 static uint8_t ble_sm_dbg_next_ltk_set;
 static uint8_t ble_sm_dbg_next_csrk[16];
 static uint8_t ble_sm_dbg_next_csrk_set;
-static uint8_t ble_sm_dbg_sc_pub_key[64];
-static uint8_t ble_sm_dbg_sc_priv_key[32];
-static uint8_t ble_sm_dbg_sc_keys_set;
 
 void
 ble_sm_dbg_set_next_pair_rand(uint8_t *next_pair_rand)
@@ -198,16 +195,6 @@ ble_sm_dbg_set_next_csrk(uint8_t *next_csrk)
     ble_sm_dbg_next_csrk_set = 1;
 }
 
-void
-ble_sm_dbg_set_sc_keys(uint8_t *pubkey, uint8_t *privkey)
-{
-    memcpy(ble_sm_dbg_sc_pub_key, pubkey,
-           sizeof ble_sm_dbg_sc_pub_key);
-    memcpy(ble_sm_dbg_sc_priv_key, privkey,
-           sizeof ble_sm_dbg_sc_priv_key);
-    ble_sm_dbg_sc_keys_set = 1;
-}
-
 int
 ble_sm_dbg_num_procs(void)
 {
@@ -357,28 +344,6 @@ ble_sm_gen_csrk(struct ble_sm_proc *proc, uint8_t *csrk)
     return 0;
 }
 
-int
-ble_sm_gen_pub_priv(void *pub, uint32_t *priv)
-{
-    int rc;
-
-#if MYNEWT_VAL(BLE_HS_DEBUG)
-    if (ble_sm_dbg_sc_keys_set) {
-        ble_sm_dbg_sc_keys_set = 0;
-        memcpy(pub, ble_sm_dbg_sc_pub_key, sizeof ble_sm_dbg_sc_pub_key);
-        memcpy(priv, ble_sm_dbg_sc_priv_key, sizeof ble_sm_dbg_sc_priv_key);
-        return 0;
-    }
-#endif
-
-    rc = ble_sm_alg_gen_key_pair(pub, priv);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
 static void
 ble_sm_proc_set_timer(struct ble_sm_proc *proc)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1cf40bb0/net/nimble/host/src/ble_sm_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_priv.h b/net/nimble/host/src/ble_sm_priv.h
index 93b55e2..1b87eb5 100644
--- a/net/nimble/host/src/ble_sm_priv.h
+++ b/net/nimble/host/src/ble_sm_priv.h
@@ -442,7 +442,6 @@ struct ble_sm_proc *ble_sm_proc_find(uint16_t conn_handle, uint8_t state,
                                      int is_initiator,
                                      struct ble_sm_proc **out_prev);
 int ble_sm_gen_pair_rand(uint8_t *pair_rand);
-int ble_sm_gen_pub_priv(void *pub, uint32_t *priv);
 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);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1cf40bb0/net/nimble/host/src/ble_sm_sc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_sc.c b/net/nimble/host/src/ble_sm_sc.c
index 4bc7603..b7d3906 100644
--- a/net/nimble/host/src/ble_sm_sc.c
+++ b/net/nimble/host/src/ble_sm_sc.c
@@ -89,6 +89,24 @@ static const uint8_t ble_sm_sc_resp_ioa[5 /*resp*/ ][5 /*init*/ ] =
       {IOACT_INPUT,   IOACT_NUMCMP, IOACT_DISP,  IOACT_NONE, IOACT_NUMCMP},
 };
 
+static uint8_t ble_sm_dbg_sc_pub_key[64];
+static uint8_t ble_sm_dbg_sc_priv_key[32];
+static uint8_t ble_sm_dbg_sc_keys_set;
+
+#if MYNEWT_VAL(BLE_HS_DEBUG)
+
+void
+ble_sm_dbg_set_sc_keys(uint8_t *pubkey, uint8_t *privkey)
+{
+    memcpy(ble_sm_dbg_sc_pub_key, pubkey,
+           sizeof ble_sm_dbg_sc_pub_key);
+    memcpy(ble_sm_dbg_sc_priv_key, privkey,
+           sizeof ble_sm_dbg_sc_priv_key);
+    ble_sm_dbg_sc_keys_set = 1;
+}
+
+#endif
+
 int
 ble_sm_sc_io_action(struct ble_sm_proc *proc)
 {
@@ -138,6 +156,28 @@ ble_sm_sc_io_action(struct ble_sm_proc *proc)
 }
 
 static int
+ble_sm_gen_pub_priv(void *pub, uint32_t *priv)
+{
+    int rc;
+
+#if MYNEWT_VAL(BLE_HS_DEBUG)
+    if (ble_sm_dbg_sc_keys_set) {
+        ble_sm_dbg_sc_keys_set = 0;
+        memcpy(pub, ble_sm_dbg_sc_pub_key, sizeof ble_sm_dbg_sc_pub_key);
+        memcpy(priv, ble_sm_dbg_sc_priv_key, sizeof ble_sm_dbg_sc_priv_key);
+        return 0;
+    }
+#endif
+
+    rc = ble_sm_alg_gen_key_pair(pub, priv);
+    if (rc != 0) {
+        return rc;
+    }
+
+    return 0;
+}
+
+static int
 ble_sm_sc_ensure_keys_generated(void)
 {
     int rc;


[2/2] incubator-mynewt-core git commit: libs/os - Allow OS device list to be reset.

Posted by cc...@apache.org.
libs/os - Allow OS device list to be reset.

This change is necessary for effecting a full system reset between unit
tests.  Without this function, the same UART device gets added to the
device list a second time, creating a cycle in the list.


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/fdc06afc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fdc06afc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fdc06afc

Branch: refs/heads/develop
Commit: fdc06afc6cc45c2cb3e07d2fa854f478c2cfe2b8
Parents: 1cf40bb
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Sep 26 15:49:23 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Sep 26 15:51:08 2016 -0700

----------------------------------------------------------------------
 libs/os/include/os/os_dev.h |  1 +
 libs/os/src/os.c            |  3 +++
 libs/os/src/os_dev.c        | 13 +++++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fdc06afc/libs/os/include/os/os_dev.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_dev.h b/libs/os/include/os/os_dev.h
index be2123d..def42c0 100644
--- a/libs/os/include/os/os_dev.h
+++ b/libs/os/include/os/os_dev.h
@@ -109,5 +109,6 @@ int os_dev_suspend_all(os_time_t, uint8_t);
 int os_dev_resume_all(void);
 struct os_dev *os_dev_open(char *devname, uint32_t timo, void *arg);
 int os_dev_close(struct os_dev *dev);
+void os_dev_reset(void);
 
 #endif /* _OS_DEV_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fdc06afc/libs/os/src/os.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os.c b/libs/os/src/os.c
index a7c7a5b..3089a97 100644
--- a/libs/os/src/os.c
+++ b/libs/os/src/os.c
@@ -146,6 +146,9 @@ os_init(void)
     TAILQ_INIT(&g_callout_list);
     STAILQ_INIT(&g_os_task_list);
 
+    /* Initialize device list. */
+    os_dev_reset();
+
     err = os_arch_os_init();
     assert(err == OS_OK);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fdc06afc/libs/os/src/os_dev.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_dev.c b/libs/os/src/os_dev.c
index fbd70b8..fa8709b 100644
--- a/libs/os/src/os_dev.c
+++ b/libs/os/src/os_dev.c
@@ -23,8 +23,7 @@
 
 #include <string.h>
 
-static STAILQ_HEAD(, os_dev) g_os_dev_list =
-    STAILQ_HEAD_INITIALIZER(g_os_dev_list);
+static STAILQ_HEAD(, os_dev) g_os_dev_list;
 
 static int
 os_dev_init(struct os_dev *dev, char *name, uint8_t stage,
@@ -298,3 +297,13 @@ err:
     return (rc);
 }
 
+/**
+ * Clears the device list.  This function does not close any devices or free
+ * any resources; its purpose is to allow a full system reset between unit
+ * tests.
+ */
+void
+os_dev_reset(void)
+{
+    STAILQ_INIT(&g_os_dev_list);
+}