@@ -9815,408 +9950,1730 @@ static const struct generic_data set_exp_feat_unknown = {
.expect_status = MGMT_STATUS_NOT_SUPPORTED,
};
-static const char load_irks_params[] = { 0x01, 0x00,
- 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0x01,
- 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
- 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
+static const uint8_t add_device_le_public_param_1[] = {
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* BDADDR */
+ 0x01, /* Type - LE Public */
+ 0x02, /* Action - Auto-Connect */
+};
+static const uint8_t add_device_rsp_le_public[] = {
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* BDADDR */
+ 0x01, /* Type - LE Public */
+};
+static const char load_irks_le_public_param_1[] = {
+ 0x01, 0x00, /* Key Count */
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Key 1 - BDADDR */
+ 0x01, /* Key 1 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 1 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+};
-static void setup_load_irks_callback(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- if (status != MGMT_STATUS_SUCCESS) {
- tester_setup_failed();
- return;
- }
+static const uint8_t add_device_le_public_param_2[] = {
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x01, /* Type - LE Public */
+ 0x00, /* Action - Background scan */
+};
- tester_print("Load IRK completed");
-}
+static const uint8_t add_device_rsp_le_public_2[] = {
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x01, /* Type - LE Public */
+};
-static void setup_exp_feat_callback(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- if (status != MGMT_STATUS_SUCCESS) {
- tester_setup_failed();
- return;
+static const uint8_t add_device_le_public_param_3[] = {
+ 0x33, 0x33, 0x33, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x01, /* Type - LE Public */
+ 0x00, /* Action - Background scan */
+};
+
+static const uint8_t add_device_rsp_le_public_3[] = {
+ 0x33, 0x33, 0x33, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x01, /* Type - LE Public */
+};
+
+static const uint8_t add_device_le_public_param_4[] = {
+ 0x44, 0x44, 0x44, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x01, /* Type - LE Public */
+ 0x00, /* Action - Background scan */
+};
+
+static const uint8_t add_device_rsp_le_public_4[] = {
+ 0x44, 0x44, 0x44, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x01, /* Type - LE Public */
+};
+
+static const char load_irks_2_devices_param[] = {
+ 0x02, 0x00, /* Key Count */
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Key 1 - BDADDR */
+ 0x01, /* Key 1 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 1 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Key 2 - BDADDR */
+ 0x01, /* Key 2 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 2 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88
+};
+
+static const char load_irks_3_devices_param[] = {
+ 0x03, 0x00, /* Key Count */
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Key 1 - BDADDR */
+ 0x01, /* Key 1 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 1 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Key 2 - BDADDR */
+ 0x01, /* Key 2 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 2 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x33, 0x33, 0x33, 0x44, 0x55, 0x66, /* Key 3 - BDADDR */
+ 0x01, /* Key 3 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 3 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+};
+
+static const char load_irks_4_devices_param[] = {
+ 0x04, 0x00, /* Key Count */
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Key 1 - BDADDR */
+ 0x01, /* Key 1 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 1 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Key 2 - BDADDR */
+ 0x01, /* Key 2 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 2 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x33, 0x33, 0x33, 0x44, 0x55, 0x66, /* Key 3 - BDADDR */
+ 0x01, /* Key 3 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 3 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x55, 0x66, /* Key 4 - BDADDR */
+ 0x01, /* Key 4 - Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Key 4 - Value */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+};
+
+static const uint8_t le_add_to_accept_list_param[] = {
+ 0x00, /* Type */
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */
+};
+
+static const uint8_t le_add_to_white_list_param_2[] = {
+ 0x00, /* Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Address */
+};
+
+static const uint8_t le_add_to_white_list_param_3[] = {
+ 0x00, /* Type */
+ 0x33, 0x33, 0x33, 0x44, 0x55, 0x66, /* Address */
+};
+
+static const uint8_t le_add_to_resolv_list_param[] = {
+ 0x00, /* Type */
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* BDADDR */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Peer IRK */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* Local IRK */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+};
+
+static const uint8_t le_add_to_resolv_list_param_2[] = {
+ 0x00, /* Type */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Peer IRK */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* Local IRK */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+};
+
+static const uint8_t le_add_to_resolv_list_param_4[] = {
+ 0x00, /* Type */
+ 0x44, 0x44, 0x44, 0x44, 0x55, 0x66, /* BDADDR */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Peer IRK */
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* Local IRK */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+};
+
+static const char set_resolv_off_param[] = { 0x00 };
+static const char set_resolv_on_param[] = { 0x01 };
+
+static const struct generic_data ll_privacy_add_device_1 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_1,
+ .send_len = sizeof(add_device_le_public_param_1),
+ .expect_param = add_device_rsp_le,
+ .expect_len = sizeof(add_device_rsp_le),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_1,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_1),
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_ACCEPT_LIST,
+ .expect_hci_param = le_add_to_accept_list_param,
+ .expect_hci_len = sizeof(le_add_to_accept_list_param),
+};
+
+static uint16_t settings_le_privacy_ll_privacy[] = { MGMT_OP_SET_LE,
+ MGMT_OP_SET_PRIVACY,
+ MGMT_OP_SET_EXP_FEATURE, 0 };
+
+static const struct generic_data ll_privacy_add_device_2 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_1,
+ .send_len = sizeof(add_device_le_public_param_1),
+ .expect_param = add_device_rsp_le_public,
+ .expect_len = sizeof(add_device_rsp_le_public),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_1,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_1),
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST,
+ .expect_hci_param = le_add_to_resolv_list_param,
+ .expect_hci_len = sizeof(le_add_to_resolv_list_param),
+};
+
+static const struct hci_cmd_data ll_privacy_add_device_3_hci_list[] = {
+ {
+ .opcode = BT_HCI_CMD_LE_SET_RESOLV_ENABLE,
+ .param = set_resolv_off_param,
+ .len = sizeof(set_resolv_off_param),
+ },
+ {
+ .opcode = BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST,
+ .param = le_add_to_resolv_list_param,
+ .len = sizeof(le_add_to_resolv_list_param),
+ },
+ {
+ .opcode = BT_HCI_CMD_LE_ADD_TO_ACCEPT_LIST,
+ .param = le_add_to_accept_list_param,
+ .len = sizeof(le_add_to_accept_list_param),
+ },
+ {
+ .opcode = BT_HCI_CMD_LE_SET_RESOLV_ENABLE,
+ .param = set_resolv_on_param,
+ .len = sizeof(set_resolv_on_param),
+ },
+};
+
+static const struct generic_data ll_privacy_add_device_3 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_1,
+ .send_len = sizeof(add_device_le_public_param_1),
+ .expect_param = add_device_rsp_le,
+ .expect_len = sizeof(add_device_rsp_le),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_1,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_1),
+ .expect_hci_list = ll_privacy_add_device_3_hci_list,
+};
+
+static const struct generic_data ll_privacy_add_device_4 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_2,
+ .send_len = sizeof(add_device_le_public_param_2),
+ .expect_param = add_device_rsp_le_public_2,
+ .expect_len = sizeof(add_device_rsp_le_public_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_2,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_2),
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_ACCEPT_LIST,
+ .expect_hci_param = le_add_to_white_list_param_2,
+ .expect_hci_len = sizeof(le_add_to_white_list_param_2),
+};
+
+static const struct generic_data ll_privacy_add_device_5 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_2,
+ .send_len = sizeof(add_device_le_public_param_2),
+ .expect_param = add_device_rsp_le_public_2,
+ .expect_len = sizeof(add_device_rsp_le_public_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_2,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_2),
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST,
+ .expect_hci_param = le_add_to_resolv_list_param_2,
+ .expect_hci_len = sizeof(le_add_to_resolv_list_param_2),
+};
+
+static const struct generic_data ll_privacy_add_device_6 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_4,
+ .send_len = sizeof(add_device_le_public_param_4),
+ .expect_param = add_device_rsp_le_public_4,
+ .expect_len = sizeof(add_device_rsp_le_public_4),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_4,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_4),
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST,
+ .expect_hci_param = le_add_to_resolv_list_param_4,
+ .expect_hci_len = sizeof(le_add_to_resolv_list_param_4),
+};
+
+static const struct generic_data ll_privacy_add_device_7 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_3,
+ .send_len = sizeof(add_device_le_public_param_3),
+ .expect_param = add_device_rsp_le_public_3,
+ .expect_len = sizeof(add_device_rsp_le_public_3),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_3,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_3),
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_ACCEPT_LIST,
+ .expect_hci_param = le_add_to_white_list_param_3,
+ .expect_hci_len = sizeof(le_add_to_white_list_param_3),
+};
+
+static const char set_ext_adv_disable[] = {
+ 0x00, 0x00,
+};
+
+static const struct generic_data ll_privacy_add_device_8 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_3,
+ .send_len = sizeof(add_device_le_public_param_3),
+ .expect_param = add_device_rsp_le_public_3,
+ .expect_len = sizeof(add_device_rsp_le_public_3),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_3,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_3),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ .expect_hci_param = set_ext_adv_disable,
+ .expect_hci_len = sizeof(set_ext_adv_disable),
+};
+
+static const struct hci_cmd_data ll_privacy_add_device_9_hci_list[] = {
+ {
+ .opcode = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ .len = sizeof(set_ext_adv_disable),
+ .param = set_ext_adv_disable,
+ },
+ {
+ .opcode = BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST,
+ .len = sizeof(le_add_to_resolv_list_param),
+ .param = le_add_to_resolv_list_param
+ },
+};
+
+static const struct generic_data ll_privacy_add_device_9 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_ADD_DEVICE,
+ .send_param = add_device_le_public_param_1,
+ .send_len = sizeof(add_device_le_public_param_1),
+ .expect_param = add_device_rsp_le_public,
+ .expect_len = sizeof(add_device_rsp_le_public),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+ .expect_alt_ev_param = add_device_le_public_param_1,
+ .expect_alt_ev_len = sizeof(add_device_le_public_param_1),
+ .expect_hci_list = ll_privacy_add_device_9_hci_list,
+};
+
+static const struct generic_data ll_privacy_remove_device_1 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_REMOVE_DEVICE,
+ .send_param = remove_device_param_2,
+ .send_len = sizeof(remove_device_param_2),
+ .expect_param = remove_device_param_2,
+ .expect_len = sizeof(remove_device_param_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_ACCEPT_LIST,
+ .expect_hci_param = le_add_to_accept_list_param,
+ .expect_hci_len = sizeof(le_add_to_accept_list_param),
+ .expect_alt_ev = MGMT_EV_DEVICE_REMOVED,
+ .expect_alt_ev_param = remove_device_param_2,
+ .expect_alt_ev_len = sizeof(remove_device_param_2),
+};
+
+static const struct generic_data ll_privacy_remove_device_2 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_REMOVE_DEVICE,
+ .send_param = remove_device_param_2,
+ .send_len = sizeof(remove_device_param_2),
+ .expect_param = remove_device_param_2,
+ .expect_len = sizeof(remove_device_param_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST,
+ .expect_hci_param = le_add_to_accept_list_param,
+ .expect_hci_len = sizeof(le_add_to_accept_list_param),
+ .expect_alt_ev = MGMT_EV_DEVICE_REMOVED,
+ .expect_alt_ev_param = remove_device_param_2,
+ .expect_alt_ev_len = sizeof(remove_device_param_2),
+};
+
+static const struct generic_data ll_privacy_remove_device_3 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_REMOVE_DEVICE,
+ .send_param = remove_device_param_2,
+ .send_len = sizeof(remove_device_param_2),
+ .expect_param = remove_device_param_2,
+ .expect_len = sizeof(remove_device_param_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_RESOLV_ENABLE,
+ .expect_hci_param = set_resolv_off_param,
+ .expect_hci_len = sizeof(set_resolv_off_param),
+ .expect_alt_ev = MGMT_EV_DEVICE_REMOVED,
+ .expect_alt_ev_param = remove_device_param_2,
+ .expect_alt_ev_len = sizeof(remove_device_param_2),
+};
+
+static const struct generic_data ll_privacy_remove_device_4 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_REMOVE_DEVICE,
+ .send_param = remove_device_param_2,
+ .send_len = sizeof(remove_device_param_2),
+ .expect_param = remove_device_param_2,
+ .expect_len = sizeof(remove_device_param_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST,
+ .expect_hci_param = le_add_to_accept_list_param,
+ .expect_hci_len = sizeof(le_add_to_accept_list_param),
+ .expect_alt_ev = MGMT_EV_DEVICE_REMOVED,
+ .expect_alt_ev_param = remove_device_param_2,
+ .expect_alt_ev_len = sizeof(remove_device_param_2),
+};
+
+static const struct generic_data ll_privacy_remove_device_5 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_REMOVE_DEVICE,
+ .send_param = remove_device_param_2,
+ .send_len = sizeof(remove_device_param_2),
+ .expect_param = remove_device_param_2,
+ .expect_len = sizeof(remove_device_param_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST,
+ .expect_hci_param = le_add_to_accept_list_param,
+ .expect_hci_len = sizeof(le_add_to_accept_list_param),
+ .expect_alt_ev = MGMT_EV_DEVICE_REMOVED,
+ .expect_alt_ev_param = remove_device_param_2,
+ .expect_alt_ev_len = sizeof(remove_device_param_2),
+};
+
+static const struct generic_data ll_privacy_start_discovery_ll_privacy_1 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_SET_RESOLV_ENABLE,
+ .setup_expect_hci_param = set_resolv_on_param,
+ .setup_expect_hci_len = sizeof(set_resolv_on_param),
+ .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_hci_command = BT_HCI_CMD_LE_SET_RESOLV_ENABLE,
+ .expect_hci_param = set_resolv_off_param,
+ .expect_hci_len = sizeof(set_resolv_off_param),
+};
+
+static const struct generic_data ll_privacy_start_discovery_ll_privacy_2 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST,
+ .setup_expect_hci_param = le_add_to_accept_list_param,
+ .setup_expect_hci_len = sizeof(le_add_to_accept_list_param),
+ .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_hci_command = BT_HCI_CMD_LE_SET_RESOLV_ENABLE,
+ .expect_hci_param = set_resolv_off_param,
+ .expect_hci_len = sizeof(set_resolv_off_param),
+ .expect_alt_ev = MGMT_EV_DISCOVERING,
+ .expect_alt_ev_param = start_discovery_le_evt,
+ .expect_alt_ev_len = sizeof(start_discovery_le_evt),
+};
+
+static const struct generic_data ll_privacy_advertising_1 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_SET_ADVERTISING,
+ .send_param = set_adv_on_param2,
+ .send_len = sizeof(set_adv_on_param2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_ignore_param = true,
+};
+
+static const struct generic_data ll_privacy_acceptor_1 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .io_cap = 0x04, /* KeyboardDisplay */
+ .client_io_cap = 0x04, /* KeyboardDisplay */
+ .client_auth_req = 0x05, /* Bonding - MITM */
+ .expect_alt_ev = MGMT_EV_NEW_LONG_TERM_KEY,
+ .expect_alt_ev_len = sizeof(struct mgmt_ev_new_long_term_key),
+ .verify_alt_ev_func = verify_ltk,
+};
+
+static const struct generic_data ll_privacy_acceptor_2 = {
+ .setup_settings = settings_le_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .io_cap = 0x04, /* KeyboardDisplay */
+ .client_io_cap = 0x04, /* KeyboardDisplay */
+ .just_works = true,
+ .expect_alt_ev = MGMT_EV_NEW_LONG_TERM_KEY,
+ .expect_alt_ev_len = sizeof(struct mgmt_ev_new_long_term_key),
+ .verify_alt_ev_func = verify_ltk,
+};
+
+static const uint8_t unpair_client_1[] = {
+ 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00, /* Address */
+ 0x01, /* Type */
+ 0x01, /* Disconnect */
+};
+
+static const uint8_t unpair_resp_param_1[] = {
+ 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00, /* Address */
+ 0x01, /* Type */
+};
+
+static const uint8_t add_paired_client_1[] = {
+ 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00, /* Address */
+ 0x01, /* Type */
+ 0x00,
+};
+
+static const uint8_t remove_paired_device_1[] = {
+ 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00, /* Address */
+ 0x01, /* Type */
+};
+
+static const uint8_t add_to_al_client[] = {
+ 0x00, /* Address Type */
+ 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00, /* Address */
+};
+
+static uint16_t settings_powered_le_sc_bondable_privacy_ll_privacy[] = {
+ MGMT_OP_SET_LE,
+ MGMT_OP_SET_SSP,
+ MGMT_OP_SET_BONDABLE,
+ MGMT_OP_SET_SECURE_CONN,
+ MGMT_OP_SET_PRIVACY,
+ MGMT_OP_SET_EXP_FEATURE,
+ MGMT_OP_SET_POWERED, 0 };
+
+static const struct generic_data ll_privacy_pair_1 = {
+ .setup_settings = settings_powered_le_sc_bondable_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_PAIR_DEVICE,
+ .send_func = pair_device_send_param_func,
+ .addr_type_avail = true,
+ .addr_type = 0x01,
+ .client_enable_sc = true,
+ .client_enable_ssp = true,
+ .client_enable_adv = true,
+ .expect_sc_key = true,
+ .io_cap = 0x02, /* KeyboardOnly */
+ .client_io_cap = 0x02, /* KeyboardOnly */
+ .client_auth_req = 0x05, /* Bonding - MITM */
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_func = pair_device_expect_param_func,
+ .expect_alt_ev = MGMT_EV_NEW_LONG_TERM_KEY,
+ .expect_alt_ev_len = sizeof(struct mgmt_ev_new_long_term_key),
+ .verify_alt_ev_func = verify_ltk,
+};
+
+static const struct generic_data ll_privacy_pair_2 = {
+ .setup_settings = settings_powered_le_sc_bondable_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_PAIR_DEVICE,
+ .send_func = pair_device_send_param_func,
+ .addr_type_avail = true,
+ .addr_type = 0x01,
+ .client_enable_sc = true,
+ .client_enable_ssp = true,
+ .client_enable_adv = true,
+ .expect_sc_key = true,
+ .io_cap = 0x02, /* KeyboardOnly */
+ .client_io_cap = 0x02, /* KeyboardOnly */
+ .client_auth_req = 0x05, /* Bonding - MITM */
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_func = pair_device_expect_param_func,
+ .expect_alt_ev = MGMT_EV_NEW_LONG_TERM_KEY,
+ .expect_alt_ev_len = sizeof(struct mgmt_ev_new_long_term_key),
+ .verify_alt_ev_func = verify_ltk,
+ .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_ACCEPT_LIST,
+ .expect_hci_param = add_to_al_client,
+ .expect_hci_len = sizeof(add_to_al_client),
+};
+
+static const struct generic_data ll_privacy_unpair_1 = {
+ .setup_settings = settings_powered_le_sc_bondable_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_PAIR_DEVICE,
+ .send_func = pair_device_send_param_func,
+ .addr_type_avail = true,
+ .addr_type = 0x01,
+ .client_enable_sc = true,
+ .client_enable_ssp = true,
+ .client_enable_adv = true,
+ .expect_sc_key = true,
+ .io_cap = 0x02, /* KeyboardOnly */
+ .client_io_cap = 0x02, /* KeyboardOnly */
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_func = pair_device_expect_param_func,
+ .expect_alt_ev = MGMT_EV_DEVICE_UNPAIRED,
+ .expect_alt_ev_param = unpair_resp_param_1,
+ .expect_alt_ev_len = sizeof(unpair_resp_param_1),
+};
+
+static const struct generic_data ll_privacy_unpair_2 = {
+ .setup_settings = settings_powered_le_sc_bondable_privacy_ll_privacy,
+ .setup_exp_feat_param = set_exp_feat_param_ll_privacy,
+ .send_opcode = MGMT_OP_PAIR_DEVICE,
+ .send_func = pair_device_send_param_func,
+ .addr_type_avail = true,
+ .addr_type = 0x01,
+ .client_enable_sc = true,
+ .client_enable_ssp = true,
+ .client_enable_adv = true,
+ .expect_sc_key = true,
+ .io_cap = 0x02, /* KeyboardOnly */
+ .client_io_cap = 0x02, /* KeyboardOnly */
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_func = pair_device_expect_param_func,
+ .expect_alt_ev = MGMT_EV_DEVICE_UNPAIRED,
+ .expect_alt_ev_param = unpair_resp_param_1,
+ .expect_alt_ev_len = sizeof(unpair_resp_param_1),
+ .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_ACCEPT_LIST,
+ .expect_hci_param = add_to_al_client,
+ .expect_hci_len = sizeof(add_to_al_client),
+};
+
+static void setup_load_irks_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_setup_failed();
+ return;
+ }
+
+ tester_print("Load IRK completed");
+}
+
+static void setup_add_device_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_setup_failed();
+ return;
+ }
+
+ tester_print("New Device is Added");
+}
+
+static void setup_remove_device_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ bool bthost = PTR_TO_INT(user_data);
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_setup_failed();
+ return;
+ }
+
+ tester_print("Device is Removed");
+
+ if (bthost)
+ setup_bthost();
+}
+
+static void setup_add_adv_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct mgmt_rp_add_advertising *rp =
+ (struct mgmt_rp_add_advertising *) param;
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_setup_failed();
+ return;
+ }
+
+ tester_print("Add Advertising setup complete (instance %d)",
+ rp->instance);
+}
+
+static void setup_add_adv_callback_adv(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+ struct mgmt_rp_add_advertising *rp =
+ (struct mgmt_rp_add_advertising *) param;
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_setup_failed();
+ return;
+ }
+
+ tester_print("Add Advertising setup complete (instance %d)",
+ rp->instance);
+
+ /* Add another advertising */
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 2);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_advertising_callback,
+ NULL, NULL);
+}
+
+static void setup_ll_privacy_with_irk1(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_le_public_param_1),
+ load_irks_le_public_param_1,
+ setup_load_irks_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+
+}
+
+static void setup_ll_privacy_dev1_and_irk2(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+
+ /* Add IRKs of Device1 and Device2 */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_2_devices_param),
+ load_irks_2_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ /* Add Device 1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+static void setup_ll_privacy_3_devices(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+
+ /* Add IRKs of 4 Devices */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_4_devices_param),
+ load_irks_4_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ /* Add Device 1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 2 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 3 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_3),
+ add_device_le_public_param_3,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+static void setup_ll_privacy_2_devices_extra_rl(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+
+ hciemu_set_central_le_rl_len(data->hciemu, 2);
+
+ /* Add IRKs of 4 Devices */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_4_devices_param),
+ load_irks_4_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ /* Add Device 1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 2 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+static void setup_ll_privacy_2_devices_extra_al(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+
+ hciemu_set_central_le_al_len(data->hciemu, 2);
+
+ /* Add IRKs of 3 Devices */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_3_devices_param),
+ load_irks_3_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ /* Add Device 1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 2 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+/* Enable LL Privacy and Add 2 devices */
+static void setup_ll_privacy_device2_discovry(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+ uint8_t disc_param[] = { 0x06 };
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+ /* Load IRKs */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_2_devices_param),
+ load_irks_2_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ /* Load Device1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
+ sizeof(disc_param), disc_param,
+ setup_discovery_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_STOP_DISCOVERY, data->mgmt_index,
+ sizeof(disc_param), disc_param,
+ setup_discovery_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_REMOVE_DEVICE, data->mgmt_index,
+ sizeof(add_device_rsp_le_public),
+ add_device_rsp_le_public,
+ setup_remove_device_callback,
+ NULL, NULL);
+}
+
+/* Enable LL Privacy and Add Advertising */
+static void setup_ll_privacy_adv(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char param[] = { 0x01 };
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+/* Enable LL Privacy and Add Advertising */
+static void setup_ll_privacy_2_advs(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char param[] = { 0x01 };
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_le_public_param_1),
+ load_irks_le_public_param_1,
+ setup_load_irks_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback_adv, NULL, NULL);
+}
+
+static void setup_ll_privacy_dev_2_advs(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char param[] = { 0x01 };
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_le_public_param_1),
+ load_irks_le_public_param_1,
+ setup_load_irks_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ NULL, NULL, NULL);
+
+ /* Add Device 2 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback_adv, NULL, NULL);
+}
+
+static void setup_ll_privacy_adv_3_devices(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char param[] = { 0x01 };
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback, NULL, NULL);
+
+ /* Add IRKs of 4 Devices */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_4_devices_param),
+ load_irks_4_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ /* Add Device 1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 2 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 3 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_3),
+ add_device_le_public_param_3,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+static void setup_ll_privacy_adv_1_device_2_advs(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char param[] = { 0x01 };
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ /* Add IRKs of 4 Devices */
+ mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
+ sizeof(load_irks_4_devices_param),
+ load_irks_4_devices_param,
+ setup_load_irks_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ NULL, NULL, NULL);
+
+ /* Add Device 1 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ setup_add_device_callback, NULL, NULL);
+
+ /* Add Device 2 */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_2),
+ add_device_le_public_param_2,
+ setup_add_device_callback, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback_adv, NULL, NULL);
+}
+
+static void setup_add_2_advertisings(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+ unsigned char param[] = { 0x01 };
+
+ tester_print("Adding advertising instance while powered");
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback_adv,
+ NULL, NULL);
+}
+
+static void setup_add_2_advertisings_no_power(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+ unsigned char param[] = { 0x01 };
+
+ tester_print("Adding advertising instance while not powered");
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_adv_callback_adv,
+ NULL, NULL);
+}
+
+static void setup_ll_privacy_enable_powered(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned char param[] = { 0x01 };
+ struct bthost *bthost;
+
+ bthost = hciemu_client_get_host(data->hciemu);
+ bthost_set_scan_params(bthost, 0x01, 0x00, 0x00);
+ bthost_set_scan_enable(bthost, 0x01);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+static void setup_ll_privacy_add_adv(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ unsigned char param[] = { 0x01 };
+ unsigned char set_adv_param[] = { 0x02 };
+ struct bthost *bthost;
+
+ /* Setup bthost to enable the scan */
+ bthost = hciemu_client_get_host(data->hciemu);
+ bthost_set_scan_params(bthost, 0x01, 0x00, 0x00);
+ bthost_set_scan_enable(bthost, 0x01);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_BONDABLE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_IO_CAPABILITY, data->mgmt_index,
+ sizeof(test->io_cap), &test->io_cap,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_ADVERTISING, data->mgmt_index,
+ sizeof(set_adv_param),
+ &set_adv_param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), param,
+ setup_powered_callback, NULL, NULL);
+}
+
+static bool power_off(uint16_t index)
+{
+ int sk, err;
+
+ sk = hci_open_dev(index);
+ if (sk < 0)
+ return false;
+
+ err = ioctl(sk, HCIDEVDOWN, index);
+
+ hci_close_dev(sk);
+
+ if (err < 0)
+ return false;
+
+ return true;
+}
+
+/* Read HCI commands in the expect_hci_list and add it to the queue
+ */
+static void add_expect_hci_list(struct test_data *data)
+{
+ const struct generic_data *test = data->test_data;
+ const struct hci_cmd_data *hci_cmd_data;
+
+ /* Initialize the queue */
+ data->expect_hci_q = queue_new();
+
+ hci_cmd_data = test->expect_hci_list;
+ for (; hci_cmd_data->opcode; hci_cmd_data++) {
+ struct hci_entry *entry;
+
+ entry = new0(struct hci_entry, 1);
+ entry->cmd_data = hci_cmd_data;
+ queue_push_tail(data->expect_hci_q, entry);
+
+ test_add_condition(data);
+ }
+}
+
+static void test_command_generic(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const void *send_param = test->send_param;
+ uint16_t send_len = test->send_len;
+ unsigned int id;
+ uint16_t index;
+
+ index = test->send_index_none ? MGMT_INDEX_NONE : data->mgmt_index;
+
+ if (test->expect_settings_set || test->expect_settings_unset) {
+ tester_print("Registering new settings notification");
+
+ id = mgmt_register(data->mgmt, MGMT_EV_NEW_SETTINGS, index,
+ command_generic_new_settings, NULL, NULL);
+ data->mgmt_settings_id = id;
+
+ id = mgmt_register(data->mgmt_alt, MGMT_EV_NEW_SETTINGS, index,
+ command_generic_new_settings_alt, NULL, NULL);
+ data->mgmt_alt_settings_id = id;
+ test_add_condition(data);
+ }
+
+ if (test->expect_alt_ev) {
+ tester_print("Registering %s notification",
+ mgmt_evstr(test->expect_alt_ev));
+ id = mgmt_register(data->mgmt_alt, test->expect_alt_ev, index,
+ command_generic_event_alt, NULL, NULL);
+ data->mgmt_alt_ev_id = id;
+ test_add_condition(data);
+ }
+
+ if (test->expect_hci_command) {
+ tester_print("Registering HCI command callback");
+ hciemu_add_central_post_command_hook(data->hciemu,
+ command_hci_callback, data);
+ test_add_condition(data);
+ } else if (test->expect_hci_list) {
+ /* Use this when it needs to check more than 1 hci command.
+ * However, it cannot be used with expect_hci_command.
+ */
+ tester_print("Registering HCI command list callback");
+ hciemu_add_central_post_command_hook(data->hciemu,
+ command_hci_list_callback, data);
+ add_expect_hci_list(data);
+ }
+
+ if (test->send_opcode == 0x0000) {
+ tester_print("Executing no-op test");
+ return;
+ }
+
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(test->send_opcode),
+ test->send_opcode);
+
+ if (test->send_func)
+ send_param = test->send_func(&send_len);
+
+ if (test->force_power_off) {
+ mgmt_send_nowait(data->mgmt, test->send_opcode, index,
+ send_len, send_param,
+ command_generic_callback, NULL, NULL);
+ power_off(data->mgmt_index);
+ } else {
+ mgmt_send(data->mgmt, test->send_opcode, index, send_len,
+ send_param, command_generic_callback,
+ NULL, NULL);
+ }
+
+ test_add_condition(data);
+}
+
+static void check_scan(void *user_data)
+{
+ struct test_data *data = tester_get_data();
+
+ if (hciemu_get_central_le_scan_enable(data->hciemu)) {
+ tester_warn("LE scan still enabled");
+ tester_test_failed();
+ return;
+ }
+
+ if (hciemu_get_central_scan_enable(data->hciemu)) {
+ tester_warn("BR/EDR scan still enabled");
+ tester_test_failed();
+ return;
}
- tester_print("LL Privacy Exp feature is enabled");
+ test_condition_complete(data);
}
-static void setup_ll_privacy(const void *test_data)
+static void test_remove_device(const void *test_data)
{
struct test_data *data = tester_get_data();
- unsigned char param[] = { 0x01 };
- const uint8_t *ext_feat_param;
- size_t ext_feat_len;
- const char *irk_param;
- size_t irk_len;
- unsigned char privacy_param[] = { 0x01,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
- tester_print("Enabling LL Privacy feature");
+ test_command_generic(test_data);
+ tester_wait(1, check_scan, NULL);
+ test_add_condition(data);
+}
+
+static void trigger_device_found(void *user_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);
- ext_feat_param = set_exp_feat_param_ll_privacy;
- ext_feat_len = sizeof(set_exp_feat_param_ll_privacy);
+ 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);
- irk_param = load_irks_params;
- irk_len = sizeof(load_irks_params);
+ bthost_set_adv_enable(bthost, 0x01);
+ } else if (data->hciemu_type >= HCIEMU_TYPE_BREDRLE50) {
+ bthost_set_ext_adv_params(bthost);
+ if (test->set_adv)
+ bthost_set_ext_adv_data(bthost, test->adv_data,
+ test->adv_data_len);
- mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
- sizeof(param), ¶m,
- NULL, NULL, NULL);
+ bthost_set_ext_adv_enable(bthost, 0x01);
+ }
- mgmt_send(data->mgmt, MGMT_OP_SET_PRIVACY, data->mgmt_index,
- sizeof(privacy_param), privacy_param,
- NULL, NULL, NULL);
+ if (data->hciemu_type != HCIEMU_TYPE_LE)
+ bthost_write_scan_enable(bthost, 0x03);
- mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
- irk_len, irk_param,
- setup_load_irks_callback, NULL, NULL);
+ test_condition_complete(data);
+}
- mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, data->mgmt_index,
- ext_feat_len, ext_feat_param,
- setup_exp_feat_callback, NULL, NULL);
+static void test_device_found(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
- mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
- sizeof(param), param,
- setup_powered_callback, NULL, NULL);
+ test_command_generic(test_data);
+ /* Make sure discovery is enabled before enabling advertising. */
+ tester_wait(1, trigger_device_found, NULL);
+ test_add_condition(data);
}
-static void setup_add_device_callback(uint8_t status, uint16_t length,
- const void *param, void *user_data)
+static void pairing_new_conn(uint16_t handle, void *user_data)
{
- if (status != MGMT_STATUS_SUCCESS) {
- tester_setup_failed();
- return;
- }
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost;
- tester_print("New Device is Added");
+ tester_print("New connection with handle 0x%04x", handle);
+
+ bthost = hciemu_client_get_host(data->hciemu);
+
+ bthost_request_auth(bthost, handle);
}
-static void setup_ll_privacy_device(const void *test_data)
+static void test_pairing_acceptor(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
- unsigned char param[] = { 0x01 };
- const uint8_t *ext_feat_param;
- size_t ext_feat_len;
- const char *irk_param;
- size_t irk_len;
- const uint8_t *dev_param;
- size_t dev_len;
- unsigned char privacy_param[] = { 0x01,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
+ const uint8_t *central_bdaddr;
+ struct bthost *bthost;
+ uint8_t addr_type;
- tester_print("Setup expected HCI command 0x%04x",
- test->setup_expect_hci_command);
- hciemu_add_central_post_command_hook(data->hciemu,
- command_setup_hci_callback, data);
- test_add_setup_condition(data);
+ if (test->expect_alt_ev) {
+ unsigned int id;
+
+ tester_print("Registering %s notification",
+ mgmt_evstr(test->expect_alt_ev));
+ id = mgmt_register(data->mgmt_alt, test->expect_alt_ev,
+ data->mgmt_index,
+ command_generic_event_alt, NULL, NULL);
+ data->mgmt_alt_ev_id = id;
+ test_add_condition(data);
+ }
- tester_print("Enabling LL Privacy feature");
+ central_bdaddr = hciemu_get_central_bdaddr(data->hciemu);
+ if (!central_bdaddr) {
+ tester_warn("No central bdaddr");
+ tester_test_failed();
+ return;
+ }
- ext_feat_param = set_exp_feat_param_ll_privacy;
- ext_feat_len = sizeof(set_exp_feat_param_ll_privacy);
+ bthost = hciemu_client_get_host(data->hciemu);
+ bthost_set_connect_cb(bthost, pairing_new_conn, data);
- irk_param = load_irks_params;
- irk_len = sizeof(load_irks_params);
+ if (data->hciemu_type == HCIEMU_TYPE_BREDRLE)
+ addr_type = BDADDR_BREDR;
+ else
+ addr_type = BDADDR_LE_PUBLIC;
- dev_param = add_device_success_param_6;
- dev_len = sizeof(add_device_success_param_6);
+ bthost_hci_connect(bthost, central_bdaddr, addr_type);
+}
- mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
- sizeof(param), ¶m,
- NULL, NULL, NULL);
- mgmt_send(data->mgmt, MGMT_OP_SET_PRIVACY, data->mgmt_index,
- sizeof(privacy_param), privacy_param,
- NULL, NULL, NULL);
+static void check_le_ext_adv_discovery(void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *adv_addr;
+ struct bthost *bthost;
- mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
- irk_len, irk_param,
- setup_load_irks_callback, NULL, NULL);
+ adv_addr = hciemu_get_central_adv_addr(data->hciemu, 0x00);
+ if (!adv_addr) {
+ tester_warn("No EXT ADV Address");
+ tester_test_failed();
+ return;
+ }
- mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, data->mgmt_index,
- ext_feat_len, ext_feat_param,
- setup_exp_feat_callback, NULL, NULL);
+ bthost = hciemu_client_get_host(data->hciemu);
+ if (bthost_search_ext_adv_addr(bthost, adv_addr))
+ tester_test_passed();
+ else
+ tester_test_failed();
- mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
- dev_len, dev_param,
- setup_add_device_callback, NULL, NULL);
+ test_condition_complete(data);
+}
- mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
- sizeof(param), param,
- setup_powered_callback, NULL, NULL);
+static void test_ll_privacy_bthost_scan_report(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ test_command_generic(test_data);
+ tester_wait(1, check_le_ext_adv_discovery, NULL);
+ test_add_condition(data);
}
-static const uint8_t add_device_success_param_4[] = {
- 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
- 0x01,
- 0x02,
-};
+static void test_pairing_acceptor_ll_privacy_le_random(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const uint8_t *adv_addr;
+ struct bthost *bthost;
-/* Enable LL Privacy and Add 2 devices */
-static void setup_ll_privacy_device2(const void *test_data)
+ if (test->expect_alt_ev) {
+ unsigned int id;
+
+ tester_print("Registering %s notification",
+ mgmt_evstr(test->expect_alt_ev));
+ id = mgmt_register(data->mgmt_alt, test->expect_alt_ev,
+ data->mgmt_index,
+ command_generic_event_alt, NULL, NULL);
+ data->mgmt_alt_ev_id = id;
+ test_add_condition(data);
+ }
+
+ adv_addr = hciemu_get_central_adv_addr(data->hciemu, 0x00);
+ if (!adv_addr) {
+ tester_warn("No EXT ADV Address");
+ tester_test_failed();
+ return;
+ }
+
+ tester_print("Ext Adv Address: %02x:%02x:%02x:%02x:%02x:%02x",
+ adv_addr[0], adv_addr[1], adv_addr[2],
+ adv_addr[3], adv_addr[4], adv_addr[5]);
+
+ bthost = hciemu_client_get_host(data->hciemu);
+ bthost_set_connect_cb(bthost, pairing_new_conn, data);
+
+ bthost_hci_ext_connect(bthost, adv_addr, BDADDR_LE_RANDOM);
+}
+
+static void new_link_key_evt_pair_2_callback(uint16_t index, uint16_t length,
+ const void *param,
+ void *user_data)
{
struct test_data *data = tester_get_data();
- unsigned char param[] = { 0x01 };
- const uint8_t *ext_feat_param;
- size_t ext_feat_len;
- const char *irk_param;
- size_t irk_len;
- const uint8_t *dev_param, *dev2_param;
- size_t dev_len, dev2_len;
- unsigned char privacy_param[] = { 0x01,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
- tester_print("Enabling LL Privacy feature");
+ tester_print("New %s event received", mgmt_evstr(MGMT_EV_NEW_LINK_KEY));
- ext_feat_param = set_exp_feat_param_ll_privacy;
- ext_feat_len = sizeof(set_exp_feat_param_ll_privacy);
+ mgmt_unregister(data->mgmt, data->mgmt_discov_ev_id);
- irk_param = load_irks_params;
- irk_len = sizeof(load_irks_params);
+ /* TODO: validate the event */
+ test_condition_complete(data);
+}
- dev_param = add_device_success_param_6;
- dev_len = sizeof(add_device_success_param_6);
+static void test_ll_privacy_pair_2(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned int id;
- dev2_param = add_device_success_param_4;
- dev2_len = sizeof(add_device_success_param_4);
+ test_command_generic(test_data);
- mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
- sizeof(param), ¶m,
- NULL, NULL, NULL);
+ tester_print("Registering New Link Key notification");
+ id = mgmt_register(data->mgmt, MGMT_EV_NEW_LINK_KEY,
+ data->mgmt_index, new_link_key_evt_pair_2_callback,
+ NULL, NULL);
+ /* Reuse the variable */
+ data->mgmt_discov_ev_id = id;
+ test_add_condition(data);
+}
- mgmt_send(data->mgmt, MGMT_OP_SET_PRIVACY, data->mgmt_index,
- sizeof(privacy_param), privacy_param,
- NULL, NULL, NULL);
+static void unpair_device_command_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
- mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index,
- irk_len, irk_param,
- setup_load_irks_callback, NULL, NULL);
+ tester_print("%s (0x%04x): %s (0x%02x)",
+ mgmt_opstr(MGMT_OP_UNPAIR_DEVICE),
+ MGMT_OP_UNPAIR_DEVICE, mgmt_errstr(status), status);
- mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, data->mgmt_index,
- ext_feat_len, ext_feat_param,
- setup_exp_feat_callback, NULL, NULL);
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_warn("Unexpected status got %d expected %d",
+ status, MGMT_STATUS_SUCCESS);
+ tester_test_failed();
+ return;
+ }
+ test_condition_complete(data);
+}
- mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
- dev_len, dev_param,
- setup_add_device_callback, NULL, NULL);
+static void unpair_device(void *user_data)
+{
+ struct test_data *data = tester_get_data();
- mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
- dev2_len, dev2_param,
- setup_add_device_callback, NULL, NULL);
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(MGMT_OP_UNPAIR_DEVICE),
+ MGMT_OP_UNPAIR_DEVICE);
- mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
- sizeof(param), param,
- setup_powered_callback, NULL, NULL);
+ /* Send Unpair command */
+ mgmt_send(data->mgmt, MGMT_OP_UNPAIR_DEVICE, data->mgmt_index,
+ sizeof(unpair_client_1), unpair_client_1,
+ unpair_device_command_callback, NULL, NULL);
+ test_add_condition(data);
}
-static bool power_off(uint16_t index)
+static void disconnect_device_command_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
{
- int sk, err;
+ struct test_data *data = tester_get_data();
- sk = hci_open_dev(index);
- if (sk < 0)
- return false;
+ tester_print("%s (0x%04x): %s (0x%02x)",
+ mgmt_opstr(MGMT_OP_DISCONNECT),
+ MGMT_OP_DISCONNECT, mgmt_errstr(status), status);
- err = ioctl(sk, HCIDEVDOWN, index);
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_warn("Unexpected status got %d expected %d",
+ status, MGMT_STATUS_SUCCESS);
+ tester_test_failed();
+ return;
+ }
+ test_condition_complete(data);
- hci_close_dev(sk);
+ unpair_device(NULL);
+}
- if (err < 0)
- return false;
+static void unpair_disconnect_device(void *user_data)
+{
+ struct test_data *data = tester_get_data();
- return true;
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(MGMT_OP_DISCONNECT),
+ MGMT_OP_DISCONNECT);
+
+ /* Send Unpair command */
+ mgmt_send(data->mgmt, MGMT_OP_DISCONNECT, data->mgmt_index,
+ sizeof(remove_paired_device_1), remove_paired_device_1,
+ disconnect_device_command_callback, NULL, NULL);
+
+ test_add_condition(data);
}
-static void test_command_generic(const void *test_data)
+static void new_link_key_evt_unpair_callback(uint16_t index, uint16_t length,
+ const void *param,
+ void *user_data)
{
struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- const void *send_param = test->send_param;
- uint16_t send_len = test->send_len;
- unsigned int id;
- uint16_t index;
- index = test->send_index_none ? MGMT_INDEX_NONE : data->mgmt_index;
+ tester_print("New %s event received", mgmt_evstr(MGMT_EV_NEW_LINK_KEY));
+
+ mgmt_unregister(data->mgmt, data->mgmt_discov_ev_id);
+
+ /* TODO: validate the event */
+ test_condition_complete(data);
+
+ /* Wait 1 sec for pairing command complete event */
+ tester_wait(1, unpair_disconnect_device, NULL);
+}
- if (test->expect_settings_set || test->expect_settings_unset) {
- tester_print("Registering new settings notification");
+static void test_ll_privacy_unpair(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned int id;
- id = mgmt_register(data->mgmt, MGMT_EV_NEW_SETTINGS, index,
- command_generic_new_settings, NULL, NULL);
- data->mgmt_settings_id = id;
+ test_command_generic(test_data);
- id = mgmt_register(data->mgmt_alt, MGMT_EV_NEW_SETTINGS, index,
- command_generic_new_settings_alt, NULL, NULL);
- data->mgmt_alt_settings_id = id;
- test_add_condition(data);
- }
+ tester_print("Registering New Link Key notification");
+ id = mgmt_register(data->mgmt, MGMT_EV_NEW_LINK_KEY,
+ data->mgmt_index, new_link_key_evt_unpair_callback,
+ NULL, NULL);
+ /* Reuse the variable */
+ data->mgmt_discov_ev_id = id;
+ test_add_condition(data);
+}
- if (test->expect_alt_ev) {
- tester_print("Registering %s notification",
- mgmt_evstr(test->expect_alt_ev));
- id = mgmt_register(data->mgmt_alt, test->expect_alt_ev, index,
- command_generic_event_alt, NULL, NULL);
- data->mgmt_alt_ev_id = id;
- test_add_condition(data);
- }
+static void remove_device_command_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
- if (test->expect_hci_command) {
- tester_print("Registering HCI command callback");
- hciemu_add_central_post_command_hook(data->hciemu,
- command_hci_callback, data);
- test_add_condition(data);
- }
+ tester_print("%s (0x%04x): %s (0x%02x)",
+ mgmt_opstr(MGMT_OP_REMOVE_DEVICE),
+ MGMT_OP_REMOVE_DEVICE, mgmt_errstr(status), status);
- if (test->send_opcode == 0x0000) {
- tester_print("Executing no-op test");
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_warn("Unexpected status got %d expected %d",
+ status, MGMT_STATUS_SUCCESS);
+ tester_test_failed();
return;
}
+ test_condition_complete(data);
- tester_print("Sending %s (0x%04x)", mgmt_opstr(test->send_opcode),
- test->send_opcode);
+ unpair_device(NULL);
+}
- if (test->send_func)
- send_param = test->send_func(&send_len);
+static void remove_device(void *user_data)
+{
+ struct test_data *data = tester_get_data();
- if (test->force_power_off) {
- mgmt_send_nowait(data->mgmt, test->send_opcode, index,
- send_len, send_param,
- command_generic_callback, NULL, NULL);
- power_off(data->mgmt_index);
- } else {
- mgmt_send(data->mgmt, test->send_opcode, index, send_len,
- send_param, command_generic_callback,
- NULL, NULL);
- }
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(MGMT_OP_REMOVE_DEVICE),
+ MGMT_OP_REMOVE_DEVICE);
+ /* Send Unpair command */
+ mgmt_send(data->mgmt, MGMT_OP_REMOVE_DEVICE, data->mgmt_index,
+ sizeof(remove_paired_device_1), remove_paired_device_1,
+ remove_device_command_callback, NULL, NULL);
test_add_condition(data);
}
-static void check_scan(void *user_data)
+static void add_device_2_command_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
{
struct test_data *data = tester_get_data();
- if (hciemu_get_central_le_scan_enable(data->hciemu)) {
- tester_warn("LE scan still enabled");
- tester_test_failed();
- return;
- }
+ tester_print("%s (0x%04x): %s (0x%02x)",
+ mgmt_opstr(MGMT_OP_ADD_DEVICE),
+ MGMT_OP_ADD_DEVICE, mgmt_errstr(status), status);
- if (hciemu_get_central_scan_enable(data->hciemu)) {
- tester_warn("BR/EDR scan still enabled");
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_warn("Unexpected status got %d expected %d",
+ status, MGMT_STATUS_SUCCESS);
tester_test_failed();
return;
}
test_condition_complete(data);
+
+ remove_device(NULL);
}
-static void test_remove_device(const void *test_data)
+static void add_device_2(void *user_data)
{
struct test_data *data = tester_get_data();
- test_command_generic(test_data);
- tester_wait(1, check_scan, NULL);
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(MGMT_OP_ADD_DEVICE),
+ MGMT_OP_ADD_DEVICE);
+
+ /* Send Add Device command */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_device_le_public_param_1),
+ add_device_le_public_param_1,
+ add_device_2_command_callback, NULL, NULL);
+
test_add_condition(data);
}
-static void trigger_device_found(void *user_data)
+static void add_device_command_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_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);
+ tester_print("%s (0x%04x): %s (0x%02x)",
+ mgmt_opstr(MGMT_OP_ADD_DEVICE),
+ MGMT_OP_ADD_DEVICE, mgmt_errstr(status), status);
- 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);
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_warn("Unexpected status got %d expected %d",
+ status, MGMT_STATUS_SUCCESS);
+ tester_test_failed();
+ return;
+ }
+ test_condition_complete(data);
- bthost_set_adv_enable(bthost, 0x01);
- } else if (data->hciemu_type >= HCIEMU_TYPE_BREDRLE50) {
- bthost_set_ext_adv_params(bthost);
- if (test->set_adv)
- bthost_set_ext_adv_data(bthost, test->adv_data,
- test->adv_data_len);
+ add_device_2(NULL);
+}
- bthost_set_ext_adv_enable(bthost, 0x01);
- }
+static void add_device(void *user_data)
+{
+ struct test_data *data = tester_get_data();
- if (data->hciemu_type != HCIEMU_TYPE_LE)
- bthost_write_scan_enable(bthost, 0x03);
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(MGMT_OP_ADD_DEVICE),
+ MGMT_OP_ADD_DEVICE);
- test_condition_complete(data);
+ /* Send Unpair command */
+ mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index,
+ sizeof(add_paired_client_1), add_paired_client_1,
+ add_device_command_callback, NULL, NULL);
+ test_add_condition(data);
}
-static void test_device_found(const void *test_data)
+static void unpair_2_disconnect_command_callback(uint8_t status,
+ uint16_t length,
+ const void *param,
+ void *user_data)
{
struct test_data *data = tester_get_data();
- test_command_generic(test_data);
+ tester_print("%s (0x%04x): %s (0x%02x)",
+ mgmt_opstr(MGMT_OP_DISCONNECT),
+ MGMT_OP_DISCONNECT, mgmt_errstr(status), status);
- /* Make sure discovery is enabled before enabling advertising. */
- tester_wait(1, trigger_device_found, NULL);
- test_add_condition(data);
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_warn("Unexpected status got %d expected %d",
+ status, MGMT_STATUS_SUCCESS);
+ tester_test_failed();
+ return;
+ }
+ test_condition_complete(data);
+
+ add_device(NULL);
}
-static void pairing_new_conn(uint16_t handle, void *user_data)
+static void unpair_2_disconnect_device(void *user_data)
{
struct test_data *data = tester_get_data();
- struct bthost *bthost;
- tester_print("New connection with handle 0x%04x", handle);
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(MGMT_OP_DISCONNECT),
+ MGMT_OP_DISCONNECT);
- bthost = hciemu_client_get_host(data->hciemu);
+ /* Send Unpair command */
+ mgmt_send(data->mgmt, MGMT_OP_DISCONNECT, data->mgmt_index,
+ sizeof(remove_paired_device_1), remove_paired_device_1,
+ unpair_2_disconnect_command_callback, NULL, NULL);
- bthost_request_auth(bthost, handle);
+ test_add_condition(data);
}
-static void test_pairing_acceptor(const void *test_data)
+static void new_link_key_evt_add_dev_callback(uint16_t index, uint16_t length,
+ const void *param,
+ void *user_data)
{
struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- const uint8_t *central_bdaddr;
- struct bthost *bthost;
- uint8_t addr_type;
- if (test->expect_alt_ev) {
- unsigned int id;
+ tester_print("New %s event received", mgmt_evstr(MGMT_EV_NEW_LINK_KEY));
- tester_print("Registering %s notification",
- mgmt_evstr(test->expect_alt_ev));
- id = mgmt_register(data->mgmt_alt, test->expect_alt_ev,
- data->mgmt_index,
- command_generic_event_alt, NULL, NULL);
- data->mgmt_alt_ev_id = id;
- test_add_condition(data);
- }
+ mgmt_unregister(data->mgmt, data->mgmt_discov_ev_id);
- central_bdaddr = hciemu_get_central_bdaddr(data->hciemu);
- if (!central_bdaddr) {
- tester_warn("No central bdaddr");
- tester_test_failed();
- return;
- }
+ /* TODO: validate the event */
+ test_condition_complete(data);
- bthost = hciemu_client_get_host(data->hciemu);
- bthost_set_connect_cb(bthost, pairing_new_conn, data);
+ /* Wait 1 sec for pairing command complete event */
+ tester_wait(1, unpair_2_disconnect_device, NULL);
+}
- if (data->hciemu_type == HCIEMU_TYPE_BREDRLE)
- addr_type = BDADDR_BREDR;
- else
- addr_type = BDADDR_LE_PUBLIC;
+static void test_ll_privacy_unpair_2(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ unsigned int id;
- bthost_hci_connect(bthost, central_bdaddr, addr_type);
+ test_command_generic(test_data);
+
+ tester_print("Registering New Link Key notification");
+ id = mgmt_register(data->mgmt, MGMT_EV_NEW_LINK_KEY,
+ data->mgmt_index, new_link_key_evt_add_dev_callback,
+ NULL, NULL);
+ /* Reuse the variable */
+ data->mgmt_discov_ev_id = id;
+ test_add_condition(data);
}
static void connected_event(uint16_t index, uint16_t length, const void *param,