Diff between 6031e6b8280cd0e4b7389502241954921b0e8284 and f465a00ff733980ec4d3dbd0ad5b87f34aed9827

Changed Files

File Additions Deletions Status
emulator/btdev.c +40 -0 modified

Full Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index bfee0ed..eba9f57 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;