nimble/l2cap: Use endian.h API for protocol data Don't use TOFROMLE16 API for protocol data. This API hide direction of convertion making code hard to follow.
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/7e1ac05a Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7e1ac05a Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7e1ac05a Branch: refs/heads/master Commit: 7e1ac05a06168984fa0bf772fdb72caedd086327 Parents: fd6c58a Author: Szymon Janc <szymon.j...@codecoup.pl> Authored: Fri Mar 24 15:50:09 2017 +0100 Committer: Szymon Janc <szymon.j...@codecoup.pl> Committed: Mon Apr 10 11:31:33 2017 +0200 ---------------------------------------------------------------------- net/nimble/host/src/ble_l2cap_sig_cmd.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7e1ac05a/net/nimble/host/src/ble_l2cap_sig_cmd.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_l2cap_sig_cmd.c b/net/nimble/host/src/ble_l2cap_sig_cmd.c index ae8b102..1fe5683 100644 --- a/net/nimble/host/src/ble_l2cap_sig_cmd.c +++ b/net/nimble/host/src/ble_l2cap_sig_cmd.c @@ -36,21 +36,17 @@ ble_l2cap_sig_tx(uint16_t conn_handle, struct os_mbuf *txom) return rc; } -static void -ble_l2cap_sig_hdr_swap(struct ble_l2cap_sig_hdr *dst, - struct ble_l2cap_sig_hdr *src) -{ - dst->op = src->op; - dst->identifier = src->identifier; - dst->length = TOFROMLE16(src->length); -} - void ble_l2cap_sig_hdr_parse(void *payload, uint16_t len, struct ble_l2cap_sig_hdr *dst) { + struct ble_l2cap_sig_hdr *src = payload; + BLE_HS_DBG_ASSERT(len >= BLE_L2CAP_SIG_HDR_SZ); - ble_l2cap_sig_hdr_swap(dst, payload); + + dst->op = src->op; + dst->identifier = src->identifier; + dst->length = le16toh(src->length); } int