From c7b7c0fe697376e36c450407382a0c3ecaeb006c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 13 Jan 2013 17:45:44 -0800 Subject: [PATCH] monitor: Add more ATT protocol decodings --- monitor/bt.h | 19 +++++++++++++++++++ monitor/l2cap.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/monitor/bt.h b/monitor/bt.h index 1b70f4351..f4f3f2df1 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -1634,6 +1634,13 @@ struct bt_l2cap_att_read_type_rsp { uint8_t length; } __attribute__ ((packed)); +#define BT_L2CAP_ATT_READ_REQ 0x0a +struct bt_l2cap_att_read_req { + uint16_t handle; +} __attribute__ ((packed)); + +#define BT_L2CAP_ATT_READ_RSP 0x0b + #define BT_L2CAP_ATT_READ_GROUP_TYPE_REQ 0x10 struct bt_l2cap_att_read_group_type_req { uint16_t start_handle; @@ -1645,6 +1652,18 @@ struct bt_l2cap_att_read_group_type_rsp { uint8_t length; } __attribute__ ((packed)); +#define BT_L2CAP_ATT_HANDLE_VALUE_NOTIFY 0x1b +struct bt_l2cap_att_handle_value_notify { + uint16_t handle; +} __attribute__ ((packed)); + +#define BT_L2CAP_ATT_HANDLE_VALUE_IND 0x1d +struct bt_l2cap_att_handle_value_ind { + uint16_t handle; +} __attribute__ ((packed)); + +#define BT_L2CAP_ATT_HANDLE_VALUE_CONF 0x1e + struct bt_l2cap_hdr_smp { uint8_t code; } __attribute__ ((packed)); diff --git a/monitor/l2cap.c b/monitor/l2cap.c index 7602673de..2f2b7ae18 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -1655,6 +1655,18 @@ static void att_read_type_rsp(const struct l2cap_frame *frame) frame->data + 1, frame->size - 1); } +static void att_read_req(const struct l2cap_frame *frame) +{ + const struct bt_l2cap_att_read_req *pdu = frame->data; + + print_field("Handle: 0x%4.4x", btohs(pdu->handle)); +} + +static void att_read_rsp(const struct l2cap_frame *frame) +{ + print_hex_field("Value", frame->data, frame->size); +} + static void att_read_group_type_req(const struct l2cap_frame *frame) { print_handle_range("Handle range", frame->data); @@ -1670,6 +1682,26 @@ static void att_read_group_type_rsp(const struct l2cap_frame *frame) frame->data + 1, frame->size - 1); } +static void att_handle_value_notify(const struct l2cap_frame *frame) +{ + const struct bt_l2cap_att_handle_value_notify *pdu = frame->data; + + print_field("Handle: 0x%4.4x", btohs(pdu->handle)); + print_hex_field(" Data", frame->data + 2, frame->size - 2); +} + +static void att_handle_value_ind(const struct l2cap_frame *frame) +{ + const struct bt_l2cap_att_handle_value_ind *pdu = frame->data; + + print_field("Handle: 0x%4.4x", btohs(pdu->handle)); + print_hex_field(" Data", frame->data + 2, frame->size - 2); +} + +static void att_handle_value_conf(const struct l2cap_frame *frame) +{ +} + struct att_opcode_data { uint8_t opcode; const char *str; @@ -1693,8 +1725,10 @@ static const struct att_opcode_data att_opcode_table[] = { att_read_type_req, 6, false }, { 0x09, "Read By Type Response", att_read_type_rsp, 4, false }, - { 0x0a, "Read Request" }, - { 0x0b, "Read Response" }, + { 0x0a, "Read Request", + att_read_req, 2, true }, + { 0x0b, "Read Response", + att_read_rsp, 0, false }, { 0x0c, "Read Blob Request" }, { 0x0d, "Read Blob Response" }, { 0x0e, "Read Multiple Request" }, @@ -1709,9 +1743,12 @@ static const struct att_opcode_data att_opcode_table[] = { { 0x17, "Prepare Write Response" }, { 0x18, "Execute Write Request" }, { 0x19, "Execute Write Response" }, - { 0x1b, "Handle Value Notification" }, - { 0x1d, "Handle Value Indication" }, - { 0x1e, "Handle Value Confirmation" }, + { 0x1b, "Handle Value Notification", + att_handle_value_notify, 2, false }, + { 0x1d, "Handle Value Indication", + att_handle_value_ind, 2, false }, + { 0x1e, "Handle Value Confirmation", + att_handle_value_conf, 0, true }, { 0x52, "Write Command" }, { 0xd2, "Signed Write Command" }, { } -- 2.47.3