11#ifndef ZEPHYR_INCLUDE_BLUETOOTH_L2CAP_H_
12#define ZEPHYR_INCLUDE_BLUETOOTH_L2CAP_H_
34#define BT_L2CAP_HDR_SIZE 4
37#define BT_L2CAP_TX_MTU (CONFIG_BT_L2CAP_TX_MTU)
40#define BT_L2CAP_RX_MTU (CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE)
49#define BT_L2CAP_BUF_SIZE(mtu) BT_BUF_ACL_SIZE(BT_L2CAP_HDR_SIZE + (mtu))
52#define BT_L2CAP_SDU_HDR_SIZE 2
62#define BT_L2CAP_SDU_TX_MTU (BT_L2CAP_TX_MTU - BT_L2CAP_SDU_HDR_SIZE)
74#define BT_L2CAP_SDU_RX_MTU (BT_L2CAP_RX_MTU - BT_L2CAP_SDU_HDR_SIZE)
85#define BT_L2CAP_SDU_BUF_SIZE(mtu) BT_L2CAP_BUF_SIZE(BT_L2CAP_SDU_HDR_SIZE + (mtu))
96#define BT_L2CAP_ECRED_MIN_MTU 64
107#define BT_L2CAP_ECRED_MIN_MPS 64
121#define BT_L2CAP_ECRED_CHAN_MAX_PER_REQ 5
232#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
236#if defined(CONFIG_BT_L2CAP_SEG_RECV)
260 size_t _pdu_remaining;
272#define BT_L2CAP_LE_CHAN(_ch) CONTAINER_OF(_ch, struct bt_l2cap_le_chan, chan)
309 struct k_fifo _pdu_tx_queue;
442#if defined(CONFIG_BT_L2CAP_SEG_RECV)
482#define BT_L2CAP_CHAN_SEND_RESERVE (BT_L2CAP_BUF_SIZE(0))
487#define BT_L2CAP_SDU_CHAN_SEND_RESERVE (BT_L2CAP_SDU_BUF_SIZE(0))
long atomic_t
Definition atomic_types.h:15
Bluetooth data buffer API.
Bluetooth connection handling.
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:111
bt_security_t
Security level.
Definition conn.h:809
int bt_l2cap_ecred_chan_reconfigure(struct bt_l2cap_chan **chans, uint16_t mtu)
Reconfigure Enhanced Credit Based L2CAP channels.
int bt_l2cap_server_register(struct bt_l2cap_server *server)
Register L2CAP server.
bt_l2cap_chan_status
Status of L2CAP channel.
Definition l2cap.h:159
enum bt_l2cap_chan_status bt_l2cap_chan_status_t
Status of L2CAP channel.
int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, uint16_t psm)
Connect L2CAP channel.
enum bt_l2cap_chan_state bt_l2cap_chan_state_t
Life-span states of L2CAP CoC channel.
int bt_l2cap_br_server_register(struct bt_l2cap_server *server)
Register L2CAP server on BR/EDR oriented connection.
bt_l2cap_chan_state
Life-span states of L2CAP CoC channel.
Definition l2cap.h:144
int bt_l2cap_ecred_chan_reconfigure_explicit(struct bt_l2cap_chan **chans, size_t chan_count, uint16_t mtu, uint16_t mps)
Reconfigure Enhanced Credit Based L2CAP channels.
int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan)
Disconnect L2CAP channel.
void(* bt_l2cap_chan_destroy_t)(struct bt_l2cap_chan *chan)
Channel destroy callback.
Definition l2cap.h:130
int bt_l2cap_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf)
Send data to L2CAP channel.
int bt_l2cap_chan_give_credits(struct bt_l2cap_chan *chan, uint16_t additional_credits)
Give credits to the remote.
int bt_l2cap_chan_recv_complete(struct bt_l2cap_chan *chan, struct net_buf *buf)
Complete receiving L2CAP channel data.
int bt_l2cap_ecred_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan **chans, uint16_t psm)
Connect Enhanced Credit Based L2CAP channels.
@ BT_L2CAP_STATUS_SHUTDOWN
Channel shutdown status.
Definition l2cap.h:168
@ BT_L2CAP_STATUS_OUT
Channel can send at least one PDU.
Definition l2cap.h:161
@ BT_L2CAP_NUM_STATUS
Definition l2cap.h:174
@ BT_L2CAP_STATUS_ENCRYPT_PENDING
Channel encryption pending status.
Definition l2cap.h:171
@ BT_L2CAP_DISCONNECTED
Channel disconnected.
Definition l2cap.h:146
@ BT_L2CAP_CONFIG
Channel in config state, BR/EDR specific.
Definition l2cap.h:150
@ BT_L2CAP_CONNECTED
Channel ready for upper layer traffic on it.
Definition l2cap.h:152
@ BT_L2CAP_DISCONNECTING
Channel in disconnecting state.
Definition l2cap.h:154
@ BT_L2CAP_CONNECTING
Channel in connecting state.
Definition l2cap.h:148
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
__INTPTR_TYPE__ off_t
Definition types.h:36
flags
Definition parser.h:96
state
Definition parser_state.h:29
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
BREDR L2CAP Channel structure.
Definition l2cap.h:283
struct bt_l2cap_br_endpoint rx
Channel Receiving Endpoint.
Definition l2cap.h:287
struct k_work_delayable rtx_work
Definition l2cap.h:301
bt_security_t required_sec_level
Definition l2cap.h:298
uint16_t psm
Remote PSM to be connected.
Definition l2cap.h:295
struct k_work_sync rtx_sync
Definition l2cap.h:302
struct bt_l2cap_chan chan
Common L2CAP channel reference object.
Definition l2cap.h:285
bt_l2cap_chan_state_t state
Definition l2cap.h:293
struct bt_l2cap_br_endpoint tx
Channel Transmission Endpoint.
Definition l2cap.h:289
uint8_t ident
Helps match request context during CoC.
Definition l2cap.h:297
BREDR L2CAP Endpoint structure.
Definition l2cap.h:275
uint16_t mtu
Endpoint Maximum Transmission Unit.
Definition l2cap.h:279
uint16_t cid
Endpoint Channel Identifier (CID)
Definition l2cap.h:277
L2CAP Channel operations structure.
Definition l2cap.h:316
int(* recv)(struct bt_l2cap_chan *chan, struct net_buf *buf)
Channel recv callback.
Definition l2cap.h:402
void(* encrypt_change)(struct bt_l2cap_chan *chan, uint8_t hci_status)
Channel encrypt_change callback.
Definition l2cap.h:351
void(* disconnected)(struct bt_l2cap_chan *chan)
Channel disconnected callback.
Definition l2cap.h:334
void(* connected)(struct bt_l2cap_chan *chan)
Channel connected callback.
Definition l2cap.h:324
void(* status)(struct bt_l2cap_chan *chan, atomic_t *status)
Channel status callback.
Definition l2cap.h:423
void(* released)(struct bt_l2cap_chan *chan)
Definition l2cap.h:430
void(* sent)(struct bt_l2cap_chan *chan)
Channel sent callback.
Definition l2cap.h:413
void(* seg_recv)(struct bt_l2cap_chan *chan, size_t sdu_len, off_t seg_offset, struct net_buf_simple *seg)
Handle L2CAP segments directly.
Definition l2cap.h:474
void(* reconfigured)(struct bt_l2cap_chan *chan)
Channel reconfigured callback.
Definition l2cap.h:440
L2CAP Channel structure.
Definition l2cap.h:178
struct bt_conn * conn
Channel connection reference.
Definition l2cap.h:180
sys_snode_t node
Definition l2cap.h:183
const struct bt_l2cap_chan_ops * ops
Channel operations reference.
Definition l2cap.h:182
atomic_t status[ATOMIC_BITMAP_SIZE(BT_L2CAP_NUM_STATUS)]
Definition l2cap.h:186
bt_l2cap_chan_destroy_t destroy
Definition l2cap.h:184
LE L2CAP Channel structure.
Definition l2cap.h:202
struct bt_l2cap_le_endpoint tx
Channel Transmission Endpoint.
Definition l2cap.h:229
uint16_t pending_rx_mtu
Pending RX MTU on ECFC reconfigure, used internally by stack.
Definition l2cap.h:220
struct k_fifo tx_queue
Channel Transmission queue (for SDUs)
Definition l2cap.h:231
struct bt_l2cap_le_endpoint rx
Channel Receiving Endpoint.
Definition l2cap.h:217
struct bt_l2cap_chan chan
Common L2CAP channel reference object.
Definition l2cap.h:204
LE L2CAP Endpoint structure.
Definition l2cap.h:190
uint16_t mtu
Endpoint Maximum Transmission Unit.
Definition l2cap.h:194
uint16_t mps
Endpoint Maximum PDU payload Size.
Definition l2cap.h:196
atomic_t credits
Endpoint credits.
Definition l2cap.h:198
uint16_t cid
Endpoint Channel Identifier (CID)
Definition l2cap.h:192
L2CAP Server structure.
Definition l2cap.h:490
uint16_t psm
Server PSM.
Definition l2cap.h:504
sys_snode_t node
Definition l2cap.h:529
bt_security_t sec_level
Required minimum security level.
Definition l2cap.h:507
int(* accept)(struct bt_conn *conn, struct bt_l2cap_server *server, struct bt_l2cap_chan **chan)
Server accept callback.
Definition l2cap.h:526
A structure used to submit work after a delay.
Definition kernel.h:4013
A structure holding internal state for a pending synchronous operation on a work item or queue.
Definition kernel.h:4096
A structure used to submit work.
Definition kernel.h:3985
Simple network buffer representation.
Definition net_buf.h:89
Network buffer representation.
Definition net_buf.h:1006