Bluetooth: Host: Pass pointer to server in L2CAP accept() callback

Add a pointer to the associated server structure in the L2CAP accept()
callback. This allows the callee to know which server an incoming L2CAP
connection is associated with.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
This commit is contained in:
Donatien Garnier 2023-07-18 16:44:24 +01:00 committed by Carles Cufí
parent 3f585f527b
commit 815891643e
7 changed files with 13 additions and 7 deletions

View file

@ -453,6 +453,7 @@ struct bt_l2cap_server {
* authorization.
*
* @param conn The connection that is requesting authorization
* @param server Pointer to the server structure this callback relates to
* @param chan Pointer to received the allocated channel
*
* @return 0 in case of success or negative value in case of error.
@ -460,7 +461,8 @@ struct bt_l2cap_server {
* @return -EACCES if application did not authorize the connection.
* @return -EPERM if encryption key size is too short.
*/
int (*accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan);
int (*accept)(struct bt_conn *conn, struct bt_l2cap_server *server,
struct bt_l2cap_chan **chan);
sys_snode_t node;
};

View file

@ -3723,7 +3723,8 @@ int bt_eatt_reconfigure(struct bt_conn *conn, uint16_t mtu)
#endif /* CONFIG_BT_TESTING */
#endif /* CONFIG_BT_EATT */
static int bt_eatt_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
static int bt_eatt_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
struct bt_l2cap_chan **chan)
{
struct bt_att_chan *att_chan = att_get_fixed_chan(conn);
struct bt_att *att = att_chan->att;

View file

@ -220,7 +220,8 @@ int bt_avdtp_disconnect(struct bt_avdtp *session)
return bt_l2cap_chan_disconnect(&session->br_chan.chan);
}
int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
struct bt_l2cap_chan **chan)
{
struct bt_avdtp *session = NULL;
int result;

View file

@ -1048,7 +1048,7 @@ static uint16_t l2cap_chan_accept(struct bt_conn *conn,
/* Request server to accept the new connection and allocate the
* channel.
*/
err = server->accept(conn, chan);
err = server->accept(conn, server, chan);
if (err < 0) {
return le_err_to_result(err);
}

View file

@ -747,7 +747,7 @@ static void l2cap_br_conn_req(struct bt_l2cap_br *l2cap, uint8_t ident,
* channel. If no free channels available for PSM server reply with
* proper result and quit since chan pointer is uninitialized then.
*/
if (server->accept(conn, &chan) < 0) {
if (server->accept(conn, server, &chan) < 0) {
result = BT_L2CAP_BR_ERR_NO_RESOURCES;
goto no_chan;
}

View file

@ -1704,7 +1704,8 @@ int bt_rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc)
return rfcomm_dlc_close(dlc);
}
static int rfcomm_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
static int rfcomm_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
struct bt_l2cap_chan **chan)
{
struct bt_rfcomm_session *session;

View file

@ -1389,7 +1389,8 @@ static int bt_sdp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
*
* @return 0 for success, or relevant error code
*/
static int bt_sdp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
static int bt_sdp_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
struct bt_l2cap_chan **chan)
{
static const struct bt_l2cap_chan_ops ops = {
.connected = bt_sdp_connected,