Skip to content

Commit 01a8e8e

Browse files
lylezhu2012m-alperen-sener
authored andcommitted
[nrf fromtree] Bluetooth: RFCOMM: Add a argument server to bt_rfcomm_server.accept
In current implementation, the `accept` cannot be identified if the same one `accept` callback is passed by the upper layer. Similar with `accept` of `bt_l2cap_server.accept`, add a parameter `server` to the `bt_rfcomm_server.accept` callback. Add a argument `server` to function bt_hfp_hf_accept() to avoid building issue for HFP_HF. Add a argument `server` to function rfcomm_accept() to avoid building issue for shell/rfcomm.c. Signed-off-by: Lyle Zhu <[email protected]> (cherry picked from commit 40993fe)
1 parent fe67510 commit 01a8e8e

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

include/zephyr/bluetooth/classic/rfcomm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ struct bt_rfcomm_server {
144144
* authorization.
145145
*
146146
* @param conn The connection that is requesting authorization
147+
* @param server Pointer to the server structure this callback relates to
147148
* @param dlc Pointer to received the allocated dlc
148149
*
149150
* @return 0 in case of success or negative value in case of error.
150151
*/
151-
int (*accept)(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc);
152+
int (*accept)(struct bt_conn *conn, struct bt_rfcomm_server *server,
153+
struct bt_rfcomm_dlc **dlc);
152154

153155
struct bt_rfcomm_server *_next;
154156
};

subsys/bluetooth/host/classic/hfp_hf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,8 @@ static void hfp_hf_sent(struct bt_rfcomm_dlc *dlc, int err)
716716
LOG_DBG("DLC %p sent cb (err %d)", dlc, err);
717717
}
718718

719-
static int bt_hfp_hf_accept(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc)
719+
static int bt_hfp_hf_accept(struct bt_conn *conn, struct bt_rfcomm_server *server,
720+
struct bt_rfcomm_dlc **dlc)
720721
{
721722
int i;
722723
static struct bt_rfcomm_dlc_ops ops = {

subsys/bluetooth/host/classic/rfcomm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session
495495
return NULL;
496496
}
497497

498-
if (server->accept(session->br_chan.chan.conn, &dlc) < 0) {
498+
if (server->accept(session->br_chan.chan.conn, server, &dlc) < 0) {
499499
LOG_DBG("Incoming connection rejected");
500500
return NULL;
501501
}

subsys/bluetooth/host/classic/shell/rfcomm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ static struct bt_rfcomm_dlc rfcomm_dlc = {
125125
.mtu = 30,
126126
};
127127

128-
static int rfcomm_accept(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc)
128+
static int rfcomm_accept(struct bt_conn *conn, struct bt_rfcomm_server *server,
129+
struct bt_rfcomm_dlc **dlc)
129130
{
130131
shell_print(ctx_shell, "Incoming RFCOMM conn %p", conn);
131132

0 commit comments

Comments
 (0)