Skip to contentSkip to conversation

emulator: Add support to config the white and resolve list

PATCH Superseded Tedd Ho-Jeong An 2 participants 3 messages Aug 17, 2021 Bluetooth drivers

v9 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

PATCH v9 1/2 emulator: Add support to config the white and resolve list

From: Tedd Ho-Jeong An <[email protected]>

This patch adds interfaces to config the white list and resolve list in the btdev.

---
 emulator/btdev.c  | 41 +++++++++++++++++++++++++++++++----------
 emulator/btdev.h  |  4 ++++
 emulator/hciemu.c | 16 ++++++++++++++++
 emulator/hciemu.h |  4 ++++
 4 files changed, 55 insertions(+), 10 deletions(-)
emulator/btdev.c +31 -10
index f8daf4587..a197e4917 100644
@@ -33,8 +33,8 @@
 #include "monitor/bt.h"
 #include "btdev.h"
 
-#define WL_SIZE			16
-#define RL_SIZE			16
+#define WL_SIZE			3
+#define RL_SIZE			4
 #define CIS_SIZE		3
 
 #define has_bredr(btdev)	(!((btdev)->features[4] & 0x20))
@@ -191,6 +191,10 @@ struct btdev {
 	} __attribute__ ((packed)) le_cig;
 	uint8_t  le_iso_path[2];
 
+	/* Real time length of WL array */
+	uint8_t le_wl_len;
+	/* Real time length of RL array */
+	uint8_t le_rl_len;
 	struct btdev_wl le_wl[WL_SIZE];
 	struct btdev_rl le_rl[RL_SIZE];
 	uint8_t  le_rl_enable;
@@ -475,6 +479,18 @@ static void rl_clear(struct btdev *dev)
 		rl_reset(&dev->le_rl[i]);
 }
 
+/* Set the real time length of WL array */
+void btdev_set_wl_len(struct btdev *btdev, uint8_t len)
+{
+	btdev->le_wl_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
@@ -486,6 +502,9 @@ static void btdev_reset(struct btdev *btdev)
 
 	wl_clear(btdev);
 	rl_clear(btdev);
+
+	btdev->le_wl_len = WL_SIZE;
+	btdev->le_rl_len = RL_SIZE;
 }
 
 static int cmd_reset(struct btdev *dev, const void *data, uint8_t len)
@@ -3515,7 +3534,7 @@ static int cmd_read_wl_size(struct btdev *dev, const void *data, uint8_t len)
 	struct bt_hci_rsp_le_read_white_list_size rsp;
 
 	rsp.status = BT_HCI_ERR_SUCCESS;
-	rsp.size = WL_SIZE;
+	rsp.size = dev->le_wl_len;
 	cmd_complete(dev, BT_HCI_CMD_LE_READ_WHITE_LIST_SIZE, &rsp,
 						sizeof(rsp));
 
@@ -3602,7 +3621,7 @@ static int cmd_add_wl(struct btdev *dev, const void *data, uint8_t len)
 	if (cmd->addr_type > 0x01)
 		return -EINVAL;
 
-	for (i = 0; i < WL_SIZE; i++) {
+	for (i = 0; i < dev->le_wl_len; i++) {
 		struct btdev_wl *wl = &dev->le_wl[i];
 
 		if (WL_ADDR_EQUAL(wl, cmd->addr_type, &cmd->addr)) {
@@ -3653,7 +3672,7 @@ static int cmd_remove_wl(struct btdev *dev, const void *data, uint8_t len)
 	if (cmd->addr_type > 0x01)
 		return -EINVAL;
 
-	for (i = 0; i < WL_SIZE; i++) {
+	for (i = 0; i < dev->le_wl_len; i++) {
 		struct btdev_wl *wl = &dev->le_wl[i];
 
 		ba2str(&wl->addr, addr);
@@ -3668,7 +3687,7 @@ static int cmd_remove_wl(struct btdev *dev, const void *data, uint8_t len)
 		}
 	}
 
-	if (i == WL_SIZE)
+	if (i == dev->le_wl_len)
 		return -EINVAL;
 
 	status = BT_HCI_ERR_SUCCESS;
@@ -3699,7 +3718,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)) {
@@ -3750,7 +3769,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)) {
@@ -3759,7 +3778,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;
@@ -3797,7 +3816,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));
@@ -6236,6 +6255,8 @@ struct btdev *btdev_create(enum btdev_type type, uint16_t id)
 	btdev->conns = queue_new();
 	btdev->le_ext_adv = queue_new();
 
+	btdev->le_wl_len = WL_SIZE;
+	btdev->le_rl_len = RL_SIZE;
 	return btdev;
 }
 
emulator/btdev.h +4 -0
index f7cba149a..b427a3a66 100644
@@ -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_wl_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);
 
