From c612f6df80373bb79ad523c5b8f25e92e91b6ae7 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 3 Aug 2021 17:04:47 +0200 Subject: [PATCH] monitor: Count number of control messages Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- monitor/analyze.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/monitor/analyze.c b/monitor/analyze.c index 9f6d986..aac5c39 100755 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -38,6 +38,7 @@ struct hci_dev { unsigned long vendor_diag; unsigned long system_note; unsigned long user_log; + unsigned long ctrl_msg; unsigned long unknown; uint16_t manufacturer; }; @@ -78,6 +79,7 @@ static void dev_destroy(void *data) printf(" %lu vendor diagnostics\n", dev->vendor_diag); printf(" %lu system notes\n", dev->system_note); printf(" %lu user logs\n", dev->user_log); + printf(" %lu control messages \n", dev->ctrl_msg); printf(" %lu unknown opcodes\n", dev->unknown); printf("\n"); @@ -301,6 +303,18 @@ static void user_log(struct timeval *tv, uint16_t index, dev->user_log++; } +static void ctrl_msg(struct timeval *tv, uint16_t index, + const void *data, uint16_t size) +{ + struct hci_dev *dev; + + dev = dev_lookup(index); + if (!dev) + return; + + dev->ctrl_msg++; +} + static void iso_pkt(struct timeval *tv, uint16_t index, const void *data, uint16_t size) { @@ -398,6 +412,12 @@ void analyze_trace(const char *path) case BTSNOOP_OPCODE_USER_LOGGING: user_log(&tv, index, buf, pktlen); break; + case BTSNOOP_OPCODE_CTRL_OPEN: + case BTSNOOP_OPCODE_CTRL_CLOSE: + case BTSNOOP_OPCODE_CTRL_COMMAND: + case BTSNOOP_OPCODE_CTRL_EVENT: + ctrl_msg(&tv, index, buf, pktlen); + break; case BTSNOOP_OPCODE_ISO_TX_PKT: case BTSNOOP_OPCODE_ISO_RX_PKT: iso_pkt(&tv, index, buf, pktlen); -- 2.7.4