[PATCH BlueZ 1/4] android/tester-gatt: DRY/bugfix search single PDUs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The search service with a single service response PDUs are repeated
multiple times throughout the testing data.  Use a macro instead.

Also, the final PDU was malformed on many of these (had 0x11 instead of
0x10 in the "request opcode in error" slot) which this fixes.
---
 android/tester-gatt.c | 106 +++++++++++++-------------------------------------
 1 file changed, 26 insertions(+), 80 deletions(-)

diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 13e096f..b88eeff 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -832,11 +832,14 @@ static struct send_resp_data send_resp_data_2 = {
 	.response = &response_2,
 };
 
+#define SEARCH_SERVICE_SINGLE_SUCCESS_PDUS				\
+	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),		\
+	raw_pdu(0x01, 0x10, 0x11, 0x00, 0x0a)				\
+
 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),
-	raw_pdu(0x01, 0x10, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	end_pdu
 };
 
@@ -857,10 +860,7 @@ static struct iovec search_service_3[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -869,10 +869,7 @@ static struct iovec get_characteristic_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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -885,10 +882,7 @@ static struct iovec get_descriptor_1[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -901,10 +895,7 @@ static struct iovec get_descriptor_2[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -915,10 +906,7 @@ static struct iovec get_descriptor_3[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
 	raw_pdu(0x09, 0x08, 0x02, 0x00, 0x15, 0x00, 0x19, 0x00, 0xff, 0xfe),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x02, 0x28),
@@ -927,10 +915,7 @@ static struct iovec get_included_1[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
 	raw_pdu(0x09, 0x06, 0x02, 0x00, 0x15, 0x00, 0x19, 0x00),
 	raw_pdu(0x0a, 0x15, 0x00),
@@ -942,20 +927,14 @@ static struct iovec get_included_2[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
 	raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
 	end_pdu
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -966,10 +945,7 @@ static struct iovec read_characteristic_1[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -980,10 +956,7 @@ static struct iovec read_characteristic_2[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -998,10 +971,7 @@ static struct iovec read_descriptor_1[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1016,10 +986,7 @@ static struct iovec read_descriptor_2[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1029,10 +996,7 @@ static struct iovec write_characteristic_1[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1043,10 +1007,7 @@ static struct iovec write_characteristic_2[] = {
 };
 
 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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1057,10 +1018,7 @@ static struct iovec write_characteristic_3[] = {
 };
 
 static struct iovec write_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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1075,10 +1033,7 @@ static struct iovec write_descriptor_1[] = {
 };
 
 static struct iovec write_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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1093,10 +1048,7 @@ static struct iovec write_descriptor_2[] = {
 };
 
 static struct iovec notification_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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1105,10 +1057,7 @@ static struct iovec notification_1[] = {
 };
 
 static struct iovec notification_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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
@@ -1119,10 +1068,7 @@ static struct iovec notification_2[] = {
 };
 
 static struct iovec notification_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),
-	raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
+	SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
 	raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
 	raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
 	raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
-- 
2.1.0.rc2.206.gedb03e5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux