linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list
@ 2021-10-25 20:31 Tedd Ho-Jeong An
  2021-10-25 20:31 ` [BlueZ PATCH 2/4] emulator: bthost: Add support LE Ext Adv Report Tedd Ho-Jeong An
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Tedd Ho-Jeong An @ 2021-10-25 20:31 UTC (permalink / raw)
  To: linux-bluetooth

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 177633b9c..2cbe24edc 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -198,6 +198,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;
@@ -482,6 +486,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
@@ -493,6 +509,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)
@@ -3578,7 +3597,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));
 
@@ -3669,7 +3688,7 @@ static int cmd_add_al(struct btdev *dev, const void *data, uint8_t len)
 		goto done;
 	}
 
-	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)) {
@@ -3731,7 +3750,7 @@ static int cmd_remove_al(struct btdev *dev, const void *data, uint8_t len)
 		goto done;
 	}
 
-	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);
@@ -3746,7 +3765,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) {
 		status = BT_HCI_ERR_INVALID_PARAMETERS;
 		goto done;
 	}
@@ -3785,7 +3804,7 @@ static int cmd_add_rl(struct btdev *dev, const void *data, uint8_t len)
 		goto done;
 	}
 
-	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)) {
@@ -3847,7 +3866,7 @@ static int cmd_remove_rl(struct btdev *dev, const void *data, uint8_t len)
 		goto done;
 	}
 
-	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)) {
@@ -3856,7 +3875,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) {
 		status = BT_HCI_ERR_INVALID_PARAMETERS;
 		goto done;
 	}
@@ -3902,7 +3921,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));
@@ -6358,6 +6377,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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [BlueZ PATCH 2/4] emulator: bthost: Add support LE Ext Adv Report
  2021-10-25 20:31 [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Tedd Ho-Jeong An
@ 2021-10-25 20:31 ` Tedd Ho-Jeong An
  2021-10-25 20:31 ` [BlueZ PATCH 3/4] emulator: Add support to get the advertising address Tedd Ho-Jeong An
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Tedd Ho-Jeong An @ 2021-10-25 20:31 UTC (permalink / raw)
  To: linux-bluetooth

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch adds support LE_Extended_Advertising_Report Eevnt in bthost.
---
 emulator/bthost.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++
 emulator/bthost.h |   5 ++
 2 files changed, 123 insertions(+)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 4f1598f0d..61f1cd361 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -25,6 +25,7 @@
 
 #include "src/shared/util.h"
 #include "src/shared/tester.h"
+#include "src/shared/queue.h"
 #include "monitor/bt.h"
 #include "monitor/rfcomm.h"
 #include "bthost.h"
@@ -187,6 +188,15 @@ struct rfcomm_connection_data {
 	void *user_data;
 };
 
+struct le_ext_adv {
+	struct bthost *bthost;
+	uint16_t event_type;
+	uint8_t  addr_type;
+	uint8_t  addr[6];
+	uint8_t  direct_addr_type;
+	uint8_t  direct_addr[6];
+};
+
 struct bthost {
 	bool ready;
 	bthost_ready_cb ready_cb;
@@ -215,6 +225,8 @@ struct bthost {
 	bool le;
 	bool sc;
 
+	struct queue *le_ext_adv;
+
 	bthost_debug_func_t debug_callback;
 	bthost_destroy_func_t debug_destroy;
 	void *debug_data;
@@ -234,6 +246,8 @@ struct bthost *bthost_create(void)
 		return NULL;
 	}
 
+	bthost->le_ext_adv = queue_new();
+
 	/* Set defaults */
 	bthost->io_capability = 0x03;
 
@@ -403,6 +417,32 @@ static struct rfcomm_conn_cb_data *bthost_find_rfcomm_cb_by_channel(
 	return NULL;
 }
 
+static struct le_ext_adv *le_ext_adv_new(struct bthost *bthost)
+{
+	struct le_ext_adv *ext_adv;
+
+	ext_adv = new0(struct le_ext_adv, 1);
+	ext_adv->bthost = bthost;
+
+	/* Add to queue */
+	if (!queue_push_tail(bthost->le_ext_adv, ext_adv)) {
+		free(ext_adv);
+		return NULL;
+	}
+
+	return ext_adv;
+}
+
+static void le_ext_adv_free(void *data)
+{
+	struct le_ext_adv *ext_adv = data;
+
+	/* Remove from queue */
+	queue_remove(ext_adv->bthost->le_ext_adv, ext_adv);
+
+	free(ext_adv);
+}
+
 void bthost_destroy(struct bthost *bthost)
 {
 	if (!bthost)
@@ -449,6 +489,8 @@ void bthost_destroy(struct bthost *bthost)
 
 	smp_stop(bthost->smp_data);
 
+	queue_destroy(bthost->le_ext_adv, le_ext_adv_free);
+
 	free(bthost);
 }
 
@@ -1306,6 +1348,38 @@ static void evt_le_cis_req(struct bthost *bthost, const void *data, uint8_t len)
 	send_command(bthost, BT_HCI_CMD_LE_ACCEPT_CIS, &cmd, sizeof(cmd));
 }
 
+static void evt_le_ext_adv_report(struct bthost *bthost, const void *data,
+								uint8_t len)
+{
+	const struct bt_hci_evt_le_ext_adv_report *ev = data;
+	const struct bt_hci_le_ext_adv_report *report;
+	struct le_ext_adv *le_ext_adv;
+	int i;
+
+	data += sizeof(ev->num_reports);
+
+	for (i = 0; i < ev->num_reports; i++) {
+		char addr_str[18];
+
+		report = data;
+		ba2str((bdaddr_t *) report->addr, addr_str);
+
+		bthost_debug(bthost, "le ext adv report: %s (0x%02x)",
+						addr_str, report->addr_type);
+
+		/* Add ext event to the queue */
+		le_ext_adv = le_ext_adv_new(bthost);
+		if (le_ext_adv) {
+			le_ext_adv->addr_type = report->addr_type;
+			memcpy(le_ext_adv->addr, report->addr, 6);
+			le_ext_adv->direct_addr_type = report->direct_addr_type;
+			memcpy(le_ext_adv->direct_addr, report->direct_addr, 6);
+		}
+
+		data += (sizeof(*report) + report->data_len);
+	}
+}
+
 static void evt_le_meta_event(struct bthost *bthost, const void *data,
 								uint8_t len)
 {
@@ -1333,6 +1407,9 @@ static void evt_le_meta_event(struct bthost *bthost, const void *data,
 	case BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE:
 		evt_le_ext_conn_complete(bthost, evt_data, len - 1);
 		break;
+	case BT_HCI_EVT_LE_EXT_ADV_REPORT:
+		evt_le_ext_adv_report(bthost, evt_data, len - 1);
+		break;
 	case BT_HCI_EVT_LE_CIS_REQ:
 		evt_le_cis_req(bthost, evt_data, len - 1);
 		break;
@@ -2583,6 +2660,29 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
 	send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
 }
 
+void bthost_set_scan_params(struct bthost *bthost, uint8_t scan_type,
+				uint8_t addr_type, uint8_t filter_policy)
+{
+	struct bt_hci_cmd_le_set_scan_parameters cp;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.type = scan_type;
+	cp.own_addr_type = addr_type;
+	cp.filter_policy = filter_policy;
+	send_command(bthost, BT_HCI_CMD_LE_SET_SCAN_PARAMETERS,
+							&cp, sizeof(cp));
+}
+
+void bthost_set_scan_enable(struct bthost *bthost, uint8_t enable)
+{
+	struct bt_hci_cmd_le_set_scan_enable cp;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.enable = enable;
+	send_command(bthost, BT_HCI_CMD_LE_SET_SCAN_ENABLE,
+							&cp, sizeof(cp));
+}
+
 void bthost_set_ext_adv_params(struct bthost *bthost)
 {
 	struct bt_hci_cmd_le_set_ext_adv_params cp;
@@ -2612,6 +2712,24 @@ void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable)
 	send_command(bthost, BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE, cp, 6);
 }
 
+bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr)
+{
+	const struct queue_entry *entry;
+
+	if (queue_isempty(bthost->le_ext_adv))
+		return false;
+
+	for (entry = queue_get_entries(bthost->le_ext_adv); entry;
+							entry = entry->next) {
+		struct le_ext_adv *le_ext_adv = entry->data;
+
+		if (!memcmp(le_ext_adv->addr, addr, 6))
+			return true;
+	}
+
+	return false;
+}
+
 void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode)
 {
 	send_command(bthost, BT_HCI_CMD_WRITE_SIMPLE_PAIRING_MODE, &mode, 1);
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 3dec44514..868af5469 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -84,6 +84,11 @@ void bthost_set_ext_adv_data(struct bthost *bthost, const uint8_t *data,
 								uint8_t len);
 void bthost_set_ext_adv_params(struct bthost *bthost);
 void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable);
+bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr);
+
+void bthost_set_scan_params(struct bthost *bthost, uint8_t scan_type,
+				uint8_t addr_type, uint8_t filter_policy);
+void bthost_set_scan_enable(struct bthost *bthost, uint8_t enable);
 
 void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [BlueZ PATCH 3/4] emulator: Add support to get the advertising address
  2021-10-25 20:31 [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Tedd Ho-Jeong An
  2021-10-25 20:31 ` [BlueZ PATCH 2/4] emulator: bthost: Add support LE Ext Adv Report Tedd Ho-Jeong An
