* [PATCH BlueZ 0/1] client/player: Allow the user to control BIG encryption
@ 2023-12-20 10:21 Vlad Pruteanu
2023-12-20 10:21 ` [PATCH BlueZ 1/1] " Vlad Pruteanu
0 siblings, 1 reply; 5+ messages in thread
From: Vlad Pruteanu @ 2023-12-20 10:21 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
iulia.tanasescu, andrei.istodorescu, luiz.dentz, Vlad Pruteanu
This commit adds support for controlling the use of encryption and
setting the broadcast code. On the source side the user will be
prompted to choose if he wants to use the BIG mode 3 encryption,
and the Broadcast Code to be used (custom/default value). On the
sink side only the Broadcast Code option is displayed as the use
of encryption is set according to the BASE of the source.
Vlad Pruteanu (1):
client/player: Allow the user to control BIG encryption
client/player.c | 75 ++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 59 insertions(+), 16 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH BlueZ 1/1] client/player: Allow the user to control BIG encryption
2023-12-20 10:21 [PATCH BlueZ 0/1] client/player: Allow the user to control BIG encryption Vlad Pruteanu
@ 2023-12-20 10:21 ` Vlad Pruteanu
2023-12-20 11:30 ` bluez.test.bot
0 siblings, 1 reply; 5+ messages in thread
From: Vlad Pruteanu @ 2023-12-20 10:21 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
iulia.tanasescu, andrei.istodorescu, luiz.dentz, Vlad Pruteanu
This commit adds support for controlling the use of encryption and
setting the broadcast code. On the source side the user will be
prompted to choose if he wants to use the BIG mode 3 encryption,
and the Broadcast Code to be used (custom/default value). On the
sink side only the Broadcast Code option is displayed as the use
of encryption is set according to the BASE of the source.
---
client/player.c | 75 ++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 59 insertions(+), 16 deletions(-)
diff --git a/client/player.c b/client/player.c
index 92fc91f92..7a5277fad 100644
--- a/client/player.c
+++ b/client/player.c
@@ -1966,6 +1966,11 @@ static void append_bcast_qos(DBusMessageIter *iter, struct endpoint_config *cfg)
g_dbus_dict_append_entry(iter, "Framing", DBUS_TYPE_BYTE,
&bcast_qos.bcast.framing);
+ bt_shell_printf("Encryption 0x%02x\n", bcast_qos.bcast.encryption);
+
+ g_dbus_dict_append_entry(iter, "Encryption", DBUS_TYPE_BYTE,
+ &bcast_qos.bcast.encryption);
+
bt_shell_printf("SyncFactor %u\n", bcast_qos.bcast.sync_factor);
g_dbus_dict_append_entry(iter, "SyncFactor", DBUS_TYPE_BYTE,
@@ -3110,6 +3115,34 @@ static void endpoint_config(const char *input, void *user_data)
endpoint_set_config(cfg);
}
+static void set_broadcast_code(const char *input, void *user_data)
+{
+ struct endpoint_config *cfg = user_data;
+ char *endptr;
+
+ /* If input is no, set the encryption flag to 0.*/
+ if (!strcasecmp(input, "n") || !strcasecmp(input, "no"))
+ bcast_qos.bcast.encryption = 0;
+ else
+ bcast_qos.bcast.encryption = 1;
+
+ /* If input is auto, do nothing, default value will be used */
+ if (!(!strcasecmp(input, "a") || !strcasecmp(input, "auto"))) {
+ bcast_qos.bcast.bcode[0] = strtol(input, &endptr, 16);
+
+ for (uint8_t i = 1; i < 16; i++)
+ bcast_qos.bcast.bcode[i] = strtol(endptr, &endptr, 16);
+ }
+ bt_shell_printf("%ld\n", sizeof(bcast_qos.bcast.bcode));
+ iov_append(&cfg->ep->bcode, bcast_qos.bcast.bcode,
+ sizeof(bcast_qos.bcast.bcode));
+ /* Copy capabilities for broadcast*/
+ iov_append(&cfg->caps, base_lc3_16_2_1,
+ sizeof(base_lc3_16_2_1));
+
+ endpoint_set_config(cfg);
+}
+
static struct endpoint *endpoint_new(const struct capabilities *cap);
static void cmd_config_endpoint(int argc, char *argv[])
@@ -3119,7 +3152,7 @@ static void cmd_config_endpoint(int argc, char *argv[])
const struct capabilities *cap;
char *uuid;
uint8_t codec_id;
- bool broadcast = false;
+ bool local_ep_not_provided = false;
cfg = new0(struct endpoint_config, 1);
@@ -3142,7 +3175,7 @@ static void cmd_config_endpoint(int argc, char *argv[])
codec_id = strtol(argv[3], NULL, 0);
cap = find_capabilities(uuid, codec_id);
if (cap) {
- broadcast = true;
+ local_ep_not_provided = true;
cfg->ep = endpoint_new(cap);
cfg->ep->preset = find_presets_name(uuid, argv[3]);
if (!cfg->ep->preset)
@@ -3154,9 +3187,10 @@ static void cmd_config_endpoint(int argc, char *argv[])
}
}
- if (((broadcast == false) && (argc > 3)) ||
- ((broadcast == true) && (argc > 4))) {
- char *preset_name = (broadcast == false)?argv[3]:argv[4];
+ if (((local_ep_not_provided == false) && (argc > 3)) ||
+ ((local_ep_not_provided == true) && (argc > 4))) {
+ char *preset_name = (local_ep_not_provided == false)
+ ? argv[3]:argv[4];
preset = preset_find_name(cfg->ep->preset, preset_name);
if (!preset) {
@@ -3164,23 +3198,32 @@ static void cmd_config_endpoint(int argc, char *argv[])
goto fail;
}
+ /* Set QoS parameters */
+ cfg->qos = &preset->qos;
+
if (cfg->ep->broadcast) {
- iov_append(&cfg->ep->bcode, bcast_qos.bcast.bcode,
- sizeof(bcast_qos.bcast.bcode));
- /* Copy capabilities for broadcast*/
- iov_append(&cfg->caps, base_lc3_16_2_1,
- sizeof(base_lc3_16_2_1));
+ /* If the endpoint is configured to be a broadcast
+ * sink or source allow the user to set a custom
+ * broadcast code or use the default one. Selecting
+ * 'no' will result in the broadcast not using any
+ * encryption.
+ */
+ if (!strcmp(cfg->ep->uuid, BAA_SERVICE_UUID) ||
+ !strcmp(cfg->ep->uuid, BCAA_SERVICE_UUID)) {
+ bt_shell_prompt_input(cfg->ep->path,
+ "Enter the broadcast code (value/auto/no):",
+ set_broadcast_code, cfg);
+ return;
+ }
+
} else {
/* Copy capabilities */
iov_append(&cfg->caps, preset->data.iov_base,
preset->data.iov_len);
- }
- /* Set QoS parameters */
- cfg->qos = &preset->qos;
-
- endpoint_set_config(cfg);
- return;
+ endpoint_set_config(cfg);
+ return;
+ }
}
bt_shell_prompt_input(cfg->ep->path, "Enter configuration:",
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 1/1] client/player: Allow the user to control BIG encryption
@ 2023-10-02 12:37 Vlad Pruteanu
2023-10-02 13:50 ` bluez.test.bot
0 siblings, 1 reply; 5+ messages in thread
From: Vlad Pruteanu @ 2023-10-02 12:37 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
iulia.tanasescu, andrei.istodorescu, luiz.dentz, Vlad Pruteanu
This commit adds support for controling the use of encryption and
setting the broadcast code. This is done as part of the endpoint.config
command. For source endpoints the encryption flag and broadcast code can
be set, while the sink supports only broadcast code setting. If no custom
broadcast code is provided, the default one will be used.
---
client/player.c | 50 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 43 insertions(+), 7 deletions(-)
diff --git a/client/player.c b/client/player.c
index d1809f24f..3a9313bfd 100644
--- a/client/player.c
+++ b/client/player.c
@@ -2792,10 +2792,10 @@ static void cmd_config_endpoint(int argc, char *argv[])
const struct capabilities *cap;
char *uuid;
uint8_t codec_id;
- bool broadcast = false;
+ bool local_ep_not_provided = false;
+ uint8_t bcode_arg_position = 0;
cfg = new0(struct endpoint_config, 1);
-
/* Search for the remote endpoint name on DBUS */
cfg->proxy = g_dbus_proxy_lookup(endpoints, NULL, argv[1],
BLUEZ_MEDIA_ENDPOINT_INTERFACE);
@@ -2815,7 +2815,7 @@ static void cmd_config_endpoint(int argc, char *argv[])
codec_id = strtol(argv[3], NULL, 0);
cap = find_capabilities(uuid, codec_id);
if (cap) {
- broadcast = true;
+ local_ep_not_provided = true;
cfg->ep = endpoint_new(cap);
cfg->ep->preset = find_presets_name(uuid, argv[3]);
if (!cfg->ep->preset)
@@ -2827,9 +2827,10 @@ static void cmd_config_endpoint(int argc, char *argv[])
}
}
- if (((broadcast == false) && (argc > 3)) ||
- ((broadcast == true) && (argc > 4))) {
- char *preset_name = (broadcast == false)?argv[3]:argv[4];
+ if (((local_ep_not_provided == false) && (argc > 3)) ||
+ ((local_ep_not_provided == true) && (argc > 4))) {
+ uint8_t offset = (local_ep_not_provided == false)?0:1;
+ char *preset_name = argv[3 + offset];
preset = preset_find_name(cfg->ep->preset, preset_name);
if (!preset) {
@@ -2837,7 +2838,42 @@ static void cmd_config_endpoint(int argc, char *argv[])
goto fail;
}
+ /* If the endpoint is configured to be a source allow
+ *the user to decide if encryption is enabled or not.
+ */
+ if (!strcmp(cfg->ep->uuid, BCAA_SERVICE_UUID) &&
+ argc > 4 + offset) {
+ uint8_t value = strtol(argv[4 + offset],
+ NULL, 0);
+
+ if (value < 2)
+ bcast_qos.bcast.encryption = value;
+ else
+ goto fail;
+ }
+
+ /* If the endpoint is configured to be a source or a
+ *sink allow the user to set a custom broadcast code.
+ *If no broadcast code is set, the default will be used.
+ */
+ if (!strcmp(cfg->ep->uuid, BCAA_SERVICE_UUID) &&
+ (argc > 5 + offset))
+ bcode_arg_position = 5 + offset;
+
+ /*The broadcast code is found at a smaller index due to the sink
+ *config not using the encryption flag parameter.
+ */
+ if (!strcmp(cfg->ep->uuid, BAA_SERVICE_UUID) &&
+ argc > 4 + offset)
+ bcode_arg_position = 4 + offset;
+
+ if (bcode_arg_position != 0)
+ for (uint8_t i = 0; i < 16; i++)
+ bcast_qos.bcast.bcode[i] =
+ strtol(argv[bcode_arg_position + i], NULL, 16);
+
if (cfg->ep->broadcast) {
+
iov_append(&cfg->ep->bcode, bcast_qos.bcast.bcode,
sizeof(bcast_qos.bcast.bcode));
/* Copy capabilities for broadcast*/
@@ -3253,7 +3289,7 @@ static const struct bt_shell_menu endpoint_menu = {
"Register Endpoint",
local_endpoint_generator },
{ "config",
- "<endpoint> [local endpoint/UUID] [preset/codec id] [preset]",
+ "<endpoint> [local endpoint/UUID] [preset/codec id] [preset] [encryption] [broadcast code=xx xx ...]",
cmd_config_endpoint,
"Configure Endpoint",
endpoint_generator },
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ 1/1] client/player: Allow the user to control BIG encryption
@ 2023-09-21 10:39 Vlad Pruteanu
2023-09-21 19:02 ` bluez.test.bot
0 siblings, 1 reply; 5+ messages in thread
From: Vlad Pruteanu @ 2023-09-21 10:39 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, silviu.barbulescu, iulia.tanasescu,
andrei.istodorescu, mihai-octavian.urzica, Vlad Pruteanu
This commit adds support for controling the use of encryption and
setting the broadcast code. This is done as part of the endpoint.config
command. For source endpoints the encryption flag and broadcast code can
be set, while the sink supports only broadcast code setting. If no custom
broadcast code is provided, the default one will be used.
---
client/player.c | 50 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 43 insertions(+), 7 deletions(-)
diff --git a/client/player.c b/client/player.c
index 42721c210..492a1ce54 100644
--- a/client/player.c
+++ b/client/player.c
@@ -2750,10 +2750,10 @@ static void cmd_config_endpoint(int argc, char *argv[])
const struct capabilities *cap;
char *uuid;
uint8_t codec_id;
- bool broadcast = false;
+ bool local_ep_not_provided = false;
+ uint8_t bcode_arg_position = 0;
cfg = new0(struct endpoint_config, 1);
-
/* Search for the remote endpoint name on DBUS */
cfg->proxy = g_dbus_proxy_lookup(endpoints, NULL, argv[1],
BLUEZ_MEDIA_ENDPOINT_INTERFACE);
@@ -2773,7 +2773,7 @@ static void cmd_config_endpoint(int argc, char *argv[])
codec_id = strtol(argv[3], NULL, 0);
cap = find_capabilities(uuid, codec_id);
if (cap) {
- broadcast = true;
+ local_ep_not_provided = true;
cfg->ep = endpoint_new(cap);
cfg->ep->preset = find_presets_name(uuid, argv[3]);
if (!cfg->ep->preset)
@@ -2785,9 +2785,10 @@ static void cmd_config_endpoint(int argc, char *argv[])
}
}
- if (((broadcast == false) && (argc > 3)) ||
- ((broadcast == true) && (argc > 4))) {
- char *preset_name = (broadcast == false)?argv[3]:argv[4];
+ if (((local_ep_not_provided == false) && (argc > 3)) ||
+ ((local_ep_not_provided == true) && (argc > 4))) {
+ uint8_t offset = (local_ep_not_provided == false)?0:1;
+ char *preset_name = argv[3 + offset];
preset = preset_find_name(cfg->ep->preset, preset_name);
if (!preset) {
@@ -2795,7 +2796,42 @@ static void cmd_config_endpoint(int argc, char *argv[])
goto fail;
}
+ /* If the endpoint is configured to be a source allow
+ *the user to decide if encryption is enabled or not.
+ */
+ if (!strcmp(cfg->ep->uuid, BCAA_SERVICE_UUID) &&
+ argc > 4 + offset) {
+ uint8_t value = strtol(argv[4 + offset],
+ NULL, 0);
+
+ if (value < 2)
+ bcast_qos.bcast.encryption = value;
+ else
+ goto fail;
+ }
+
+ /* If the endpoint is configured to be a source or a
+ *sink allow the user to set a custom broadcast code.
+ *If no broadcast code is set, the default will be used.
+ */
+ if (!strcmp(cfg->ep->uuid, BCAA_SERVICE_UUID) &&
+ (argc > 5 + offset))
+ bcode_arg_position = 5 + offset;
+
+ /*The broadcast code is found at a smaller index due to the sink
+ *config not using the encryption flag parameter.
+ */
+ if (!strcmp(cfg->ep->uuid, BAA_SERVICE_UUID) &&
+ argc > 4 + offset)
+ bcode_arg_position = 4 + offset;
+
+ if (bcode_arg_position != 0)
+ for (uint8_t i = 0; i < 16; i++)
+ bcast_qos.bcast.bcode[i] =
+ strtol(argv[bcode_arg_position + i], NULL, 16);
+
if (cfg->ep->broadcast) {
+
iov_append(&cfg->ep->bcode, bcast_qos.bcast.bcode,
sizeof(bcast_qos.bcast.bcode));
/* Copy capabilities for broadcast*/
@@ -3213,7 +3249,7 @@ static const struct bt_shell_menu endpoint_menu = {
"Register Endpoint",
local_endpoint_generator },
{ "config",
- "<endpoint> [local endpoint/UUID] [preset/codec id] [preset]",
+ "<endpoint> [local endpoint/UUID] [preset/codec id] [preset] [encryption] [broadcast code=xx xx ...]",
cmd_config_endpoint,
"Configure Endpoint",
endpoint_generator },
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-20 11:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-20 10:21 [PATCH BlueZ 0/1] client/player: Allow the user to control BIG encryption Vlad Pruteanu
2023-12-20 10:21 ` [PATCH BlueZ 1/1] " Vlad Pruteanu
2023-12-20 11:30 ` bluez.test.bot
-- strict thread matches above, loose matches on Subject: below --
2023-10-02 12:37 [PATCH BlueZ 1/1] " Vlad Pruteanu
2023-10-02 13:50 ` bluez.test.bot
2023-09-21 10:39 [PATCH BlueZ 1/1] " Vlad Pruteanu
2023-09-21 19:02 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).