This allows to set any ADV data and not just flags.
---
android/tester-main.c | 13 +++++++++++--
emulator/bthost.c | 35 +++++++++++++++++------------------
emulator/bthost.h | 5 +++--
tools/l2cap-tester.c | 2 +-
tools/mgmt-tester.c | 2 +-
tools/smp-tester.c | 2 +-
6 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/android/tester-main.c b/android/tester-main.c
index 2506548..19400fc 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -2719,8 +2719,17 @@ void emu_setup_powered_remote_action(void)
bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
if ((data->hciemu_type == HCIEMU_TYPE_LE) ||
- (data->hciemu_type == HCIEMU_TYPE_BREDRLE))
- bthost_set_adv_enable(bthost, 0x01, 0x02);
+ (data->hciemu_type == HCIEMU_TYPE_BREDRLE)) {
+ uint8_t adv[4];
+
+ adv[0] = 0x02; /* Field length */
+ adv[1] = 0x01; /* Flags */
+ adv[2] = 0x02; /* Flags value */
+ adv[3] = 0x00; /* Field terminator */
+
+ bthost_set_adv_data(bthost, adv, sizeof(adv));
+ bthost_set_adv_enable(bthost, 0x01);
+ }
if (data->hciemu_type != HCIEMU_TYPE_LE)
bthost_write_scan_enable(bthost, 0x03);
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 2b48ad8..29bbe5d 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -2279,30 +2279,29 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
}
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable, uint8_t flags)
+void bthost_set_adv_data(struct bthost *bthost, const uint8_t *data,
+ uint8_t len)
{
- struct bt_hci_cmd_le_set_adv_parameters cp;
-
- memset(&cp, 0, sizeof(cp));
- send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
- &cp, sizeof(cp));
+ struct bt_hci_cmd_le_set_adv_data adv_cp;
- if (flags) {
- struct bt_hci_cmd_le_set_adv_data adv_cp;
+ memset(adv_cp.data, 0, 31);
- memset(adv_cp.data, 0, 31);
-
- adv_cp.data[0] = 0x02; /* Field length */
- adv_cp.data[1] = 0x01; /* Flags */
- adv_cp.data[2] = flags;
+ if (len) {
+ adv_cp.len = len;
+ memcpy(adv_cp.data, data, len);
+ }
- adv_cp.data[3] = 0x00; /* Field terminator */
+ send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
+ sizeof(adv_cp));
+}
- adv_cp.len = 1 + adv_cp.data[0];
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
+{
+ struct bt_hci_cmd_le_set_adv_parameters cp;
- send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
- sizeof(adv_cp));
- }
+ memset(&cp, 0, sizeof(cp));
+ send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ &cp, sizeof(cp));
send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
}
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 6beb1f4..7110db8 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -79,8 +79,9 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
- uint8_t flags);
+void bthost_set_adv_data(struct bthost *bthost, const uint8_t *data,
+ uint8_t len);
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 7f03591..2b89045 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -546,7 +546,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, user_data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01, 0x00);
+ bthost_set_adv_enable(bthost, 0x01);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index fab8d35..fd5ef7d 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4547,7 +4547,7 @@ static void setup_bthost(void)
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01, 0x00);
+ bthost_set_adv_enable(bthost, 0x01);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index c44dc2d..d24c9b2 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
@@ -493,7 +493,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
- bthost_set_adv_enable(bthost, 0x01, 0x00);
+ bthost_set_adv_enable(bthost, 0x01);
}
static void make_pk(struct test_data *data)
--
1.9.3
Hi Szymon,
On Thu, May 14, 2015, Szymon Janc wrote:
> This allows to set any ADV data and not just flags.
> ---
> android/tester-main.c | 13 +++++++++++--
> emulator/bthost.c | 35 +++++++++++++++++------------------
> emulator/bthost.h | 5 +++--
> tools/l2cap-tester.c | 2 +-
> tools/mgmt-tester.c | 2 +-
> tools/smp-tester.c | 2 +-
> 6 files changed, 34 insertions(+), 25 deletions(-)
All three patches have been applied. Thanks.
Johan
---
doc/test-coverage.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt
index 2fb70ad..268c465 100644
--- a/doc/test-coverage.txt
+++ b/doc/test-coverage.txt
@@ -39,7 +39,7 @@ Automated end-to-end testing
Application Count Description
-------------------------------------------
-mgmt-tester 295 Kernel management interface testing
+mgmt-tester 296 Kernel management interface testing
l2cap-tester 27 Kernel L2CAP implementation testing
rfcomm-tester 9 Kernel RFCOMM implementation testing
bnep-tester 1 Kernel BNEP implementation testing
@@ -48,7 +48,7 @@ sco-tester 8 Kernel SCO implementation testing
gap-tester 1 Daemon D-Bus API testing
hci-tester 14 Controller hardware testing
-----
- 361
+ 362
Android end-to-end testing
--
1.9.3
This test verify if kernel correctly terminates EIR when invalid
ADV_DATA (length includes non-significant part) was received from
remote device.
---
tools/mgmt-tester.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index fd5ef7d..3ecddab 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -429,6 +429,9 @@ struct generic_data {
bool force_power_off;
bool addr_type_avail;
uint8_t addr_type;
+ bool set_adv;
+ const uint8_t *adv_data;
+ uint8_t adv_data_len;
};
static const char dummy_data[] = { 0x00 };
@@ -4467,6 +4470,33 @@ static const struct generic_data remove_advertising_success_2 = {
.expect_hci_len = sizeof(set_adv_off_param),
};
+/* based on G-Tag ADV_DATA */
+static const uint8_t adv_data_invalid_significant_len[] = { 0x02, 0x01, 0x06,
+ 0x0d, 0xff, 0x80, 0x01, 0x02, 0x15, 0x12, 0x34, 0x80, 0x91,
+ 0xd0, 0xf2, 0xbb, 0xc5, 0x03, 0x02, 0x0f, 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const char device_found_valid[] = { 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00,
+ 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x02, 0x01,
+ 0x06, 0x0d, 0xff, 0x80, 0x01, 0x02, 0x15, 0x12, 0x34, 0x80,
+ 0x91, 0xd0, 0xf2, 0xbb, 0xc5, 0x03, 0x02, 0x0f, 0x18 };
+
+static const struct generic_data device_found_gtag = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_START_DISCOVERY,
+ .send_param = start_discovery_le_param,
+ .send_len = sizeof(start_discovery_le_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = start_discovery_le_param,
+ .expect_len = sizeof(start_discovery_le_param),
+ .expect_alt_ev = MGMT_EV_DEVICE_FOUND,
+ .expect_alt_ev_param = device_found_valid,
+ .expect_alt_ev_len = sizeof(device_found_valid),
+ .set_adv = true,
+ .adv_data_len = sizeof(adv_data_invalid_significant_len),
+ .adv_data = adv_data_invalid_significant_len,
+};
+
static const struct generic_data read_local_oob_not_powered_test = {
.send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA,
.expect_status = MGMT_STATUS_NOT_POWERED,
@@ -5481,6 +5511,29 @@ static void test_command_generic(const void *test_data)
test_add_condition(data);
}
+static void test_device_found(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ struct bthost *bthost;
+
+ bthost = hciemu_client_get_host(data->hciemu);
+
+ if ((data->hciemu_type == HCIEMU_TYPE_LE) ||
+ (data->hciemu_type == HCIEMU_TYPE_BREDRLE)) {
+ if (test->set_adv)
+ bthost_set_adv_data(bthost, test->adv_data,
+ test->adv_data_len);
+
+ bthost_set_adv_enable(bthost, 0x01);
+ }
+
+ if (data->hciemu_type != HCIEMU_TYPE_LE)
+ bthost_write_scan_enable(bthost, 0x03);
+
+ test_command_generic(test_data);
+}
+
static void pairing_new_conn(uint16_t handle, void *user_data)
{
struct test_data *data = tester_get_data();
@@ -6535,5 +6588,9 @@ int main(int argc, char *argv[])
&read_local_oob_success_sc_test,
NULL, test_command_generic);
+ test_bredrle("Device Found - Invalid remote ADV_DATA",
+ &device_found_gtag,
+ NULL, test_device_found);
+
return tester_run();
}
--
1.9.3