From: Tedd Ho-Jeong An <hj.tedd.an@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC BlueZ PATCH v13 1/5] emulator: Add support to config the accept and resolve list
Date: Thu, 21 Oct 2021 10:48:00 -0700 [thread overview]
Message-ID: <20211021174804.340160-1-hj.tedd.an@gmail.com> (raw)
From: Tedd Ho-Jeong An <tedd.an@intel.com>
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
next reply other threads:[~2021-10-21 17:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 17:48 Tedd Ho-Jeong An [this message]
2021-10-21 17:48 ` [RFC BlueZ PATCH v13 2/5] emulator: bthost: Add support LE Ext Adv Report Tedd Ho-Jeong An
2021-10-21 17:48 ` [RFC BlueZ PATCH v13 3/5] emulator: Add support to get the advertising address Tedd Ho-Jeong An
2021-10-21 17:48 ` [RFC BlueZ PATCH v13 4/5] tools/mgmt-tester: Add support for experimental feature in setup Tedd Ho-Jeong An
2021-10-21 17:48 ` [RFC BlueZ PATCH v13 5/5] tools/mgmt-tester: Add LL Privacy test cases Tedd Ho-Jeong An
2021-10-21 18:41 ` [RFC,BlueZ,v13,1/5] emulator: Add support to config the accept and resolve list bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211021174804.340160-1-hj.tedd.an@gmail.com \
--to=hj.tedd.an@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.