Bluetooth: Add CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL
This adds an option to enable L2CAP dynamic channel support, fixed channels are not affected by it. Change-Id: If36bece46b7b94142ea1ac976b878d1b5ae6a578 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
4a41da9b38
commit
d55e4ca91c
5 changed files with 49 additions and 33 deletions
|
@ -79,6 +79,8 @@ struct bt_l2cap_chan_ops {
|
||||||
struct bt_buf *buf);
|
struct bt_buf *buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
|
||||||
|
|
||||||
/** @brief L2CAP Server structure. */
|
/** @brief L2CAP Server structure. */
|
||||||
struct bt_l2cap_server {
|
struct bt_l2cap_server {
|
||||||
/** Server PSM */
|
/** Server PSM */
|
||||||
|
@ -100,5 +102,6 @@ struct bt_l2cap_server {
|
||||||
*/
|
*/
|
||||||
int bt_l2cap_server_register(struct bt_l2cap_server *server);
|
int bt_l2cap_server_register(struct bt_l2cap_server *server);
|
||||||
|
|
||||||
|
#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */
|
||||||
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
|
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
|
||||||
#endif /* __BT_L2CAP_H */
|
#endif /* __BT_L2CAP_H */
|
||||||
|
|
|
@ -45,6 +45,11 @@ config BLUETOOTH_SMP
|
||||||
prompt "Security Manager Protocol support"
|
prompt "Security Manager Protocol support"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config BLUETOOTH_L2CAP_DYNAMIC_CHANNEL
|
||||||
|
bool
|
||||||
|
prompt "L2CAP Dynamic Channel support"
|
||||||
|
default n
|
||||||
|
|
||||||
config BLUETOOTH_SIGNING
|
config BLUETOOTH_SIGNING
|
||||||
bool
|
bool
|
||||||
prompt "Data signing support"
|
prompt "Data signing support"
|
||||||
|
|
|
@ -48,7 +48,9 @@
|
||||||
#define L2CAP_LE_CID_END 0x007f
|
#define L2CAP_LE_CID_END 0x007f
|
||||||
|
|
||||||
static struct bt_l2cap_fixed_chan *channels;
|
static struct bt_l2cap_fixed_chan *channels;
|
||||||
|
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
|
||||||
static struct bt_l2cap_server *servers;
|
static struct bt_l2cap_server *servers;
|
||||||
|
#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */
|
||||||
|
|
||||||
/* L2CAP signalling channel specific context */
|
/* L2CAP signalling channel specific context */
|
||||||
struct bt_l2cap {
|
struct bt_l2cap {
|
||||||
|
@ -101,39 +103,6 @@ void bt_l2cap_fixed_chan_register(struct bt_l2cap_fixed_chan *chan)
|
||||||
channels = chan;
|
channels = chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bt_l2cap_server *l2cap_server_lookup_psm(uint16_t psm)
|
|
||||||
{
|
|
||||||
struct bt_l2cap_server *server;
|
|
||||||
|
|
||||||
for (server = servers; server; server = server->_next) {
|
|
||||||
if (server->psm == psm) {
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bt_l2cap_server_register(struct bt_l2cap_server *server)
|
|
||||||
{
|
|
||||||
if (server->psm < 0x0080 || server->psm > 0x00ff || !server->accept) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if given PSM is already in use */
|
|
||||||
if (l2cap_server_lookup_psm(server->psm)) {
|
|
||||||
BT_DBG("PSM already registered\n");
|
|
||||||
return -EADDRINUSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BT_DBG("PSM 0x%04x\n", server->psm);
|
|
||||||
|
|
||||||
server->_next = servers;
|
|
||||||
servers = server;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void l2cap_chan_alloc_cid(struct bt_conn *conn,
|
static void l2cap_chan_alloc_cid(struct bt_conn *conn,
|
||||||
struct bt_l2cap_chan *chan)
|
struct bt_l2cap_chan *chan)
|
||||||
{
|
{
|
||||||
|
@ -332,6 +301,40 @@ static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident,
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
|
||||||
|
static struct bt_l2cap_server *l2cap_server_lookup_psm(uint16_t psm)
|
||||||
|
{
|
||||||
|
struct bt_l2cap_server *server;
|
||||||
|
|
||||||
|
for (server = servers; server; server = server->_next) {
|
||||||
|
if (server->psm == psm) {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bt_l2cap_server_register(struct bt_l2cap_server *server)
|
||||||
|
{
|
||||||
|
if (server->psm < 0x0080 || server->psm > 0x00ff || !server->accept) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if given PSM is already in use */
|
||||||
|
if (l2cap_server_lookup_psm(server->psm)) {
|
||||||
|
BT_DBG("PSM already registered\n");
|
||||||
|
return -EADDRINUSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BT_DBG("PSM 0x%04x\n", server->psm);
|
||||||
|
|
||||||
|
server->_next = servers;
|
||||||
|
servers = server;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
|
static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
|
||||||
struct bt_buf *buf)
|
struct bt_buf *buf)
|
||||||
{
|
{
|
||||||
|
@ -432,6 +435,7 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
|
||||||
rsp:
|
rsp:
|
||||||
bt_l2cap_send(conn, BT_L2CAP_CID_LE_SIG, buf);
|
bt_l2cap_send(conn, BT_L2CAP_CID_LE_SIG, buf);
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */
|
||||||
|
|
||||||
static void l2cap_recv(struct bt_l2cap_chan *chan, struct bt_buf *buf)
|
static void l2cap_recv(struct bt_l2cap_chan *chan, struct bt_buf *buf)
|
||||||
{
|
{
|
||||||
|
@ -469,9 +473,11 @@ static void l2cap_recv(struct bt_l2cap_chan *chan, struct bt_buf *buf)
|
||||||
le_conn_param_update_req(l2cap, hdr->ident, buf);
|
le_conn_param_update_req(l2cap, hdr->ident, buf);
|
||||||
break;
|
break;
|
||||||
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||||
|
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
|
||||||
case BT_L2CAP_LE_CONN_REQ:
|
case BT_L2CAP_LE_CONN_REQ:
|
||||||
le_conn_req(l2cap, hdr->ident, buf);
|
le_conn_req(l2cap, hdr->ident, buf);
|
||||||
break;
|
break;
|
||||||
|
#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */
|
||||||
default:
|
default:
|
||||||
BT_WARN("Unknown L2CAP PDU code 0x%02x\n", hdr->code);
|
BT_WARN("Unknown L2CAP PDU code 0x%02x\n", hdr->code);
|
||||||
rej_not_understood(chan->conn, hdr->ident);
|
rej_not_understood(chan->conn, hdr->ident);
|
||||||
|
|
|
@ -10,3 +10,4 @@ CONFIG_BLUETOOTH_PERIPHERAL=y
|
||||||
CONFIG_BLUETOOTH_SMP=y
|
CONFIG_BLUETOOTH_SMP=y
|
||||||
CONFIG_BLUETOOTH_SIGNING=y
|
CONFIG_BLUETOOTH_SIGNING=y
|
||||||
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
||||||
|
CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL=y
|
||||||
|
|
|
@ -10,5 +10,6 @@ CONFIG_BLUETOOTH_PERIPHERAL=y
|
||||||
CONFIG_BLUETOOTH_SMP=y
|
CONFIG_BLUETOOTH_SMP=y
|
||||||
CONFIG_BLUETOOTH_SIGNING=y
|
CONFIG_BLUETOOTH_SIGNING=y
|
||||||
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
||||||
|
CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL=y
|
||||||
CONFIG_TINYCRYPT=y
|
CONFIG_TINYCRYPT=y
|
||||||
CONFIG_TINYCRYPT_AES=y
|
CONFIG_TINYCRYPT_AES=y
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue