client/player: Add support to Max Transports in endpoint.register
Luiz Augusto von Dentz
maintainerPATCH 1/1 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(-)
client/player.c +59 -2
@@ -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 ;
Signature · 1 line
2.40.0
Luiz Augusto von Dentz
maintainerPATCH 1/1 client/player: Fix not checking for SupportedUUIDs
From: Luiz Augusto von Dentz <[email protected]>
When registering an endpoint it should always check for SupportedUUIDs.
--- client/player.c | 66 +++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 24 deletions(-)
client/player.c +42 -24
@@ -2190,9 +2190,32 @@ static void register_endpoint_reply(DBusMessage *message, void *user_data)return bt_shell_noninteractive_quit (EXIT_SUCCESS ); } +static bool media_supports_uuid (GDBusProxy *proxy,const char *uuid) +{ +DBusMessageIter iter, array; + +if (!g_dbus_proxy_get_property (proxy,"SupportedUUIDs" , &iter)) +return false; + +dbus_message_iter_recurse (&iter, &array); +while (dbus_message_iter_get_arg_type (&array) ==DBUS_TYPE_STRING ) { +const char *support_uuid; + +dbus_message_iter_get_basic (&array, &support_uuid); + +if (!strcasecmp (uuid, support_uuid)) +return true; + +dbus_message_iter_next (&array); + } + +return false; +} + static void endpoint_register(struct endpoint *ep) { GList *l; + int registered = 0; if (!g_dbus_register_interface(dbus_conn, ep->path, BLUEZ_MEDIA_ENDPOINT_INTERFACE,
@@ -2203,6 +2226,9 @@ static void endpoint_register(struct endpoint *ep) } for (l = medias; l; l = g_list_next(l)) { + if (!media_supports_uuid(l->data, ep->uuid)) + continue; + if (!g_dbus_proxy_method_call(l->data, "RegisterEndpoint", register_endpoint_setup, register_endpoint_reply,
@@ -2211,8 +2237,13 @@ static void endpoint_register(struct endpoint *ep) BLUEZ_MEDIA_ENDPOINT_INTERFACE); goto fail; } + + registered++; } +if (!registered) + goto fail; +return ; fail:
@@ -3015,33 +3046,20 @@ static struct endpoint *endpoint_new(const struct capabilities *cap)static void register_endpoints (GDBusProxy *proxy) {struct endpoint *ep; -DBusMessageIter iter, array; +size_t i; -if (!g_dbus_proxy_get_property (proxy,"SupportedUUIDs" , &iter)) -return ; +for (i =0 ; i <ARRAY_SIZE (caps); i++) { +const struct capabilities *cap = &caps[i]; -dbus_message_iter_recurse (&iter, &array); -while (dbus_message_iter_get_arg_type (&array) ==DBUS_TYPE_STRING ) { -const char *uuid; -size_t i; +if (!media_supports_uuid (proxy, cap->uuid)) +continue ; -dbus_message_iter_get_basic (&array, &uuid); - -for (i =0 ; i <ARRAY_SIZE (caps); i++) { -const struct capabilities *cap = &caps[i]; - -if (strcasecmp (cap->uuid, uuid)) -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 ; -endpoint_register (ep); - } - -dbus_message_iter_next (&array); + 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 ; +endpoint_register (ep); } }
Signature · 1 line
2.40.0
RE: [BlueZ] client/player: Fix not checking for SupportedUUIDs
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: client/player.c:3015
error: client/player.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
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
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html