Return-Path: From: Michael Janssen To: linux-bluetooth@vger.kernel.org Cc: Michael Janssen Subject: [PATCH BlueZ v2 1/4] android/tester-gatt: Fix search single PDUs Date: Thu, 13 Nov 2014 09:39:14 -0800 Message-Id: <1415900357-27027-2-git-send-email-jamuraa@chromium.org> In-Reply-To: <1415900357-27027-1-git-send-email-jamuraa@chromium.org> References: <1415900357-27027-1-git-send-email-jamuraa@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: The final PDU of the search single exchange was malformed on many of these: 0x11 instead of 0x10 in the "request opcode in error" slot. This patch fixes this bug and deduplicates the repeated PDUs by using a macro instead. --- 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