summaryrefslogtreecommitdiff
path: root/monitor/att.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-20 16:36:57 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-20 17:23:09 -0700
commit8e1fd164a7960962235f3757d4e49df7c0229ea0 (patch)
tree1a0aeed9c1ef3987f20f30580aed7e6cd11f1232 /monitor/att.c
parent20e944ece7a1d43d2976289c85c19e5ad2056cbd (diff)
downloadbluez-8e1fd164a7960962235f3757d4e49df7c0229ea0.tar.gz
monitor/att: Fix not matching read frame direction
There could be read frames pending on both direction so this ensures the direction is matched properly.
Diffstat (limited to 'monitor/att.c')
-rw-r--r--monitor/att.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/monitor/att.c b/monitor/att.c
index 51d83e649..d06a1b223 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -404,7 +404,8 @@ static void att_read_type_rsp(const struct l2cap_frame *frame)
struct att_read {
struct gatt_db_attribute *attr;
- uint16_t cid;
+ bool in;
+ uint16_t chan;
void (*func)(const struct l2cap_frame *frame);
};
@@ -553,7 +554,8 @@ static void att_read_req(const struct l2cap_frame *frame)
read = new0(struct att_read, 1);
read->attr = attr;
- read->cid = frame->cid;
+ read->in = frame->in;
+ read->chan = frame->chan;
read->func = handler->read;
queue_push_tail(data->reads, read);
@@ -564,7 +566,13 @@ static bool match_read_frame(const void *data, const void *match_data)
const struct att_read *read = data;
const struct l2cap_frame *frame = match_data;
- return read->cid == frame->cid;
+ /* Read frame and response frame shall be in the opposite direction to
+ * match.
+ */
+ if (read->in == frame->in)
+ return false;
+
+ return read->chan == frame->chan;
}
static void att_read_rsp(const struct l2cap_frame *frame)