From: Iulia Tanasescu <iulia.tanasescu@nxp.com>
To: linux-bluetooth@vger.kernel.org
Cc: Silviu Florian Barbulescu <silviu.barbulescu@nxp.com>
Subject: [PATCH BlueZ 4/6] btio: Add support for setsockopt (BT_IO_OPT_BASE)
Date: Tue, 23 May 2023 17:35:02 +0300 [thread overview]
Message-ID: <20230523143504.3319-5-iulia.tanasescu@nxp.com> (raw)
In-Reply-To: <20230523143504.3319-1-iulia.tanasescu@nxp.com>
From: Silviu Florian Barbulescu <silviu.barbulescu@nxp.com>
This adds btio support for setting the BT_IO_OPT_BASE socket option.
---
btio/btio.c | 26 +++++++++++++++++++++++---
btio/btio.h | 2 ++
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/btio/btio.c b/btio/btio.c
index 6f6d76dc8..b68bfb14c 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -70,6 +70,7 @@ struct set_opts {
uint32_t priority;
uint16_t voice;
struct bt_iso_qos qos;
+ struct bt_iso_base base;
};
struct connect {
@@ -858,7 +859,7 @@ voice:
return TRUE;
}
-static gboolean iso_set(int sock, struct bt_iso_qos *qos, GError **err)
+static gboolean iso_set_qos(int sock, struct bt_iso_qos *qos, GError **err)
{
if (setsockopt(sock, SOL_BLUETOOTH, BT_ISO_QOS, qos,
sizeof(*qos)) < 0) {
@@ -869,6 +870,16 @@ static gboolean iso_set(int sock, struct bt_iso_qos *qos, GError **err)
return TRUE;
}
+static gboolean iso_set_base(int sock, struct bt_iso_base *base, GError **err)
+{
+ if (setsockopt(sock, SOL_BLUETOOTH, BT_ISO_BASE, base->base,
+ base->base_len) < 0) {
+ ERROR_FAILED(err, "setsockopt(BT_ISO_BASE)", errno);
+ return FALSE;
+ }
+
+ return TRUE;
+}
static gboolean parse_set_opts(struct set_opts *opts, GError **err,
BtIOOption opt1, va_list args)
{
@@ -966,6 +977,9 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
case BT_IO_OPT_QOS:
opts->qos = *va_arg(args, struct bt_iso_qos *);
break;
+ case BT_IO_OPT_BASE:
+ opts->base = *va_arg(args, struct bt_iso_base *);
+ break;
case BT_IO_OPT_INVALID:
case BT_IO_OPT_KEY_SIZE:
case BT_IO_OPT_SOURCE_CHANNEL:
@@ -1290,6 +1304,7 @@ parse_opts:
case BT_IO_OPT_MTU:
case BT_IO_OPT_VOICE:
case BT_IO_OPT_QOS:
+ case BT_IO_OPT_BASE:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
@@ -1444,6 +1459,7 @@ static gboolean rfcomm_get(int sock, GError **err, BtIOOption opt1,
case BT_IO_OPT_PRIORITY:
case BT_IO_OPT_VOICE:
case BT_IO_OPT_QOS:
+ case BT_IO_OPT_BASE:
case BT_IO_OPT_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
@@ -1554,6 +1570,7 @@ static gboolean sco_get(int sock, GError **err, BtIOOption opt1, va_list args)
case BT_IO_OPT_PRIORITY:
case BT_IO_OPT_VOICE:
case BT_IO_OPT_QOS:
+ case BT_IO_OPT_BASE:
case BT_IO_OPT_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
@@ -1627,6 +1644,7 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args)
case BT_IO_OPT_QOS:
*(va_arg(args, struct bt_iso_qos *)) = qos;
break;
+ case BT_IO_OPT_BASE:
case BT_IO_OPT_HANDLE:
case BT_IO_OPT_CLASS:
case BT_IO_OPT_DEFER_TIMEOUT:
@@ -1740,7 +1758,7 @@ gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...)
case BT_IO_SCO:
return sco_set(sock, opts.mtu, opts.voice, err);
case BT_IO_ISO:
- return iso_set(sock, &opts.qos, err);
+ return iso_set_qos(sock, &opts.qos, err);
case BT_IO_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
@@ -1820,7 +1838,9 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts,
}
if (iso_bind(sock, &opts->src, opts->src_type, err) < 0)
goto failed;
- if (!iso_set(sock, &opts->qos, err))
+ if (!iso_set_qos(sock, &opts->qos, err))
+ goto failed;
+ if (!iso_set_base(sock, &opts->base, err))
goto failed;
break;
case BT_IO_INVALID:
diff --git a/btio/btio.h b/btio/btio.h
index 9636fd467..e9a8a01a3 100644
--- a/btio/btio.h
+++ b/btio/btio.h
@@ -5,6 +5,7 @@
*
* Copyright (C) 2009-2010 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2009-2010 Nokia Corporation
+ * Copyright 2023 NXP
*
*
*/
@@ -45,6 +46,7 @@ typedef enum {
BT_IO_OPT_VOICE,
BT_IO_OPT_PHY,
BT_IO_OPT_QOS,
+ BT_IO_OPT_BASE
} BtIOOption;
typedef enum {
--
2.34.1
next prev parent reply other threads:[~2023-05-23 14:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 14:34 [PATCH BlueZ 0/6] Add initial support for BAP broadcast source Iulia Tanasescu
2023-05-23 14:34 ` [PATCH BlueZ 1/6] doc: Update Docs " Iulia Tanasescu
2023-05-23 15:14 ` Add initial support " bluez.test.bot
2023-05-23 14:35 ` [PATCH BlueZ 2/6] lib: Add macro definitions for BAP broadcast source support Iulia Tanasescu
2023-05-23 14:35 ` [PATCH BlueZ 3/6] monitor: Check for ISO broadcast support in controller Iulia Tanasescu
2023-05-23 14:35 ` Iulia Tanasescu [this message]
2023-05-23 14:35 ` [PATCH BlueZ 5/6] client/player: Update bluetoothctl with support for broadcast source Iulia Tanasescu
2023-05-23 16:31 ` Luiz Augusto von Dentz
2023-05-24 8:38 ` Silviu Florian Barbulescu
2023-05-23 14:35 ` [PATCH BlueZ 6/6] bap: Add initial support for BAP " Iulia Tanasescu
2023-05-23 16:46 ` Luiz Augusto von Dentz
2023-05-24 11:44 ` Silviu Florian Barbulescu
2023-05-26 22:10 ` [PATCH BlueZ 0/6] " patchwork-bot+bluetooth
2023-05-26 22:40 ` 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=20230523143504.3319-5-iulia.tanasescu@nxp.com \
--to=iulia.tanasescu@nxp.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=silviu.barbulescu@nxp.com \
/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