Bluetooth: L2CAP: Add destroy callback to fixed L2CAP channels
Add the option to provide the destroy callback to the fixed channels. This can be used to free the memory for the L2CAP channel context which is provided by the fixed channel in the accept callback. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
d55a09ff05
commit
83f108afd1
5 changed files with 11 additions and 9 deletions
|
@ -2238,7 +2238,7 @@ static int bt_att_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
|||
return 0;
|
||||
}
|
||||
|
||||
BT_L2CAP_CHANNEL_DEFINE(att_fixed_chan, BT_L2CAP_CID_ATT, bt_att_accept);
|
||||
BT_L2CAP_CHANNEL_DEFINE(att_fixed_chan, BT_L2CAP_CID_ATT, bt_att_accept, NULL);
|
||||
|
||||
void bt_att_init(void)
|
||||
{
|
||||
|
|
|
@ -354,7 +354,7 @@ void bt_l2cap_connected(struct bt_conn *conn)
|
|||
ch->rx.cid = fchan->cid;
|
||||
ch->tx.cid = fchan->cid;
|
||||
|
||||
if (!l2cap_chan_add(conn, chan, NULL)) {
|
||||
if (!l2cap_chan_add(conn, chan, fchan->destroy)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1919,7 +1919,7 @@ static int l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
BT_L2CAP_CHANNEL_DEFINE(le_fixed_chan, BT_L2CAP_CID_LE_SIG, l2cap_accept);
|
||||
BT_L2CAP_CHANNEL_DEFINE(le_fixed_chan, BT_L2CAP_CID_LE_SIG, l2cap_accept, NULL);
|
||||
|
||||
void bt_l2cap_init(void)
|
||||
{
|
||||
|
|
|
@ -202,12 +202,14 @@ struct bt_l2cap_le_credits {
|
|||
struct bt_l2cap_fixed_chan {
|
||||
u16_t cid;
|
||||
int (*accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan);
|
||||
bt_l2cap_chan_destroy_t destroy;
|
||||
};
|
||||
|
||||
#define BT_L2CAP_CHANNEL_DEFINE(_name, _cid, _accept) \
|
||||
#define BT_L2CAP_CHANNEL_DEFINE(_name, _cid, _accept, _destroy) \
|
||||
const Z_STRUCT_SECTION_ITERABLE(bt_l2cap_fixed_chan, _name) = { \
|
||||
.cid = _cid, \
|
||||
.accept = _accept, \
|
||||
.cid = _cid, \
|
||||
.accept = _accept, \
|
||||
.destroy = _destroy, \
|
||||
}
|
||||
|
||||
/* Need a name different than bt_l2cap_fixed_chan for a different section */
|
||||
|
|
|
@ -5311,10 +5311,10 @@ static bool le_sc_supported(void)
|
|||
BT_CMD_TEST(bt_dev.supported_commands, 34, 2);
|
||||
}
|
||||
|
||||
BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept);
|
||||
BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept, NULL);
|
||||
#if defined(CONFIG_BT_BREDR)
|
||||
BT_L2CAP_CHANNEL_DEFINE(smp_br_fixed_chan, BT_L2CAP_CID_BR_SMP,
|
||||
bt_smp_br_accept);
|
||||
bt_smp_br_accept, NULL);
|
||||
#endif /* CONFIG_BT_BREDR */
|
||||
|
||||
int bt_smp_init(void)
|
||||
|
|
|
@ -93,7 +93,7 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept);
|
||||
BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept, NULL);
|
||||
|
||||
int bt_smp_init(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue