2014-10-02 08:10:48

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 00/13] android/tester: Unifying the way PDU is handled

This patchset makes all testers use common struct for using raw data (PDUs).
Also some helpers were added for pdu matching and sending.

v4 changes:
* patches were redone with iovectors from the start,
* sdp pdu sending was improved (no need to have non const pdus anymore)

v3 changes:
* added one more patch replacing the pdu struct with iovec and making testers
use bthost's iovec specific API.
* minor include fix
* minor commit message correction

v2 changes:
* added generic hook and connect callback in tester-main for handling simple
cases when only pdu exchange is needed on given channel

Jakub Tyszkowski (13):
android/tester: Replace gatt-tester's pdu structs with io vectors
android/tester: Expose structs holding request pdu and response pdu
android/tester: Make HidHost tests use io vectors for pdu
android/tester: Make PAN tests use io vectors for pdu
android/tester: Make HDP tests use io vectors for pdu
android/tester: Add generic hook to handle pdu exchange
android/tester: Make A2DP use generic pdu exchange mechanism
android/tester: Make AVRCP tests use generic pdu exchange mechanism
android/tester: Make GATT use generic cid_data
android/tester: Make HDP tests use generic PDU exchange mechanism
android/tester: Make HIDHost tests use generic PDU exchange mechanism
android/tester: Make PAN use generic PDU exchange mechanism
android/tester: Use generic connect callback for simple cases

android/tester-a2dp.c | 108 +++++++--------------
android/tester-avrcp.c | 180 +++++++++++++----------------------
android/tester-gatt.c | 95 +++++++------------
android/tester-hdp.c | 200 ++++++++++++++++-----------------------
android/tester-hidhost.c | 241 +++++++++++++++++++++--------------------------
android/tester-main.c | 71 ++++++++++++++
android/tester-main.h | 26 +++++
android/tester-pan.c | 45 +++------
8 files changed, 430 insertions(+), 536 deletions(-)

--
1.9.1



2014-10-02 11:22:17

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCHv4 00/13] android/tester: Unifying the way PDU is handled

Hi Jakub,

On Thu, Oct 2, 2014 at 11:10 AM, Jakub Tyszkowski
<[email protected]> wrote:
> This patchset makes all testers use common struct for using raw data (PDUs).
> Also some helpers were added for pdu matching and sending.
>
> v4 changes:
> * patches were redone with iovectors from the start,
> * sdp pdu sending was improved (no need to have non const pdus anymore)
>
> v3 changes:
> * added one more patch replacing the pdu struct with iovec and making testers
> use bthost's iovec specific API.
> * minor include fix
> * minor commit message correction
>
> v2 changes:
> * added generic hook and connect callback in tester-main for handling simple
> cases when only pdu exchange is needed on given channel
>
> Jakub Tyszkowski (13):
> android/tester: Replace gatt-tester's pdu structs with io vectors
> android/tester: Expose structs holding request pdu and response pdu
> android/tester: Make HidHost tests use io vectors for pdu
> android/tester: Make PAN tests use io vectors for pdu
> android/tester: Make HDP tests use io vectors for pdu
> android/tester: Add generic hook to handle pdu exchange
> android/tester: Make A2DP use generic pdu exchange mechanism
> android/tester: Make AVRCP tests use generic pdu exchange mechanism
> android/tester: Make GATT use generic cid_data
> android/tester: Make HDP tests use generic PDU exchange mechanism
> android/tester: Make HIDHost tests use generic PDU exchange mechanism
> android/tester: Make PAN use generic PDU exchange mechanism
> android/tester: Use generic connect callback for simple cases
>
> android/tester-a2dp.c | 108 +++++++--------------
> android/tester-avrcp.c | 180 +++++++++++++----------------------
> android/tester-gatt.c | 95 +++++++------------
> android/tester-hdp.c | 200 ++++++++++++++++-----------------------
> android/tester-hidhost.c | 241 +++++++++++++++++++++--------------------------
> android/tester-main.c | 71 ++++++++++++++
> android/tester-main.h | 26 +++++
> android/tester-pan.c | 45 +++------
> 8 files changed, 430 insertions(+), 536 deletions(-)
>
> --
> 1.9.1

Applied, thanks.


--
Luiz Augusto von Dentz

2014-10-02 08:11:01

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 13/13] android/tester: Use generic connect callback for simple cases

This is usefull when no custom behavior and just simple pdu exchange
is needed.
---
android/tester-avrcp.c | 13 +------------
android/tester-hdp.c | 32 ++------------------------------
android/tester-hidhost.c | 12 +-----------
android/tester-main.c | 10 ++++++++++
android/tester-main.h | 1 +
android/tester-pan.c | 13 +------------
6 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c
index 7f110d2..192a48e 100644
--- a/android/tester-avrcp.c
+++ b/android/tester-avrcp.c
@@ -139,20 +139,9 @@ static struct emu_set_l2cap_data a2dp_setup_data = {
.user_data = &a2dp_data,
};

-static void sdp_connect_request_cb(uint16_t handle, uint16_t cid,
- void *user_data)
-{
- struct emu_l2cap_cid_data *cid_data = user_data;
-
- cid_data->handle = handle;
- cid_data->cid = cid;
-
- tester_handle_l2cap_data_exchange(cid_data);
-}
-
static struct emu_set_l2cap_data sdp_setup_data = {
.psm = 1,
- .func = sdp_connect_request_cb,
+ .func = tester_generic_connect_cb,
.user_data = &sdp_data,
};

diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index e9c0c1d..ab7666d 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
@@ -243,16 +243,6 @@ static void hdp_unregister_app_action(void)
schedule_action_verification(step);
}

-static void hdp_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
-{
- struct emu_l2cap_cid_data *cid_data = user_data;
-
- cid_data->handle = handle;
- cid_data->cid = cid;
-
- tester_handle_l2cap_data_exchange(cid_data);
-}
-
static void mcap_ctrl_cid_hook_cb(const void *data, uint16_t len,
void *user_data)
{
@@ -315,28 +305,10 @@ static void mcap_ctrl_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
cid_data);
}

-static void mcap_data_cid_hook_cb(const void *data, uint16_t len,
- void *user_data)
-{
-}
-
-static void mcap_data_connect_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->handle = handle;
- cid_data->cid = cid;
-
- bthost_add_cid_hook(bthost, handle, cid, mcap_data_cid_hook_cb,
- cid_data);
-}
-
/* Emulate SDP (PSM = 1) */
static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
.psm = 1,
- .func = hdp_sdp_search_cb,
+ .func = tester_generic_connect_cb,
.user_data = &sdp_cid_data,
};

@@ -350,7 +322,7 @@ static struct emu_set_l2cap_data l2cap_setup_cc_data = {
/* Emulate Data Channel (PSM = 0x1003) */
static struct emu_set_l2cap_data l2cap_setup_dc_data = {
.psm = 0x1003,
- .func = mcap_data_connect_cb,
+ .func = tester_generic_connect_cb,
.user_data = &data_cid_data,
};

diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 9173092..8da5d32 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -135,16 +135,6 @@ static struct emu_l2cap_cid_data sdp_cid_data = {
static struct emu_l2cap_cid_data ctrl_cid_data;
static struct emu_l2cap_cid_data intr_cid_data;

-static void hid_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
-{
- struct emu_l2cap_cid_data *cid_data = user_data;
-
- cid_data->handle = handle;
- cid_data->cid = cid;
-
- tester_handle_l2cap_data_exchange(cid_data);
-}
-
static void hid_prepare_reply_protocol_mode(struct emu_l2cap_cid_data *cid_data)
{
struct test_data *t_data = tester_get_data();
@@ -245,7 +235,7 @@ static void hid_intr_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
/* Emulate SDP (PSM = 1) */
static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
.psm = 1,
- .func = hid_sdp_search_cb,
+ .func = tester_generic_connect_cb,
.user_data = &sdp_cid_data,
};

diff --git a/android/tester-main.c b/android/tester-main.c
index 5ef0401..5517973 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -2188,6 +2188,16 @@ void tester_handle_l2cap_data_exchange(struct emu_l2cap_cid_data *cid_data)
emu_generic_cid_hook_cb, cid_data);
}

