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/11/17 20:33:55 UTC

[1/4] incubator-mynewt-core git commit: BLE Host - Don't allow ATT tx to unconnected peer

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 88fcc21b3 -> 8813bdf00


BLE Host - Don't allow ATT tx to unconnected peer

The ATT client transmit function (ble_att_clt_tx_req) assumed the
specified connection handle was valid, and proceded to dereference some
null pointers.

Now, the function returns BLE_HS_ENOTCONN immediately if the specified
connection handle is not valid.


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

Branch: refs/heads/develop
Commit: 0d77b691a3367ddf37d3ea0a7c0e08e0ace4fa3c
Parents: 88fcc21
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 17 11:22:23 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 17 11:22:23 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_clt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d77b691/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index a4a6988..e03f6fe 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -71,8 +71,12 @@ ble_att_clt_tx_req(uint16_t conn_handle, struct os_mbuf *txom)
     ble_hs_lock();
 
     ble_att_conn_chan_find(conn_handle, &conn, &chan);
-    ble_att_truncate_to_mtu(chan, txom);
-    rc = ble_l2cap_tx(conn, chan, txom);
+    if (chan == NULL) {
+        rc = BLE_HS_ENOTCONN;
+    } else {
+        ble_att_truncate_to_mtu(chan, txom);
+        rc = ble_l2cap_tx(conn, chan, txom);
+    }
 
     ble_hs_unlock();
 


[2/4] incubator-mynewt-core git commit: BLE Host - whitespace fix.

Posted by cc...@apache.org.
BLE Host - whitespace fix.


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

Branch: refs/heads/develop
Commit: f31fbdd4f918c541548a8af2035f98a4e315dead
Parents: 0d77b69
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 17 12:15:10 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 17 12:15:10 2016 -0800

----------------------------------------------------------------------
 net/nimble/transport/ram/src/ble_hci_ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f31fbdd4/net/nimble/transport/ram/src/ble_hci_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/ram/src/ble_hci_ram.c b/net/nimble/transport/ram/src/ble_hci_ram.c
index 457c5cc..6c34a52 100644
--- a/net/nimble/transport/ram/src/ble_hci_ram.c
+++ b/net/nimble/transport/ram/src/ble_hci_ram.c
@@ -97,7 +97,7 @@ ble_hci_trans_ll_evt_tx(uint8_t *hci_ev)
 int
 ble_hci_trans_hs_acl_tx(struct os_mbuf *om)
 {
-   int rc;
+    int rc;
 
     assert(ble_hci_ram_rx_acl_ll_cb != NULL);
 


[3/4] incubator-mynewt-core git commit: BLE Host - Don't send overly-large ACL data pkts.

Posted by cc...@apache.org.
BLE Host - Don't send overly-large ACL data pkts.

The host was misinterpreting the buffer size that the controller
indicates in its response to the LE Read Buffer Size HCI command.
Specifically, the host interpreted the value as the number of bytes it
can put in an ACL payload.  This is wrong; the value is the total size
of an ACL data packet, including the ACL data header.

The fix is to reduce the maximum number of data bytes the host includes
in an ACL data packet by four (size of an ACL data header).


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

Branch: refs/heads/develop
Commit: b4c9f850d8562f9f1201728476546540243ba7c1
Parents: f31fbdd
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 17 12:25:16 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 17 12:25:16 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs_hci.c            | 18 +++++++++++++++---
 net/nimble/host/test/src/ble_hs_test_util.c |  4 ++--
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b4c9f850/net/nimble/host/src/ble_hs_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci.c b/net/nimble/host/src/ble_hs_hci.c
index ebb75d9..ba86e2f 100644
--- a/net/nimble/host/src/ble_hs_hci.c
+++ b/net/nimble/host/src/ble_hs_hci.c
@@ -352,6 +352,15 @@ ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg)
     return 0;
 }
 
