23#include "ble_l2cap_coc_priv.h"
24#include "nimble/nimble/host/include/host/ble_l2cap.h"
26#include "nimble/porting/nimble/include/stats/stats.h"
27#include "nimble/porting/nimble/include/os/queue.h"
28#include "nimble/porting/nimble/include/os/os_mbuf.h"
36STATS_SECT_START(ble_l2cap_stats)
37 STATS_SECT_ENTRY(chan_create)
38 STATS_SECT_ENTRY(chan_delete)
39 STATS_SECT_ENTRY(update_init)
40 STATS_SECT_ENTRY(update_rx)
41 STATS_SECT_ENTRY(update_fail)
42 STATS_SECT_ENTRY(proc_timeout)
43 STATS_SECT_ENTRY(sig_tx)
44 STATS_SECT_ENTRY(sig_rx)
45 STATS_SECT_ENTRY(sm_tx)
46 STATS_SECT_ENTRY(sm_rx)
48extern STATS_SECT_DECL(ble_l2cap_stats) ble_l2cap_stats;
55#define BLE_L2CAP_CID_BLACK_HOLE 0xffff
57#define BLE_L2CAP_HDR_SZ 4
59typedef uint8_t ble_l2cap_chan_flags;
61typedef int ble_l2cap_rx_fn(
struct ble_l2cap_chan *chan);
63struct ble_l2cap_chan {
64 SLIST_ENTRY(ble_l2cap_chan) next;
79 uint16_t peer_coc_mps;
82 ble_l2cap_chan_flags flags;
87 ble_l2cap_rx_fn *rx_fn;
89#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) != 0
91 struct ble_l2cap_coc_endpoint coc_rx;
92 struct ble_l2cap_coc_endpoint coc_tx;
93 uint16_t initial_credits;
94 ble_l2cap_event_fn *cb;
104typedef int ble_l2cap_tx_fn(
struct ble_hs_conn *conn,
105 struct ble_l2cap_chan *chan);
107#define BLE_L2CAP_CHAN_F_TXED_MTU 0x01
108#define BLE_L2CAP_CHAN_F_DISCONNECTING 0x02
110SLIST_HEAD(ble_l2cap_chan_list, ble_l2cap_chan);
112int ble_l2cap_parse_hdr(
struct os_mbuf *om,
int off,
113 struct ble_l2cap_hdr *l2cap_hdr);
114struct os_mbuf *ble_l2cap_prepend_hdr(
struct os_mbuf *om, uint16_t cid,
117struct ble_l2cap_chan *ble_l2cap_chan_alloc(uint16_t conn_handle);
118void ble_l2cap_chan_free(
struct ble_hs_conn *conn,
struct ble_l2cap_chan *chan);
120bool ble_l2cap_is_mtu_req_sent(
const struct ble_l2cap_chan *chan);
122int ble_l2cap_rx(
struct ble_hs_conn *conn,
123 struct hci_data_hdr *hci_hdr,
125 ble_l2cap_rx_fn **out_rx_cb,
126 int *out_reject_cid);
127int ble_l2cap_tx(
struct ble_hs_conn *conn,
struct ble_l2cap_chan *chan,
130void ble_l2cap_remove_rx(
struct ble_hs_conn *conn,
struct ble_l2cap_chan *chan);
132int ble_l2cap_init(
void);
135int ble_l2cap_enhanced_connect(uint16_t conn_handle,
136 uint16_t psm, uint16_t mtu,
137 uint8_t num,
struct os_mbuf *sdu_rx[],
138 ble_l2cap_event_fn *cb,
void *cb_arg);
139int ble_l2cap_reconfig(
struct ble_l2cap_chan *chans[], uint8_t num, uint16_t new_mtu);
Definition os_mempool.h:57