linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] monitor: Add support for analyzing index info
@ 2016-04-26 20:52 Szymon Janc
  2016-04-26 20:52 ` [PATCH 2/2] monitor: Display all events type in analyze Szymon Janc
  2016-06-17  8:26 ` [PATCH 1/2] monitor: Add support for analyzing index info Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Szymon Janc @ 2016-04-26 20:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Will now show vendor name if it was provided in snoop file.
---
 monitor/analyze.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/monitor/analyze.c b/monitor/analyze.c
index 0f2d19a..197c7f9 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -29,6 +29,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "lib/bluetooth.h"
+
 #include "src/shared/util.h"
 #include "src/shared/queue.h"
 #include "src/shared/btsnoop.h"
@@ -45,6 +47,7 @@ struct hci_dev {
 	unsigned long num_evt;
 	unsigned long num_acl;
 	unsigned long num_sco;
+	uint16_t manufacturer;
 };
 
 static struct queue *dev_list;
@@ -67,9 +70,14 @@ static void dev_destroy(void *data)
 	}
 
 	printf("Found %s controller with index %u\n", str, dev->index);
-	printf("  BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+	printf("  BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
 			dev->bdaddr[5], dev->bdaddr[4], dev->bdaddr[3],
 			dev->bdaddr[2], dev->bdaddr[1], dev->bdaddr[0]);
+	if (dev->manufacturer != 0xffff)
+		printf(" (%s)", bt_compidtostr(dev->manufacturer));
+	printf("\n");
+
+
 	printf("  %lu commands\n", dev->num_cmd);
 	printf("  %lu events\n", dev->num_evt);
 	printf("  %lu ACL packets\n", dev->num_acl);
@@ -90,6 +98,7 @@ static struct hci_dev *dev_alloc(uint16_t index)
 	}
 
 	dev->index = index;
+	dev->manufacturer = 0xffff;
 
 	return dev;
 }
@@ -251,6 +260,22 @@ static void sco_pkt(struct timeval *tv, uint16_t index,
 	dev->num_sco++;
 }
 
+static void info_index(struct timeval *tv, uint16_t index,
+					const void *data, uint16_t size)
+{
+	const struct btsnoop_opcode_index_info *hdr = data;
+	struct hci_dev *dev;
+
+	data += sizeof(*hdr);
+	size -= sizeof(*hdr);
+
+	dev = dev_lookup(index);
+	if (!dev)
+		return;
+
+	dev->manufacturer = hdr->manufacturer;
+}
+
 void analyze_trace(const char *path)
 {
 	struct btsnoop *btsnoop_file;
@@ -312,6 +337,9 @@ void analyze_trace(const char *path)
 		case BTSNOOP_OPCODE_OPEN_INDEX:
 		case BTSNOOP_OPCODE_CLOSE_INDEX:
 			break;
+		case BTSNOOP_OPCODE_INDEX_INFO:
+			info_index(&tv, index, buf, pktlen);
+			break;
 		default:
 			fprintf(stderr, "Wrong opcode %u\n", opcode);
 			goto done;
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] monitor: Display all events type in analyze
  2016-04-26 20:52 [PATCH 1/2] monitor: Add support for analyzing index info Szymon Janc
@ 2016-04-26 20:52 ` Szymon Janc
  2016-06-17  8:26 ` [PATCH 1/2] monitor: Add support for analyzing index info Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2016-04-26 20:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This add support for counting all event types in analyze.
---
 monitor/analyze.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/monitor/analyze.c b/monitor/analyze.c
index 197c7f9..94f0c57 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -47,6 +47,9 @@ struct hci_dev {
 	unsigned long num_evt;
 	unsigned long num_acl;
 	unsigned long num_sco;
+	unsigned long vendor_diag;
+	unsigned long system_note;
+	unsigned long user_log;
 	uint16_t manufacturer;
 };
 
@@ -82,6 +85,9 @@ static void dev_destroy(void *data)
 	printf("  %lu events\n", dev->num_evt);
 	printf("  %lu ACL packets\n", dev->num_acl);
 	printf("  %lu SCO packets\n", dev->num_sco);
+	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("\n");
 
 	free(dev);
@@ -276,6 +282,42 @@ static void info_index(struct timeval *tv, uint16_t index,
 	dev->manufacturer = hdr->manufacturer;
 }
 
