2023-05-11 20:46:29

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ] client/player: Add support to Max Transports in endpoint.register

From: Luiz Augusto von Dentz <[email protected]>

[bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): 1
[/local/endpoint/ep0] CIG (auto/value): a
[/local/endpoint/ep0] CIS (auto/value): a
---
client/player.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)

diff --git a/client/player.c b/client/player.c
index 2880c5ffe140..f055ff941569 100644
--- a/client/player.c
+++ b/client/player.c
@@ -73,6 +73,7 @@ struct endpoint {
struct iovec *meta;
bool auto_accept;
bool acquiring;
+ uint8_t max_transports;
uint8_t cig;
uint8_t cis;
char *transport;
@@ -1056,6 +1057,16 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn,
print_iter("\t", "Properties", &props);

free(ep->transport);
+
+ if (!ep->max_transports) {
+ bt_shell_printf("Maximum transports reached: rejecting\n");
+ return g_dbus_create_error(msg,
+ "org.bluez.Error.Rejected",
+ "Maximum transports reached");
+ }
+
+ ep->max_transports--;
+
ep->transport = strdup(path);

if (ep->auto_accept) {
@@ -1672,6 +1683,13 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *conn,
bt_shell_printf("Endpoint: SelectConfiguration\n");
print_iter("\t", "Capabilities", &args);

+ if (!ep->max_transports) {
+ bt_shell_printf("Maximum transports reached: rejecting\n");
+ return g_dbus_create_error(msg,
+ "org.bluez.Error.Rejected",
+ "Maximum transports reached");
+ }
+
if (!ep->auto_accept) {
ep->msg = dbus_message_ref(msg);
bt_shell_prompt_input("Endpoint", "Enter preset/configuration:",
@@ -1688,8 +1706,11 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *conn,

reply = endpoint_select_config_reply(msg, p->data.iov_base,
p->data.iov_len);
- if (!reply)
- return NULL;
+ if (!reply) {
+ reply = g_dbus_create_error(msg, "org.bluez.Error.Rejected",
+ NULL);
+ return reply;
+ }

bt_shell_printf("Auto Accepting using %s...\n", p->name);

@@ -1878,6 +1899,13 @@ static DBusMessage *endpoint_select_properties(DBusConnection *conn,
bt_shell_printf("Endpoint: SelectProperties\n");
print_iter("\t", "Properties", &args);

+ if (!ep->max_transports) {
+ bt_shell_printf("Maximum transports reached: rejecting\n");
+ return g_dbus_create_error(msg,
+ "org.bluez.Error.Rejected",
+ "Maximum transports reached");
+ }
+
if (!ep->auto_accept) {
ep->msg = dbus_message_ref(msg);
bt_shell_prompt_input("Endpoint", "Enter preset/configuration:",
@@ -1903,6 +1931,9 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *conn,
{
struct endpoint *ep = user_data;

+ if (ep->max_transports != UINT8_MAX)
+ ep->max_transports++;
+
free(ep->transport);
ep->transport = NULL;

@@ -2234,12 +2265,37 @@ static void endpoint_cig(const char *input, void *user_data)
bt_shell_prompt_input(ep->path, "CIS (auto/value):", endpoint_cis, ep);
}

+static void endpoint_max_transports(const char *input, void *user_data)
+{
+ struct endpoint *ep = user_data;
+ char *endptr = NULL;
+ int value;
+
+ if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) {
+ ep->max_transports = UINT8_MAX;
+ } else {
+ value = strtol(input, &endptr, 0);
+
+ if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+ bt_shell_printf("Invalid argument: %s\n", input);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ ep->max_transports = value;
+ }
+
+ bt_shell_prompt_input(ep->path, "CIG (auto/value):", endpoint_cig, ep);
+}
+
static void endpoint_auto_accept(const char *input, void *user_data)
{
struct endpoint *ep = user_data;

if (!strcasecmp(input, "y") || !strcasecmp(input, "yes")) {
ep->auto_accept = true;
+ bt_shell_prompt_input(ep->path, "Max Transports (auto/value):",
+ endpoint_max_transports, ep);
+ return;
} else if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
ep->auto_accept = false;
} else {
@@ -2977,6 +3033,7 @@ static void register_endpoints(GDBusProxy *proxy)
continue;

ep = endpoint_new(cap);
+ ep->max_transports = UINT8_MAX;
ep->auto_accept = true;
ep->cig = BT_ISO_QOS_CIG_UNSET;
ep->cis = BT_ISO_QOS_CIS_UNSET;
--
2.40.0



2023-05-11 21:40:16

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ] client/player: Add support to Max Transports in endpoint.register

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=746898

---Test result---

Test Summary:
CheckPatch PASS 0.57 seconds
GitLint PASS 0.35 seconds
BuildEll PASS 27.20 seconds
BluezMake PASS 886.46 seconds
MakeCheck PASS 12.36 seconds
MakeDistcheck PASS 156.11 seconds
CheckValgrind PASS 253.21 seconds
CheckSmatch PASS 341.50 seconds
bluezmakeextell PASS 103.03 seconds
IncrementalBuild PASS 738.62 seconds
ScanBuild PASS 1058.26 seconds



---
Regards,
Linux Bluetooth

2023-05-12 20:42:49

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ] client/player: Add support to Max Transports in endpoint.register

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Thu, 11 May 2023 13:28:24 -0700 you wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
> [/local/endpoint/ep0] Auto Accept (yes/no): y
> [/local/endpoint/ep0] Max Transports (auto/value): 1
> [/local/endpoint/ep0] CIG (auto/value): a
> [/local/endpoint/ep0] CIS (auto/value): a
>
> [...]

Here is the summary with links:
- [BlueZ] client/player: Add support to Max Transports in endpoint.register
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fe16cf2a7ee3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html