summaryrefslogtreecommitdiff
path: root/android/tester-hidhost.c
diff options
context:
space:
mode:
authorJakub Tyszkowski <jakub.tyszkowski@tieto.com>2014-10-02 10:10:51 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-10-02 14:20:48 +0300
commit92b1fb608f1054d5aadb330d8348a381a2966cf5 (patch)
treeaefabcd96b233cde6faeb790c6965e4a1237a386 /android/tester-hidhost.c
parent8c888307c25cd08c00ed71e3b911cc3c2189445f (diff)
downloadbluez-92b1fb608f1054d5aadb330d8348a381a2966cf5.tar.gz
android/tester: Make HidHost tests use io vectors for pdu
Diffstat (limited to 'android/tester-hidhost.c')
-rw-r--r--android/tester-hidhost.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index c7e3a6735..032736982 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,