emulator/hciemu.c +16 -0
index fe5ef747a..ec60b7cea 100644
@@ -580,6 +580,22 @@ void hciemu_set_master_le_states(struct hciemu *hciemu, const uint8_t *le_states
 	btdev_set_le_states(hciemu->dev, le_states);
 }
 
+void hciemu_set_master_le_wl_len(struct hciemu *hciemu, uint8_t len)
+{
+	if (!hciemu || !hciemu->dev)
+		return;
+
+	btdev_set_wl_len(hciemu->dev, len);
+}
+
+void hciemu_set_master_le_rl_len(struct hciemu *hciemu, uint8_t len)
+{
+	if (!hciemu || !hciemu->dev)
+		return;
+
+	btdev_set_rl_len(hciemu->dev, len);
+}
+
 bool hciemu_add_master_post_command_hook(struct hciemu *hciemu,
 			hciemu_command_func_t function, void *user_data)
 {
emulator/hciemu.h +4 -0
index 8bf2d070e..4a89b8d59 100644
@@ -60,6 +60,10 @@ uint8_t hciemu_get_master_le_scan_enable(struct hciemu *hciemu);
 void hciemu_set_master_le_states(struct hciemu *hciemu,
 						const uint8_t *le_states);
 
+void hciemu_set_master_le_wl_len(struct hciemu *hciemu, uint8_t len);
+
+void hciemu_set_master_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);
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v9 2/2 tools/mgmt-tester: Add LL Privacy test cases

From: Tedd Ho-Jeong An <[email protected]>

This patch adds LL Privacy related test cases.

Multi Ext Advertising - Success 3 (Add 2 Advs) Multi Ext Advertising - Success 4 (Remove Adv) Multi Ext Advertising - Success 5 (Remove all) Multi Ext Advertising - Success 6 (Add w/o power on) Multi Ext Advertising - Fail (Add MAX)

LL Privacy - Add Device 1 (Add to WL)
LL Privacy - Add Device 2 (Add to RL)
LL Privacy - Add Device 3 (Enable RL)
LL Privacy - Add Device 4 (2 Devices to WL) LL Privacy - Add Device 5 (2 Devices to RL) LL Privacy - Add Device 6 (RL is full)
LL Privacy - Add Device 7 (WL is full)
LL Privacy - Add Device 8 (Disable Adv)
LL Privacy - Add Device 9 (Multi Adv)
LL Privacy - Add Device 10 (Multi Dev and Multi Adv)

LL Privacy - Remove Device 1 (Remove from WL) LL Privacy - Remove Device 2 (Remove from RL) LL Privacy - Remove Device 3 (Disable RL) LL Privacy - Remove Device 4 (Disable Adv) LL Privacy - Remove Device 5 (Multi Adv)

LL Privacy - Start Discovery 1 (Disable RL) LL Privacy - Start Discovery 2 (Disable RL)

LL Privacy - Advertising 1 (Scan Results) LL Privacy - Acceptor 1
LL Privacy - Acceptor 2

---
 emulator/btdev.c    |   31 +-
 emulator/btdev.h    |    2 +
 emulator/bthost.c   |  118 +++
 emulator/bthost.h   |    5 +
 emulator/hciemu.c   |    9 +
 emulator/hciemu.h   |    2 +
 tools/mgmt-tester.c | 1846 ++++++++++++++++++++++++++++++++++++-------
 7 files changed, 1720 insertions(+), 293 deletions(-)
emulator/btdev.c +26 -5
index a197e4917..c189339a6 100644
@@ -4592,6 +4592,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 {
@@ -4707,6 +4708,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;
 	}
 
@@ -4761,6 +4765,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)
@@ -4825,7 +4831,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;
 	}
