Diff between c6cd3f52e4dd505cd7f265ee783ae975065a90dc and 1030023dd2b3ed1b96972798ef5066eea71c0119

Changed Files

File Additions Deletions Status
src/shared/att-types.h +3 -0 modified
src/shared/att.c +10 -1 modified

Full Patch

diff --git a/src/shared/att-types.h b/src/shared/att-types.h
index a6b23e4..24bf3da 100644
--- a/src/shared/att-types.h
+++ b/src/shared/att-types.h
@@ -55,6 +55,9 @@
 #define BT_ATT_OP_HANDLE_VAL_IND		0x1D
 #define BT_ATT_OP_HANDLE_VAL_CONF		0x1E
 
+/* Special opcode to receive all requests (legacy servers) */
+#define BT_ATT_ALL_REQUESTS 0x00
+
 /* Error codes for Error response PDU */
 #define BT_ATT_ERROR_INVALID_HANDLE			0x01
 #define BT_ATT_ERROR_READ_NOT_PERMITTED			0x02
diff --git a/src/shared/att.c b/src/shared/att.c
index 6adde22..aa80cef 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -575,6 +575,15 @@ struct notify_data {
 	bool handler_found;
 };
 
+static bool opcode_match(uint8_t opcode, uint8_t test_opcode)
+{
+	if (opcode == BT_ATT_ALL_REQUESTS &&
+				    get_op_type(test_opcode) == ATT_OP_TYPE_REQ)
+		return true;
+
+	return opcode == test_opcode;
+}
+
 static void notify_handler(void *data, void *user_data)
 {
 	struct att_notify *notify = data;
@@ -583,7 +592,7 @@ static void notify_handler(void *data, void *user_data)
 	if (notify->removed)
 		return;
 
-	if (notify->opcode != not_data->opcode)
+	if (!opcode_match(notify->opcode, not_data->opcode))
 		return;
 
 	not_data->handler_found = true;