+static void vendor_diag(struct timeval *tv, uint16_t index,
+					const void *data, uint16_t size)
+{
+	struct hci_dev *dev;
+
+	dev = dev_lookup(index);
+	if (!dev)
+		return;
+
+	dev->vendor_diag++;
+}
+
+static void system_note(struct timeval *tv, uint16_t index,
+					const void *data, uint16_t size)
+{
+	struct hci_dev *dev;
+
+	dev = dev_lookup(index);
+	if (!dev)
+		return;
+
+	dev->system_note++;
+}
+
+static void user_log(struct timeval *tv, uint16_t index,
+					const void *data, uint16_t size)
+{
+	struct hci_dev *dev;
+
+	dev = dev_lookup(index);
+	if (!dev)
+		return;
+
+	dev->user_log++;
+}
+
 void analyze_trace(const char *path)
 {
 	struct btsnoop *btsnoop_file;
@@ -340,6 +382,15 @@ void analyze_trace(const char *path)
 		case BTSNOOP_OPCODE_INDEX_INFO:
 			info_index(&tv, index, buf, pktlen);
 			break;
+		case BTSNOOP_OPCODE_VENDOR_DIAG:
+			vendor_diag(&tv, index, buf, pktlen);
+			break;
+		case BTSNOOP_OPCODE_SYSTEM_NOTE:
+			system_note(&tv, index, buf, pktlen);
+			break;
+		case BTSNOOP_OPCODE_USER_LOGGING:
+			user_log(&tv, index, buf, pktlen);
+			break;
 		default:
 			fprintf(stderr, "Wrong opcode %u\n", opcode);
 			goto done;
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] monitor: Add support for analyzing index info
  2016-04-26 20:52 [PATCH 1/2] monitor: Add support for analyzing index info Szymon Janc
  2016-04-26 20:52 ` [PATCH 2/2] monitor: Display all events type in analyze Szymon Janc
@ 2016-06-17  8:26 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2016-06-17  8:26 UTC (permalink / raw)
  To: linux-bluetooth

On Tuesday 26 April 2016 22:52:12 Szymon Janc wrote:
> Will now show vendor name if it was provided in snoop file.
> ---
>  monitor/analyze.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor/analyze.c b/monitor/analyze.c
> index 0f2d19a..197c7f9 100644
> --- a/monitor/analyze.c
> +++ b/monitor/analyze.c
> @@ -29,6 +29,8 @@
>  #include <stdio.h>
>  #include <string.h>
> 
> +#include "lib/bluetooth.h"
> +
>  #include "src/shared/util.h"
>  #include "src/shared/queue.h"
>  #include "src/shared/btsnoop.h"
> @@ -45,6 +47,7 @@ struct hci_dev {
>  	unsigned long num_evt;
>  	unsigned long num_acl;
>  	unsigned long num_sco;
> +	uint16_t manufacturer;
>  };
> 
>  static struct queue *dev_list;
> @@ -67,9 +70,14 @@ static void dev_destroy(void *data)
>  	}
> 
>  	printf("Found %s controller with index %u\n", str, dev->index);
> -	printf("  BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
> +	printf("  BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
>  			dev->bdaddr[5], dev->bdaddr[4], dev->bdaddr[3],
>  			dev->bdaddr[2], dev->bdaddr[1], dev->bdaddr[0]);
> +	if (dev->manufacturer != 0xffff)
> +		printf(" (%s)", bt_compidtostr(dev->manufacturer));
> +	printf("\n");
> +
> +
>  	printf("  %lu commands\n", dev->num_cmd);
>  	printf("  %lu events\n", dev->num_evt);
>  	printf("  %lu ACL packets\n", dev->num_acl);
> @@ -90,6 +98,7 @@ static struct hci_dev *dev_alloc(uint16_t index)
>  	}
> 
>  	dev->index = index;
> +	dev->manufacturer = 0xffff;
> 
>  	return dev;
>  }
> @@ -251,6 +260,22 @@ static void sco_pkt(struct timeval *tv, uint16_t index,
> dev->num_sco++;
>  }
> 
> +static void info_index(struct timeval *tv, uint16_t index,
> +					const void *data, uint16_t size)
> +{
> +	const struct btsnoop_opcode_index_info *hdr = data;
> +	struct hci_dev *dev;
> +
> +	data += sizeof(*hdr);
> +	size -= sizeof(*hdr);
> +
> +	dev = dev_lookup(index);
> +	if (!dev)
> +		return;
> +
> +	dev->manufacturer = hdr->manufacturer;
> +}
> +
>  void analyze_trace(const char *path)
>  {
>  	struct btsnoop *btsnoop_file;
> @@ -312,6 +337,9 @@ void analyze_trace(const char *path)
>  		case BTSNOOP_OPCODE_OPEN_INDEX:
>  		case BTSNOOP_OPCODE_CLOSE_INDEX:
>  			break;
> +		case BTSNOOP_OPCODE_INDEX_INFO:
> +			info_index(&tv, index, buf, pktlen);
> +			break;
>  		default:
>  			fprintf(stderr, "Wrong opcode %u\n", opcode);
>  			goto done;

Pushed.

-- 
pozdrawiam
Szymon Janc

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-17  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-26 20:52 [PATCH 1/2] monitor: Add support for analyzing index info Szymon Janc
2016-04-26 20:52 ` [PATCH 2/2] monitor: Display all events type in analyze Szymon Janc
2016-06-17  8:26 ` [PATCH 1/2] monitor: Add support for analyzing index info Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).