Diff between 6386e2d2c94779651718d0a558ecbdbd40e27696 and f45ee9ff351880f673a5ce7f7644477e0a7df826

Changed Files

File Additions Deletions Status
Makefile.tools +1 -1 modified
tools/btmgmt.c +14 -2 modified

Full Patch

diff --git a/Makefile.tools b/Makefile.tools
index e1f693c..ec79cea 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -43,7 +43,7 @@ tools_hcieventmask_LDADD = lib/libbluetooth-private.la
 
 noinst_PROGRAMS += tools/btmgmt monitor/btmon emulator/btvirt emulator/b1ee
 
-tools_btmgmt_SOURCES = tools/btmgmt.c src/glib-helper.c
+tools_btmgmt_SOURCES = tools/btmgmt.c src/glib-helper.c src/eir.c
 tools_btmgmt_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
 
 monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index f06f0bf..2084b59 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -43,6 +43,7 @@
 
 #include <glib.h>
 #include "glib-helper.h"
+#include "eir.h"
 
 static bool monitor = false;
 static bool discovery = false;
@@ -462,6 +463,7 @@ static int mgmt_device_found(int mgmt_sk, uint16_t index,
 {
 	uint32_t flags;
 	uint16_t eir_len;
+	struct eir_data eir;
 
 	if (len < sizeof(*ev)) {
 		fprintf(stderr,
@@ -478,14 +480,24 @@ static int mgmt_device_found(int mgmt_sk, uint16_t index,
 		return -EINVAL;
 	}
 
+	memset(&eir, 0, sizeof(eir));
+	eir_parse(&eir, ev->eir, eir_len);
+
 	if (monitor || discovery) {
 		char addr[18];
 		ba2str(&ev->addr.bdaddr, addr);
 		printf("hci%u dev_found: %s type %s rssi %d "
-			"flags 0x%04x eir_len %u\n", index, addr,
-			typestr(ev->addr.type), ev->rssi, flags, eir_len);
+			"flags 0x%04x ", index, addr,
+			typestr(ev->addr.type), ev->rssi, flags);
+
+		if (eir.name)
+			printf("name %s\n", eir.name);
+		else
+			printf("eir_len %u\n", eir_len);
 	}
 
+	eir_data_free(&eir);
+
 	if (discovery && (flags & MGMT_DEV_FOUND_CONFIRM_NAME)) {
 		struct mgmt_cp_confirm_name cp;