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
#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 },
.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,
.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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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:
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;
}
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++;
}