+void tester_generic_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
+{
+ struct emu_l2cap_cid_data *cid_data = user_data;
+
+ cid_data->handle = handle;
+ cid_data->cid = cid;
+
+ tester_handle_l2cap_data_exchange(cid_data);
+}
+
static void rfcomm_connect_cb(uint16_t handle, uint16_t cid, void *user_data,
bool status)
{
diff --git a/android/tester-main.h b/android/tester-main.h
index aa56cd2..c6662ca 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -510,6 +510,7 @@ struct test_case {
};

void tester_handle_l2cap_data_exchange(struct emu_l2cap_cid_data *cid_data);
+void tester_generic_connect_cb(uint16_t handle, uint16_t cid, void *user_data);

/* Get, remove test cases API */
struct queue *get_bluetooth_tests(void);
diff --git a/android/tester-pan.c b/android/tester-pan.c
index b10a214..aff1980 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -35,20 +35,9 @@ static struct emu_l2cap_cid_data cid_data = {
.pdu = pdus,
};

-static void pan_connect_request_cb(uint16_t handle, uint16_t cid,
- void *user_data)
-{
- struct emu_l2cap_cid_data *cid_data = user_data;
-
- cid_data->handle = handle;
- cid_data->cid = cid;
-
- tester_handle_l2cap_data_exchange(cid_data);
-}
-
static struct emu_set_l2cap_data l2cap_setup_data = {
.psm = 15,
- .func = pan_connect_request_cb,
+ .func = tester_generic_connect_cb,
.user_data = &cid_data,
};

--
1.9.1


2014-10-02 08:10:58

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 10/13] android/tester: Make HDP tests use generic PDU exchange mechanism

---
android/tester-hdp.c | 185 ++++++++++++++++++++++++---------------------------
1 file changed, 87 insertions(+), 98 deletions(-)

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
@@ -28,16 +28,75 @@ typedef enum {
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 */

@@ -184,87 +243,14 @@ static void hdp_unregister_app_action(void)
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,
@@ -272,6 +258,7 @@ 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;
@@ -296,8 +283,8 @@ static void mcap_ctrl_cid_hook_cb(const void *data, uint16_t len,
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 */
@@ -308,8 +295,8 @@ static void mcap_ctrl_cid_hook_cb(const void *data, uint16_t len,
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;
}
@@ -319,12 +306,13 @@ static void mcap_ctrl_connect_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.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,
@@ -336,33 +324,34 @@ static void mcap_data_connect_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.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)
--
1.9.1


2014-10-02 08:10:56

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 08/13] android/tester: Make AVRCP tests use generic pdu exchange mechanism

---
android/tester-avrcp.c | 112 +++++++++++++++++--------------------------------
1 file changed, 38 insertions(+), 74 deletions(-)

diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c
index dfcf801..7f110d2 100644
--- a/android/tester-avrcp.c
+++ b/android/tester-avrcp.c
@@ -25,35 +25,35 @@

static struct queue *list;

-struct emu_cid_data {
- uint16_t handle;
- uint16_t cid;
+#define sdp_rsp_pdu 0x07, \
+ 0x00, 0x00, \
+ 0x00, 0x7f, \
+ 0x00, 0x7c, \
+ 0x36, 0x00, 0x79, 0x36, 0x00, 0x3b, 0x09, 0x00, 0x00, \
+ 0x0a, 0x00, 0x01, 0x00, 0x04, 0x09, 0x00, 0x01, 0x35, \
+ 0x06, 0x19, 0x11, 0x0e, 0x19, 0x11, 0x0f, 0x09, 0x00, \
+ 0x04, 0x35, 0x10, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, \
+ 0x00, 0x17, 0x35, 0x06, 0x19, 0x00, 0x17, 0x09, 0x01, \
+ 0x03, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, \
+ 0x11, 0x0e, 0x09, 0x01, 0x00, 0x09, 0x03, 0x11, 0x09, \
+ 0x00, 0x01, 0x36, 0x00, 0x38, 0x09, 0x00, 0x00, 0x0a, \
+ 0x00, 0x01, 0x00, 0x05, 0x09, 0x00, 0x01, 0x35, 0x03, \
+ 0x19, 0x11, 0x0c, 0x09, 0x00, 0x04, 0x35, 0x10, 0x35, \
+ 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x17, 0x35, 0x06, \
+ 0x19, 0x00, 0x17, 0x09, 0x01, 0x03, 0x09, 0x00, 0x09, \
+ 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x0e, 0x09, 0x01, \
+ 0x04, 0x09, 0x03, 0x11, 0x09, 0x00, 0x02, \
+ 0x00
+
+static const struct pdu_set sdp_pdus[] = {
+ { end_pdu, raw_pdu(sdp_rsp_pdu) },
+ { end_pdu, end_pdu },
};

-static struct emu_cid_data sdp_data;
-static struct emu_cid_data a2dp_data;
-static struct emu_cid_data avrcp_data;
-
-static const struct iovec sdp_rsp_pdu = raw_pdu(
- 0x07, /* PDU id */
- 0x00, 0x00, /* Transaction id */
- 0x00, 0x7f, /* Response length */
- 0x00, 0x7c, /* Attributes length */
- 0x36, 0x00, 0x79, 0x36, 0x00, 0x3b, 0x09, 0x00, 0x00,
- 0x0a, 0x00, 0x01, 0x00, 0x04, 0x09, 0x00, 0x01, 0x35,
- 0x06, 0x19, 0x11, 0x0e, 0x19, 0x11, 0x0f, 0x09, 0x00,
- 0x04, 0x35, 0x10, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09,
- 0x00, 0x17, 0x35, 0x06, 0x19, 0x00, 0x17, 0x09, 0x01,
- 0x03, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19,
- 0x11, 0x0e, 0x09, 0x01, 0x00, 0x09, 0x03, 0x11, 0x09,
- 0x00, 0x01, 0x36, 0x00, 0x38, 0x09, 0x00, 0x00, 0x0a,
- 0x00, 0x01, 0x00, 0x05, 0x09, 0x00, 0x01, 0x35, 0x03,
- 0x19, 0x11, 0x0c, 0x09, 0x00, 0x04, 0x35, 0x10, 0x35,
- 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x17, 0x35, 0x06,
- 0x19, 0x00, 0x17, 0x09, 0x01, 0x03, 0x09, 0x00, 0x09,
- 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x0e, 0x09, 0x01,
- 0x04, 0x09, 0x03, 0x11, 0x09, 0x00, 0x02,
- 0x00); /* no continuation */
+static struct emu_l2cap_cid_data sdp_data = {
+ .pdu = sdp_pdus,
+ .is_sdp = TRUE,
+};

#define req_dsc 0x00, 0x01
#define rsp_dsc 0x02, 0x01, 0x04, 0x08
@@ -84,6 +84,12 @@ static const struct pdu_set pdus[] = {
{ end_pdu, end_pdu },
};

+static struct emu_l2cap_cid_data a2dp_data = {
+ .pdu = pdus,
+};
+
+static struct emu_l2cap_cid_data avrcp_data;
+
static void print_avrcp(const char *str, void *user_data)
{
tester_debug("avrcp: %s", str);
@@ -99,7 +105,7 @@ static void avrcp_connect_request_cb(uint16_t handle, uint16_t cid,
{
struct test_data *data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(data->hciemu);
- struct emu_cid_data *cid_data = user_data;
+ struct emu_l2cap_cid_data *cid_data = user_data;

cid_data->handle = handle;
cid_data->cid = cid;
@@ -113,41 +119,10 @@ static struct emu_set_l2cap_data avrcp_setup_data = {
.user_data = &avrcp_data,
};

-static void print_a2dp(const char *str, void *user_data)
-{
- tester_debug("a2dp: %s", str);
-}
-
-static void a2dp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
-{
- struct emu_cid_data *cid_data = user_data;
- struct test_data *t_data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- int i;
-
- util_hexdump('>', data, len, print_a2dp, NULL);
-
- for (i = 0; pdus[i].req.iov_base; i++) {
- if (pdus[i].req.iov_len != len)
- continue;
-
- if (memcmp(pdus[i].req.iov_base, data, len))
- continue;
-
- util_hexdump('<', pdus[i].rsp.iov_base, pdus[i].rsp.iov_len,
- print_a2dp, NULL);
-
- bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid,
- &pdus[i].rsp, 1);
- }
-}
-
static void a2dp_connect_request_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_cid_data *cid_data = user_data;
+ struct emu_l2cap_cid_data *cid_data = user_data;

if (cid_data->handle)
return;
@@ -155,7 +130,7 @@ static void a2dp_connect_request_cb(uint16_t handle, uint16_t cid,
cid_data->handle = handle;
cid_data->cid = cid;

- bthost_add_cid_hook(bthost, handle, cid, a2dp_cid_hook_cb, cid_data);
+ tester_handle_l2cap_data_exchange(cid_data);
}

static struct emu_set_l2cap_data a2dp_setup_data = {
@@ -164,26 +139,15 @@ static struct emu_set_l2cap_data a2dp_setup_data = {
.user_data = &a2dp_data,
};

-static void 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;
-
- bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid, &sdp_rsp_pdu,
- 1);
-}
static void sdp_connect_request_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_cid_data *cid_data = user_data;
+ struct emu_l2cap_cid_data *cid_data = user_data;

cid_data->handle = handle;
cid_data->cid = cid;

- bthost_add_cid_hook(bthost, handle, cid, sdp_cid_hook_cb, cid_data);
+ tester_handle_l2cap_data_exchange(cid_data);
}

static struct emu_set_l2cap_data sdp_setup_data = {
--
1.9.1


2014-10-02 08:11:00

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 12/13] android/tester: Make PAN use generic PDU exchange mechanism

---
android/tester-pan.c | 41 ++++++++++++++---------------------------
1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/android/tester-pan.c b/android/tester-pan.c
index 5aa6c35..b10a214 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -23,46 +23,33 @@

static struct queue *list; /* List of pan test cases */

-struct emu_cid_data {
- uint16_t nap_handle;
- uint16_t nap_cid;
-};
-
-static struct emu_cid_data cid_data;
+#define pan_conn_req_pdu 0x01, 0x01, 0x02, 0x11, 0x16, 0x11, 0x15
+#define pan_conn_rsp_pdu 0x01, 0x02, 0x00, 0x00

-static const struct iovec pan_conn_req_pdu = raw_pdu(0x01, 0x01, 0x02, 0x11,
- 0x16, 0x11, 0x15);
-static const struct iovec pan_conn_rsp_pdu = raw_pdu(0x01, 0x02, 0x00, 0x00);
+static const struct pdu_set pdus[] = {
+ { raw_pdu(pan_conn_req_pdu), raw_pdu(pan_conn_rsp_pdu) },
+ { end_pdu, end_pdu },
+};

-static void pan_nap_cid_hook_cb(const void *data, uint16_t len, void *user_data)
-{
- struct test_data *t_data = tester_get_data();
- struct emu_cid_data *cid_data = user_data;
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
-
- if (!memcmp((uint8_t *) data, pan_conn_req_pdu.iov_base, len))
- bthost_send_cid_v(bthost, cid_data->nap_handle,
- cid_data->nap_cid,
- &pan_conn_rsp_pdu, 1);
-}
+static struct emu_l2cap_cid_data cid_data = {
+ .pdu = pdus,
+};

static void pan_connect_request_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.nap_handle = handle;
- cid_data.nap_cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;

- bthost_add_cid_hook(bthost, handle, cid, pan_nap_cid_hook_cb,
- &cid_data);
+ tester_handle_l2cap_data_exchange(cid_data);
}

