You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/07 00:05:29 UTC
[34/50] incubator-mynewt-core git commit: nimble/l2cap: Remove not
needed **om from ble_l2cap_rx_fn
nimble/l2cap: Remove not needed **om from ble_l2cap_rx_fn
Since this callback function has ble_l2cap_chan as a parameter,
we don't need to provide there os_mbuf with data as this is already
in chan->rx_buf
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/bf244379
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/bf244379
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/bf244379
Branch: refs/heads/1_0_0_dev
Commit: bf2443799b36ea1202e200bee9d911fe99e56466
Parents: 505cea6
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Thu Feb 2 15:00:25 2017 +0100
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Mar 6 15:52:16 2017 -0800
----------------------------------------------------------------------
net/nimble/host/src/ble_att.c | 6 +++++-
net/nimble/host/src/ble_hs_hci_evt.c | 7 ++-----
net/nimble/host/src/ble_l2cap.c | 7 +++----
net/nimble/host/src/ble_l2cap_coc.c | 2 +-
net/nimble/host/src/ble_l2cap_priv.h | 3 +--
net/nimble/host/src/ble_l2cap_sig.c | 8 ++++++--
net/nimble/host/src/ble_sm.c | 14 +++++++++-----
net/nimble/host/test/src/ble_hs_test_util.c | 7 ++-----
net/nimble/host/test/src/ble_l2cap_test.c | 2 +-
9 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/src/ble_att.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index 7876e0d..7fe095b 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -461,11 +461,12 @@ ble_att_chan_mtu(const struct ble_l2cap_chan *chan)
}
static int
-ble_att_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
+ble_att_rx(struct ble_l2cap_chan *chan)
{
const struct ble_att_rx_dispatch_entry *entry;
uint8_t op;
uint16_t conn_handle;
+ struct os_mbuf **om;
int rc;
conn_handle = ble_l2cap_get_conn_handle(chan);
@@ -473,6 +474,9 @@ ble_att_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
return BLE_HS_ENOTCONN;
}
+ om = &chan->rx_buf;
+ BLE_HS_DBG_ASSERT(*om != NULL);
+
rc = os_mbuf_copydata(*om, 0, 1, &op);
if (rc != 0) {
return BLE_HS_EMSGSIZE;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/src/ble_hs_hci_evt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_evt.c b/net/nimble/host/src/ble_hs_hci_evt.c
index 7f868a6..cd98f7f 100644
--- a/net/nimble/host/src/ble_hs_hci_evt.c
+++ b/net/nimble/host/src/ble_hs_hci_evt.c
@@ -612,7 +612,6 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om)
struct hci_data_hdr hci_hdr;
struct ble_hs_conn *conn;
ble_l2cap_rx_fn *rx_cb;
- struct os_mbuf *rx_buf;
uint16_t conn_handle;
int reject_cid;
int rc;
@@ -648,7 +647,7 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om)
reject_cid = -1;
} else {
/* Forward ACL data to L2CAP. */
- rc = ble_l2cap_rx(conn, &hci_hdr, om, &rx_cb, &rx_buf, &reject_cid);
+ rc = ble_l2cap_rx(conn, &hci_hdr, om, &rx_cb, &reject_cid);
om = NULL;
}
@@ -658,10 +657,8 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om)
case 0:
/* Final fragment received. */
BLE_HS_DBG_ASSERT(rx_cb != NULL);
- BLE_HS_DBG_ASSERT(rx_buf != NULL);
- rc = rx_cb(conn->bhc_rx_chan, &rx_buf);
+ rc = rx_cb(conn->bhc_rx_chan);
ble_l2cap_forget_rx(conn, conn->bhc_rx_chan);
- os_mbuf_free_chain(rx_buf);
break;
case BLE_HS_EAGAIN:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index d909b78..306eac1 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -173,6 +173,7 @@ void
ble_l2cap_forget_rx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan)
{
conn->bhc_rx_chan = NULL;
+ os_mbuf_free_chain(chan->rx_buf);
chan->rx_buf = NULL;
chan->rx_len = 0;
}
@@ -209,7 +210,7 @@ ble_l2cap_append_rx(struct ble_l2cap_chan *chan, struct os_mbuf *frag)
static int
ble_l2cap_rx_payload(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf *om,
- ble_l2cap_rx_fn **out_rx_cb, struct os_mbuf **out_rx_buf)
+ ble_l2cap_rx_fn **out_rx_cb)
{
int len_diff;
int rc;
@@ -231,7 +232,6 @@ ble_l2cap_rx_payload(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
} else if (len_diff == 0) {
/* All fragments received. */
*out_rx_cb = chan->rx_fn;
- *out_rx_buf = chan->rx_buf;
rc = 0;
} else {
/* More fragments remain. */
@@ -299,7 +299,6 @@ ble_l2cap_rx(struct ble_hs_conn *conn,
struct hci_data_hdr *hci_hdr,
struct os_mbuf *om,
ble_l2cap_rx_fn **out_rx_cb,
- struct os_mbuf **out_rx_buf,
int *out_reject_cid)
{
struct ble_l2cap_chan *chan;
@@ -367,7 +366,7 @@ ble_l2cap_rx(struct ble_hs_conn *conn,
goto err;
}
- rc = ble_l2cap_rx_payload(conn, chan, om, out_rx_cb, out_rx_buf);
+ rc = ble_l2cap_rx_payload(conn, chan, om, out_rx_cb);
om = NULL;
if (rc != 0) {
goto err;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/src/ble_l2cap_coc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_coc.c b/net/nimble/host/src/ble_l2cap_coc.c
index 178370d..ac1b6fa 100644
--- a/net/nimble/host/src/ble_l2cap_coc.c
+++ b/net/nimble/host/src/ble_l2cap_coc.c
@@ -117,7 +117,7 @@ ble_l2cap_coc_srv_find(uint16_t psm)
}
static int
-ble_l2cap_coc_rx_fn(struct ble_l2cap_chan *chan, struct os_mbuf **rxom)
+ble_l2cap_coc_rx_fn(struct ble_l2cap_chan *chan)
{
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/src/ble_l2cap_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_priv.h b/net/nimble/host/src/ble_l2cap_priv.h
index 64ffa22..5db63c3 100644
--- a/net/nimble/host/src/ble_l2cap_priv.h
+++ b/net/nimble/host/src/ble_l2cap_priv.h
@@ -62,7 +62,7 @@ extern struct os_mempool ble_l2cap_chan_pool;
typedef uint8_t ble_l2cap_chan_flags;
-typedef int ble_l2cap_rx_fn(struct ble_l2cap_chan *chan, struct os_mbuf **rxom);
+typedef int ble_l2cap_rx_fn(struct ble_l2cap_chan *chan);
struct ble_l2cap_chan {
SLIST_ENTRY(ble_l2cap_chan) next;
@@ -113,7 +113,6 @@ int ble_l2cap_rx(struct ble_hs_conn *conn,
struct hci_data_hdr *hci_hdr,
struct os_mbuf *om,
ble_l2cap_rx_fn **out_rx_cb,
- struct os_mbuf **out_rx_buf,
int *out_reject_cid);
int ble_l2cap_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf *txom);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index 93d73ed..abc00ae 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -1012,13 +1012,17 @@ ble_l2cap_sig_disconnect(struct ble_l2cap_chan *chan)
*****************************************************************************/
static int
-ble_l2cap_sig_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
+ble_l2cap_sig_rx(struct ble_l2cap_chan *chan)
{
struct ble_l2cap_sig_hdr hdr;
ble_l2cap_sig_rx_fn *rx_cb;
- uint16_t conn_handle = chan->conn_handle;
+ uint16_t conn_handle;
+ struct os_mbuf **om;
int rc;
+ conn_handle = chan->conn_handle;
+ om = &chan->rx_buf;
+
STATS_INC(ble_l2cap_stats, sig_rx);
BLE_HS_LOG(DEBUG, "L2CAP - rxed signalling msg: ");
ble_hs_log_mbuf(*om);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/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 603d99c..ef2f41b 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -2326,12 +2326,13 @@ ble_sm_unbond(uint8_t peer_id_addr_type, const uint8_t *peer_id_addr)
}
static int
-ble_sm_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
+ble_sm_rx(struct ble_l2cap_chan *chan)
{
struct ble_sm_result res;
ble_sm_rx_fn *rx_cb;
uint8_t op;
uint16_t conn_handle;
+ struct os_mbuf *om;
int rc;
STATS_INC(ble_l2cap_stats, sm_rx);
@@ -2341,19 +2342,22 @@ ble_sm_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
return BLE_HS_ENOTCONN;
}
- rc = os_mbuf_copydata(*om, 0, 1, &op);
+ om = chan->rx_buf;
+ BLE_HS_DBG_ASSERT(om != NULL);
+
+ rc = os_mbuf_copydata(om, 0, 1, &op);
if (rc != 0) {
return BLE_HS_EBADDATA;
}
/* Strip L2CAP SM header from the front of the mbuf. */
- os_mbuf_adj(*om, 1);
+ os_mbuf_adj(om, 1);
rx_cb = ble_sm_dispatch_get(op);
if (rx_cb != NULL) {
memset(&res, 0, sizeof res);
- rx_cb(conn_handle, om, &res);
+ rx_cb(conn_handle, &om, &res);
ble_sm_process_result(conn_handle, &res);
rc = res.app_status;
} else {
@@ -2491,7 +2495,7 @@ ble_sm_init(void)
* simple
*/
static int
-ble_sm_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
+ble_sm_rx(struct ble_l2cap_chan *chan)
{
struct ble_sm_pair_fail *cmd;
struct os_mbuf *txom;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/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 9fa2d3d..d084c39 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -934,7 +934,6 @@ ble_hs_test_util_l2cap_rx(uint16_t conn_handle,
{
struct ble_hs_conn *conn;
ble_l2cap_rx_fn *rx_cb;
- struct os_mbuf *rx_buf;
int reject_cid;
int rc;
@@ -942,7 +941,7 @@ ble_hs_test_util_l2cap_rx(uint16_t conn_handle,
conn = ble_hs_conn_find(conn_handle);
if (conn != NULL) {
- rc = ble_l2cap_rx(conn, hci_hdr, om, &rx_cb, &rx_buf, &reject_cid);
+ rc = ble_l2cap_rx(conn, hci_hdr, om, &rx_cb, &reject_cid);
} else {
os_mbuf_free_chain(om);
}
@@ -953,10 +952,8 @@ ble_hs_test_util_l2cap_rx(uint16_t conn_handle,
rc = BLE_HS_ENOTCONN;
} else if (rc == 0) {
TEST_ASSERT_FATAL(rx_cb != NULL);
- TEST_ASSERT_FATAL(rx_buf != NULL);
- rc = rx_cb(conn->bhc_rx_chan, &rx_buf);
+ rc = rx_cb(conn->bhc_rx_chan);
ble_l2cap_forget_rx(conn, conn->bhc_rx_chan);
- os_mbuf_free_chain(rx_buf);
} else if (rc == BLE_HS_EAGAIN) {
/* More fragments on the way. */
rc = 0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bf244379/net/nimble/host/test/src/ble_l2cap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_l2cap_test.c b/net/nimble/host/test/src/ble_l2cap_test.c
index e68971d..3fc7876 100644
--- a/net/nimble/host/test/src/ble_l2cap_test.c
+++ b/net/nimble/host/test/src/ble_l2cap_test.c
@@ -94,7 +94,7 @@ ble_l2cap_test_util_verify_tx_update_conn(
}
static int
-ble_l2cap_test_util_dummy_rx(struct ble_l2cap_chan *chan, struct os_mbuf **om)
+ble_l2cap_test_util_dummy_rx(struct ble_l2cap_chan *chan)
{
return 0;
}