Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp88759rwb; Tue, 6 Dec 2022 17:44:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf72WZ915A1xqnuQ8cTREwuKy3lBv/Xj+TIl9CQX2dBDhmvMZf0/msysEe4mQZWwSj8BTq2c X-Received: by 2002:a63:5c1:0:b0:478:9809:cf15 with SMTP id 184-20020a6305c1000000b004789809cf15mr16616969pgf.12.1670377466083; Tue, 06 Dec 2022 17:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670377466; cv=none; d=google.com; s=arc-20160816; b=C6jFdbG+oyHrYz3hl/aRuKnbvDWK/0AoaLYaXzpjPB23QRkninqwLBnEvR9zQGBeiT TMp0DFNt6a1XNsaYGTXlcKeQlQKyDwHbYqiETm3nnY3Um5xNUNfnmQvNRrvcegtcXDdP ++8o+Ly9ZOoLtObYJD/q7LLA38ynIDkfxLGYWh/UYdIx60SlXzsaHXnV7ghsnzHq99r7 hu9lRU1LMSUNheM4LVbuHTEPy7/Wgmw7CTROW1cv6urTUTHH1gFdQGiQIDhz0kfDt93Z qg46iPrmCWZ6gZAiWkwCCr1Ghqa/gbX2siKjxMDqTGeRJoY4vSOJbQ9CUOCiG30wDFIL Epsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=F99bIoVtHG8cjb55LqZzKd/PjrOlVr7ynteymuxY+mc=; b=SgTq48wIW+DXz8OGwpcQiST1CM2YOxqPAJRFtOK1GRJlrq212MKlXfDVDxzsNqdKWz 2r6CFCpwZyAP8pjz1ij3An5hREa3XJSxM+QG3HxiXty8MroiVlEK9ki4impjaQ4sk/7X 0d7iS4HzxjemERNbR5IWSM/az8D3FRvG5uoXy/ncNa8adDMQxe4vbIdzimu5TG33S9fT zUnlPX2C9YFtkYBZHr6xY1if3fNjOu6TG1TFwdz/hGd7M4PwAnbbhvMbAi1jYmEOLHpA g5FowA5dLiIrw2TgYhD2SKKvcs8jRL77lgkuivcOsBxsGQihtehFncxeE30v2ZhTKYPl ZYqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IuXFdMlM; 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 u6-20020a170903124600b00178431e112asi21231084plh.449.2022.12.06.17.44.11; Tue, 06 Dec 2022 17:44:26 -0800 (PST) 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=20210112 header.b=IuXFdMlM; 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 S229866AbiLGBfu (ORCPT + 99 others); Tue, 6 Dec 2022 20:35:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbiLGBft (ORCPT ); Tue, 6 Dec 2022 20:35:49 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDE74B9A1 for ; Tue, 6 Dec 2022 17:35:48 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so73832pjj.2 for ; Tue, 06 Dec 2022 17:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=F99bIoVtHG8cjb55LqZzKd/PjrOlVr7ynteymuxY+mc=; b=IuXFdMlMhsBhY/YLx5VNbAwQypv5EM0iNmdOa03m9eNyHxEl/Ugay9JLfQO4QRD/E6 cgtMNanN4YL99RU55KALSdk0lPeLhQMZRb0oVsyU1nxE5/j1wmKc0RgO78n/PH1wSnL0 wca9rT4kmgUsdwlqDU5posoxG4Giy2TY0ZwuD4IeuhGTotGQfZvIZKLOkenewoWfyRen 9qQHAGHbnwVKLgT1JNnXSO9r0SzUKEt6KtLzwpA4VChPLHVdMCjVtZJa/wv5iukVGfuu WcJ0jM1SQVNPBrM3jnzQlhHdbTpeHCsx71d30wja/yz4YoWcXZCOYt6DSiWrg1bxgYc+ 3wcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=F99bIoVtHG8cjb55LqZzKd/PjrOlVr7ynteymuxY+mc=; b=Judd0qiiQ7wtBwZF51kDbaHTvkmk/HJS+j6PQKd4QWOKQp+sT6nebxloWijmX9Jnxu ZhsFxfll4aEB8GFbtbmdIg80Ky+2sAtnuxk7YV8t1Q115/4Mr22ZBUxNfypf5SCClrmH wVGWafHnLtp3az256O8czxU3LmopZFiAkXf9h9jWRnCxrdXjaBxu4XJnKz+HUbWrZZow S0tbmurH5FrDSnLOv5Jx+pqeEgKSmEK5agol3RNRaOFNchmvResoRX8w7Dd0aUnCNw18 hcDA20uLEwswjRpG42M7WC5qGPcQcc8dTGHZ1l7KynkT97YSfUlnU1Pw+LAas5C34jLC xa2g== X-Gm-Message-State: ANoB5pkDl23v+36w5VSBBhx1NBEkvIt9cLP+pm7zN3Kl6aqxoQYNyAtP IZC0ERzZpj3KcXD90GqpGLM7rs/htiCF09Z2 X-Received: by 2002:a17:903:2345:b0:189:cca6:3969 with SMTP id c5-20020a170903234500b00189cca63969mr16203635plh.88.1670376947940; Tue, 06 Dec 2022 17:35:47 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id p2-20020a170902780200b001869394a372sm751077pll.201.2022.12.06.17.35.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 17:35:47 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/2] bthost: Add callback to accept ISO connections Date: Tue, 6 Dec 2022 17:35:45 -0800 Message-Id: <20221207013546.4162481-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 From: Luiz Augusto von Dentz This enables setting an accept callback which can return reject reason if the connection shall not be accepted. --- emulator/bthost.c | 21 ++++++++++++++++++--- emulator/bthost.h | 5 +++-- tools/iso-tester.c | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/emulator/bthost.c b/emulator/bthost.c index b05198953506..3cce4666c4e7 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -224,6 +224,7 @@ struct bthost { void *cmd_complete_data; bthost_new_conn_cb new_conn_cb; void *new_conn_data; + bthost_accept_conn_cb accept_iso_cb; bthost_new_conn_cb new_iso_cb; void *new_iso_data; struct rfcomm_connection_data *rfcomm_conn_data; @@ -1465,12 +1466,25 @@ static void evt_le_cis_req(struct bthost *bthost, const void *data, uint8_t len) { const struct bt_hci_evt_le_cis_req *ev = data; struct bt_hci_cmd_le_accept_cis cmd; + struct bt_hci_cmd_le_reject_cis rej; if (len < sizeof(*ev)) return; - memset(&cmd, 0, sizeof(cmd)); + if (bthost->accept_iso_cb) { + memset(&rej, 0, sizeof(rej)); + rej.reason = bthost->accept_iso_cb(le16_to_cpu(ev->cis_handle), + bthost->new_iso_data); + if (rej.reason) { + rej.handle = ev->cis_handle; + send_command(bthost, BT_HCI_CMD_LE_REJECT_CIS, + &rej, sizeof(rej)); + return; + } + } + + memset(&cmd, 0, sizeof(cmd)); cmd.handle = ev->cis_handle; send_command(bthost, BT_HCI_CMD_LE_ACCEPT_CIS, &cmd, sizeof(cmd)); @@ -2893,9 +2907,10 @@ void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb, bthost->new_conn_data = user_data; } -void bthost_set_iso_cb(struct bthost *bthost, bthost_new_conn_cb cb, - void *user_data) +void bthost_set_iso_cb(struct bthost *bthost, bthost_accept_conn_cb accept, + bthost_new_conn_cb cb, void *user_data) { + bthost->accept_iso_cb = accept; bthost->new_iso_cb = cb; bthost->new_iso_data = user_data; } diff --git a/emulator/bthost.h b/emulator/bthost.h index 2cfdef766e4d..c424444763c4 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -44,13 +44,14 @@ typedef void (*bthost_cmd_complete_cb) (uint16_t opcode, uint8_t status, void bthost_set_cmd_complete_cb(struct bthost *bthost, bthost_cmd_complete_cb cb, void *user_data); +typedef uint8_t (*bthost_accept_conn_cb) (uint16_t handle, void *user_data); typedef void (*bthost_new_conn_cb) (uint16_t handle, void *user_data); void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb, void *user_data); -void bthost_set_iso_cb(struct bthost *bthost, bthost_new_conn_cb cb, - void *user_data); +void bthost_set_iso_cb(struct bthost *bthost, bthost_accept_conn_cb accept, + bthost_new_conn_cb cb, void *user_data); void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr, uint8_t addr_type); diff --git a/tools/iso-tester.c b/tools/iso-tester.c index 269fbe2d6c62..d29f35695a00 100644 --- a/tools/iso-tester.c +++ b/tools/iso-tester.c @@ -752,7 +752,7 @@ static void setup_powered_callback(uint8_t status, uint16_t length, continue; if (isodata->send || isodata->recv || isodata->disconnect) - bthost_set_iso_cb(host, iso_new_conn, data); + bthost_set_iso_cb(host, NULL, iso_new_conn, data); if (isodata->bcast) { bthost_set_pa_params(host); -- 2.37.3