summaryrefslogtreecommitdiff
path: root/emulator/btdev.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-06-07 10:43:59 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-06-09 11:26:01 -0700
commitf465a00ff733980ec4d3dbd0ad5b87f34aed9827 (patch)
treed57fb86c6fbca6db20f3a81fbd3284ebf525f929 /emulator/btdev.c
parent6031e6b8280cd0e4b7389502241954921b0e8284 (diff)
downloadbluez-f465a00ff733980ec4d3dbd0ad5b87f34aed9827.tar.gz
btdev: Check advertising/scanning states when changing Resolving List
Resolving List cannot be changed when advertising/scanning: • Advertising (other than periodic advertising) is enabled, • Scanning is enabled, or • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, or HCI_LE_Periodic_Advertising_Create_Sync command is outstanding.
Diffstat (limited to 'emulator/btdev.c')
-rw-r--r--emulator/btdev.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/emulator/btdev.c b/emulator/btdev.c
index bfee0ed7b..eba9f57f9 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -3566,6 +3566,16 @@ static int cmd_add_rl(struct btdev *dev, const void *data, uint8_t len)
bool exists = false;
int i, pos = -1;
+ /* This command shall not be used when address resolution is enabled in
+ * the Controller and:
+ * • Advertising (other than periodic advertising) is enabled,
+ * • Scanning is enabled, or
+ * • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection,
+ * or HCI_LE_Periodic_Advertising_Create_Sync command is outstanding.
+ */
+ if (dev->le_adv_enable || dev->le_scan_enable)
+ return -EPERM;
+
/* Valid range for address type is 0x00 to 0x01 */
if (cmd->addr_type > 0x01)
return -EINVAL;
@@ -3607,6 +3617,16 @@ static int cmd_remove_rl(struct btdev *dev, const void *data, uint8_t len)
uint8_t status;
int i;
+ /* This command shall not be used when address resolution is enabled in
+ * the Controller and:
+ * • Advertising (other than periodic advertising) is enabled,
+ * • Scanning is enabled, or
+ * • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection,
+ * or HCI_LE_Periodic_Advertising_Create_Sync command is outstanding.
+ */
+ if (dev->le_adv_enable || dev->le_scan_enable)
+ return -EPERM;
+
/* Valid range for address type is 0x00 to 0x01 */
if (cmd->addr_type > 0x01)
return -EINVAL;
@@ -3634,6 +3654,16 @@ static int cmd_clear_rl(struct btdev *dev, const void *data, uint8_t len)
{
uint8_t status;
+ /* This command shall not be used when address resolution is enabled in
+ * the Controller and:
+ * • Advertising (other than periodic advertising) is enabled,
+ * • Scanning is enabled, or
+ * • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection,
+ * or HCI_LE_Periodic_Advertising_Create_Sync command is outstanding.
+ */
+ if (dev->le_adv_enable || dev->le_scan_enable)
+ return -EPERM;
+
rl_clear(dev);
status = BT_HCI_ERR_SUCCESS;
@@ -3699,6 +3729,16 @@ static int cmd_set_rl_enable(struct btdev *dev, const void *data, uint8_t len)
const struct bt_hci_cmd_le_set_resolv_enable *cmd = data;
uint8_t status;
+ /* This command shall not be used when address resolution is enabled in
+ * the Controller and:
+ * • Advertising (other than periodic advertising) is enabled,
+ * • Scanning is enabled, or
+ * • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection,
+ * or HCI_LE_Periodic_Advertising_Create_Sync command is outstanding.
+ */
+ if (dev->le_adv_enable || dev->le_scan_enable)
+ return -EPERM;
+
/* Valid range for address resolution enable is 0x00 to 0x01 */
if (cmd->enable > 0x01)
return -EINVAL;