|
|
1cc1d0c |
From 661a9057b123e794897c8957c29530a5f428ec7b Mon Sep 17 00:00:00 2001
|
|
|
1cc1d0c |
From: Jakub Sitnicki <jsitnicki@gmail.com>
|
|
|
1cc1d0c |
Date: Thu, 26 Mar 2015 22:35:29 +0100
|
|
|
1cc1d0c |
Subject: [PATCH] Fix building Bluetooth Linux Monitor support with BlueZ 5.1+
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
Starting from version 5.1 BlueZ no longer exports the mgmt.h header
|
|
|
1cc1d0c |
or any other header that declares the structure of packets passed
|
|
|
1cc1d0c |
over HCI sockets set to use the HCI monitor channel.
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
Declare the structure locally and give it the same name as in the
|
|
|
1cc1d0c |
Linux kernel 3.4+.
|
|
|
1cc1d0c |
---
|
|
|
1cc1d0c |
pcap-bt-monitor-linux.c | 18 ++++++++++++++----
|
|
|
1cc1d0c |
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c
|
|
|
1cc1d0c |
index f193e26..b18bdca 100644
|
|
|
1cc1d0c |
--- a/pcap-bt-monitor-linux.c
|
|
|
1cc1d0c |
+++ b/pcap-bt-monitor-linux.c
|
|
|
1cc1d0c |
@@ -34,12 +34,12 @@
|
|
|
1cc1d0c |
#endif
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
#include <errno.h>
|
|
|
1cc1d0c |
+#include <stdint.h>
|
|
|
1cc1d0c |
#include <stdlib.h>
|
|
|
1cc1d0c |
#include <string.h>
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
#include <bluetooth/bluetooth.h>
|
|
|
1cc1d0c |
#include <bluetooth/hci.h>
|
|
|
1cc1d0c |
-#include <bluetooth/mgmt.h>
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
#include "pcap/bluetooth.h"
|
|
|
1cc1d0c |
#include "pcap-int.h"
|
|
|
1cc1d0c |
@@ -49,6 +49,16 @@
|
|
|
1cc1d0c |
#define BT_CONTROL_SIZE 32
|
|
|
1cc1d0c |
#define INTERFACE_NAME "bluetooth-monitor"
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
+/*
|
|
|
1cc1d0c |
+ * Fields and alignment must match the declaration in the Linux kernel 3.4+.
|
|
|
1cc1d0c |
+ * See struct hci_mon_hdr in include/net/bluetooth/hci_mon.h.
|
|
|
1cc1d0c |
+ */
|
|
|
1cc1d0c |
+struct hci_mon_hdr {
|
|
|
1cc1d0c |
+ uint16_t opcode;
|
|
|
1cc1d0c |
+ uint16_t index;
|
|
|
1cc1d0c |
+ uint16_t len;
|
|
|
1cc1d0c |
+} __attribute__((packed));
|
|
|
1cc1d0c |
+
|
|
|
1cc1d0c |
int
|
|
|
1cc1d0c |
bt_monitor_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
|
|
1cc1d0c |
{
|
|
|
1cc1d0c |
@@ -72,12 +82,12 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|
|
1cc1d0c |
ssize_t ret;
|
|
|
1cc1d0c |
struct pcap_pkthdr pkth;
|
|
|
1cc1d0c |
pcap_bluetooth_linux_monitor_header *bthdr;
|
|
|
1cc1d0c |
- struct mgmt_hdr hdr;
|
|
|
1cc1d0c |
+ struct hci_mon_hdr hdr;
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
bthdr = (pcap_bluetooth_linux_monitor_header*) &handle->buffer[handle->offset];
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
iv[0].iov_base = &hd;;
|
|
|
1cc1d0c |
- iv[0].iov_len = MGMT_HDR_SIZE;
|
|
|
1cc1d0c |
+ iv[0].iov_len = sizeof(hdr);
|
|
|
1cc1d0c |
iv[1].iov_base = &handle->buffer[handle->offset + sizeof(pcap_bluetooth_linux_monitor_header)];
|
|
|
1cc1d0c |
iv[1].iov_len = handle->snapshot;
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
@@ -103,7 +113,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|
|
1cc1d0c |
return -1;
|
|
|
1cc1d0c |
}
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
- pkth.caplen = ret - MGMT_HDR_SIZE + sizeof(pcap_bluetooth_linux_monitor_header);
|
|
|
1cc1d0c |
+ pkth.caplen = ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header);
|
|
|
1cc1d0c |
pkth.len = pkth.caplen;
|
|
|
1cc1d0c |
|
|
|
1cc1d0c |
for (cmsg = CMSG_FIRSTHDR(&msg;; cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
|
|
1cc1d0c |
--
|
|
|
1cc1d0c |
2.4.0
|
|
|
1cc1d0c |
|