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/06/15 02:27:42 UTC

[20/50] [abbrv] incubator-mynewt-core git commit: BLE Host - Fix wrong peer addr type in ltk req rx.

BLE Host - Fix wrong peer addr type in ltk req rx.


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

Branch: refs/heads/develop
Commit: d986a276f6210700ba96c6a426a5a7e767e0dcb1
Parents: 60e0453
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 8 09:36:27 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jun 14 19:23:35 2016 -0700

----------------------------------------------------------------------
 apps/bletiny/src/misc.c                |  8 +++++---
 net/nimble/host/include/host/ble_gap.h |  2 ++
 net/nimble/host/src/ble_gap.c          |  3 ++-
 net/nimble/host/src/ble_sm.c           | 13 ++++++++++---
 4 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d986a276/apps/bletiny/src/misc.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/misc.c b/apps/bletiny/src/misc.c
index ecfcd9a..83c28cd 100644
--- a/apps/bletiny/src/misc.c
+++ b/apps/bletiny/src/misc.c
@@ -96,9 +96,11 @@ chr_is_empty(struct bletiny_svc *svc, struct bletiny_chr *chr)
 void
 print_conn_desc(struct ble_gap_conn_desc *desc)
 {
-    console_printf("handle=%d peer_ota_addr_type=%d "
-                   "peer_ota_addr=",
-                   desc->conn_handle, desc->peer_ota_addr_type);
+    console_printf("handle=%d our_ota_addr_type=%d our_ota_addr=",
+                   desc->conn_handle, desc->our_ota_addr_type);
+    print_addr(desc->our_ota_addr);
+    console_printf(" peer_ota_addr_type=%d peer_ota_addr=",
+                   desc->peer_ota_addr_type);
     print_addr(desc->peer_ota_addr);
     console_printf(" peer_id_addr_type=%d peer_id_addr=",
                    desc->peer_id_addr_type);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d986a276/net/nimble/host/include/host/ble_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h
index faa8f92..4542cdb 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -121,12 +121,14 @@ struct ble_gap_conn_desc {
     struct ble_gap_sec_state sec_state;
     uint8_t peer_ota_addr[6];
     uint8_t peer_id_addr[6];
+    uint8_t our_ota_addr[6];
     uint16_t conn_handle;
     uint16_t conn_itvl;
     uint16_t conn_latency;
     uint16_t supervision_timeout;
     uint8_t peer_ota_addr_type;
     uint8_t peer_id_addr_type;
+    uint8_t our_ota_addr_type;
 };
 
 struct ble_gap_crt_params {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d986a276/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index a2c007a..d3a07e1 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -278,7 +278,7 @@ ble_gap_fill_conn_desc(struct ble_hs_conn *conn,
     uint8_t *our_ota_addr;
 
     ble_hs_conn_addrs(conn,
-                      NULL, &our_ota_addr,
+                      &desc->our_ota_addr_type, &our_ota_addr,
                       NULL, NULL,
                       &desc->peer_ota_addr_type, &peer_ota_addr,
                       &desc->peer_id_addr_type, &peer_id_addr);
@@ -286,6 +286,7 @@ ble_gap_fill_conn_desc(struct ble_hs_conn *conn,
     desc->conn_handle = conn->bhc_handle;
     memcpy(desc->peer_ota_addr, peer_ota_addr, 6);
     memcpy(desc->peer_id_addr, peer_id_addr, 6);
+    memcpy(desc->our_ota_addr, our_ota_addr, 6);
     desc->conn_itvl = conn->bhc_itvl;
     desc->conn_latency = conn->bhc_latency;
     desc->supervision_timeout = conn->bhc_supervision_timeout;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d986a276/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 68c0c0d..3c8f1b3 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -1189,6 +1189,7 @@ ble_sm_ltk_req_rx(struct hci_le_lt_key_req *evt)
     int store_rc;
     int bonding;
     uint8_t peer_addr[6];
+    uint8_t *peer_id_addr;
     uint8_t peer_addr_type;
 
     /* Silence gcc warning. */
@@ -1238,8 +1239,10 @@ ble_sm_ltk_req_rx(struct hci_le_lt_key_req *evt)
         if (conn == NULL) {
             res.app_status = BLE_HS_ENOTCONN;
         } else {
-            peer_addr_type = conn->bhc_addr_type;
-            memcpy(peer_addr, conn->bhc_addr, 6);
+            ble_hs_conn_addrs(conn,
+                              NULL, NULL, NULL, NULL,
+                              NULL, NULL, &peer_addr_type, &peer_id_addr);
+            memcpy(peer_addr, peer_id_addr, 6);
         }
     }
 
@@ -1638,6 +1641,7 @@ ble_sm_sec_req_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
     struct ble_store_value_sec value_sec;
     struct ble_store_key_sec key_sec;
     struct ble_hs_conn *conn;
+    uint8_t *peer_id_addr;
     int authreq_mitm;
 
     res->app_status = ble_hs_misc_pullup_base(om, BLE_SM_SEC_REQ_SZ);
@@ -1666,9 +1670,12 @@ ble_sm_sec_req_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
          * sender; remember the sender's address while the connection list is
          * locked.
          */
+        ble_hs_conn_addrs(conn,
+                          NULL, NULL, NULL, NULL,
+                          NULL, NULL, &key_sec.peer_addr_type, &peer_id_addr);
         memset(&key_sec, 0, sizeof key_sec);
         key_sec.peer_addr_type = conn->bhc_addr_type;
-        memcpy(key_sec.peer_addr, conn->bhc_addr, 6);
+        memcpy(key_sec.peer_addr, peer_id_addr, 6);
     }
 
     ble_hs_unlock();