2024-01-29 20:42:22

by Victor Pushkarev

[permalink] [raw]
Subject: [PATCH BlueZ v1 2/2] a2dp: Reject connection when the channel limit is exceeded

Reject incoming connection when the configured limit
for A2DP channels is exceeded.

Signed-off-by: Victor Pushkarev <[email protected]>
---
profiles/audio/a2dp.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index b43161a13..117b27db3 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -2549,6 +2549,14 @@ static void confirm_cb(GIOChannel *io, gpointer data)
if (!chan)
goto drop;

+ if (btd_opts.a2dp.channels &&
+ queue_length(server->channels) > btd_opts.a2dp.channels) {
+ device_request_disconnect(device, NULL);
+ DBG("Reject current connection, A2DP channel limit exceeded: %d",
+ btd_opts.a2dp.channels);
+ goto drop;
+ }
+
chan->auth_id = btd_request_authorization(&src, &dst,
ADVANCED_AUDIO_UUID,
auth_cb, chan);
--
2.39.3 (Apple Git-145)



2024-01-29 21:09:28

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ v1 2/2] a2dp: Reject connection when the channel limit is exceeded

Hi,

On Mon, Jan 29, 2024 at 3:42 PM Victor Pushkarev
<[email protected]> wrote:
>
> Reject incoming connection when the configured limit
> for A2DP channels is exceeded.
>
> Signed-off-by: Victor Pushkarev <[email protected]>
> ---
> profiles/audio/a2dp.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
> index b43161a13..117b27db3 100644
> --- a/profiles/audio/a2dp.c
> +++ b/profiles/audio/a2dp.c
> @@ -2549,6 +2549,14 @@ static void confirm_cb(GIOChannel *io, gpointer data)
> if (!chan)
> goto drop;
>
> + if (btd_opts.a2dp.channels &&
> + queue_length(server->channels) > btd_opts.a2dp.channels) {
> + device_request_disconnect(device, NULL);
> + DBG("Reject current connection, A2DP channel limit exceeded: %d",
> + btd_opts.a2dp.channels);
> + goto drop;
> + }

NAK, this is the wrong layer to do this, it is up to the MediaEndpoint
implementation to tell how many streams it can handle.

> chan->auth_id = btd_request_authorization(&src, &dst,
> ADVANCED_AUDIO_UUID,
> auth_cb, chan);
> --
> 2.39.3 (Apple Git-145)
>
>


--
Luiz Augusto von Dentz