struct bt_att { /* The channel this context is associated with */ struct bt_l2cap_chan chan; struct bt_att_req req; /* TODO: Allow more than one pending request */ }; static struct bt_att bt_att_pool[CONFIG_BLUETOOTH_MAX_CONN]; /* * Pool for outgoing ATT packets. Reserve one buffer per connection plus * one additional one in case cloning is needed. */ static struct nano_fifo att_buf; static NET_BUF_POOL(att_pool, CONFIG_BLUETOOTH_MAX_CONN + 1, BT_L2CAP_BUF_SIZE(CONFIG_BLUETOOTH_ATT_MTU), &att_buf, NULL, 0); static void att_req_destroy(struct bt_att_req *req) { if (req->buf) { net_buf_unref(req->buf); } if (req->destroy) { req->destroy(req->user_data); } memset(req, 0, sizeof(*req)); }
#include "hci_core.h" #include "conn_internal.h" #include "l2cap_internal.h" #include "keys.h" #include "smp.h" #include "att_internal.h" #if !defined(CONFIG_BLUETOOTH_DEBUG_CONN) #undef BT_DBG #define BT_DBG(fmt, ...) #endif /* Pool for outgoing ACL fragments */ static struct nano_fifo frag_buf; static NET_BUF_POOL(frag_pool, 1, BT_L2CAP_BUF_SIZE(23), &frag_buf, NULL, BT_BUF_USER_DATA_MIN); /* Pool for dummy buffers to wake up the tx fibers */ static struct nano_fifo dummy; static NET_BUF_POOL(dummy_pool, CONFIG_BLUETOOTH_MAX_CONN, 0, &dummy, NULL, 0); /* How long until we cancel HCI_LE_Create_Connection */ #define CONN_TIMEOUT (3 * sys_clock_ticks_per_sec) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) const struct bt_conn_auth_cb *bt_auth; #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ static struct bt_conn conns[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_conn_cb *callback_list;
#define BT_L2CAP_MAX_LE_MPS CONFIG_BLUETOOTH_L2CAP_IN_MTU /* For now use MPS - SDU length to disable segmentation */ #define BT_L2CAP_MAX_LE_MTU (BT_L2CAP_MAX_LE_MPS - 2) #define l2cap_lookup_ident(conn, ident) __l2cap_lookup_ident(conn, ident, false) #define l2cap_remove_ident(conn, ident) __l2cap_lookup_ident(conn, ident, true) static struct bt_l2cap_fixed_chan *le_channels; #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) static struct bt_l2cap_server *servers; #endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ /* Pool for outgoing LE signaling packets, MTU is 23 */ static struct nano_fifo le_sig; static NET_BUF_POOL(le_sig_pool, CONFIG_BLUETOOTH_MAX_CONN, BT_L2CAP_BUF_SIZE(L2CAP_LE_MIN_MTU), &le_sig, NULL, BT_BUF_USER_DATA_MIN); #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) /* Pool for outgoing LE data packets, MTU is 23 */ static struct nano_fifo le_data; static NET_BUF_POOL(le_data_pool, CONFIG_BLUETOOTH_MAX_CONN, BT_L2CAP_BUF_SIZE(L2CAP_LE_MIN_MTU), &le_data, NULL, BT_BUF_USER_DATA_MIN); #endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ /* L2CAP signalling channel specific context */ struct bt_l2cap { /* The channel this context is associated with */ struct bt_l2cap_le_chan chan; };
#include <bluetooth/log.h> #include <bluetooth/bluetooth.h> #include <bluetooth/conn.h> #include <bluetooth/buf.h> #include "hci_core.h" #include "conn_internal.h" #include "l2cap_internal.h" #include "smp.h" static struct bt_l2cap_chan bt_smp_pool[CONFIG_BLUETOOTH_MAX_CONN]; /* Pool for outgoing SMP signaling packets, MTU is 23 */ static struct nano_fifo smp_buf; static NET_BUF_POOL(smp_pool, CONFIG_BLUETOOTH_MAX_CONN, BT_L2CAP_BUF_SIZE(23), &smp_buf, NULL, BT_BUF_USER_DATA_MIN); int bt_smp_sign_verify(struct bt_conn *conn, struct net_buf *buf) { return -ENOTSUP; } int bt_smp_sign(struct bt_conn *conn, struct net_buf *buf) { return -ENOTSUP; } static void bt_smp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf) { struct bt_conn *conn = chan->conn;