All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] unit/test-gatt: Fix /TP/GAR/CL/BV-04-C test
@ 2015-06-18 15:01 Luiz Augusto von Dentz
  2015-06-18 15:01 ` [PATCH BlueZ 2/3] unit/test-gatt: Fix /TP/GAR/CL/BV-07-C test Luiz Augusto von Dentz
  2015-06-18 15:01 ` [PATCH BlueZ 3/3] shared/att: Auto retry if request fails Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-06-18 15:01 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The response should be Read Blob Reponse 0x0d not 0x0b which is Read
Response.
---
 unit/test-gatt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 40e2ca9..f6448d5 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -2881,7 +2881,7 @@ int main(int argc, char *argv[])
 			&test_long_read_1,
 			SERVICE_DATA_1_PDUS,
 			raw_pdu(0x0c, 0x03, 0x00, 0x00, 0x00),
-			raw_pdu(0x0b, 0x01, 0x02, 0x03));
+			raw_pdu(0x0d, 0x01, 0x02, 0x03));
 
 	define_test_client("/TP/GAR/CL/BV-04-C/512B", test_client, service_db_1,
 			&test_long_read_2,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 2/3] unit/test-gatt: Fix /TP/GAR/CL/BV-07-C test
  2015-06-18 15:01 [PATCH BlueZ 1/3] unit/test-gatt: Fix /TP/GAR/CL/BV-04-C test Luiz Augusto von Dentz
@ 2015-06-18 15:01 ` Luiz Augusto von Dentz
  2015-06-18 15:01 ` [PATCH BlueZ 3/3] shared/att: Auto retry if request fails Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-06-18 15:01 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The response should be Read Blob Reponse 0x0d not 0x0b which is Read
Response.
---
 unit/test-gatt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index f6448d5..bb6a270 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -3264,7 +3264,7 @@ int main(int argc, char *argv[])
 			&test_long_read_9,
 			SERVICE_DATA_1_PDUS,
 			raw_pdu(0x0c, 0x04, 0x00, 0x00, 0x00),
-			raw_pdu(0x0b, 0x01, 0x02, 0x03));
+			raw_pdu(0x0d, 0x01, 0x02, 0x03));
 
 	define_test_client("/TP/GAR/CL/BV-07-C/512B", test_client, service_db_1,
 			&test_long_read_10,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 3/3] shared/att: Auto retry if request fails
  2015-06-18 15:01 [PATCH BlueZ 1/3] unit/test-gatt: Fix /TP/GAR/CL/BV-04-C test Luiz Augusto von Dentz
  2015-06-18 15:01 ` [PATCH BlueZ 2/3] unit/test-gatt: Fix /TP/GAR/CL/BV-07-C test Luiz Augusto von Dentz
@ 2015-06-18 15:01 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-06-18 15:01 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds auto retry logic to requests when a security error happen,
it will first attempt to elevate the security to match the requirement
and then retry sending the request once again.
---
 src/shared/att.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 4 deletions(-)

diff --git a/src/shared/att.c b/src/shared/att.c
index f9a5817..e8be4cc 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -576,6 +576,55 @@ static bool disconnect_cb(struct io *io, void *user_data)
 	return false;
 }
 
+static bool change_security(struct bt_att *att, uint8_t ecode)
+{
+	int security;
+
+	security = bt_att_get_security(att);
+	if (ecode == BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION &&
+					security < BT_ATT_SECURITY_MEDIUM)
+		security = BT_ATT_SECURITY_MEDIUM;
+	else if (ecode == BT_ATT_ERROR_AUTHENTICATION &&
+					security < BT_ATT_SECURITY_HIGH)
+		security = BT_ATT_SECURITY_HIGH;
+	else
+		return false;
+
+	return bt_att_set_security(att, security);
+}
+
+static bool handle_error_rsp(struct bt_att *att, uint8_t *pdu,
+					ssize_t pdu_len, uint8_t *opcode)
+{
+	const struct bt_att_pdu_error_rsp *rsp;
+	struct att_send_op *op = att->pending_req;
+
+	if (pdu_len != sizeof(*rsp)) {
+		*opcode = 0;
+		return false;
+	}
+
+	rsp = (void *) pdu;
+
+	*opcode = rsp->opcode;
+
+	/* Only try to change security on L2CAP */
+	if (!att->io_on_l2cap)
+		return false;
+
+	/* Attempt to change security */
+	if (!change_security(att, rsp->ecode))
+		return false;
+
+	util_debug(att->debug_callback, att->debug_data,
+						"Retrying operation %p", op);
+
+	att->pending_req = NULL;
+
+	/* Push operation back to request queue */
+	return queue_push_head(att->req_queue, op);
+}
+
 static void handle_rsp(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
 								ssize_t pdu_len)
 {
@@ -601,10 +650,11 @@ static void handle_rsp(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
 	 * the request is malformed, end the current request with failure.
 	 */
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
-		if (pdu_len != 4)
-			goto fail;
-
-		req_opcode = pdu[0];
+		/* Return if error response cause a retry */
+		if (handle_error_rsp(att, pdu, pdu_len, &req_opcode)) {
+			wakeup_writer(att);
+			return;
+		}
 	} else if (!(req_opcode = get_req_opcode(opcode)))
 		goto fail;
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-18 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18 15:01 [PATCH BlueZ 1/3] unit/test-gatt: Fix /TP/GAR/CL/BV-04-C test Luiz Augusto von Dentz
2015-06-18 15:01 ` [PATCH BlueZ 2/3] unit/test-gatt: Fix /TP/GAR/CL/BV-07-C test Luiz Augusto von Dentz
2015-06-18 15:01 ` [PATCH BlueZ 3/3] shared/att: Auto retry if request fails Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.