Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1150343rwd; Thu, 25 May 2023 08:37:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4n2x5HHvPf/53yiQ6O+qnna0SciHZnfajoRW4t+LdWo6123QIU5ZvlAk0+rLIIp578Q8D3 X-Received: by 2002:a17:90a:7605:b0:23f:1165:b49f with SMTP id s5-20020a17090a760500b0023f1165b49fmr2137712pjk.38.1685029061840; Thu, 25 May 2023 08:37:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685029061; cv=pass; d=google.com; s=arc-20160816; b=XmL/Gj9AhVUy49gLWP+m8QLpsa1M8p7PZLIe8sSDymK4Bt40fxWIDb8be47cg0ss2X qC8RXsI/65GbB0SiZ2+Ghc6ld7e55YE1ini9uc3r3yDGvtQjXL1KijjL/giXgdi/4Rbt lljkCrkc+537X4UxFazhAaQ9mMEfHQDZGZHNIBtFObP5ywgRI+AXmNyWbISz23yQtq9z 9tNWfQY/dPQIQHDlLnVgBlv5aNSTEdEbUQSHjwD5yfntPdkIybyVzqJzr2CTwhwG0qLf 1dD/ReaA6V6fFLweVwCOhGZNBetahy/SXKH7OspsgDMpodw7ClYK5XbQLGLMNZlxdroz O3BA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BWAbnU0yLDxbBNkvU+VKimZnO3gf4rlVIppyt59m+Iw=; b=a9J/U281vZ5NUmL9eXg9lJ9L/IUaDGGhS8H5JEmPceIr7nhfvp6oP44J1dDCd5EjlR duzelj8omcUzkrK9brQ/0xY3+dCn/+QNoBQB2wTz1TwMVVcvtPs8mkReWRy20D+KStXe oTzSUoVUWxtD1KW9wo0Bnn8tqz74KzNVTgyc9cRH/OAQ7tiBXk4pSQUZAnPOZ4zSmkJB GqX5DqAkPhtx8X24eTKI1RdcHRYx5ZqSts1hFGbREHCMLKghsPbWxfRNhSSuri0tU6HM +wvYBuSY2MVa+KGQkgs9QiKTyDP5liF7ZxkdwpgCmlcbDeFA/Nq3cDyBa+eyEu45qt/w F0Kw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=LAZ7g4I1; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k130-20020a636f88000000b004faf33e2755si1361192pgc.349.2023.05.25.08.37.18; Thu, 25 May 2023 08:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=LAZ7g4I1; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241757AbjEYPfW (ORCPT + 99 others); Thu, 25 May 2023 11:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241667AbjEYPfU (ORCPT ); Thu, 25 May 2023 11:35:20 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2070.outbound.protection.outlook.com [40.107.14.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3E3AA3 for ; Thu, 25 May 2023 08:35:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JuuWsZgJakNtkhEZlelQpyFOcmEyBr4xD3/1riEDJ7nxgC9j1nrrATJ4Wnc9esof8vvqMlUSg9523UvobBfsInO0Ee25gzqdo8Oj8QFrxvw/0J/BUUWMnsAMXQ4yyTXMRxsnELjbaskKZUcJMvLDJvGJItSwMzyQdf7stI6qZfgKrwP7reg3xdSKje7yNYYFg9W80sd1Uf/6fHS7Fg8eRUX1sWUObvsjq1gJxSwVcKAf/nrkvmXS9PSxDdeUR8SX52tVJmetcW7Uvu8IhoPmOjgZDhcsaxIyJYiZhjU9UfV8CPtPQBJ5x8nzt+iuKlqqQziZ2b5oS4gJIBNbP1/hFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=BWAbnU0yLDxbBNkvU+VKimZnO3gf4rlVIppyt59m+Iw=; b=QMp8icvVGFfNzHE/S+dZi/bpXpUTND916YUSNRb6X1A6mhbrhmmUzezNGcWcM9A8NYF7yFqw037rPsWwJORDPP4/71YNfcgUUMkM+UCvb/DwI1b2Ij3CIdkVgD1Ob5yjFcudRGwIs/849NjY1jm9j6iO1sV+UwY+x0T+wAU207VWtGkIeijq7Q0HbIaSnQAAPGKbh/RFiTI7r/g77CadkqbaM4cslrnwXVMl389OE2qaZ2irXQMV1jFjuCfYXwwVH3z5071+Nj1FpsAgIn6pkuhUd4Djx7ueiqgkLA+CbFnhPXzxKo2bcgD3jYiJwA0jLBjqfZ9/vPlcCRkyuw/E5A== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BWAbnU0yLDxbBNkvU+VKimZnO3gf4rlVIppyt59m+Iw=; b=LAZ7g4I1xIGrDTOYnPDdyv4ourCI1b1V9M6xvcZjTDYonsuGItwDGhy9OrdCG/O+m+NDuq+7aSM1Rt7JCOGOkqRe/8uFPeRIqWFVQ5kSiPuhQnUXN2QtHdBcUOqJ5iMe+LFp44aQhJXMfBsG2LnISY9i7vu1XVR6yYsBK0y/kR8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5344.eurprd04.prod.outlook.com (2603:10a6:803:4b::31) by AS8PR04MB7848.eurprd04.prod.outlook.com (2603:10a6:20b:288::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29; Thu, 25 May 2023 15:35:17 +0000 Received: from VI1PR04MB5344.eurprd04.prod.outlook.com ([fe80::981d:d04a:5851:1578]) by VI1PR04MB5344.eurprd04.prod.outlook.com ([fe80::981d:d04a:5851:1578%4]) with mapi id 15.20.6411.029; Thu, 25 May 2023 15:35:17 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: Silviu Florian Barbulescu Subject: [PATCH v2 4/6] Add support for setsockopt (BT_IO_OPT_BASE) Date: Thu, 25 May 2023 18:34:50 +0300 Message-Id: <20230525153452.125789-5-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525153452.125789-1-silviu.barbulescu@nxp.com> References: <20230525153452.125789-1-silviu.barbulescu@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: AS4P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::15) To VI1PR04MB5344.eurprd04.prod.outlook.com (2603:10a6:803:4b::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5344:EE_|AS8PR04MB7848:EE_ X-MS-Office365-Filtering-Correlation-Id: ecbca499-3167-4e0b-47f1-08db5d35a3f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mz9l+BAfQ7ncrun4jadWzuWCtxwik6UJQMD//FPqEwxIA07tyDBNfGdNV+byCr5kHG8W/49mVrciCi0gAMBiEg0rSJ8ablj8z++uzhLo1XcgQ4UabzAPBmi/ERbUd3Qz0oUG27kLq6ruxi8G2gyQjbaqkH+O4Y3FrtSe/0trmYhv/RVudpUsk5Qk1vV6Z8+L7LxEwhuQv8wHrQIH6asi2GPBHbuW0CZvgSWZ6UxLblxtOWRG3JqmOA2RmdNJATXUeA3Mou6sh0XYqgubBNcja5yrNHixxIjPZd1p7kDcQmRl2TmZdLePv7gaztzhjrFLmjOXwQeKWk0vTkn+ZlLht7LD0PWiK3gCzr5bbsm8B6/FyQWoSDDbGmeKnDu9YQBHu45WU9BLP4fiZ8Wb4HHWh5rsi6UaDIqVx962FKiZQ06U8rm8VfJt/qv2AVEi8A0W3yIsMO3hDbGedp7UKp7IlSYECG0ZEp3MRTeBmwA1YFmNT4aRPcORNQ3ZFOyiT3VRZDHA59ZYoY/q0N0U9v4bHHbcWp4nETckMjDIqSIpuS5LocTfBpUSBM+e1rB+wf9rYlPFWS11bXGYDgFjgTZ7K5n++Pjkwy9KZpF2gqnPmQ45TVrFA7VsUShdxvQiXof2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5344.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(366004)(136003)(376002)(396003)(451199021)(5660300002)(36756003)(186003)(2906002)(2616005)(8936002)(6512007)(1076003)(6506007)(26005)(55236004)(478600001)(66946007)(66556008)(66476007)(6916009)(86362001)(4326008)(8676002)(38350700002)(38100700002)(41300700001)(83380400001)(316002)(52116002)(6486002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?utSGgVAFOa4QAgwXIYf/Frlp5AU5D5h3jHXZ8Z56kZMHFDD7SgC8mUYJVM6H?= =?us-ascii?Q?ZvwBh4/aSJ2VDhAGH/NreUaFhTds/J50UY4Oss28YMEUit6rRBksJcdCXXAL?= =?us-ascii?Q?Jh8CW5n6jg01JgofDoLqBQy2oCsK32+adn6Qsuz0AVTYntxGHnQHgROR3WhR?= =?us-ascii?Q?QzoL3Rp679lw/9CnTsZKwnYtpi/Cuu27kYl+eOfXm2rz4fWOMrBtlglc3HV0?= =?us-ascii?Q?2867y+afmYv/ZVh3rUia/X7jtoQRe+pKwpXUK7duwOod0Hj6DRIK107sH2FX?= =?us-ascii?Q?D4QpnClAmBx2//qhOQB/BCbJomUDgCa78P+jmoXtVBjEKyzbcfYw88gaReHu?= =?us-ascii?Q?DXzdJ0KNbCkyS4lvbYtKt9VGOL6BVblrXI4LidO+ZubTUht+emU3yAxXUC6T?= =?us-ascii?Q?d1A1q7fnvkaJnnpSiY1jLvMa2Lk+A+Ikewdl01QiYU2ZBEb/ffhf/00eMGZi?= =?us-ascii?Q?fKGWAejye+qwMI9q2WkzEOZODB359BtlqtDm5bIEfVAEODnw0qFNwsG3V49L?= =?us-ascii?Q?nIj8eVXKHfHxuwpD/mlV1Zr4knaOrWoPBDIHJVAlN02OHED/QFeYRhfE2w3A?= =?us-ascii?Q?LAExrDSYud4J6vF2lwtHpdU0kT5uat5CGa7P8VQKjqqZvW2tbQKfN0A3LZRR?= =?us-asc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geVeuweAB0nb8?= =?us-ascii?Q?6w2U1/AMJuo82IW4ep/URbCv4dOZhna0TDw52SFZnAc+J66OTQ3eLKNzmIvo?= =?us-ascii?Q?aQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecbca499-3167-4e0b-47f1-08db5d35a3f8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5344.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2023 15:35:17.0460 (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: 7HdmAu2cUdXGiCbDvl4mwPW6zqyzJDsnm/oRwSNEljLYzj4noOZD3wLqnP6DNtihIo6w8DHPfXoTE5vSEr3PY6jB3UjmlY/EaaYKnBS6Uh0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7848 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 * 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