OSDN Git Service

monitor: Add more ATT protocol decodings
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 14 Jan 2013 01:45:44 +0000 (17:45 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 14 Jan 2013 01:45:44 +0000 (17:45 -0800)
monitor/bt.h
monitor/l2cap.c

index 1b70f43..f4f3f2d 100644 (file)
@@ -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));
index 7602673..2f2b7ae 100644 (file)
@@ -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"          },
        { }