@ 2021-10-25 20:31 ` Tedd Ho-Jeong An
  2021-10-25 20:31 ` [BlueZ PATCH 4/4] tools/mgmt-tester: Add support for experimental feature in setup Tedd Ho-Jeong An
  2021-10-25 20:44 ` [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Tedd Ho-Jeong An @ 2021-10-25 20:31 UTC (permalink / raw)
  To: linux-bluetooth

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch add supprt emulator to get the advertising address of the
central device.
---
 emulator/btdev.c  | 23 +++++++++++++++++++++--
 emulator/btdev.h  |  2 ++
 emulator/hciemu.c | 15 +++++++++++++++
 emulator/hciemu.h |  3 +++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 2cbe24edc..7b311f347 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -4703,6 +4703,7 @@ static void send_ext_adv(struct btdev *btdev, const struct btdev *remote,
 					struct le_ext_adv *ext_adv,
 					uint16_t type, bool is_scan_rsp)
 {
+
 	struct __packed {
 		uint8_t num_reports;
 		union {
@@ -4818,6 +4819,9 @@ static int cmd_set_ext_adv_enable(struct btdev *dev, const void *data,
 
 		/* Disable all advertising sets */
 		queue_foreach(dev->le_ext_adv, ext_adv_disable, NULL);
+
+		dev->le_adv_enable = 0x00;
+
 		goto exit_complete;
 	}
 
@@ -4872,6 +4876,8 @@ static int cmd_set_ext_adv_enable(struct btdev *dev, const void *data,
 
 		ext_adv->enable = cmd->enable;
 
+		dev->le_adv_enable = 0x01;
+
 		if (!cmd->enable)
 			ext_adv_disable(ext_adv, NULL);
 		else if (eas->duration)
@@ -4936,7 +4942,7 @@ static int cmd_remove_adv_set(struct btdev *dev, const void *data,
 						UINT_TO_PTR(cmd->handle));
 	if (!ext_adv) {
 		status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
-		cmd_complete(dev, BT_HCI_CMD_LE_SET_EXT_ADV_DATA, &status,
+		cmd_complete(dev, BT_HCI_CMD_LE_REMOVE_ADV_SET, &status,
 						sizeof(status));
 		return 0;
 	}
@@ -5206,7 +5212,7 @@ static void le_ext_conn_complete(struct btdev *btdev,
 		/* Set Local RPA if an RPA was generated for the advertising */
 		if (ext_adv->rpa)
 			memcpy(ev.local_rpa, ext_adv->random_addr,
-					sizeof(ev.local_rpa));
+							sizeof(ev.local_rpa));
 
 		le_meta_event(conn->link->dev,
 				BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE, &ev,
@@ -6435,6 +6441,19 @@ uint8_t btdev_get_le_scan_enable(struct btdev *btdev)
 	return btdev->le_scan_enable;
 }
 
+const uint8_t *btdev_get_adv_addr(struct btdev *btdev, uint8_t handle)
+{
+	struct le_ext_adv *ext_adv;
+
+	/* Check if Ext Adv is already existed */
+	ext_adv = queue_find(btdev->le_ext_adv, match_ext_adv_handle,
+							UINT_TO_PTR(handle));
+	if (!ext_adv)
+		return NULL;
+
+	return ext_adv_addr(btdev, ext_adv);
+}
+
 void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states)
 {
 	memcpy(btdev->le_states, le_states, sizeof(btdev->le_states));
diff --git a/emulator/btdev.h b/emulator/btdev.h
index b5f9979a8..9493938c6 100644
--- a/emulator/btdev.h
+++ b/emulator/btdev.h
@@ -78,6 +78,8 @@ uint8_t btdev_get_scan_enable(struct btdev *btdev);
 
 uint8_t btdev_get_le_scan_enable(struct btdev *btdev);
 
+const uint8_t *btdev_get_adv_addr(struct btdev *btdev, uint8_t handle);
+
 void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states);
 
 void btdev_set_al_len(struct btdev *btdev, uint8_t len);
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index 1f7af3b93..057f76ff3 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -629,6 +629,21 @@ void hciemu_set_central_le_rl_len(struct hciemu *hciemu, uint8_t len)
 	btdev_set_rl_len(dev, len);
 }
 
+const uint8_t *hciemu_get_central_adv_addr(struct hciemu *hciemu,
+								uint8_t handle)
+{
+	struct btdev *dev;
+
+	if (!hciemu || !hciemu->vhci)
+		return NULL;
+
+	dev = vhci_get_btdev(hciemu->vhci);
+	if (!dev)
+		return NULL;
+
+	return btdev_get_adv_addr(dev, handle);
+}
+
 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 2a49d8bad..3a06ca578 100644
--- a/emulator/hciemu.h
+++ b/emulator/hciemu.h
@@ -65,6 +65,9 @@ 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);
 
+const uint8_t *hciemu_get_central_adv_addr(struct hciemu *hciemu,
+							uint8_t handle);
+
 typedef void (*hciemu_command_func_t)(uint16_t opcode, const void *data,
 						uint8_t len, void *user_data);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [BlueZ PATCH 4/4] tools/mgmt-tester: Add support for experimental feature in setup
  2021-10-25 20:31 [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Tedd Ho-Jeong An
  2021-10-25 20:31 ` [BlueZ PATCH 2/4] emulator: bthost: Add support LE Ext Adv Report Tedd Ho-Jeong An
  2021-10-25 20:31 ` [BlueZ PATCH 3/4] emulator: Add support to get the advertising address Tedd Ho-Jeong An
@ 2021-10-25 20:31 ` Tedd Ho-Jeong An
  2021-10-25 20:44 ` [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Tedd Ho-Jeong An @ 2021-10-25 20:31 UTC (permalink / raw)
  To: linux-bluetooth

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch adds support for experimental feature in setup_settings
options.
---
 tools/mgmt-tester.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index f490dc261..1ccce0ad6 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -260,6 +260,7 @@ struct generic_data {
 	const uint16_t *setup_settings;
 	bool setup_nobredr;
 	bool setup_limited_discov;
+	const void *setup_exp_feat_param;
 	uint16_t setup_expect_hci_command;
 	const void *setup_expect_hci_param;
 	uint8_t setup_expect_hci_len;
@@ -7222,6 +7223,7 @@ proceed:
 		unsigned char privacy_param[] = { 0x01,
 			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
 			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
+		unsigned char set_exp_feat_param[17] = { 0x00 };
 		unsigned char *param = simple_param;
 		size_t param_size = sizeof(simple_param);
 		mgmt_request_func_t func = NULL;
@@ -7250,14 +7252,30 @@ proceed:
 				memcpy(param, test->setup_discovery_param, 1);
 		}
 
+		if (*cmd == MGMT_OP_SET_EXP_FEATURE) {
+			if (test->setup_exp_feat_param) {
+				memcpy(set_exp_feat_param,
+				       test->setup_exp_feat_param, 17);
+				param_size = sizeof(set_exp_feat_param);
+				param = set_exp_feat_param;
+			}
+		}
+
 		if (*cmd == MGMT_OP_SET_LE && test->setup_nobredr) {
 			unsigned char off[] = { 0x00 };
+			tester_print("Setup sending %s (0x%04x)",
+							mgmt_opstr(*cmd), *cmd);
 			mgmt_send(data->mgmt, *cmd, data->mgmt_index,
 					param_size, param, NULL, NULL, NULL);
+			tester_print("Setup sending %s (0x%04x)",
+					mgmt_opstr(MGMT_OP_SET_BREDR),
+					MGMT_OP_SET_BREDR);
 			mgmt_send(data->mgmt, MGMT_OP_SET_BREDR,
 					data->mgmt_index, sizeof(off), off,
 					func, data, NULL);
 		} else {
+			tester_print("Setup sending %s (0x%04x)",
+							mgmt_opstr(*cmd), *cmd);
 			mgmt_send(data->mgmt, *cmd, data->mgmt_index,
 					param_size, param, func, data, NULL);
 		}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list
  2021-10-25 20:31 [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Tedd Ho-Jeong An
                   ` (2 preceding siblings ...)
  2021-10-25 20:31 ` [BlueZ PATCH 4/4] tools/mgmt-tester: Add support for experimental feature in setup Tedd Ho-Jeong An
@ 2021-10-25 20:44 ` Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2021-10-25 20:44 UTC (permalink / raw)
  To: Tedd Ho-Jeong An; +Cc: linux-bluetooth

