btmon: -A to suppress LE_ADV details.

We don't really want to know what devices are nearby.
When run in the background, we'll use -A to suppress
LE ADV messages.

Change-Id: I8827ec7db15a9facdc665aeceab141f217702718
diff --git a/monitor/main.c b/monitor/main.c
index a9fd90d..c04a94a 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -70,6 +70,7 @@
 		"\t-T, --date             Show time and date information\n"
 		"\t-S, --sco              Dump SCO traffic\n"
 		"\t-E, --ellisys [ip]     Send Ellisys HCI Injection\n"
+		"\t-A, --no_leadv         Suppress LE_ADV messages\n"
 		"\t-h, --help             Show help options\n");
 }
 
@@ -86,6 +87,7 @@
 	{ "date",    no_argument,       NULL, 'T' },
 	{ "sco",     no_argument,	NULL, 'S' },
 	{ "ellisys", required_argument, NULL, 'E' },
+	{ "no_leadv", no_argument,      NULL, 'A' },
 	{ "todo",    no_argument,       NULL, '#' },
 	{ "version", no_argument,       NULL, 'v' },
 	{ "help",    no_argument,       NULL, 'h' },
@@ -114,7 +116,7 @@
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "d:r:w:a:s:p:i:tTSE:vh",
+		opt = getopt_long(argc, argv, "d:r:w:a:s:p:i:tTSAE:vh",
 						main_options, NULL);
 		if (opt < 0)
 			break;
@@ -168,6 +170,9 @@
 		case 'S':
 			filter_mask |= PACKET_FILTER_SHOW_SCO_DATA;
 			break;
+		case 'A':
+			filter_mask |= PACKET_FILTER_SUPPRESS_LE_ADV;
+			break;
 		case 'E':
 			ellisys_server = optarg;
 			ellisys_port = 24352;
diff --git a/monitor/packet.c b/monitor/packet.c
index 6c642a8..32fbcf7 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -8926,6 +8926,14 @@
 		event_str = "Unknown";
 	}
 
+	if (filter_mask & PACKET_FILTER_SUPPRESS_LE_ADV && hdr->evt == 0x3e) {
+		uint8_t subevent = *((const uint8_t *) data);
+		if (subevent == 0x02) {
+			/* LE Advertising Report. */
+			return;
+		}
+	}
+
 	sprintf(extra_str, "(0x%2.2x) plen %d", hdr->evt, hdr->plen);
 
 	print_packet(tv, cred, index, '>', event_color, "HCI Event",
diff --git a/monitor/packet.h b/monitor/packet.h
index 322f101..30dfe38 100644
--- a/monitor/packet.h
+++ b/monitor/packet.h
@@ -33,6 +33,7 @@
 #define PACKET_FILTER_SHOW_TIME_OFFSET	(1 << 3)
 #define PACKET_FILTER_SHOW_ACL_DATA	(1 << 4)
 #define PACKET_FILTER_SHOW_SCO_DATA	(1 << 5)
+#define PACKET_FILTER_SUPPRESS_LE_ADV	(1 << 31)
 
 void packet_set_filter(unsigned long filter);
 void packet_add_filter(unsigned long filter);