Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16640410rwd; Mon, 26 Jun 2023 12:56:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6fCffdxJwEarAuAW+mw/6JrLKN80not1YMLSed31jNC4lb80Tlsi18Kqs9ZVz2S5XSZ9AI X-Received: by 2002:a17:906:64db:b0:98d:5ae2:f1c with SMTP id p27-20020a17090664db00b0098d5ae20f1cmr9493574ejn.34.1687809403677; Mon, 26 Jun 2023 12:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687809403; cv=none; d=google.com; s=arc-20160816; b=NpGL4HBrnfa0DF8OquvtW7BdixRQwHvJhH1qojyrK2po4uqcJc0p5IxHgdIsp93/PA cpNquevD5IDAn1Ejc9sOfUMoB3vAiueL4zZFbyQr8lGjFVTkaHCrT1M1+S6zK9folyNs A/es6XMY0i6hypFXZgwiceoQhIt4CfogRwxg1OQJZdUBYCVsYltvGdUe1gSO0jpYZUif 2htRNWXFURYRhOjDgMuLdIsKr16tCv7YvrPjlgivVAt+Jr7p7KzcH0z/QlwbNhFuPdhg BRPpkm9M4Xv/efG/Ui/AEXoz30g1YZIvUL8xoDm8h9pPb6ghYnbSd7HvBhcKAmoAcO2J MyTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HJHr43ETmdQF5k4COj21CqvW11WxmS13eatfPxe+o28=; fh=xJv+Klyytov3KGiQwAoOi4HC6j6hVaI+tOcmqPTIfBg=; b=OVoKnJJy9YTK7GbLzxkReYYgXqQfDi40e0qdvcbOVOMJB8ze+pF+HDbL2gh/ru/NQ7 vHYkWp/ync+O2QvUmQbFXLSxG6nSyC4mkxL5U8qSPPv7b1cTu5ZNS4F5hyDwR6imwDjc +D7Zz2hSQw37Mc0p5OJoA3LGAhVh7hktDSwOvplARE+9Sd2kGOVv8bJpK9lIEt6WX1WR RpTCj2bkGsuHhkL+ZOudebg/UvQf5i7Zi3LlACfulKavxyGNB7YvV4/+e3C4x1rggyEf Yr9fpgFdfeootefetNLDKs2K7x32be//VloLCWRoPXaDKid4MegYeIGg6YxwzIfZFbGg 5tYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KjF621Y0; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss13-20020a170907038d00b00990dbce26f3si1525775ejb.122.2023.06.26.12.56.20; Mon, 26 Jun 2023 12:56:43 -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=@gmail.com header.s=20221208 header.b=KjF621Y0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbjFZTzX (ORCPT + 99 others); Mon, 26 Jun 2023 15:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjFZTzW (ORCPT ); Mon, 26 Jun 2023 15:55:22 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 371CDE7B for ; Mon, 26 Jun 2023 12:55:21 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b69ea3b29fso25356911fa.3 for ; Mon, 26 Jun 2023 12:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687809319; x=1690401319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HJHr43ETmdQF5k4COj21CqvW11WxmS13eatfPxe+o28=; b=KjF621Y0G0nPN5zvuuDxOXsN2eRlfqnOncmLcDXZW9LSTvM5XBa/mYwU/4hYw7BEU8 R7h2JXnIZFUIkv7afVcbJd86FJHeAlLtfr0ZmuyDSygH84x+Vrl81nFcxF2mkZmdgq+y utTrc5YRxeMkA5ywop0CCr+cx11FW0rzJldMfSFRLHOD/ppswSx4GgWWNs1Kj4sUeuy5 1JrWI09ZD2cXj2WUjsVU58Mttu0LCvNTC2HYfYq96RJhAyjycPfwD0GJRy8kAQ/a0c/0 4CFZlLAobDuIS1zSaOLKPsAtmnBBxdBWa5CDnJGNFdN95zd1aku2Q6u00cWSZ8aDEaVe Fu8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687809319; x=1690401319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HJHr43ETmdQF5k4COj21CqvW11WxmS13eatfPxe+o28=; b=gQruutj3JJMBqhFT7KZwKszEPylAqeNoHw2DSxjXDfWy3SYN4hb0DTFOSegsJqIzdD BbSD8dBnNQckIpSoJwtrCYJtwhyghnN622nTqu8ZV+DW4yjIbO50PeQOnv/8HYuZdvqF XWnd/1YgwBL7RRSi6M6uO8JE0NjgAvuYxwvBTFLC36K5mofNv3jj85yVdCoqN6XYI80g iv1g22zw34Y/mthoji5hKkXIjiSET6VuqiT1YGKsUtGZVRUZx/Uu0CgnnYNEMlHVHW0I 5dSRJH58eMiF27B1qLoL7iPMVIkXCOe+O87WCXksVTdkLxXthHO5ZxnRPGrOjsU7zOno LctA== X-Gm-Message-State: AC+VfDzppuXwJP6m/h8f+UJCiI7+ykrJ52++Y0xR0bICcPyKUMGLlmlG 7NHISGkSonaY5V+KXW9sworNv4xG84heNBtTkhQ= X-Received: by 2002:a2e:3508:0:b0:2b4:5b9c:a019 with SMTP id z8-20020a2e3508000000b002b45b9ca019mr18097522ljz.8.1687809319228; Mon, 26 Jun 2023 12:55:19 -0700 (PDT) MIME-Version: 1.0 References: <20230623074657.16618-1-iulia.tanasescu@nxp.com> <20230623074657.16618-2-iulia.tanasescu@nxp.com> In-Reply-To: <20230623074657.16618-2-iulia.tanasescu@nxp.com> From: Luiz Augusto von Dentz Date: Mon, 26 Jun 2023 12:55:07 -0700 Message-ID: Subject: Re: [PATCH BlueZ 1/2] btio: Add option for binding iso broadcast address To: Iulia Tanasescu Cc: linux-bluetooth@vger.kernel.org, claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Iulia, On Fri, Jun 23, 2023 at 1:14=E2=80=AFAM Iulia Tanasescu wrote: > > This adds the BT_IO_OPT_ISO_BC_ADDR btio option, to allow the user > to set the iso_bc field of an address at bind. > > --- > btio/btio.c | 56 +++++++++++++++++++++++++++++++++++++++++++---------- > btio/btio.h | 3 ++- > 2 files changed, 48 insertions(+), 11 deletions(-) > > diff --git a/btio/btio.c b/btio/btio.c > index b68bfb14c..00e46abb0 100644 > --- a/btio/btio.c > +++ b/btio/btio.c > @@ -16,6 +16,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -71,6 +72,8 @@ struct set_opts { > uint16_t voice; > struct bt_iso_qos qos; > struct bt_iso_base base; > + struct sockaddr_iso_bc iso_bc_addr; > + bool bc_addr_set; I guess we could just check for BDADDR_ANY instead of using a dedicated fie= ld. > }; > > struct connect { > @@ -771,21 +774,40 @@ static int sco_bind(int sock, const bdaddr_t *src, = GError **err) > } > > static int iso_bind(int sock, const bdaddr_t *src, uint8_t src_type, > - GError **err) > + struct sockaddr_iso_bc *bc_addr, > + GError **err) > { > - struct sockaddr_iso addr; > + struct sockaddr_iso *addr =3D NULL; > + size_t addr_len; > + int ret =3D 0; > > - memset(&addr, 0, sizeof(addr)); > - addr.iso_family =3D AF_BLUETOOTH; > - bacpy(&addr.iso_bdaddr, src); > - addr.iso_bdaddr_type =3D src_type; > + if (bc_addr) > + addr_len =3D sizeof(*addr) + sizeof(*addr->iso_bc); > + else > + addr_len =3D sizeof(*addr); > + > + addr =3D malloc(addr_len); > + > + if (!addr) > + return -ENOMEM; > > - if (!bind(sock, (struct sockaddr *) &addr, sizeof(addr))) > - return 0; > + memset(addr, 0, addr_len); > + addr->iso_family =3D AF_BLUETOOTH; > + bacpy(&addr->iso_bdaddr, src); > + addr->iso_bdaddr_type =3D src_type; > > + if (bc_addr) > + memcpy(addr->iso_bc, bc_addr, sizeof(*bc_addr)); > + > + if (!bind(sock, (struct sockaddr *)addr, addr_len)) > + goto done; > + > + ret =3D -errno; > ERROR_FAILED(err, "iso_bind", errno); > > - return -errno; > +done: > + free(addr); > + return ret; > } > > static int sco_connect(int sock, const bdaddr_t *dst) > @@ -980,6 +1002,11 @@ static gboolean parse_set_opts(struct set_opts *opt= s, GError **err, > case BT_IO_OPT_BASE: > opts->base =3D *va_arg(args, struct bt_iso_base *= ); > break; > + case BT_IO_OPT_ISO_BC_ADDR: > + opts->iso_bc_addr =3D *va_arg(args, > + struct sockaddr_iso_bc *)= ; > + opts->bc_addr_set =3D true; > + break; > case BT_IO_OPT_INVALID: > case BT_IO_OPT_KEY_SIZE: > case BT_IO_OPT_SOURCE_CHANNEL: > @@ -1305,6 +1332,7 @@ parse_opts: > case BT_IO_OPT_VOICE: > case BT_IO_OPT_QOS: > case BT_IO_OPT_BASE: > + case BT_IO_OPT_ISO_BC_ADDR: > default: > g_set_error(err, BT_IO_ERROR, EINVAL, > "Unknown option %d", opt); > @@ -1460,6 +1488,7 @@ static gboolean rfcomm_get(int sock, GError **err, = BtIOOption opt1, > case BT_IO_OPT_VOICE: > case BT_IO_OPT_QOS: > case BT_IO_OPT_BASE: > + case BT_IO_OPT_ISO_BC_ADDR: > case BT_IO_OPT_INVALID: > default: > g_set_error(err, BT_IO_ERROR, EINVAL, > @@ -1571,6 +1600,7 @@ static gboolean sco_get(int sock, GError **err, BtI= OOption opt1, va_list args) > case BT_IO_OPT_VOICE: > case BT_IO_OPT_QOS: > case BT_IO_OPT_BASE: > + case BT_IO_OPT_ISO_BC_ADDR: > case BT_IO_OPT_INVALID: > default: > g_set_error(err, BT_IO_ERROR, EINVAL, > @@ -1660,6 +1690,7 @@ static gboolean iso_get(int sock, GError **err, BtI= OOption opt1, va_list args) > case BT_IO_OPT_FLUSHABLE: > case BT_IO_OPT_PRIORITY: > case BT_IO_OPT_VOICE: > + case BT_IO_OPT_ISO_BC_ADDR: > case BT_IO_OPT_INVALID: > default: > g_set_error(err, BT_IO_ERROR, EINVAL, > @@ -1790,6 +1821,7 @@ static GIOChannel *create_io(gboolean server, struc= t set_opts *opts, > { > int sock; > GIOChannel *io; > + struct sockaddr_iso_bc *iso_bc_addr =3D NULL; > > switch (opts->type) { > case BT_IO_L2CAP: > @@ -1836,7 +1868,11 @@ static GIOChannel *create_io(gboolean server, stru= ct set_opts *opts, > ERROR_FAILED(err, "socket(SEQPACKET, ISO)", errno= ); > return NULL; > } > - if (iso_bind(sock, &opts->src, opts->src_type, err) < 0) > + if (opts->bc_addr_set) > + iso_bc_addr =3D &opts->iso_bc_addr; > + > + if (iso_bind(sock, &opts->src, opts->src_type, > + iso_bc_addr, err) < 0) > goto failed; > if (!iso_set_qos(sock, &opts->qos, err)) > goto failed; > diff --git a/btio/btio.h b/btio/btio.h > index e9a8a01a3..516220504 100644 > --- a/btio/btio.h > +++ b/btio/btio.h > @@ -46,7 +46,8 @@ typedef enum { > BT_IO_OPT_VOICE, > BT_IO_OPT_PHY, > BT_IO_OPT_QOS, > - BT_IO_OPT_BASE > + BT_IO_OPT_BASE, > + BT_IO_OPT_ISO_BC_ADDR, > } BtIOOption; > > typedef enum { > -- > 2.34.1 > --=20 Luiz Augusto von Dentz