Diff between dd374931dd9b5121dfac03467dff601ac415aae2 and df98800943e28b515854b384481428156527b21f

Changed Files

File Additions Deletions Status
src/shared/hci.c +19 -0 modified

Full Patch

diff --git a/src/shared/hci.c b/src/shared/hci.c
index d0305ac..77d7b5c 100644
--- a/src/shared/hci.c
+++ b/src/shared/hci.c
@@ -51,6 +51,14 @@ struct sockaddr_hci {
 #define HCI_CHANNEL_RAW		0
 #define HCI_CHANNEL_USER	1
 
+#define SOL_HCI		0
+#define HCI_FILTER	2
+struct hci_filter {
+	uint32_t type_mask;
+	uint32_t event_mask[2];
+	uint16_t opcode;
+};
+
 struct bt_hci {
 	int ref_count;
 	int fd;
@@ -375,12 +383,23 @@ struct bt_hci *bt_hci_new_user_channel(uint16_t index)
 struct bt_hci *bt_hci_new_raw_device(uint16_t index)
 {
 	struct bt_hci *hci;
+	struct hci_filter flt;
 	int fd;
 
 	fd = create_socket(index, HCI_CHANNEL_RAW);
 	if (fd < 0)
 		return NULL;
 
+	memset(&flt, 0, sizeof(flt));
+	flt.type_mask = 1 << BT_H4_EVT_PKT;
+	flt.event_mask[0] = 0xffffffff;
+	flt.event_mask[1] = 0xffffffff;
+
+	if (setsockopt(fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
+		close(fd);
+		return NULL;
+	}
+
 	hci = bt_hci_new(fd);
 	if (!hci) {
 		close(fd);