You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2017/04/10 11:47:26 UTC

[34/50] incubator-mynewt-core git commit: nimble/att: Use packed struct for receiving MTU exchange

nimble/att: Use packed struct for receiving MTU exchange

Use packed structure to map it to received mbuf instead of using
dedicated parsing function. Modern compilers generate effective code
in such case anyway.


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

Branch: refs/heads/master
Commit: a31e34bb4dd830603115bc31d27551a9e578786b
Parents: 8e60273
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Mar 24 15:46:20 2017 +0100
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Mon Apr 10 11:31:32 2017 +0200

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_clt.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a31e34bb/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 c63ec52..1d45ef0 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -118,23 +118,29 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu)
 int
 ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
 {
-    struct ble_att_mtu_cmd cmd;
+    struct ble_att_mtu_cmd *cmd;
     struct ble_l2cap_chan *chan;
     uint16_t mtu;
     int rc;
 
+    /* TODO move this to common part
+     * Strip L2CAP ATT header from the front of the mbuf.
+     */
+    os_mbuf_adj(*rxom, 1);
+
     mtu = 0;
 
-    rc = ble_hs_mbuf_pullup_base(rxom, BLE_ATT_MTU_CMD_SZ);
+    rc = ble_hs_mbuf_pullup_base(rxom, sizeof(*cmd));
     if (rc == 0) {
-        ble_att_mtu_rsp_parse((*rxom)->om_data, (*rxom)->om_len, &cmd);
-        BLE_ATT_LOG_CMD(0, "mtu rsp", conn_handle, ble_att_mtu_cmd_log, &cmd);
+        cmd = (struct ble_att_mtu_cmd *)(*rxom)->om_data;
+
+        BLE_ATT_LOG_CMD(0, "mtu rsp", conn_handle, ble_att_mtu_cmd_log, cmd);
 
         ble_hs_lock();
 
         rc = ble_att_conn_chan_find(conn_handle, NULL, &chan);
         if (rc == 0) {
-            ble_att_set_peer_mtu(chan, cmd.bamc_mtu);
+            ble_att_set_peer_mtu(chan, le16toh(cmd->bamc_mtu));
             mtu = ble_att_chan_mtu(chan);
         }