diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index 5602636..e9c0c1d 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
HDP_APP_SOURCE_STREAM,
} hdp_app_reg_type;
-struct emu_cid_data {
- uint16_t sdp_handle;
- uint16_t sdp_cid;
- uint16_t ctrl_handle;
- uint16_t ctrl_cid;
- uint16_t data_handle;
- uint16_t data_cid;
+#define hdp_rsp_pdu 0x07, \
+ 0x00, 0x00, \
+ 0x01, 0xc8, \
+ 0x01, 0xc5, \
+ 0x36, 0x01, 0xc2, 0x36, 0x01, 0xbf, 0x09, 0x00, 0x00, \
+ 0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35, \
+ 0x03, 0x19, 0x14, 0x01, 0x09, 0x00, 0x04, 0x35, 0x10, \
+ 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x10, 0x01, 0x35, \
+ 0x06, 0x19, 0x00, 0x1e, 0x09, 0x01, 0x00, 0x09, 0x00, \
+ 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x14, 0x00, 0x09, \
+ 0x01, 0x01, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35, 0x0d, \
+ 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x10, 0x03, 0x35, \
+ 0x03, 0x19, 0x00, 0x1f, 0x09, 0x01, 0x00, 0x25, 0x03, \
+ 0x48, 0x44, 0x50, 0x09, 0x01, 0x01, 0x25, 0x28, 0x43, \
+ 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x2c, 0x20, 0x64, \
+ 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x2c, 0x20, 0x61, \
+ 0x6e, 0x64, 0x20, 0x72, 0x65, 0x8b, 0x6c, 0x61, 0x79, \
+ 0x20, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x20, 0x64, \
+ 0x61, 0x74, 0x61, 0x09, 0x01, 0x02, 0x25, 0x0d, 0x42, \
+ 0x4c, 0x55, 0x45, 0x54, 0x4f, 0x4f, 0x54, 0x48, 0x20, \
+ 0x53, 0x49, 0x47, 0x09, 0x02, 0x00, 0x36, 0x01, 0x22, \
+ 0x35, 0x18, 0x08, 0x01, 0x09, 0x10, 0x04, 0x08, 0x00, \
+ 0x25, 0x0f, 0x50, 0x75, 0x6c, 0x73, 0x65, 0x20, 0x4f, \
+ 0x78, 0x69, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35, \
+ 0x20, 0x08, 0x02, 0x09, 0x10, 0x07, 0x08, 0x00, 0x25, \
+ 0x17, 0x42, 0x6c, 0x6f, 0x6f, 0x64, 0x20, 0x50, 0x72, \
+ 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x20, 0x4d, 0x6f, \
+ 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0d, 0x35, 0x1a, 0x08, \
+ 0x03, 0x09, 0x10, 0x08, 0x08, 0x00, 0x25, 0x11, 0x42, \
+ 0x6f, 0x64, 0x79, 0x20, 0x54, 0x68, 0x65, 0x72, 0x6d, \
+ 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35, 0x1e, \
+ 0x08, 0x04, 0x09, 0x10, 0x0f, 0x08, 0x00, 0x25, 0x15, \
+ 0x42, 0x6f, 0x64, 0x79, 0x20, 0x57, 0x65, 0x69, 0x67, \
+ 0x68, 0x74, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x09, \
+ 0x09, 0x09, 0x0d, 0x35, 0x17, 0x08, 0x05, 0x09, 0x10, \
+ 0x11, 0x08, 0x00, 0x25, 0x0e, 0x47, 0x6c, 0x75, 0x63, \
+ 0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65, 0x72, \
+ 0x0d, 0x35, 0x18, 0x08, 0x06, 0x09, 0x10, 0x04, 0x08, \
+ 0x01, 0x25, 0x0f, 0x50, 0x75, 0x6c, 0x73, 0x65, 0x20, \
+ 0x4f, 0x78, 0x69, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, \
+ 0x35, 0x20, 0x08, 0x07, 0x09, 0x10, 0x07, 0x08, 0x01, \
+ 0x25, 0x17, 0x42, 0x6c, 0x6f, 0x6f, 0x64, 0x20, 0x50, \
+ 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x20, 0x4d, \
+ 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0d, 0x35, 0x1a, \
+ 0x08, 0x08, 0x09, 0x10, 0x08, 0x08, 0x01, 0x25, 0x11, \
+ 0x42, 0x6f, 0x64, 0x79, 0x20, 0x54, 0x68, 0x65, 0x72, \
+ 0x6d, 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35, \
+ 0x1e, 0x08, 0x09, 0x09, 0x10, 0x0f, 0x08, 0x01, 0x25, \
+ 0x15, 0x42, 0x6f, 0x64, 0x79, 0x20, 0x57, 0x65, 0x69, \
+ 0x67, 0x68, 0x74, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65, \
+ 0x09, 0x09, 0x09, 0x0d, 0x35, 0x17, 0x08, 0x0a, 0x09, \
+ 0x10, 0x11, 0x08, 0x01, 0x25, 0x0e, 0x47, 0x6c, 0x75, \
+ 0x63, 0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65, \
+ 0x72, 0x0d, 0x09, 0x03, 0x01, 0x08, 0x01, 0x09, 0x03, \
+ 0x02, 0x08, 0x00, \
+ 0x00
+
+static const struct pdu_set sdp_pdus[] = {
+ { end_pdu, raw_pdu(hdp_rsp_pdu) },
+ { end_pdu, end_pdu },
};
-struct emu_cid_data cid_data;
+static struct emu_l2cap_cid_data sdp_cid_data = {
+ .pdu = sdp_pdus,
+ .is_sdp = TRUE,
+};
+
+static struct emu_l2cap_cid_data ctrl_cid_data;
+static struct emu_l2cap_cid_data data_cid_data;
static struct queue *list; /* List of hdp test cases */
schedule_action_verification(step);
}
-static const struct iovec hdp_rsp_pdu = raw_pdu(
- 0x07, /* PDU id */
- 0x00, 0x00, /* Transaction id */
- 0x01, 0xc8, /* Response length */
- 0x01, 0xc5, /* Attributes length */
- 0x36, 0x01, 0xc2, 0x36, 0x01, 0xbf, 0x09, 0x00, 0x00,
- 0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35,
- 0x03, 0x19, 0x14, 0x01, 0x09, 0x00, 0x04, 0x35, 0x10,
- 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x10, 0x01, 0x35,
- 0x06, 0x19, 0x00, 0x1e, 0x09, 0x01, 0x00, 0x09, 0x00,
- 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x14, 0x00, 0x09,
- 0x01, 0x01, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35, 0x0d,
- 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x10, 0x03, 0x35,
- 0x03, 0x19, 0x00, 0x1f, 0x09, 0x01, 0x00, 0x25, 0x03,
- 0x48, 0x44, 0x50, 0x09, 0x01, 0x01, 0x25, 0x28, 0x43,
- 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x2c, 0x20, 0x64,
- 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x2c, 0x20, 0x61,
- 0x6e, 0x64, 0x20, 0x72, 0x65, 0x8b, 0x6c, 0x61, 0x79,
- 0x20, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x20, 0x64,
- 0x61, 0x74, 0x61, 0x09, 0x01, 0x02, 0x25, 0x0d, 0x42,
- 0x4c, 0x55, 0x45, 0x54, 0x4f, 0x4f, 0x54, 0x48, 0x20,
- 0x53, 0x49, 0x47, 0x09, 0x02, 0x00, 0x36, 0x01, 0x22,
- 0x35, 0x18, 0x08, 0x01, 0x09, 0x10, 0x04, 0x08, 0x00,
- 0x25, 0x0f, 0x50, 0x75, 0x6c, 0x73, 0x65, 0x20, 0x4f,
- 0x78, 0x69, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35,
- 0x20, 0x08, 0x02, 0x09, 0x10, 0x07, 0x08, 0x00, 0x25,
- 0x17, 0x42, 0x6c, 0x6f, 0x6f, 0x64, 0x20, 0x50, 0x72,
- 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x20, 0x4d, 0x6f,
- 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0d, 0x35, 0x1a, 0x08,
- 0x03, 0x09, 0x10, 0x08, 0x08, 0x00, 0x25, 0x11, 0x42,
- 0x6f, 0x64, 0x79, 0x20, 0x54, 0x68, 0x65, 0x72, 0x6d,
- 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35, 0x1e,
- 0x08, 0x04, 0x09, 0x10, 0x0f, 0x08, 0x00, 0x25, 0x15,
- 0x42, 0x6f, 0x64, 0x79, 0x20, 0x57, 0x65, 0x69, 0x67,
- 0x68, 0x74, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x09,
- 0x09, 0x09, 0x0d, 0x35, 0x17, 0x08, 0x05, 0x09, 0x10,
- 0x11, 0x08, 0x00, 0x25, 0x0e, 0x47, 0x6c, 0x75, 0x63,
- 0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65, 0x72,
- 0x0d, 0x35, 0x18, 0x08, 0x06, 0x09, 0x10, 0x04, 0x08,
- 0x01, 0x25, 0x0f, 0x50, 0x75, 0x6c, 0x73, 0x65, 0x20,
- 0x4f, 0x78, 0x69, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d,
- 0x35, 0x20, 0x08, 0x07, 0x09, 0x10, 0x07, 0x08, 0x01,
- 0x25, 0x17, 0x42, 0x6c, 0x6f, 0x6f, 0x64, 0x20, 0x50,
- 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x20, 0x4d,
- 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0d, 0x35, 0x1a,
- 0x08, 0x08, 0x09, 0x10, 0x08, 0x08, 0x01, 0x25, 0x11,
- 0x42, 0x6f, 0x64, 0x79, 0x20, 0x54, 0x68, 0x65, 0x72,
- 0x6d, 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35,
- 0x1e, 0x08, 0x09, 0x09, 0x10, 0x0f, 0x08, 0x01, 0x25,
- 0x15, 0x42, 0x6f, 0x64, 0x79, 0x20, 0x57, 0x65, 0x69,
- 0x67, 0x68, 0x74, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65,
- 0x09, 0x09, 0x09, 0x0d, 0x35, 0x17, 0x08, 0x0a, 0x09,
- 0x10, 0x11, 0x08, 0x01, 0x25, 0x0e, 0x47, 0x6c, 0x75,
- 0x63, 0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65,
- 0x72, 0x0d, 0x09, 0x03, 0x01, 0x08, 0x01, 0x09, 0x03,
- 0x02, 0x08, 0x00,
- 0x00);
-
-static void hdp_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
-{
- struct test_data *t_data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- struct emu_cid_data *cid_data = user_data;
-
- ((uint8_t *) hdp_rsp_pdu.iov_base)[1] = ((uint8_t *) data)[1];
- ((uint8_t *) hdp_rsp_pdu.iov_base)[2] = ((uint8_t *) data)[2];
-
- bthost_send_cid_v(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
- &hdp_rsp_pdu, 1);
-}
-
static void hdp_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
{
- struct test_data *data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+ struct emu_l2cap_cid_data *cid_data = user_data;
- cid_data.sdp_handle = handle;
- cid_data.sdp_cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;
- bthost_add_cid_hook(bthost, handle, cid, hdp_sdp_cid_hook_cb,
- &cid_data);
+ tester_handle_l2cap_data_exchange(cid_data);
}
static void mcap_ctrl_cid_hook_cb(const void *data, uint16_t len,
{
struct test_data *t_data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+ struct emu_l2cap_cid_data *cid_data = user_data;
uint8_t crt_rsp[5], del_rsp[4], config;
uint8_t opcode = ((uint8_t *) data)[0];
static bool reliable = false;
crt_rsp[4] = config;
}
- bthost_send_cid(bthost, cid_data.ctrl_handle,
- cid_data.ctrl_cid,
+ bthost_send_cid(bthost, cid_data->handle,
+ cid_data->cid,
crt_rsp, sizeof(crt_rsp));
break;
case 0x03: /* MD_RECONNECT_MDL_REQ */
del_rsp[1] = 0x00; /* Response code - Success */
del_rsp[2] = ((uint8_t *) data)[1]; /* mdlid */
del_rsp[3] = ((uint8_t *) data)[2];
- bthost_send_cid(bthost, cid_data.ctrl_handle,
- cid_data.ctrl_cid,
+ bthost_send_cid(bthost, cid_data->handle,
+ cid_data->cid,
del_rsp, sizeof(del_rsp));
break;
}
{
struct test_data *data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+ struct emu_l2cap_cid_data *cid_data = user_data;
- cid_data.ctrl_handle = handle;
- cid_data.ctrl_cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;
bthost_add_cid_hook(bthost, handle, cid, mcap_ctrl_cid_hook_cb,
- &cid_data);
+ cid_data);
}
static void mcap_data_cid_hook_cb(const void *data, uint16_t len,
{
struct test_data *data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+ struct emu_l2cap_cid_data *cid_data = user_data;
- cid_data.data_handle = handle;
- cid_data.data_cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;
bthost_add_cid_hook(bthost, handle, cid, mcap_data_cid_hook_cb,
- &cid_data);
+ cid_data);
}
/* Emulate SDP (PSM = 1) */
static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
.psm = 1,
.func = hdp_sdp_search_cb,
- .user_data = NULL,
+ .user_data = &sdp_cid_data,
};
/* Emulate Control Channel (PSM = 0x1001) */
static struct emu_set_l2cap_data l2cap_setup_cc_data = {
.psm = 0x1001,
.func = mcap_ctrl_connect_cb,
- .user_data = NULL,
+ .user_data = &ctrl_cid_data,
};
/* Emulate Data Channel (PSM = 0x1003) */
static struct emu_set_l2cap_data l2cap_setup_dc_data = {
.psm = 0x1003,
.func = mcap_data_connect_cb,
- .user_data = NULL,
+ .user_data = &data_cid_data,
};
static void hdp_connect_source_reliable_action(void)