diff --git a/nimble/host/include/host/ble_l2cap.h b/nimble/host/include/host/ble_l2cap.h index ac179be61..c20734eed 100644 --- a/nimble/host/include/host/ble_l2cap.h +++ b/nimble/host/include/host/ble_l2cap.h @@ -187,7 +187,7 @@ int ble_l2cap_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu, ble_l2cap_event_fn *cb, void *cb_arg); int ble_l2cap_disconnect(struct ble_l2cap_chan *chan); int ble_l2cap_send(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_tx); -void ble_l2cap_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx); +int ble_l2cap_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx); int ble_l2cap_get_scid(struct ble_l2cap_chan *chan); int ble_l2cap_get_dcid(struct ble_l2cap_chan *chan); int ble_l2cap_get_our_mtu(struct ble_l2cap_chan *chan); diff --git a/nimble/host/src/ble_l2cap.c b/nimble/host/src/ble_l2cap.c index 181d284bd..a9252b8e0 100644 --- a/nimble/host/src/ble_l2cap.c +++ b/nimble/host/src/ble_l2cap.c @@ -170,10 +170,10 @@ ble_l2cap_send(struct ble_l2cap_chan *chan, struct os_mbuf *sdu) return ble_l2cap_coc_send(chan, sdu); } -void +int ble_l2cap_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx) { - ble_l2cap_coc_recv_ready(chan, sdu_rx); + return ble_l2cap_coc_recv_ready(chan, sdu_rx); } void diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c index bd944d2f6..3f6c16c7a 100644 --- a/nimble/host/src/ble_l2cap_coc.c +++ b/nimble/host/src/ble_l2cap_coc.c @@ -446,12 +446,16 @@ ble_l2cap_coc_le_credits_update(uint16_t conn_handle, uint16_t dcid, ble_l2cap_coc_continue_tx(chan); } -void +int ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx) { struct ble_hs_conn *conn; struct ble_l2cap_chan *c; + if (!sdu_rx) { + return BLE_HS_EINVAL; + } + chan->coc_rx.sdu = sdu_rx; ble_hs_lock(); @@ -459,7 +463,7 @@ ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx) c = ble_hs_conn_chan_find_by_scid(conn, chan->scid); if (!c) { ble_hs_unlock(); - return; + return BLE_HS_ENOENT; } /* We want to back only that much credits which remote side is missing @@ -474,6 +478,8 @@ ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx) } ble_hs_unlock(); + + return 0; } /** diff --git a/nimble/host/src/ble_l2cap_coc_priv.h b/nimble/host/src/ble_l2cap_coc_priv.h index 4fe75e956..90d4d0200 100644 --- a/nimble/host/src/ble_l2cap_coc_priv.h +++ b/nimble/host/src/ble_l2cap_coc_priv.h @@ -65,13 +65,13 @@ struct ble_l2cap_chan * ble_l2cap_coc_chan_alloc(uint16_t conn_handle, void ble_l2cap_coc_cleanup_chan(struct ble_l2cap_chan *chan); void ble_l2cap_coc_le_credits_update(uint16_t conn_handle, uint16_t dcid, uint16_t credits); -void ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, - struct os_mbuf *sdu_rx); +int ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, + struct os_mbuf *sdu_rx); int ble_l2cap_coc_send(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_tx); #else #define ble_l2cap_coc_init() 0 #define ble_l2cap_coc_create_server(psm, mtu, cb, cb_arg) BLE_HS_ENOTSUP -#define ble_l2cap_coc_recv_ready(chan, sdu_rx) +#define ble_l2cap_coc_recv_ready(chan, sdu_rx) BLE_HS_ENOTSUP #define ble_l2cap_coc_cleanup_chan(chan) #define ble_l2cap_coc_send(chan, sdu_tx) BLE_HS_ENOTSUP #endif