@@ -5096,6 +5102,11 @@ static void le_ext_conn_complete(struct btdev *btdev,
 		ev.latency = lecc->latency;
 		ev.supv_timeout = lecc->supv_timeout;
 
+		/* 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));
+
 		le_meta_event(conn->link->dev,
 				BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE, &ev,
 				sizeof(ev));
@@ -5106,10 +5117,7 @@ static void le_ext_conn_complete(struct btdev *btdev,
 	memcpy(ev.peer_addr, cmd->peer_addr, 6);
 	ev.role = 0x00;
 
-	/* 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));
+	memset(ev.local_rpa, 0, sizeof(ev.local_rpa));
 
 	le_meta_event(btdev, BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE, &ev,
 						sizeof(ev));
@@ -6313,6 +6321,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));
emulator/btdev.h +2 -0
index b427a3a66..824b595c4 100644
@@ -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_wl_len(struct btdev *btdev, uint8_t len);
emulator/bthost.c +118 -0

178 lines not on this page · raw message

emulator/bthost.h +5 -0
index 3dec44514..868af5469 100644
@@ -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);
 
emulator/hciemu.c +9 -0
index ec60b7cea..b4de45876 100644
@@ -596,6 +596,15 @@ void hciemu_set_master_le_rl_len(struct hciemu *hciemu, uint8_t len)
 	btdev_set_rl_len(hciemu->dev, len);
 }
 
+const uint8_t *hciemu_get_master_adv_addr(struct hciemu *hciemu, uint8_t handle)
+{
+	if (!hciemu || !hciemu->dev)
+		return NULL;
+
+
+	return btdev_get_adv_addr(hciemu->dev, handle);
+}
+
 bool hciemu_add_master_post_command_hook(struct hciemu *hciemu,
 			hciemu_command_func_t function, void *user_data)
 {
emulator/hciemu.h +2 -0
index 4a89b8d59..96cfff202 100644
@@ -64,6 +64,8 @@ void hciemu_set_master_le_wl_len(struct hciemu *hciemu, uint8_t len);
 
 void hciemu_set_master_le_rl_len(struct hciemu *hciemu, uint8_t len);
 
+const uint8_t *hciemu_get_master_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);
 
tools/mgmt-tester.c +1558 -288

2,031 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw
In reply to Tedd Ho-Jeong An

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=533005

---Test result---

Test Summary:

CheckPatch                    FAIL      2.46 seconds
GitLint                       PASS      0.27 seconds
Prep - Setup ELL              PASS      51.09 seconds
Build - Prep                  PASS      0.15 seconds
Build - Configure             PASS      9.10 seconds
Build - Make                  FAIL      80.65 seconds
Make Check                    FAIL      0.86 seconds
Make Distcheck                FAIL      148.70 seconds
Build w/ext ELL - Configure   PASS      9.02 seconds
Build w/ext ELL - Make        FAIL      67.13 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
tools/mgmt-tester: Add LL Privacy test cases
WARNING:LONG_LINE: line length of 81 exceeds 80 columns
#371: FILE: emulator/hciemu.h:67:
+const uint8_t *hciemu_get_master_adv_addr(struct hciemu *hciemu, uint8_t handle);

- total: 0 errors, 1 warnings, 2324 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] tools/mgmt-tester: Add LL Privacy test cases" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
emulator/bthost.c: In function ‘evt_le_ext_adv_report’:
emulator/bthost.c:1350:3: error: implicit declaration of function ‘bthost_debug’; did you mean ‘bthost_set_debug’? [-Werror=implicit-function-declaration]

 1350 |   bthost_debug(bthost, "le ext adv report: %s (0x%02x)",
      |   ^~~~~~~~~~~~
      |   bthost_set_debug

cc1: all warnings being treated as errors make[1]: *** [Makefile:6955: emulator/bthost.o] Error 1
make: *** [Makefile:4147: all] Error 2

##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
emulator/bthost.c: In function ‘evt_le_ext_adv_report’:
emulator/bthost.c:1350:3: error: implicit declaration of function ‘bthost_debug’; did you mean ‘bthost_set_debug’? [-Werror=implicit-function-declaration]

 1350 |   bthost_debug(bthost, "le ext adv report: %s (0x%02x)",
      |   ^~~~~~~~~~~~
      |   bthost_set_debug

cc1: all warnings being treated as errors make[1]: *** [Makefile:6955: emulator/bthost.o] Error 1
make: *** [Makefile:10436: check] Error 2

##############################
Test: Make Distcheck - FAIL
Desc: Run distcheck to check the distribution
Output:
../../emulator/bthost.c: In function ‘evt_le_ext_adv_report’:
../../emulator/bthost.c:1350:3: warning: implicit declaration of function ‘bthost_debug’; did you mean ‘bthost_set_debug’? [-Wimplicit-function-declaration]

 1350 |   bthost_debug(bthost, "le ext adv report: %s (0x%02x)",
      |   ^~~~~~~~~~~~
      |   bthost_set_debug

/usr/bin/ld: emulator/android_android_tester-bthost.o: in function `evt_le_ext_adv_report':
/github/workspace/src/bluez-5.60/_build/sub/../../emulator/bthost.c:1350: undefined reference to `bthost_debug'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:4784: android/android-tester] Error 1
make[1]: *** [Makefile:4147: all] Error 2
make: *** [Makefile:10357: distcheck] Error 1

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration
Output:
emulator/bthost.c: In function ‘evt_le_ext_adv_report’:
emulator/bthost.c:1350:3: error: implicit declaration of function ‘bthost_debug’; did you mean ‘bthost_set_debug’? [-Werror=implicit-function-declaration]

 1350 |   bthost_debug(bthost, "le ext adv report: %s (0x%02x)",
      |   ^~~~~~~~~~~~
      |   bthost_set_debug

cc1: all warnings being treated as errors make[1]: *** [Makefile:6955: emulator/bthost.o] Error 1
make: *** [Makefile:4147: all] Error 2

---
Regards,
Linux Bluetooth