From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/3] bthost: Introduce bthost_add_l2cap_server_custom
Date: Wed, 26 Jun 2024 11:02:28 -0400 [thread overview]
Message-ID: <20240626150229.103047-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20240626150229.103047-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces bthost_add_l2cap_server_custom which can be used to
define custom values for MTU, MPS and credits.
---
emulator/bthost.c | 29 ++++++++++++++++++++++-------
emulator/bthost.h | 5 +++++
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/emulator/bthost.c b/emulator/bthost.c
index d69e3d34ea3c..cc9bf7240531 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -195,6 +195,9 @@ struct l2cap_pending_req {
struct l2cap_conn_cb_data {
uint16_t psm;
+ uint16_t mtu;
+ uint16_t mps;
+ uint16_t credits;
bthost_l2cap_connect_cb func;
bthost_l2cap_disconnect_cb disconn_func;
void *user_data;
@@ -2164,14 +2167,13 @@ static bool l2cap_le_conn_req(struct bthost *bthost, struct btconn *conn,
memset(&rsp, 0, sizeof(rsp));
- rsp.mtu = 23;
- rsp.mps = 23;
- rsp.credits = 1;
-
cb_data = bthost_find_l2cap_cb_by_psm(bthost, psm);
- if (cb_data)
+ if (cb_data) {
rsp.dcid = cpu_to_le16(conn->next_cid++);
- else
+ rsp.mtu = cpu_to_le16(cb_data->mtu) ? : cpu_to_le16(23);
+ rsp.mps = cpu_to_le16(cb_data->mps) ? : cpu_to_le16(23);
+ rsp.credits = cpu_to_le16(cb_data->credits) ? : cpu_to_le16(1);
+ } else
rsp.result = cpu_to_le16(0x0002); /* PSM Not Supported */
l2cap_sig_send(bthost, conn, BT_L2CAP_PDU_LE_CONN_RSP, ident, &rsp,
@@ -3511,7 +3513,8 @@ uint64_t bthost_conn_get_fixed_chan(struct bthost *bthost, uint16_t handle)
return conn->fixed_chan;
}
-void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
+void bthost_add_l2cap_server_custom(struct bthost *bthost, uint16_t psm,
+ uint16_t mtu, uint16_t mps, uint16_t credits,
bthost_l2cap_connect_cb func,
bthost_l2cap_disconnect_cb disconn_func,
void *user_data)
@@ -3523,6 +3526,9 @@ void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
return;
data->psm = psm;
+ data->mtu = mtu;
+ data->mps = mps;
+ data->credits = credits;
data->user_data = user_data;
data->func = func;
data->disconn_func = disconn_func;
@@ -3531,6 +3537,15 @@ void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
bthost->new_l2cap_conn_data = data;
}
+void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
+ bthost_l2cap_connect_cb func,
+ bthost_l2cap_disconnect_cb disconn_func,
+ void *user_data)
+{
+ bthost_add_l2cap_server_custom(bthost, psm, 0, 0, 0, func,
+ disconn_func, user_data);
+}
+
void bthost_set_sc_support(struct bthost *bthost, bool enable)
{
struct bt_hci_cmd_write_secure_conn_support cmd;
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 0c488e32afd0..2c5b0d5164cc 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -136,6 +136,11 @@ void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
bthost_l2cap_connect_cb func,
bthost_l2cap_disconnect_cb disconn_func,
void *user_data);
+void bthost_add_l2cap_server_custom(struct bthost *bthost, uint16_t psm,
+ uint16_t mtu, uint16_t mps, uint16_t credits,
+ bthost_l2cap_connect_cb func,
+ bthost_l2cap_disconnect_cb disconn_func,
+ void *user_data);
void bthost_set_sc_support(struct bthost *bthost, bool enable);
--
2.45.2
next prev parent reply other threads:[~2024-06-26 15:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 15:02 [PATCH BlueZ v1 1/3] l2cap-tester: Add tests for multiple data packets Luiz Augusto von Dentz
2024-06-26 15:02 ` Luiz Augusto von Dentz [this message]
2024-06-26 15:02 ` [PATCH BlueZ v1 3/3] l2cap-tester: Add tests for multiple data packets over LE Luiz Augusto von Dentz
2024-06-26 17:39 ` [BlueZ,v1,1/3] l2cap-tester: Add tests for multiple data packets bluez.test.bot
2024-06-27 18:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626150229.103047-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox