Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3466369pxb; Mon, 18 Oct 2021 16:11:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUXxZgDJcug9FL3X+42vz7MRfQLR4Hn1/GFpfZ7KVmVxFiOQlYGBX0ZK6t1APRbJyOzflY X-Received: by 2002:a17:902:b111:b0:13f:48e1:9bc4 with SMTP id q17-20020a170902b11100b0013f48e19bc4mr30013078plr.53.1634598665145; Mon, 18 Oct 2021 16:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634598665; cv=none; d=google.com; s=arc-20160816; b=qzPfoIz0kNUAro5AzIuh1gmr7qjCJIBtQheWM9MQ4EcSoRz6xtKpNZliYmwao4+rnd ToAVH9lNYEyv4qdTXt0MudZfDOwXLwwPTvDWKjD46WAdQh9Io3Z+VfVYgDWdkbKsO43j on48szPvAtzmGFAh5i/Rt1NICyTmdKYyEkucZw9iWl6Nv0nOWderhk0+ok9C2sxw8Nzm kPPbHldeMf/K89GSYwCN1ph1VDDuv1fvk5AmLrNc3q05/dEgi+hzhGWaYhy5kXauSW+z 1kE9I2gC8OzzikdcPJh1j0mFo/I8A1pb3o5DGXHdNWvC+K3Lnq574frMv17T5vzInBPn yUsQ== 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=+HVrtpGhtDU4jb4AP5mkfcwHZNRHWdP4BGOrKQYxClQ=; b=rlT9qXT3re1v6i2rqQ3bsTtJ9UR/l10ZTkaljU/paZZYyqY8lGUVwT4XlBkclF7q42 tqM6bxhZkU0QLnXDYFKgwmIn7Isd3xwcD4uD6+4Te1xygYBKEPqzAlZHQInjLjSOTnny yd++zUOOLoNkqQVPf88d6QksqgWY0ycsed2zEsBa1Fb+CpYn8CJF5+ssR0ekp2zF8sTx lcI06TLqO/DisPcjoZK33Se4zbyF/k7d6SwV/2uzNwbSDXOc38gZxcrBEy0Vw4XQ1rnH 2lKnk6oMcOX+6Dt0pfEsLaq43vPsxqRSZ78eO/k79z3IErk5wzyM/isDa/kIvfpoNNGz Y35w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iIEQRaCP; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d131si5875162pgc.376.2021.10.18.16.10.27; Mon, 18 Oct 2021 16:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iIEQRaCP; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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 S229627AbhJRXLI (ORCPT + 99 others); Mon, 18 Oct 2021 19:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbhJRXLI (ORCPT ); Mon, 18 Oct 2021 19:11:08 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58F4FC06161C for ; Mon, 18 Oct 2021 16:08:56 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id pf6-20020a17090b1d8600b0019fa884ab85so554171pjb.5 for ; Mon, 18 Oct 2021 16:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=+HVrtpGhtDU4jb4AP5mkfcwHZNRHWdP4BGOrKQYxClQ=; b=iIEQRaCPfrentvvvnJ8ayiRtVGf69ZLQbbaUz3PWDPETWQkjGYkJmt4wf2iDf0PCdE ZxY7U28r4yU1VnY9WB946uNqg71Ed5i6BRxM7sRvRmWfBttXHCx/zbTF3h6aQSCfoTBj hNgUux3MixfKmNv9XN8AyJDYqyBzfhi2YF37Z5n+juH1fXvNg73IUtm7NDodxUXep5p9 qk+Mm1isDSVj1I7O2NW/Gm2s6cK8lPANMgMMIiUeLieBjDTVjB3mLzGqTuIhkx02P5o5 tBHJjYzrj/Zbl1w3f8k2fLwco1ShO1nkVNWRMcy9tZGQuXJtHwgjIi7lY1NZhY57Mh2j 21HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=+HVrtpGhtDU4jb4AP5mkfcwHZNRHWdP4BGOrKQYxClQ=; b=kMyq4RKgw1ES1rcHTqVcN0Tty1E5ovgWcKav8MBvq0yXNefdLlXFaQTyHOyEJthRXx 7/HvQZCiJDJ7vpGhBY9YXaqpPzK/K5Aeq9Jc498ukejmft9gGzdTver/WKhM71hxfKNa 7wVS6jfBdoRHtXVy2qIbixFADxHaTrd+Ox64O+RVDKfAknjon0eLXWUUs6AH7NtZ+Fjf Lv2i4p+qggF8nYHmyv3eWefDXX+y6BH5rUDIn2U+pdsNv6gST4mXl9DGhs75azV1mvSa 6rM/UmOwjKy/kqnur+EmrXJogOqtqqyqiI5vKkAA1Z4gZbKJfk1gNjhG3XBMJq9GP4q3 SgSw== X-Gm-Message-State: AOAM53382ask2YrTTWgfA5lEy6pZgSYZ1pmFQLR0FYaZBJa4WW/3cIxx iMVqBRACDr3eqSBJMPNC+ovb+7FrkOwBkw== X-Received: by 2002:a17:90a:ba09:: with SMTP id s9mr2216744pjr.42.1634598535313; Mon, 18 Oct 2021 16:08:55 -0700 (PDT) Received: from han1-NUC8i7BEH.hsd1.or.comcast.net ([2601:1c0:6a01:d830:1898:ddd4:7bc6:9e0d]) by smtp.gmail.com with ESMTPSA id s30sm13469456pgn.38.2021.10.18.16.08.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 16:08:54 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [RFC BlueZ PATCH v12 1/4] emulator: Add support to config the accept and resolve list Date: Mon, 18 Oct 2021 16:08:50 -0700 Message-Id: <20211018230853.134320-1-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch adds interfaces to config the accept list and resolve list in the btdev. --- emulator/btdev.c | 37 +++++++++++++++++++++++++++++-------- emulator/btdev.h | 4 ++++ emulator/hciemu.c | 28 ++++++++++++++++++++++++++++ emulator/hciemu.h | 4 ++++ 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index f28187362..bf6a03e59 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -196,6 +196,10 @@ struct btdev { } __attribute__ ((packed)) le_cig; uint8_t le_iso_path[2]; + /* Real time length of AL array */ + uint8_t le_al_len; + /* Real time length of RL array */ + uint8_t le_rl_len; struct btdev_al le_al[AL_SIZE]; struct btdev_rl le_rl[RL_SIZE]; uint8_t le_rl_enable; @@ -480,6 +484,18 @@ static void rl_clear(struct btdev *dev) rl_reset(&dev->le_rl[i]); } +/* Set the real time length of AL array */ +void btdev_set_al_len(struct btdev *btdev, uint8_t len) +{ + btdev->le_al_len = len; +} + +/* Set the real time length of RL array */ +void btdev_set_rl_len(struct btdev *btdev, uint8_t len) +{ + btdev->le_rl_len = len; +} + static void btdev_reset(struct btdev *btdev) { /* FIXME: include here clearing of all states that should be @@ -491,6 +507,9 @@ static void btdev_reset(struct btdev *btdev) al_clear(btdev); rl_clear(btdev); + + btdev->le_al_len = AL_SIZE; + btdev->le_rl_len = RL_SIZE; } static int cmd_reset(struct btdev *dev, const void *data, uint8_t len) @@ -3576,7 +3595,7 @@ static int cmd_read_al_size(struct btdev *dev, const void *data, uint8_t len) struct bt_hci_rsp_le_read_accept_list_size rsp; rsp.status = BT_HCI_ERR_SUCCESS; - rsp.size = AL_SIZE; + rsp.size = dev->le_al_len; cmd_complete(dev, BT_HCI_CMD_LE_READ_ACCEPT_LIST_SIZE, &rsp, sizeof(rsp)); @@ -3663,7 +3682,7 @@ static int cmd_add_al(struct btdev *dev, const void *data, uint8_t len) if (cmd->addr_type > 0x01) return -EINVAL; - for (i = 0; i < AL_SIZE; i++) { + for (i = 0; i < dev->le_al_len; i++) { struct btdev_al *al = &dev->le_al[i]; if (AL_ADDR_EQUAL(al, cmd->addr_type, &cmd->addr)) { @@ -3714,7 +3733,7 @@ static int cmd_remove_al(struct btdev *dev, const void *data, uint8_t len) if (cmd->addr_type > 0x01) return -EINVAL; - for (i = 0; i < AL_SIZE; i++) { + for (i = 0; i < dev->le_al_len; i++) { struct btdev_al *al = &dev->le_al[i]; ba2str(&al->addr, addr); @@ -3729,7 +3748,7 @@ static int cmd_remove_al(struct btdev *dev, const void *data, uint8_t len) } } - if (i == AL_SIZE) + if (i == dev->le_al_len) return -EINVAL; status = BT_HCI_ERR_SUCCESS; @@ -3760,7 +3779,7 @@ static int cmd_add_rl(struct btdev *dev, const void *data, uint8_t len) if (cmd->addr_type > 0x01) return -EINVAL; - for (i = 0; i < RL_SIZE; i++) { + for (i = 0; i < dev->le_rl_len; i++) { struct btdev_rl *rl = &dev->le_rl[i]; if (RL_ADDR_EQUAL(rl, cmd->addr_type, &cmd->addr)) { @@ -3811,7 +3830,7 @@ static int cmd_remove_rl(struct btdev *dev, const void *data, uint8_t len) if (cmd->addr_type > 0x01) return -EINVAL; - for (i = 0; i < RL_SIZE; i++) { + for (i = 0; i < dev->le_rl_len; i++) { struct btdev_rl *rl = &dev->le_rl[i]; if (RL_ADDR_EQUAL(rl, cmd->addr_type, &cmd->addr)) { @@ -3820,7 +3839,7 @@ static int cmd_remove_rl(struct btdev *dev, const void *data, uint8_t len) } } - if (i == RL_SIZE) + if (i == dev->le_rl_len) return -EINVAL; status = BT_HCI_ERR_SUCCESS; @@ -3858,7 +3877,7 @@ static int cmd_read_rl_size(struct btdev *dev, const void *data, uint8_t len) struct bt_hci_rsp_le_read_resolv_list_size rsp; rsp.status = BT_HCI_ERR_SUCCESS; - rsp.size = RL_SIZE; + rsp.size = dev->le_rl_len; cmd_complete(dev, BT_HCI_CMD_LE_READ_RESOLV_LIST_SIZE, &rsp, sizeof(rsp)); @@ -6299,6 +6318,8 @@ struct btdev *btdev_create(enum btdev_type type, uint16_t id) btdev->conns = queue_new(); btdev->le_ext_adv = queue_new(); + btdev->le_al_len = AL_SIZE; + btdev->le_rl_len = RL_SIZE; return btdev; } diff --git a/emulator/btdev.h b/emulator/btdev.h index 412bfd158..b5f9979a8 100644 --- a/emulator/btdev.h +++ b/emulator/btdev.h @@ -80,6 +80,10 @@ uint8_t btdev_get_le_scan_enable(struct btdev *btdev); void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states); +void btdev_set_al_len(struct btdev *btdev, uint8_t len); + +void btdev_set_rl_len(struct btdev *btdev, uint8_t len); + void btdev_set_command_handler(struct btdev *btdev, btdev_command_func handler, void *user_data); diff --git a/emulator/hciemu.c b/emulator/hciemu.c index 4752c8a4d..1f7af3b93 100644 --- a/emulator/hciemu.c +++ b/emulator/hciemu.c @@ -601,6 +601,34 @@ void hciemu_set_central_le_states(struct hciemu *hciemu, btdev_set_le_states(dev, le_states); } +void hciemu_set_central_le_al_len(struct hciemu *hciemu, uint8_t len) +{ + struct btdev *dev; + + if (!hciemu || !hciemu->vhci) + return; + + dev = vhci_get_btdev(hciemu->vhci); + if (!dev) + return; + + btdev_set_al_len(dev, len); +} + +void hciemu_set_central_le_rl_len(struct hciemu *hciemu, uint8_t len) +{ + struct btdev *dev; + + if (!hciemu || !hciemu->vhci) + return; + + dev = vhci_get_btdev(hciemu->vhci); + if (!dev) + return; + + btdev_set_rl_len(dev, len); +} + bool hciemu_add_central_post_command_hook(struct hciemu *hciemu, hciemu_command_func_t function, void *user_data) { diff --git a/emulator/hciemu.h b/emulator/hciemu.h index 338fa844d..2a49d8bad 100644 --- a/emulator/hciemu.h +++ b/emulator/hciemu.h @@ -61,6 +61,10 @@ uint8_t hciemu_get_central_le_scan_enable(struct hciemu *hciemu); void hciemu_set_central_le_states(struct hciemu *hciemu, const uint8_t *le_states); +void hciemu_set_central_le_al_len(struct hciemu *hciemu, uint8_t len); + +void hciemu_set_central_le_rl_len(struct hciemu *hciemu, uint8_t len); + typedef void (*hciemu_command_func_t)(uint16_t opcode, const void *data, uint8_t len, void *user_data); -- 2.25.1