Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A7CA200C3E for ; Mon, 6 Mar 2017 22:18:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 79139160B89; Mon, 6 Mar 2017 21:18:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C4062160B76 for ; Mon, 6 Mar 2017 22:18:54 +0100 (CET) Received: (qmail 68450 invoked by uid 500); 6 Mar 2017 21:18:54 -0000 Mailing-List: contact commits-help@mynewt.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mynewt.incubator.apache.org Delivered-To: mailing list commits@mynewt.incubator.apache.org Received: (qmail 68389 invoked by uid 99); 6 Mar 2017 21:18:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Mar 2017 21:18:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 9006A1A03B4 for ; Mon, 6 Mar 2017 21:18:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.567 X-Spam-Level: X-Spam-Status: No, score=-6.567 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id DUWaAFB5Wc36 for ; Mon, 6 Mar 2017 21:18:52 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 05A1D5F36B for ; Mon, 6 Mar 2017 21:18:51 +0000 (UTC) Received: (qmail 66327 invoked by uid 99); 6 Mar 2017 21:18:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Mar 2017 21:18:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A0427E2F1F; Mon, 6 Mar 2017 21:18:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: marko@apache.org To: commits@mynewt.incubator.apache.org Date: Mon, 06 Mar 2017 21:18:56 -0000 Message-Id: <6eb6244d159f4330b8a5432270c2391a@git.apache.org> In-Reply-To: <3b7b6130756842dc817ed544a2a3cf6b@git.apache.org> References: <3b7b6130756842dc817ed544a2a3cf6b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [20/50] incubator-mynewt-core git commit: nimble/l2cap: Refactor handling L2CAP reject command archived-at: Mon, 06 Mar 2017 21:18:55 -0000 nimble/l2cap: Refactor handling L2CAP reject command With this patch L2CAP reject command uses a new way of preparing command and sending it 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/ba9de55a Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ba9de55a Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ba9de55a Branch: refs/heads/master Commit: ba9de55afb41bf1c1b837ae93041953aa2f59493 Parents: a443035 Author: Łukasz Rymanowski Authored: Tue Feb 28 12:14:46 2017 +0100 Committer: Łukasz Rymanowski Committed: Fri Mar 3 12:40:42 2017 +0100 ---------------------------------------------------------------------- net/nimble/host/src/ble_l2cap_sig_cmd.c | 40 +++++---------------------- net/nimble/host/src/ble_l2cap_sig_priv.h | 1 + 2 files changed, 8 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ba9de55a/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 189efd7..e6a7209 100644 --- a/net/nimble/host/src/ble_l2cap_sig_cmd.c +++ b/net/nimble/host/src/ble_l2cap_sig_cmd.c @@ -94,48 +94,22 @@ ble_l2cap_sig_hdr_write(void *payload, uint16_t len, BLE_HS_DBG_ASSERT(len >= BLE_L2CAP_SIG_HDR_SZ); ble_l2cap_sig_hdr_swap(payload, src); } -static void -ble_l2cap_sig_reject_swap(struct ble_l2cap_sig_reject *dst, - struct ble_l2cap_sig_reject *src) -{ - dst->reason = TOFROMLE16(src->reason); -} - -static void -ble_l2cap_sig_reject_write(void *payload, uint16_t len, - struct ble_l2cap_sig_reject *src, - void *data, int data_len) -{ - uint8_t *u8ptr; - - BLE_HS_DBG_ASSERT(len >= BLE_L2CAP_SIG_REJECT_MIN_SZ + data_len); - - ble_l2cap_sig_reject_swap(payload, src); - - u8ptr = payload; - u8ptr += BLE_L2CAP_SIG_REJECT_MIN_SZ; - memcpy(u8ptr, data, data_len); -} int ble_l2cap_sig_reject_tx(uint16_t conn_handle, uint8_t id, uint16_t reason, void *data, int data_len) { - struct ble_l2cap_sig_reject cmd; + struct ble_l2cap_sig_reject *cmd; struct os_mbuf *txom; - void *payload_buf; - int rc; - rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_REJECT, id, - BLE_L2CAP_SIG_REJECT_MIN_SZ + data_len, &txom, - &payload_buf); - if (rc != 0) { - return rc; + cmd = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_REJECT, id, + sizeof(*cmd) + data_len, &txom); + if (!cmd) { + return BLE_HS_ENOMEM; } - cmd.reason = reason; - ble_l2cap_sig_reject_write(payload_buf, txom->om_len, &cmd, - data, data_len); + cmd->reason = htole16(reason); + memcpy(cmd->data, data, data_len); STATS_INC(ble_l2cap_stats, sig_rx); return ble_l2cap_sig_tx(conn_handle, txom); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ba9de55a/net/nimble/host/src/ble_l2cap_sig_priv.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_l2cap_sig_priv.h b/net/nimble/host/src/ble_l2cap_sig_priv.h index f089dcb..ad3b846 100644 --- a/net/nimble/host/src/ble_l2cap_sig_priv.h +++ b/net/nimble/host/src/ble_l2cap_sig_priv.h @@ -39,6 +39,7 @@ struct ble_l2cap_sig_hdr { #define BLE_L2CAP_SIG_REJECT_MIN_SZ 2 struct ble_l2cap_sig_reject { uint16_t reason; + uint8_t data[0]; } __attribute__((packed)); #define BLE_L2CAP_SIG_UPDATE_REQ_SZ 8