Hi Tedd,

On Mon, Oct 25, 2021 at 1:32 PM Tedd Ho-Jeong An <hj.tedd.an@gmail.com> wrote:
>
> 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 177633b9c..2cbe24edc 100644
> --- a/emulator/btdev.c
> +++ b/emulator/btdev.c
> @@ -198,6 +198,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;
> @@ -482,6 +486,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
> @@ -493,6 +509,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)
> @@ -3578,7 +3597,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));
>
> @@ -3669,7 +3688,7 @@ static int cmd_add_al(struct btdev *dev, const void *data, uint8_t len)
>                 goto done;
>         }
>
> -       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)) {
> @@ -3731,7 +3750,7 @@ static int cmd_remove_al(struct btdev *dev, const void *data, uint8_t len)
>                 goto done;
>         }
>
> -       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);
> @@ -3746,7 +3765,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) {
>                 status = BT_HCI_ERR_INVALID_PARAMETERS;
>                 goto done;
>         }
> @@ -3785,7 +3804,7 @@ static int cmd_add_rl(struct btdev *dev, const void *data, uint8_t len)
>                 goto done;
>         }
>
> -       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)) {
> @@ -3847,7 +3866,7 @@ static int cmd_remove_rl(struct btdev *dev, const void *data, uint8_t len)
>                 goto done;
>         }
>
> -       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)) {
> @@ -3856,7 +3875,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) {
>                 status = BT_HCI_ERR_INVALID_PARAMETERS;
>                 goto done;
>         }
> @@ -3902,7 +3921,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));
> @@ -6358,6 +6377,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

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [BlueZ PATCH 4/4] tools/mgmt-tester: Add support for experimental feature in setup
  2021-10-25  4:47 Tedd Ho-Jeong An