+/**
+ * Calculates the largest ACL payload that the controller can accept.  This is
+ * everything in an ACL data packet except for the ACL header.
+ */
+static uint16_t
+ble_hs_hci_max_acl_payload_sz(void)
+{
+    return ble_hs_hci_buf_sz - BLE_HCI_DATA_HDR_SZ;
+}
 
 /**
  * Splits an appropriately-sized fragment from the front of an outgoing ACL
@@ -374,12 +383,15 @@ static int
 ble_hs_hci_split_frag(struct os_mbuf **om, struct os_mbuf **out_frag)
 {
     struct os_mbuf *frag;
+    uint16_t max_sz;
     int rc;
 
     /* Assume failure. */
     *out_frag = NULL;
 
-    if (OS_MBUF_PKTLEN(*om) <= ble_hs_hci_buf_sz) {
+    max_sz = ble_hs_hci_max_acl_payload_sz();
+
+    if (OS_MBUF_PKTLEN(*om) <= max_sz) {
         /* Final fragment. */
         *out_frag = *om;
         *om = NULL;
@@ -393,12 +405,12 @@ ble_hs_hci_split_frag(struct os_mbuf **om, struct os_mbuf **out_frag)
     }
 
     /* Move data from the front of the packet into the fragment mbuf. */
-    rc = os_mbuf_appendfrom(frag, *om, 0, ble_hs_hci_buf_sz);
+    rc = os_mbuf_appendfrom(frag, *om, 0, max_sz);
     if (rc != 0) {
         rc = BLE_HS_ENOMEM;
         goto err;
     }
-    os_mbuf_adj(*om, ble_hs_hci_buf_sz);
+    os_mbuf_adj(*om, max_sz);
 
     /* More fragments to follow. */
     *out_frag = frag;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b4c9f850/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 0e9ef43..083afc4 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -982,8 +982,8 @@ ble_hs_test_util_set_startup_acks(void)
         {
             .opcode = ble_hs_hci_util_opcode_join(
                 BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_BUF_SIZE),
-            /* Use a very low buffer size (16) to test fragmentation. */
-            .evt_params = { 0x10, 0x00, 0x20 },
+            /* Use a very low buffer size (20) to test fragmentation. */
+            .evt_params = { 0x14, 0x00, 0x20 },
             .evt_params_len = 3,
         },
         {


[4/4] incubator-mynewt-core git commit: BLE Host - Increase max ATT MTU to 527 (was: 240).

Posted by cc...@apache.org.
BLE Host - Increase max ATT MTU to 527 (was: 240).

Now that there are no restrictions or known bugs involving transmission
of chained mbufs, we can lift the artificial ceiling on ATT MTU.

The new number, 527, was derived as follows:
    * Largest ATT command, signed write: 15 + attribute length.
    * Max attribute size: 512
    * 15 + 512 = 527


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

Branch: refs/heads/develop
Commit: 8813bdf0040cb9a6583e1d4f7003293545631e77
Parents: b4c9f85
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 17 12:31:41 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 17 12:31:41 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_att.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8813bdf0/net/nimble/host/include/host/ble_att.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_att.h b/net/nimble/host/include/host/ble_att.h
index 452a744..e852b0b 100644
--- a/net/nimble/host/include/host/ble_att.h
+++ b/net/nimble/host/include/host/ble_att.h
@@ -94,9 +94,14 @@ struct os_mbuf;
 #define BLE_ATT_ACCESS_OP_READ              1
 #define BLE_ATT_ACCESS_OP_WRITE             2
 
-#define BLE_ATT_MTU_DFLT                23  /* Also the minimum. */
-#define BLE_ATT_MTU_MAX                 240
-#define BLE_ATT_MTU_PREFERRED_DFLT      240
+#define BLE_ATT_MTU_DFLT                    23  /* Also the minimum. */
+
+/**
+ * An ATT MTU of 527 allows the largest ATT command (signed write) to contain a
+ * 512-byte attribute value.
+ */
+#define BLE_ATT_MTU_MAX                     527
+#define BLE_ATT_MTU_PREFERRED_DFLT          527
 
 int ble_att_svr_read_local(uint16_t attr_handle, struct os_mbuf **out_om);
 int ble_att_svr_write_local(uint16_t attr_handle, struct os_mbuf *om);