static struct emu_set_l2cap_data l2cap_setup_data = {
.psm = 15,
.func = pan_connect_request_cb,
- .user_data = NULL,
+ .user_data = &cid_data,
};

static void pan_connect_action(void)
--
1.9.1


2014-10-02 08:10:59

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 11/13] android/tester: Make HIDHost tests use generic PDU exchange mechanism

---
android/tester-hidhost.c | 225 ++++++++++++++++++++++-------------------------
1 file changed, 106 insertions(+), 119 deletions(-)

diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 0327369..9173092 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -45,143 +45,128 @@

static struct queue *list; /* List of hidhost test cases */

-struct emu_cid_data {
- const int pdu_len;
- const void *pdu;
-
- uint16_t sdp_handle;
- uint16_t sdp_cid;
- uint16_t ctrl_handle;
- uint16_t ctrl_cid;
- uint16_t intr_handle;
- uint16_t intr_cid;
+#define did_req_pdu 0x06, \
+ 0x00, 0x00, \
+ 0x00, 0x0f, \
+ 0x35, 0x03, \
+ 0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00, \
+ 0x00, 0xff, 0xff, 0x00
+
+#define did_rsp_pdu 0x07, \
+ 0x00, 0x00, \
+ 0x00, 0x4f, \
+ 0x00, 0x4c, \
+ 0x35, 0x4a, 0x35, 0x48, 0x09, 0x00, 0x00, 0x0a, 0x00, \
+ 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35, 0x03, 0x19, \
+ 0x12, 0x00, 0x09, 0x00, 0x05, 0x35, 0x03, 0x19, 0x10, \
+ 0x02, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, \
+ 0x12, 0x00, 0x09, 0x01, 0x03, 0x09, 0x02, 0x00, 0x09, \
+ 0x01, 0x03, 0x09, 0x02, 0x01, 0x09, 0x1d, 0x6b, 0x09, \
+ 0x02, 0x02, 0x09, 0x02, 0x46, 0x09, 0x02, 0x03, 0x09, \
+ 0x05, 0x0e, 0x09, 0x02, 0x04, 0x28, 0x01, 0x09, 0x02, \
+ 0x05, 0x09, 0x00, 0x02, \
+ 0x00
+
+#define hid_req_pdu 0x06, \
+ 0x00, 0x01, \
+ 0x00, 0x0f, \
+ 0x35, 0x03, \
+ 0x19, 0x11, 0x24, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00, \
+ 0x00, 0xff, 0xff, 0x00
+
+#define hid_rsp_pdu 0x07, \
+ 0x00, 0x01, \
+ 0x01, 0x71, \
+ 0x01, 0x6E, \
+ 0x36, 0x01, 0x6b, 0x36, 0x01, 0x68, 0x09, 0x00, 0x00, \
+ 0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35, \
+ 0x03, 0x19, 0x11, 0x24, 0x09, 0x00, 0x04, 0x35, 0x0d, \
+ 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x11, 0x35, \
+ 0x03, 0x19, 0x00, 0x11, 0x09, 0x00, 0x05, 0x35, 0x03, \
+ 0x19, 0x10, 0x02, 0x09, 0x00, 0x06, 0x35, 0x09, 0x09, \
+ 0x65, 0x6e, 0x09, 0x00, 0x6a, 0x09, 0x01, 0x00, 0x09, \
+ 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x24, \
+ 0x09, 0x01, 0x00, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35, \
+ 0x0d, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x13, \
+ 0x35, 0x03, 0x19, 0x00, 0x11, 0x09, 0x01, 0x00, 0x25, \
+ 0x1e, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63, 0x68, \
+ 0x20, 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, \
+ 0x68, 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x4d, \
+ 0x35, 0x35, 0x35, 0x62, 0x09, 0x01, 0x01, 0x25, 0x0f, \
+ 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68, \
+ 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x09, 0x01, 0x02, \
+ 0x25, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63, \
+ 0x68, 0x09, 0x02, 0x00, 0x09, 0x01, 0x00, 0x09, 0x02, \
+ 0x01, 0x09, 0x01, 0x11, 0x09, 0x02, 0x02, 0x08, 0x80, \
+ 0x09, 0x02, 0x03, 0x08, 0x21, 0x09, 0x02, 0x04, 0x28, \
+ 0x01, 0x09, 0x02, 0x05, 0x28, 0x01, 0x09, 0x02, 0x06, \
+ 0x35, 0x74, 0x35, 0x72, 0x08, 0x22, 0x25, 0x6e, 0x05, \
+ 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, \
+ 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x08, 0x15, \
+ 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, \
+ 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0xf8, \
+ 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 0x81, 0x06, \
+ 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, \
+ 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x81, \
+ 0x06, 0x05, 0x09, 0x19, 0x09, 0x29, 0x10, 0x15, 0x00, \
+ 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0xc0, \
+ 0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, \
+ 0x10, 0x75, 0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, \
+ 0x00, 0x09, 0x01, 0x81, 0x00, 0x09, 0x01, 0x91, 0x00, \
+ 0xc0, 0x09, 0x02, 0x07, 0x35, 0x08, 0x35, 0x06, 0x09, \
+ 0x04, 0x09, 0x09, 0x01, 0x00, 0x09, 0x02, 0x08, 0x28, \
+ 0x00, 0x09, 0x02, 0x09, 0x28, 0x01, 0x09, 0x02, 0x0a, \
+ 0x28, 0x01, 0x09, 0x02, 0x0b, 0x09, 0x01, 0x00, 0x09, \
+ 0x02, 0x0c, 0x09, 0x0c, 0x80, 0x09, 0x02, 0x0d, 0x28, \
+ 0x00, 0x09, 0x02, 0x0e, 0x28, 0x01, \
+ 0x00
+
+static const struct pdu_set sdp_pdus[] = {
+ { raw_pdu(did_req_pdu), raw_pdu(did_rsp_pdu) },
+ { raw_pdu(hid_req_pdu), raw_pdu(hid_rsp_pdu) },
+ { end_pdu, end_pdu },
};

-static struct emu_cid_data cid_data;
-
-static const struct iovec did_req_pdu = raw_pdu(
- 0x06, /* PDU id */
- 0x00, 0x00, /* Transaction id */
- 0x00, 0x0f, /* Req length */
- 0x35, 0x03, /* Attributes length */
- 0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00,
- 0x00, 0xff, 0xff, 0x00); /* no continuation */
-
-static const struct iovec did_rsp_pdu = raw_pdu(
- 0x07, /* PDU id */
- 0x00, 0x00, /* Transaction id */
- 0x00, 0x4f, /* Response length */
- 0x00, 0x4c, /* Attributes length */
- 0x35, 0x4a, 0x35, 0x48, 0x09, 0x00, 0x00, 0x0a, 0x00,
- 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35, 0x03, 0x19,
- 0x12, 0x00, 0x09, 0x00, 0x05, 0x35, 0x03, 0x19, 0x10,
- 0x02, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19,
- 0x12, 0x00, 0x09, 0x01, 0x03, 0x09, 0x02, 0x00, 0x09,
- 0x01, 0x03, 0x09, 0x02, 0x01, 0x09, 0x1d, 0x6b, 0x09,
- 0x02, 0x02, 0x09, 0x02, 0x46, 0x09, 0x02, 0x03, 0x09,
- 0x05, 0x0e, 0x09, 0x02, 0x04, 0x28, 0x01, 0x09, 0x02,
- 0x05, 0x09, 0x00, 0x02,
- 0x00); /* no continuation */
-
-static const struct iovec hid_rsp_pdu = raw_pdu(
- 0x07, /* PDU id */
- 0x00, 0x01, /* Transaction id */
- 0x01, 0x71, /* Response length */
- 0x01, 0x6E, /* Attributes length */
- 0x36, 0x01, 0x6b, 0x36, 0x01, 0x68, 0x09, 0x00, 0x00,
- 0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35,
- 0x03, 0x19, 0x11, 0x24, 0x09, 0x00, 0x04, 0x35, 0x0d,
- 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x11, 0x35,
- 0x03, 0x19, 0x00, 0x11, 0x09, 0x00, 0x05, 0x35, 0x03,
- 0x19, 0x10, 0x02, 0x09, 0x00, 0x06, 0x35, 0x09, 0x09,
- 0x65, 0x6e, 0x09, 0x00, 0x6a, 0x09, 0x01, 0x00, 0x09,
- 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x24,
- 0x09, 0x01, 0x00, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35,
- 0x0d, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x13,
- 0x35, 0x03, 0x19, 0x00, 0x11, 0x09, 0x01, 0x00, 0x25,
- 0x1e, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63, 0x68,
- 0x20, 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74,
- 0x68, 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x4d,
- 0x35, 0x35, 0x35, 0x62, 0x09, 0x01, 0x01, 0x25, 0x0f,
- 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68,
- 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x09, 0x01, 0x02,
- 0x25, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63,
- 0x68, 0x09, 0x02, 0x00, 0x09, 0x01, 0x00, 0x09, 0x02,
- 0x01, 0x09, 0x01, 0x11, 0x09, 0x02, 0x02, 0x08, 0x80,
- 0x09, 0x02, 0x03, 0x08, 0x21, 0x09, 0x02, 0x04, 0x28,
- 0x01, 0x09, 0x02, 0x05, 0x28, 0x01, 0x09, 0x02, 0x06,
- 0x35, 0x74, 0x35, 0x72, 0x08, 0x22, 0x25, 0x6e, 0x05,
- 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01,
- 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x08, 0x15,
- 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02,
- 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0xf8,
- 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 0x81, 0x06,
- 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95,
- 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x81,
- 0x06, 0x05, 0x09, 0x19, 0x09, 0x29, 0x10, 0x15, 0x00,
- 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0xc0,
- 0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85,
- 0x10, 0x75, 0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff,
- 0x00, 0x09, 0x01, 0x81, 0x00, 0x09, 0x01, 0x91, 0x00,
- 0xc0, 0x09, 0x02, 0x07, 0x35, 0x08, 0x35, 0x06, 0x09,
- 0x04, 0x09, 0x09, 0x01, 0x00, 0x09, 0x02, 0x08, 0x28,
- 0x00, 0x09, 0x02, 0x09, 0x28, 0x01, 0x09, 0x02, 0x0a,
- 0x28, 0x01, 0x09, 0x02, 0x0b, 0x09, 0x01, 0x00, 0x09,
- 0x02, 0x0c, 0x09, 0x0c, 0x80, 0x09, 0x02, 0x0d, 0x28,
- 0x00, 0x09, 0x02, 0x0e, 0x28, 0x01,
- 0x00); /* no continuation */
-
-static void hid_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;
+static struct emu_l2cap_cid_data sdp_cid_data = {
+ .pdu = sdp_pdus,
+ .is_sdp = TRUE,
+};

- if (!memcmp(did_req_pdu.iov_base, data, len)) {
- bthost_send_cid_v(bthost, cid_data->sdp_handle,
- cid_data->sdp_cid, &did_rsp_pdu, 1);
- return;
- }
+static struct emu_l2cap_cid_data ctrl_cid_data;
+static struct emu_l2cap_cid_data intr_cid_data;

- bthost_send_cid_v(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
- &hid_rsp_pdu, 1);
-}
static void hid_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, hid_sdp_cid_hook_cb,
- &cid_data);
+ tester_handle_l2cap_data_exchange(cid_data);
}