@ 2021-10-25  4:47 ` Tedd Ho-Jeong An
  0 siblings, 0 replies; 6+ messages in thread
From: Tedd Ho-Jeong An @ 2021-10-25  4:47 UTC (permalink / raw)
  To: linux-bluetooth

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch adds support for experimental feature in setup_settings
options.
---
 tools/mgmt-tester.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index f490dc261..1ccce0ad6 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -260,6 +260,7 @@ struct generic_data {
 	const uint16_t *setup_settings;
 	bool setup_nobredr;
 	bool setup_limited_discov;
+	const void *setup_exp_feat_param;
 	uint16_t setup_expect_hci_command;
 	const void *setup_expect_hci_param;
 	uint8_t setup_expect_hci_len;
@@ -7222,6 +7223,7 @@ proceed:
 		unsigned char privacy_param[] = { 0x01,
 			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
 			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
+		unsigned char set_exp_feat_param[17] = { 0x00 };
 		unsigned char *param = simple_param;
 		size_t param_size = sizeof(simple_param);
 		mgmt_request_func_t func = NULL;
@@ -7250,14 +7252,30 @@ proceed:
 				memcpy(param, test->setup_discovery_param, 1);
 		}
 
+		if (*cmd == MGMT_OP_SET_EXP_FEATURE) {
+			if (test->setup_exp_feat_param) {
+				memcpy(set_exp_feat_param,
+				       test->setup_exp_feat_param, 17);
+				param_size = sizeof(set_exp_feat_param);
+				param = set_exp_feat_param;
+			}
+		}
+
 		if (*cmd == MGMT_OP_SET_LE && test->setup_nobredr) {
 			unsigned char off[] = { 0x00 };
+			tester_print("Setup sending %s (0x%04x)",
+							mgmt_opstr(*cmd), *cmd);
 			mgmt_send(data->mgmt, *cmd, data->mgmt_index,
 					param_size, param, NULL, NULL, NULL);
+			tester_print("Setup sending %s (0x%04x)",
+					mgmt_opstr(MGMT_OP_SET_BREDR),
+					MGMT_OP_SET_BREDR);
 			mgmt_send(data->mgmt, MGMT_OP_SET_BREDR,
 					data->mgmt_index, sizeof(off), off,
 					func, data, NULL);
 		} else {
+			tester_print("Setup sending %s (0x%04x)",
+							mgmt_opstr(*cmd), *cmd);
 			mgmt_send(data->mgmt, *cmd, data->mgmt_index,
 					param_size, param, func, data, NULL);
 		}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-25 20:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 20:31 [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Tedd Ho-Jeong An
2021-10-25 20:31 ` [BlueZ PATCH 2/4] emulator: bthost: Add support LE Ext Adv Report Tedd Ho-Jeong An
2021-10-25 20:31 ` [BlueZ PATCH 3/4] emulator: Add support to get the advertising address Tedd Ho-Jeong An
2021-10-25 20:31 ` [BlueZ PATCH 4/4] tools/mgmt-tester: Add support for experimental feature in setup Tedd Ho-Jeong An
2021-10-25 20:44 ` [BlueZ PATCH 1/4] emulator: Add support to config the accept and resolve list Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2021-10-25  4:47 Tedd Ho-Jeong An
2021-10-25  4:47 ` [BlueZ PATCH 4/4] tools/mgmt-tester: Add support for experimental feature in setup Tedd Ho-Jeong An

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).