From patchwork Thu Aug 29 13:25:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13783245 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2044.outbound.protection.outlook.com [40.107.104.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 272FA1AB53E for ; Thu, 29 Aug 2024 13:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724937926; cv=fail; b=NgndMxfzTSMpJX164Fz+F98OqJeiDt+M3TXS98qrgwXzz1AZiOH0dI5tq1znsb3eehUppAOyU0C2JOU7FIaM7mxLb5TW4G0W9WomIuO/gJ3nlkx+4+G41EXa3smZElsPNgyxYsPS/sPde3E+8PXEjhqh+lON1fwAfMWKu0Jio2M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724937926; c=relaxed/simple; bh=vzcXiqsU+vTi4T4eYmvv57vuHJytrPz0x+S75rlspjE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h30/bkuwsE0d/GB2yb2XlCGyvyHuIcPcPYgEpYK3H72s9ki9d/M7nvqYaAQEulEu37vq+a1XQFjwXbpBnFMhx+oZKnhI/WF76EYt+bRydI1I+dEfLtWkB1DHZwu38UEFvahThB0wSGucRmNjfSX/a1ZKmRt01dxBBG+kin/7/qI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bXMv+Y/h; arc=fail smtp.client-ip=40.107.104.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bXMv+Y/h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hnjkCHAspmp/+LocL4i2bJuzRB5pXKqCcthHNH2Z+BK5jbZ5QauByLgNDgkh+IJtfQt17hJYT9Q2ri0tsCQ1/2Bw23QuFVCQglbMURj6iomIA0SK2UTpSYwJE+3TPw9xqTY+nlaCeS1OrET7KQY9SC+0ZGF6vvIjxlgIbIeCek/9xjEY3QSo6cALPvwxTh/4JXbzWmYU0Bdh0A4rYL3jc0P3fLacA7klwgD2C3DUyFWKjbMViCPgNqZkpZlTIvLRAWozdS6MZeubtzKOvXlmar7r+AkhW0GKd1kafmhiEvi9RDYEbJ2s5uGrWRWLYnSZ5/qfb92l9Hwnu3YY8APzxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HCeCLYsLifOStSe+GzvVE1Rm6IV/nV2c2K4pzg2w420=; b=JvsH6JV9zbUkjK7Amk0hPJ49VhvLBE9mZjDbNat8xjisNPu6Q3JHJWlngrku5Juyaw2rFkXS+v0CFpsgzF77QPhT620w3bdUFBxsqEvulpjTD8Y6Aa7TkG/RtmjtXmXhmuF6Edz6Y+Oo7gzl/jK7Jg6kLgjJWtzKkI3G1sP+WSCeb2c8/45tgUClIIa10yW187DwWQ3k8QS+KtrvAMiYUCT+2hqn4dlL5spiPhDNnLPcqAU0bHpbeQKYz2uzDRXEd6i0wmmcIG7yoQzniK/IKw3JDaktZNCfg3jovmO0jhIBA7I3ojXa96PrGj4227mjdxyXpWGAzCEbocY0HNmbXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HCeCLYsLifOStSe+GzvVE1Rm6IV/nV2c2K4pzg2w420=; b=bXMv+Y/hBrp/9A1sMuxZsa7Cy0VRHGyFX+ARsFnu7+ne5kERJEjaLNYjNqd1bkDRzOj/uPq9b4nHCoOT+GV91AzoaNVQ3AZk4sONXzj0bkRNhbuVKgy7cL4o6DREjb7Je5Rf6slH+WU3D9IPjB8KI8vGiYPMBcsQyOb0pPPQGxz4817oczRG7Lo4LCyYwkvTYLTsKh5TBO00g2lhmAPSWcaFiBzvOLVC/R3iIyEyGZ+vmktb54McorMp0L5XZ/mBfheyPqNWOUgoai3UOqy39rzKFdRLkYQ0cIF8tvTErdE3l1PMJr2lpLmPhUgWvs+rC2sz2vdXhn2sQ8C3tNFzXA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AS4PR04MB9385.eurprd04.prod.outlook.com (2603:10a6:20b:4e8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 13:25:18 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 13:25:18 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 1/2] client/assistant: Enter Broadcast Code as string Date: Thu, 29 Aug 2024 16:25:06 +0300 Message-Id: <20240829132507.4545-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829132507.4545-1-iulia.tanasescu@nxp.com> References: <20240829132507.4545-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR02CA0181.eurprd02.prod.outlook.com (2603:10a6:20b:28e::18) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AS4PR04MB9385:EE_ X-MS-Office365-Filtering-Correlation-Id: 0da19dd2-4d18-4c9e-82f6-08dcc82e065a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: ATgno3CIwQyOW1iYcsxKycdojxnRLi8nJQQXPiQSAN4vsHqiEOPP0XVomTLhcK9OWlCYJbj5mP6AZeJ0mZEc3Cuscsft3Uh/o5/+gl6SL6IKYHIcfKnuNNApABK1DkiiltLaLb/Wrw6A0+7LDT6/C2sjZDIyGPtaRXIy3XI+a/QtKdAEBIiCEHcfVwNzAQSLqLO0e1vEe3iwKZ11Afsv5kh0kprLYygKeiMf8wTddTHmapx7z/+F98/N1iwXD1uA5Pr2KiSu0fIqQ719wY04JZtIBBlNBiOU3RYhoAhKltcABspEeRd5Dg1EbecAwBh1LZwFG2WG4LhsJ961z3c+B6pwCxd6LM79GpF8x7x6cCjMAUmHUhCzXEzMex+wj54M9fBCwVmf8uKCWfMv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YYhp4/frxEGbhCpik3Gjj0Bw6UuPNfdHeG2gQzXxMt65DQ4fvYGQlGnqb4HQWI4Z4Gd8Dd+Cwqbn96xj96DGxEEg01ls38Y1iqv7bwr0IV5R9Xvo5qo/NBC8OTJtxcHzhOHy1rru0nbTjhlmt2LBCIQFDJF4GGn7gTZBH7JiyF6C13huPnqoU8OMnbTU0TrzdJmTEDqTg220G9Vd3wqK+kM0dEj++Q93DyOOKulTFkTE9g4TYS2heVXLYRwY45W2ZAQ7T0PE8HsX4ZaVQgUUcmyzeFDQ9adCUZubhgTeuJKQ/sAXiCGb26IGhNYCIPcydJ79hB2jdbFhBIzrIcdHBYQNKK0yhrzlUHfBMGGSzkS3viNdxWZGxr7+BPT/B/kEwLTtdD2C0vMPKfCejI1SaTzcLv6/44EtdK9L/2wyRMA4NFOkSKlcDuEczLE8wWgq1kuXzzoe/+kvW+4r6c4IITmojYzrqVtU639TgzPOD3phFAuxjSvQPV7+NQSnb1H2JIE2s+c/BE5P10GY2uReIHMUoyh/GaN5SIJj1zxkFXPofsMD9EMtgLVGQDS5JBVwH7mh1cUV4xaQDJArmDUoxoz1obEqX1MEFOY3sHv8EsaEZW+kMuKOuUavb5cnqUgGhob0d2bvy3PuBPFJL2w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0da19dd2-4d18-4c9e-82f6-08dcc82e065a X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 13:25:18.6035 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EWiwUDUxtKrgbV3IFUKNyQfxrIZFnzTXWi6cqJHF7ksUeiFDGtYcS6lLYCKiU7dmguKEo9x5MMoJHhJKDcb5pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9385 Currently, the user sets the Broadcast Code as an array of bytes when prompted from the assistant submenu. However, the Bluetooth Core Specification requires that, on the UI level, the Broadcast Code shall be represented as a string (Vol 3, Part C, 3.2.6). This commit makes the Broadcast Code be parsed as a string from the assistant prompt. The bluetoothctl log below shows a Broadcast Assistant pushing an encrypted stream to a peer: client/bluetoothctl [bluetooth]# [CHG] Controller 00:60:37:31:7E:3F Pairable: yes [bluetooth]# AdvertisementMonitor path registered [bluetooth]# scan on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F [bluetooth]# connect 00:60:37:31:7E:3F Attempting to connect to 00:60:37:31:7E:3F [CHG] Device 00:60:37:31:7E:3F Connected: yes [00-60-37-31-7E-3F]# Connection successful [00-60-37-31-7E-3F]# [NEW] Device 19:9A:7A:71:E5:8B 19-9A-7A-71-E5-8B [00-60-37-31-7E-3F]# [NEW] Assistant /org/bluez/hci0/src_19_9A_7A_71_E5_8B/dev_00_60_37_31_7E_3F/bis1 [00-60-37-31-7E-3F]# assistant.push /org/bluez/hci0/src_19_9A_7A_71_E5_8B/dev_00_60_37_31_7E_3F/bis1 [Assistant] Enter Metadata (auto/value): a [Assistant] Enter Broadcast Code (auto/value): Borne House [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_19_9A_7A_71_E5_8B/dev_00_60_37_31_7E_3F/bis1 State: pending [00-60-37-31-7E-3F]# Assistant /org/bluez/hci0/src_19_9A_7A_71_E5_8B/dev_00_60_37_31_7E_3F/bis1 pushed [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_19_9A_7A_71_E5_8B/dev_00_60_37_31_7E_3F/bis1 State: requesting [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_19_9A_7A_71_E5_8B/dev_00_60_37_31_7E_3F/bis1 State: active The btmon log below shows the way the Broadcast Code string is converted into a byte array and sent to the peer via GATT: bluetoothd[6013]: < ACL Data TX: Handle 0 flags 0x00 dlen 28 ATT: Write Command (0x52) len 23 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[21]: 02018be5717a9a1900db5e3a02ffff010100000000 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 19:9A:7A:71:E5:8B Source_Adv_SID: 0 Broadcast_ID: 0x3a5edb PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 > ACL Data RX: Handle 0 flags 0x01 dlen 2 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 01018be5717a9a1900db5e3a0201010000000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 19:9A:7A:71:E5:8B Source_Adv_SID: 0 Broadcast_ID: 0x3a5edb PA_Sync_State: Synchronized to PA BIG_Encryption: Broadcast_Code required Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000000 bluetoothd[6013]: < ACL Data TX: Handle 0 flags 0x00 dlen 25 ATT: Write Command (0x52) len 20 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[18]: 040142c3b8726e6520486f75736500000000 Opcode: Set Broadcast_Code (0x04) Source_ID: 1 Broadcast_Code[16]: 426f726e6520486f7573650000000000 > ACL Data RX: Handle 0 flags 0x01 dlen 2 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 01018be5717a9a1900db5e3a0202010100000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 19:9A:7A:71:E5:8B Source_Adv_SID: 0 Broadcast_ID: 0x3a5edb PA_Sync_State: Synchronized to PA BIG_Encryption: Decrypting Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 --- client/assistant.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/client/assistant.c b/client/assistant.c index 77fb78329..16e94664a 100644 --- a/client/assistant.c +++ b/client/assistant.c @@ -255,28 +255,32 @@ static void push_reply(DBusMessage *message, void *user_data) static void assistant_set_bcode_cfg(const char *input, void *user_data) { struct assistant_config *cfg = user_data; - char *endptr; - uint8_t *bcode = cfg->qos.bcast.bcode; if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) { - memset(bcode, 0, BCODE_LEN); + memset(cfg->qos.bcast.bcode, 0, BCODE_LEN); } else { - bcode[0] = strtol(input, &endptr, 16); + if (strlen(input) > BCODE_LEN) { + bt_shell_printf("Input string too long %s\n", input); + goto fail; + } - for (uint8_t i = 1; i < BCODE_LEN; i++) - bcode[i] = strtol(endptr, &endptr, 16); + memcpy(cfg->qos.bcast.bcode, input, strlen(input)); } if (!g_dbus_proxy_method_call(cfg->proxy, "Push", push_setup, push_reply, cfg, NULL)) { bt_shell_printf("Failed to push assistant\n"); + goto fail; + } - free(cfg->meta); - g_free(cfg); + return; - return bt_shell_noninteractive_quit(EXIT_FAILURE); - } +fail: + free(cfg->meta); + g_free(cfg); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); } static void assistant_set_metadata_cfg(const char *input, void *user_data)