diff mbox series

[v2,8/8] emulator: Return error for ext adv feature not supported

Message ID 20201104234228.2257427-8-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [v2,1/8] doc: Add tester.config | expand

Commit Message

Luiz Augusto von Dentz Nov. 4, 2020, 11:42 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This return an error if LE Set Extended Advertising Enable is used with
unsupported features.
---
 emulator/btdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 42276a2ce..a36493346 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -3760,8 +3760,19 @@  static void default_cmd(struct btdev *btdev, uint16_t opcode,
 		if (btdev->le_adv_enable == lseae->enable)
 			status = BT_HCI_ERR_COMMAND_DISALLOWED;
 		else {
-			btdev->le_adv_enable = lseae->enable;
-			status = BT_HCI_ERR_SUCCESS;
+			const struct bt_hci_cmd_ext_adv_set *eas;
+
+			if (lseae->num_of_sets) {
+				eas = data + sizeof(*lseae);
+				if (eas->duration || lseae->num_of_sets > 1)
+					status = BT_HCI_ERR_INVALID_PARAMETERS;
+				else
+					status = BT_HCI_ERR_SUCCESS;
+			} else
+				status = BT_HCI_ERR_SUCCESS;
+
+			if (status == BT_HCI_ERR_SUCCESS)
+				btdev->le_adv_enable = lseae->enable;
 		}
 		cmd_complete(btdev, opcode, &status, sizeof(status));
 		if (status == BT_HCI_ERR_SUCCESS && btdev->le_adv_enable)