-static void hid_prepare_reply_protocol_mode(struct emu_cid_data *cid_data)
+static void hid_prepare_reply_protocol_mode(struct emu_l2cap_cid_data *cid_data)
{
struct test_data *t_data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
const struct iovec pdu = raw_pdu(0xa0, 0x00);

- bthost_send_cid_v(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
- &pdu, 1);
+ bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid, &pdu, 1);
}

-static void hid_prepare_reply_report(struct emu_cid_data *cid_data)
+static void hid_prepare_reply_report(struct emu_l2cap_cid_data *cid_data)
{
struct test_data *t_data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
const struct iovec pdu = raw_pdu(0xa2, 0x01, 0x00);

- bthost_send_cid_v(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
- &pdu, 1);
+ bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid, &pdu, 1);
}

static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
void *user_data)
{
- struct emu_cid_data *cid_data = user_data;
+ struct emu_l2cap_cid_data *cid_data = user_data;
uint8_t header = ((uint8_t *) data)[0];
struct step *step;

@@ -218,12 +203,13 @@ static void hid_ctrl_connect_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.ctrl_handle = handle;
- cid_data.ctrl_cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;

bthost_add_cid_hook(bthost, handle, cid, hid_ctrl_cid_hook_cb,
- &cid_data);
+ cid_data);
}

static void hid_intr_cid_hook_cb(const void *data, uint16_t len,
@@ -247,33 +233,34 @@ static void hid_intr_connect_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.intr_handle = handle;
- cid_data.intr_cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;

bthost_add_cid_hook(bthost, handle, cid, hid_intr_cid_hook_cb,
- &cid_data);
+ cid_data);
}

/* Emulate SDP (PSM = 1) */
static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
.psm = 1,
.func = hid_sdp_search_cb,
- .user_data = NULL,
+ .user_data = &sdp_cid_data,
};

/* Emulate Control Channel (PSM = 17) */
static struct emu_set_l2cap_data l2cap_setup_cc_data = {
.psm = 17,
.func = hid_ctrl_connect_cb,
- .user_data = NULL,
+ .user_data = &ctrl_cid_data,
};

/* Emulate Interrupt Channel (PSM = 19) */
static struct emu_set_l2cap_data l2cap_setup_ic_data = {
.psm = 19,
.func = hid_intr_connect_cb,
- .user_data = NULL,
+ .user_data = &intr_cid_data,
};

static void hidhost_connect_action(void)
--
1.9.1


2014-10-02 08:10:52

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 04/13] android/tester: Make PAN tests use io vectors for pdu

---
android/tester-pan.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/android/tester-pan.c b/android/tester-pan.c
index 8d41d34..5aa6c35 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -29,9 +29,10 @@ struct emu_cid_data {
};

static struct emu_cid_data cid_data;
-static uint8_t pan_conn_req_pdu[] = { 0x01, 0x01, 0x02, 0x11, 0x16,
- 0x11, 0x15 };
-static uint8_t pan_conn_rsp_pdu[] = { 0x01, 0x02, 0x00, 0x00 };
+
+static const struct iovec pan_conn_req_pdu = raw_pdu(0x01, 0x01, 0x02, 0x11,
+ 0x16, 0x11, 0x15);
+static const struct iovec pan_conn_rsp_pdu = raw_pdu(0x01, 0x02, 0x00, 0x00);

