aboutsummaryrefslogtreecommitdiff
path: root/pcap-bt-monitor-linux.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2020-07-01 02:15:40 -0700
committerGuy Harris <gharris@sonic.net>2020-07-01 02:15:40 -0700
commit5a68762e8b0cae345e4f42ff2dc4eee9ce32329d (patch)
tree86aa6ef65f73ee37f2ac80031ae2f81bb2d3c457 /pcap-bt-monitor-linux.c
parent89b721fb41bf47b21662752221a4dd13a464da99 (diff)
Handle the pcap_t+private data in a fashion that makes fewer assumptions.
The sizeof operator and alignof macro can be given a type "name" that's anonymous, e.g. sizeof(struct { int a; char *b; }). Have pcap_create_common() and pcap_open_offline_common() take, as arguments, the total size of a structure containing both the pcap_t and the private data as members, and the offset of the private data in that structure, and define macros that calculate those given, as an argument, the data type of the private data. This avoids making assumptions about the alignment of those two items within the structure; that *might* fix GitHub issue #940 if the issue is that the ARM compiler being used does 16-byte alignment of the private structure, rather than the 8-byte alignment we were wiring in.
Diffstat (limited to 'pcap-bt-monitor-linux.c')
-rw-r--r--pcap-bt-monitor-linux.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c
index 7b75b5cc..ad4fc375 100644
--- a/pcap-bt-monitor-linux.c
+++ b/pcap-bt-monitor-linux.c
@@ -50,6 +50,14 @@
#define INTERFACE_NAME "bluetooth-monitor"
/*
+ * Private data.
+ * Currently contains nothing.
+ */
+struct pcap_bt_monitor {
+ int dummy;
+};
+
+/*
* Fields and alignment must match the declaration in the Linux kernel 3.4+.
* See struct hci_mon_hdr in include/net/bluetooth/hci_mon.h.
*/
@@ -256,7 +264,7 @@ bt_monitor_create(const char *device, char *ebuf, int *is_ours)
}
*is_ours = 1;
- p = pcap_create_common(ebuf, 0);
+ p = PCAP_CREATE_COMMON(ebuf, struct pcap_bt_monitor);
if (p == NULL)
return NULL;