static void pan_nap_cid_hook_cb(const void *data, uint16_t len, void *user_data)
{
@@ -39,10 +40,10 @@ static void pan_nap_cid_hook_cb(const void *data, uint16_t len, void *user_data)
struct emu_cid_data *cid_data = user_data;
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);

- if (!memcmp((uint8_t *) data, pan_conn_req_pdu,
- sizeof(pan_conn_req_pdu)))
- bthost_send_cid(bthost, cid_data->nap_handle, cid_data->nap_cid,
- pan_conn_rsp_pdu, sizeof(pan_conn_rsp_pdu));
+ if (!memcmp((uint8_t *) data, pan_conn_req_pdu.iov_base, len))
+ bthost_send_cid_v(bthost, cid_data->nap_handle,
+ cid_data->nap_cid,
+ &pan_conn_rsp_pdu, 1);
}

static void pan_connect_request_cb(uint16_t handle, uint16_t cid,
--
1.9.1


2014-10-02 08:10:57

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 09/13] android/tester: Make GATT use generic cid_data

---
android/tester-gatt.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index cb0b377..acad195 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -41,14 +41,6 @@ static bt_uuid_t app1_uuid = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
};

-struct emu_cid_data {
- const int pdu_len;
- const void *pdu;
-
- uint16_t handle;
- uint16_t cid;
-};
-
struct gatt_connect_data {
const int app_id;
const int conn_id;
@@ -124,7 +116,7 @@ static bt_property_t prop_test_scan_mode_conn = {
.len = sizeof(setprop_scan_mode_conn_val),
};

-static struct emu_cid_data cid_data;
+static struct emu_l2cap_cid_data cid_data;

static struct gatt_connect_data app1_conn_req = {
.app_id = APP1_ID,
@@ -854,7 +846,7 @@ static void gatt_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;
+ struct emu_l2cap_cid_data *cid_data = user_data;
const uint8_t *pdu = data;
struct iovec *gatt_pdu = queue_peek_head(t_data->pdus);

--
1.9.1


2014-10-02 08:10:55

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 07/13] android/tester: Make A2DP use generic pdu exchange mechanism

---
android/tester-a2dp.c | 51 +++++++++------------------------------------------
1 file changed, 9 insertions(+), 42 deletions(-)

diff --git a/android/tester-a2dp.c b/android/tester-a2dp.c
index 1ff628e..dcb7f79 100644
--- a/android/tester-a2dp.c
+++ b/android/tester-a2dp.c
@@ -25,13 +25,6 @@

static struct queue *list;

-struct emu_cid_data {
- uint16_t handle;
- uint16_t cid;
-};
-
-static struct emu_cid_data cid_data;
-
#define req_dsc 0x00, 0x01
#define rsp_dsc 0x02, 0x01, 0x04, 0x08
#define req_get 0x10, 0x02, 0x04
@@ -61,54 +54,28 @@ static const struct pdu_set pdus[] = {
{ end_pdu, end_pdu },
};

-static void print_data(const char *str, void *user_data)
-{
- tester_debug("a2dp: %s", str);
-}
-
-static void a2dp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
-{
- struct emu_cid_data *cid_data = user_data;
- struct test_data *t_data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- int i;
-
- util_hexdump('>', data, len, print_data, NULL);
-
- for (i = 0; pdus[i].req.iov_base; i++) {
- if (pdus[i].req.iov_len != len)
- continue;
-
- if (memcmp(pdus[i].req.iov_base, data, len))
- continue;
-
- util_hexdump('<', pdus[i].rsp.iov_base, pdus[i].rsp.iov_len,
- print_data, NULL);
-
- bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid,
- &pdus[i].rsp, 1);
- }
-}
+static struct emu_l2cap_cid_data cid_data = {
+ .pdu = pdus,
+};

static void a2dp_connect_request_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;

- if (cid_data.handle)
+ if (cid_data->handle)
return;

- cid_data.handle = handle;
- cid_data.cid = cid;
+ cid_data->handle = handle;
+ cid_data->cid = cid;

- bthost_add_cid_hook(bthost, handle, cid, a2dp_cid_hook_cb, &cid_data);
+ tester_handle_l2cap_data_exchange(cid_data);
}

static struct emu_set_l2cap_data l2cap_setup_data = {
.psm = 25,
.func = a2dp_connect_request_cb,
- .user_data = NULL,
+ .user_data = &cid_data,
};

static void a2dp_connect_action(void)
--
1.9.1


2014-10-02 08:10:54

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 06/13] android/tester: Add generic hook to handle pdu exchange

This allows tester-main to register hooks for certain CID to
automatically perform pdu exchange by registering array of pdu pairs
(request_pdu, response_pdu). When end_pdu is used instead of
request_pdu, response is sent immediately without incoming pdu
verification. A pair with end_pdus set as request and response is
considered as the end of pdu pairs array.

This callback can also handle sdp request<->response while transaction
ID for the response is swaped to match the one from SDP request.

'emu_l2cap_cid_data' is used to pass tha appropriate data to the hook
mechanism. It is similar to 'emu_cid_data" used in other testers and
eventually will replace those.
---
android/tester-main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
android/tester-main.h | 10 +++++++++
2 files changed, 71 insertions(+)

diff --git a/android/tester-main.c b/android/tester-main.c
index 5bf9096..5ef0401 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -16,6 +16,7 @@
*/
#include <stdbool.h>

+#include "src/shared/util.h"
#include "emulator/bthost.h"
#include "tester-main.h"

@@ -2127,6 +2128,66 @@ void emu_add_l2cap_server_action(void)
schedule_action_verification(step);
}

+static void print_data(const char *str, void *user_data)
+{
+ tester_debug("tester: %s", str);
+}
+
+static void emu_generic_cid_hook_cb(const void *data, uint16_t len,
+ void *user_data)
+{
+ struct test_data *t_data = tester_get_data();
+ struct emu_l2cap_cid_data *cid_data = user_data;
+ const struct pdu_set *pdus = cid_data->pdu;
+ struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+ int i;
+
+ for (i = 0; pdus[i].rsp.iov_base; i++) {
+ if (pdus[i].req.iov_base) {
+ if (pdus[i].req.iov_len != len)
+ continue;
+
+ if (memcmp(pdus[i].req.iov_base, data, len))
+ continue;
+ }
+
+ if (pdus[i].rsp.iov_base) {
+ util_hexdump('>', pdus[i].rsp.iov_base,
+ pdus[i].rsp.iov_len, print_data, NULL);
+
+ /* if its sdp pdu use transaction ID from request */
+ if (cid_data->is_sdp) {
+ struct iovec rsp[3];
+
+ rsp[0].iov_base = pdus[i].rsp.iov_base;
+ rsp[0].iov_len = 1;
+
+ rsp[1].iov_base = ((uint8_t *) data) + 1;
+ rsp[1].iov_len = 2;
+
+ rsp[2].iov_base = pdus[i].rsp.iov_base + 3;
+ rsp[2].iov_len = pdus[i].rsp.iov_len - 3;
+
+ bthost_send_cid_v(bthost, cid_data->handle,
+ cid_data->cid, rsp, 3);
+ } else {
+ bthost_send_cid_v(bthost, cid_data->handle,
+ cid_data->cid, &pdus[i].rsp, 1);
+ }
+
+ }
+ }
+}
+
+void tester_handle_l2cap_data_exchange(struct emu_l2cap_cid_data *cid_data)
+{
+ struct test_data *t_data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+
+ bthost_add_cid_hook(bthost, cid_data->handle, cid_data->cid,
+ emu_generic_cid_hook_cb, cid_data);
+}
+
static void rfcomm_connect_cb(uint16_t handle, uint16_t cid, void *user_data,
bool status)
{
diff --git a/android/tester-main.h b/android/tester-main.h
index 3ebad2b..aa56cd2 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -439,6 +439,14 @@ struct emu_set_l2cap_data {
void *user_data;
};

+struct emu_l2cap_cid_data {
+ const struct pdu_set *pdu;
+
+ uint16_t handle;
+ uint16_t cid;
+ bool is_sdp;
+};
+
/*
* Callback data structure should be enhanced with data
* returned by callbacks. It's used for test case step
@@ -501,6 +509,8 @@ struct test_case {
const struct step *step;
};

+void tester_handle_l2cap_data_exchange(struct emu_l2cap_cid_data *cid_data);
+
/* Get, remove test cases API */
struct queue *get_bluetooth_tests(void);
void remove_bluetooth_tests(void);
--
1.9.1


2014-10-02 08:10:53

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 05/13] android/tester: Make HDP tests use io vectors for pdu

---
android/tester-hdp.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index 9ecef21..5602636 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
@@ -184,7 +184,8 @@ static void hdp_unregister_app_action(void)
schedule_action_verification(step);
}

-static uint8_t hdp_rsp_pdu[] = { 0x07, /* PDU id */
+static const struct iovec hdp_rsp_pdu = raw_pdu(
+ 0x07, /* PDU id */
0x00, 0x00, /* Transaction id */
0x01, 0xc8, /* Response length */
0x01, 0xc5, /* Attributes length */
@@ -239,7 +240,7 @@ static uint8_t hdp_rsp_pdu[] = { 0x07, /* PDU id */
0x63, 0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65,
0x72, 0x0d, 0x09, 0x03, 0x01, 0x08, 0x01, 0x09, 0x03,
0x02, 0x08, 0x00,
- 0x00 };
+ 0x00);

static void hdp_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
{
@@ -247,11 +248,11 @@ static void hdp_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
struct emu_cid_data *cid_data = user_data;

- hdp_rsp_pdu[1] = ((uint8_t *) data)[1];
- hdp_rsp_pdu[2] = ((uint8_t *) data)[2];
+ ((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(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
- hdp_rsp_pdu, sizeof(hdp_rsp_pdu));
+ 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)
--
1.9.1


2014-10-02 08:10:50

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 02/13] android/tester: Expose structs holding request pdu and response pdu

This exposes the structs holding request and response pdus from a2dp
and avrcp testers and makes it available to other testers. It also
makes it use iovectors. Some helper macros were also extracted from
gatt tester and reused.
---
android/tester-a2dp.c | 73 +++++++++++++++++++++-----------------------
android/tester-avrcp.c | 83 ++++++++++++++++++++++++--------------------------
android/tester-gatt.c | 10 ------
android/tester-main.h | 15 +++++++++
4 files changed, 89 insertions(+), 92 deletions(-)

diff --git a/android/tester-a2dp.c b/android/tester-a2dp.c
index 1b2a8ce..1ff628e 100644
--- a/android/tester-a2dp.c
+++ b/android/tester-a2dp.c
@@ -32,38 +32,33 @@ struct emu_cid_data {

static struct emu_cid_data cid_data;

-static const uint8_t req_dsc[] = { 0x00, 0x01 };
-static const uint8_t rsp_dsc[] = { 0x02, 0x01, 0x04, 0x08 };
-static const uint8_t req_get[] = { 0x10, 0x02, 0x04 };
-static const uint8_t rsp_get[] = { 0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00,
- 0x00, 0xff, 0xff, 0x02, 0x40 };
-static const uint8_t req_cfg[] = { 0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07,
- 0x06, 0x00, 0x00, 0x21, 0x15, 0x02,
- 0x40 };
-static const uint8_t rsp_cfg[] = { 0x22, 0x03 };
-static const uint8_t req_open[] = { 0x30, 0x06, 0x04 };
-static const uint8_t rsp_open[] = { 0x32, 0x06 };
-static const uint8_t req_close[] = { 0x40, 0x08, 0x04 };
-static const uint8_t rsp_close[] = { 0x42, 0x08 };
-static const uint8_t req_start[] = { 0x40, 0x07, 0x04 };
-static const uint8_t rsp_start[] = { 0x42, 0x07 };
-static const uint8_t req_suspend[] = { 0x50, 0x09, 0x04 };
-static const uint8_t rsp_suspend[] = { 0x52, 0x09 };
-
-const struct pdu {
- const uint8_t *req;
- size_t req_len;
- const uint8_t *rsp;
- size_t rsp_len;
-} pdus[] = {
- { req_dsc, sizeof(req_dsc), rsp_dsc, sizeof(rsp_dsc) },
- { req_get, sizeof(req_get), rsp_get, sizeof(rsp_get) },
- { req_cfg, sizeof(req_cfg), rsp_cfg, sizeof(rsp_cfg) },
- { req_open, sizeof(req_open), rsp_open, sizeof(rsp_open) },
- { req_close, sizeof(req_close), rsp_close, sizeof(rsp_close) },
- { req_start, sizeof(req_start), rsp_start, sizeof(rsp_start) },
- { req_suspend, sizeof(req_suspend), rsp_suspend, sizeof(rsp_start) },
- { },
+#define req_dsc 0x00, 0x01
+#define rsp_dsc 0x02, 0x01, 0x04, 0x08
+#define req_get 0x10, 0x02, 0x04
+#define rsp_get 0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, \
+ 0x00, 0xff, 0xff, 0x02, 0x40
+#define req_cfg 0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, \
+ 0x06, 0x00, 0x00, 0x21, 0x15, 0x02, \
+ 0x40
+#define rsp_cfg 0x22, 0x03
+#define req_open 0x30, 0x06, 0x04
+#define rsp_open 0x32, 0x06
+#define req_close 0x40, 0x08, 0x04
+#define rsp_close 0x42, 0x08
+#define req_start 0x40, 0x07, 0x04
+#define rsp_start 0x42, 0x07
+#define req_suspend 0x50, 0x09, 0x04
+#define rsp_suspend 0x52, 0x09
+
+static const struct pdu_set pdus[] = {
+ { raw_pdu(req_dsc), raw_pdu(rsp_dsc) },
+ { raw_pdu(req_get), raw_pdu(rsp_get) },
+ { raw_pdu(req_cfg), raw_pdu(rsp_cfg) },
+ { raw_pdu(req_open), raw_pdu(rsp_open) },
+ { raw_pdu(req_close), raw_pdu(rsp_close) },
+ { raw_pdu(req_start), raw_pdu(rsp_start) },
+ { raw_pdu(req_suspend), raw_pdu(rsp_suspend) },
+ { end_pdu, end_pdu },
};

static void print_data(const char *str, void *user_data)
@@ -80,18 +75,18 @@ static void a2dp_cid_hook_cb(const void *data, uint16_t len, void *user_data)

util_hexdump('>', data, len, print_data, NULL);

- for (i = 0; pdus[i].req; i++) {
- if (pdus[i].req_len != len)
+ for (i = 0; pdus[i].req.iov_base; i++) {
+ if (pdus[i].req.iov_len != len)
continue;

- if (memcmp(pdus[i].req, data, len))
+ if (memcmp(pdus[i].req.iov_base, data, len))
continue;

- util_hexdump('<', pdus[i].rsp, pdus[i].rsp_len, print_data,
- NULL);
+ util_hexdump('<', pdus[i].rsp.iov_base, pdus[i].rsp.iov_len,
+ print_data, NULL);

- bthost_send_cid(bthost, cid_data->handle, cid_data->cid,
- pdus[i].rsp, pdus[i].rsp_len);
+ bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid,
+ &pdus[i].rsp, 1);
}
}

diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c
index 07b95f5..dfcf801 100644
--- a/android/tester-avrcp.c
+++ b/android/tester-avrcp.c
@@ -34,7 +34,8 @@ static struct emu_cid_data sdp_data;
static struct emu_cid_data a2dp_data;
static struct emu_cid_data avrcp_data;

-static const uint8_t sdp_rsp_pdu[] = { 0x07, /* PDU id */
+static const struct iovec sdp_rsp_pdu = raw_pdu(
+ 0x07, /* PDU id */
0x00, 0x00, /* Transaction id */
0x00, 0x7f, /* Response length */
0x00, 0x7c, /* Attributes length */
@@ -52,39 +53,35 @@ static const uint8_t sdp_rsp_pdu[] = { 0x07, /* PDU id */
0x19, 0x00, 0x17, 0x09, 0x01, 0x03, 0x09, 0x00, 0x09,
0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x0e, 0x09, 0x01,
0x04, 0x09, 0x03, 0x11, 0x09, 0x00, 0x02,
- 0x00}; /* no continuation */
-static const uint8_t req_dsc[] = { 0x00, 0x01 };
-static const uint8_t rsp_dsc[] = { 0x02, 0x01, 0x04, 0x08 };
-static const uint8_t req_get[] = { 0x10, 0x02, 0x04 };
-static const uint8_t rsp_get[] = { 0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00,
- 0x00, 0xff, 0xff, 0x02, 0x40 };
-static const uint8_t req_cfg[] = { 0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07,
- 0x06, 0x00, 0x00, 0x21, 0x15, 0x02,
- 0x40 };
-static const uint8_t rsp_cfg[] = { 0x22, 0x03 };
-static const uint8_t req_open[] = { 0x30, 0x06, 0x04 };
-static const uint8_t rsp_open[] = { 0x32, 0x06 };
-static const uint8_t req_close[] = { 0x40, 0x08, 0x04 };
-static const uint8_t rsp_close[] = { 0x42, 0x08 };
-static const uint8_t req_start[] = { 0x40, 0x07, 0x04 };
-static const uint8_t rsp_start[] = { 0x42, 0x07 };
-static const uint8_t req_suspend[] = { 0x50, 0x09, 0x04 };
-static const uint8_t rsp_suspend[] = { 0x52, 0x09 };
-
-static const struct pdu {
- const uint8_t *req;
- size_t req_len;
- const uint8_t *rsp;
- size_t rsp_len;
-} pdus[] = {
- { req_dsc, sizeof(req_dsc), rsp_dsc, sizeof(rsp_dsc) },
- { req_get, sizeof(req_get), rsp_get, sizeof(rsp_get) },
- { req_cfg, sizeof(req_cfg), rsp_cfg, sizeof(rsp_cfg) },
- { req_open, sizeof(req_open), rsp_open, sizeof(rsp_open) },
- { req_close, sizeof(req_close), rsp_close, sizeof(rsp_close) },
- { req_start, sizeof(req_start), rsp_start, sizeof(rsp_start) },
- { req_suspend, sizeof(req_suspend), rsp_suspend, sizeof(rsp_start) },
- { },
+ 0x00); /* no continuation */
+
+#define req_dsc 0x00, 0x01
+#define rsp_dsc 0x02, 0x01, 0x04, 0x08
+#define req_get 0x10, 0x02, 0x04
+#define rsp_get 0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, \
+ 0x00, 0xff, 0xff, 0x02, 0x40
+#define req_cfg 0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, \
+ 0x06, 0x00, 0x00, 0x21, 0x15, 0x02, \
+ 0x40
+#define rsp_cfg 0x22, 0x03
+#define req_open 0x30, 0x06, 0x04
+#define rsp_open 0x32, 0x06
+#define req_close 0x40, 0x08, 0x04
+#define rsp_close 0x42, 0x08
+#define req_start 0x40, 0x07, 0x04
+#define rsp_start 0x42, 0x07
+#define req_suspend 0x50, 0x09, 0x04
+#define rsp_suspend 0x52, 0x09
+
+static const struct pdu_set pdus[] = {
+ { raw_pdu(req_dsc), raw_pdu(rsp_dsc) },
+ { raw_pdu(req_get), raw_pdu(rsp_get) },
+ { raw_pdu(req_cfg), raw_pdu(rsp_cfg) },
+ { raw_pdu(req_open), raw_pdu(rsp_open) },
+ { raw_pdu(req_close), raw_pdu(rsp_close) },
+ { raw_pdu(req_start), raw_pdu(rsp_start) },
+ { raw_pdu(req_suspend), raw_pdu(rsp_suspend) },
+ { end_pdu, end_pdu },
};

static void print_avrcp(const char *str, void *user_data)
@@ -130,18 +127,18 @@ static void a2dp_cid_hook_cb(const void *data, uint16_t len, void *user_data)

util_hexdump('>', data, len, print_a2dp, NULL);

- for (i = 0; pdus[i].req; i++) {
- if (pdus[i].req_len != len)
+ for (i = 0; pdus[i].req.iov_base; i++) {
+ if (pdus[i].req.iov_len != len)
continue;

- if (memcmp(pdus[i].req, data, len))
+ if (memcmp(pdus[i].req.iov_base, data, len))
continue;

- util_hexdump('<', pdus[i].rsp, pdus[i].rsp_len, print_a2dp,
- NULL);
+ util_hexdump('<', pdus[i].rsp.iov_base, pdus[i].rsp.iov_len,
+ print_a2dp, NULL);

- bthost_send_cid(bthost, cid_data->handle, cid_data->cid,
- pdus[i].rsp, pdus[i].rsp_len);
+ bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid,
+ &pdus[i].rsp, 1);
}
}

@@ -173,8 +170,8 @@ static void sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
struct emu_cid_data *cid_data = user_data;

- bthost_send_cid(bthost, cid_data->handle, cid_data->cid,
- sdp_rsp_pdu, sizeof(sdp_rsp_pdu));
+ bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid, &sdp_rsp_pdu,
+ 1);
}
static void sdp_connect_request_cb(uint16_t handle, uint16_t cid,
void *user_data)
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 6b7eaf9..cb0b377 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -34,16 +34,6 @@
#define CONN1_ID 1
#define CONN2_ID 2

-#define raw_data(args...) ((unsigned char[]) { args })
-
-#define raw_pdu(args...) \
- { \
- .iov_base = raw_data(args), \
- .iov_len = sizeof(raw_data(args)), \
- }
-
-#define end_pdu { .iov_base = NULL }
-
static struct queue *list; /* List of gatt test cases */

static bt_uuid_t app1_uuid = {
diff --git a/android/tester-main.h b/android/tester-main.h
index e152ff3..3ebad2b 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -55,6 +55,21 @@
#include <hardware/bt_gatt_client.h>
#include <hardware/bt_gatt_server.h>

+struct pdu_set {
+ struct iovec req;
+ struct iovec rsp;
+};
+
+#define raw_data(args...) ((unsigned char[]) { args })
+
+#define raw_pdu(args...) \
+ { \
+ .iov_base = raw_data(args), \
+ .iov_len = sizeof(raw_data(args)), \
+ }
+
+#define end_pdu { .iov_base = NULL }
+
#define TEST_CASE_BREDR(text, ...) { \
HCIEMU_TYPE_BREDR, \
text, \
--
1.9.1


2014-10-02 08:10:51

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 03/13] android/tester: Make HidHost tests use io vectors for pdu

---
android/tester-hidhost.c | 48 ++++++++++++++++++++----------------------------
1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index c7e3a67..0327369 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -59,14 +59,16 @@ struct emu_cid_data {

static struct emu_cid_data cid_data;

-static const uint8_t did_req_pdu[] = { 0x06, /* PDU id */
+static const struct iovec did_req_pdu = raw_pdu(
+ 0x06, /* PDU id */
0x00, 0x00, /* Transaction id */
0x00, 0x0f, /* Req length */
0x35, 0x03, /* Attributes length */
0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00,
- 0x00, 0xff, 0xff, 0x00 }; /* no continuation */
+ 0x00, 0xff, 0xff, 0x00); /* no continuation */

-static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
+static const struct iovec did_rsp_pdu = raw_pdu(
+ 0x07, /* PDU id */
0x00, 0x00, /* Transaction id */
0x00, 0x4f, /* Response length */
0x00, 0x4c, /* Attributes length */
@@ -79,9 +81,10 @@ static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
0x02, 0x02, 0x09, 0x02, 0x46, 0x09, 0x02, 0x03, 0x09,
0x05, 0x0e, 0x09, 0x02, 0x04, 0x28, 0x01, 0x09, 0x02,
0x05, 0x09, 0x00, 0x02,
- 0x00 }; /* no continuation */
+ 0x00); /* no continuation */

-static const uint8_t hid_rsp_pdu[] = { 0x07, /* PDU id */
+static const struct iovec hid_rsp_pdu = raw_pdu(
+ 0x07, /* PDU id */
0x00, 0x01, /* Transaction id */
0x01, 0x71, /* Response length */
0x01, 0x6E, /* Attributes length */
@@ -126,7 +129,7 @@ static const uint8_t hid_rsp_pdu[] = { 0x07, /* PDU id */
0x28, 0x01, 0x09, 0x02, 0x0b, 0x09, 0x01, 0x00, 0x09,
0x02, 0x0c, 0x09, 0x0c, 0x80, 0x09, 0x02, 0x0d, 0x28,
0x00, 0x09, 0x02, 0x0e, 0x28, 0x01,
- 0x00 }; /* no continuation */
+ 0x00); /* no continuation */

static void hid_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
{
@@ -134,14 +137,14 @@ static void hid_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
struct emu_cid_data *cid_data = user_data;

- if (!memcmp(did_req_pdu, data, len)) {
- bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
- did_rsp_pdu, sizeof(did_rsp_pdu));
+ if (!memcmp(did_req_pdu.iov_base, data, len)) {
+ bthost_send_cid_v(bthost, cid_data->sdp_handle,
+ cid_data->sdp_cid, &did_rsp_pdu, 1);
return;
}

- bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
- hid_rsp_pdu, sizeof(hid_rsp_pdu));
+ bthost_send_cid_v(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
+ &hid_rsp_pdu, 1);
}
static void hid_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
{
@@ -159,31 +162,20 @@ static void hid_prepare_reply_protocol_mode(struct emu_cid_data *cid_data)
{
struct test_data *t_data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- uint8_t pdu[2] = { 0, 0 };
- uint16_t pdu_len = 0;
+ const struct iovec pdu = raw_pdu(0xa0, 0x00);

- pdu_len = 2;
- pdu[0] = 0xa0;
- pdu[1] = 0x00;
-
- bthost_send_cid(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
- (void *)pdu, pdu_len);
+ bthost_send_cid_v(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
+ &pdu, 1);
}

static void hid_prepare_reply_report(struct emu_cid_data *cid_data)
{
struct test_data *t_data = tester_get_data();
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- uint8_t pdu[3] = { 0, 0, 0 };
- uint16_t pdu_len = 0;
-
- pdu_len = 3;
- pdu[0] = 0xa2;
- pdu[1] = 0x01;
- pdu[2] = 0x00;
+ const struct iovec pdu = raw_pdu(0xa2, 0x01, 0x00);

- bthost_send_cid(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
- (void *)pdu, pdu_len);
+ bthost_send_cid_v(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
+ &pdu, 1);
}

static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
--
1.9.1


2014-10-02 08:10:49

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCHv4 01/13] android/tester: Replace gatt-tester's pdu structs with io vectors

This is the first step in unifying the way pdu is handled.
---
android/tester-gatt.c | 81 ++++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 43 deletions(-)

diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 693a8a3..6b7eaf9 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -34,23 +34,18 @@
#define CONN1_ID 1
#define CONN2_ID 2

-#define data(args...) ((const unsigned char[]) { args })
+#define raw_data(args...) ((unsigned char[]) { args })

#define raw_pdu(args...) \
{ \
- .data = data(args), \
- .size = sizeof(data(args)), \
+ .iov_base = raw_data(args), \
+ .iov_len = sizeof(raw_data(args)), \
}

-#define end_pdu { .data = NULL }
+#define end_pdu { .iov_base = NULL }

static struct queue *list; /* List of gatt test cases */

-struct pdu {
- const uint8_t *data;
- uint16_t size;
-};
-
static bt_uuid_t app1_uuid = {
.uu = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
@@ -161,8 +156,8 @@ static struct gatt_search_service_data search_services_1 = {
.filter_uuid = NULL,
};

-static const uint8_t exchange_mtu_req_pdu[] = { 0x02, 0xa0, 0x02 };
-static const uint8_t exchange_mtu_resp_pdu[] = { 0x03, 0xa0, 0x02 };
+static const struct iovec exchange_mtu_req_pdu = raw_pdu(0x02, 0xa0, 0x02);
+static const struct iovec exchange_mtu_resp_pdu = raw_pdu(0x03, 0xa0, 0x02);

static struct bt_action_data bearer_type = {
.bearer_type = BDADDR_LE_PUBLIC,
@@ -392,7 +387,7 @@ static struct set_write_params set_write_param_3 = {
.status = 0x01
};

-static struct pdu search_service[] = {
+static struct iovec search_service[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -400,7 +395,7 @@ static struct pdu search_service[] = {
end_pdu
};

-static struct pdu search_service_2[] = {
+static struct iovec search_service_2[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -410,13 +405,13 @@ static struct pdu search_service_2[] = {
end_pdu
};

-static struct pdu search_service_3[] = {
+static struct iovec search_service_3[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
end_pdu
};

-static struct pdu get_characteristic_1[] = {
+static struct iovec get_characteristic_1[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -428,7 +423,7 @@ static struct pdu get_characteristic_1[] = {
end_pdu
};

-static struct pdu get_descriptor_1[] = {
+static struct iovec get_descriptor_1[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -444,7 +439,7 @@ static struct pdu get_descriptor_1[] = {
end_pdu
};

-static struct pdu get_descriptor_2[] = {
+static struct iovec get_descriptor_2[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -460,7 +455,7 @@ static struct pdu get_descriptor_2[] = {
end_pdu
};

-static struct pdu get_descriptor_3[] = {
+static struct iovec get_descriptor_3[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -474,7 +469,7 @@ static struct pdu get_descriptor_3[] = {
end_pdu
};

-static struct pdu get_included_1[] = {
+static struct iovec get_included_1[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -486,7 +481,7 @@ static struct pdu get_included_1[] = {
end_pdu
};

-static struct pdu get_included_2[] = {
+static struct iovec get_included_2[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -501,7 +496,7 @@ static struct pdu get_included_2[] = {
end_pdu
};

-static struct pdu get_included_3[] = {
+static struct iovec get_included_3[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -511,7 +506,7 @@ static struct pdu get_included_3[] = {
end_pdu
};

-static struct pdu read_characteristic_1[] = {
+static struct iovec read_characteristic_1[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -525,7 +520,7 @@ static struct pdu read_characteristic_1[] = {
end_pdu
};

-static struct pdu read_characteristic_2[] = {
+static struct iovec read_characteristic_2[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -539,7 +534,7 @@ static struct pdu read_characteristic_2[] = {
end_pdu
};

-static struct pdu read_descriptor_1[] = {
+static struct iovec read_descriptor_1[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -557,7 +552,7 @@ static struct pdu read_descriptor_1[] = {
end_pdu
};

-static struct pdu read_descriptor_2[] = {
+static struct iovec read_descriptor_2[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -575,7 +570,7 @@ static struct pdu read_descriptor_2[] = {
end_pdu
};

-static struct pdu write_characteristic_1[] = {
+static struct iovec write_characteristic_1[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -588,7 +583,7 @@ static struct pdu write_characteristic_1[] = {
end_pdu
};

-static struct pdu write_characteristic_2[] = {
+static struct iovec write_characteristic_2[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -602,7 +597,7 @@ static struct pdu write_characteristic_2[] = {
end_pdu
};

-static struct pdu write_characteristic_3[] = {
+static struct iovec write_characteristic_3[] = {
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
@@ -871,16 +866,16 @@ static void gatt_cid_hook_cb(const void *data, uint16_t len, void *user_data)
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
struct emu_cid_data *cid_data = user_data;
const uint8_t *pdu = data;
- struct pdu *gatt_pdu = queue_peek_head(t_data->pdus);
+ struct iovec *gatt_pdu = queue_peek_head(t_data->pdus);

switch (pdu[0]) {
case L2CAP_ATT_EXCHANGE_MTU_REQ:
tester_print("Exchange MTU request received.");

- if (!memcmp(exchange_mtu_req_pdu, pdu, len))
- bthost_send_cid(bthost, cid_data->handle, cid_data->cid,
- exchange_mtu_resp_pdu,
- sizeof(exchange_mtu_resp_pdu));
+ if (!memcmp(exchange_mtu_req_pdu.iov_base, pdu, len))
+ bthost_send_cid_v(bthost, cid_data->handle,
+ cid_data->cid,
+ &exchange_mtu_resp_pdu, 1);

break;
case L2CAP_ATT_EXCHANGE_MTU_RSP:
@@ -888,29 +883,29 @@ static void gatt_cid_hook_cb(const void *data, uint16_t len, void *user_data)

break;
default:
- if (!gatt_pdu || !gatt_pdu->data) {
+ if (!gatt_pdu || !gatt_pdu->iov_base) {
tester_print("Unknown ATT packet.");
break;
}

- if (gatt_pdu->size != len) {
+ if (gatt_pdu->iov_len != len) {
tester_print("Size of incoming frame is not valid");
- tester_print("Expected size = %d incoming size = %d",
- gatt_pdu->size, len);
+ tester_print("Expected size = %zd incoming size = %d",
+ gatt_pdu->iov_len, len);
break;
}

- if (memcmp(gatt_pdu->data, data, len)) {
+ if (memcmp(gatt_pdu->iov_base, data, len)) {
tester_print("Incoming data mismatch");
break;
}
queue_pop_head(t_data->pdus);
gatt_pdu = queue_pop_head(t_data->pdus);
- if (!gatt_pdu || !gatt_pdu->data)
+ if (!gatt_pdu || !gatt_pdu->iov_base)
break;

- bthost_send_cid(bthost, cid_data->handle, cid_data->cid,
- gatt_pdu->data, gatt_pdu->size);
+ bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid,
+ gatt_pdu, 1);

break;
}
@@ -957,9 +952,9 @@ static void init_pdus(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
struct step *step = g_new0(struct step, 1);
- struct pdu *pdu = current_data_step->set_data;
+ struct iovec *pdu = current_data_step->set_data;

- while (pdu->data) {
+ while (pdu->iov_base) {
queue_push_tail(data->pdus, pdu);
pdu++;
}
--
1.9.1