diff options
author | Joseph Mingrone <jrm@FreeBSD.org> | 2023-03-31 19:01:44 +0000 |
---|---|---|
committer | Joseph Mingrone <jrm@FreeBSD.org> | 2023-03-31 19:02:22 +0000 |
commit | 6f9cba8f8b5efd16249633e52483ea351876b67b (patch) | |
tree | 544c9dc831f12dad8ce0bf0af943eb68d07a845f /contrib/libpcap/pcap-bt-monitor-linux.c | |
parent | d860991a7289c673d19467ea7faae46df7681db1 (diff) | |
parent | 35af88c96350eb786f1198dfb6b29a171016e6bf (diff) | |
download | src-6f9cba8f8b5efd16249633e52483ea351876b67b.tar.gz src-6f9cba8f8b5efd16249633e52483ea351876b67b.zip |
libpcap: Update to 1.10.3
Local changes:
- In contrib/libpcap/pcap/bpf.h, do not include pcap/dlt.h. Our system
net/dlt.h is pulled in from net/bpf.h.
- sys/net/dlt.h: Incorporate changes from libpcap 1.10.3.
- lib/libpcap/Makefile: Update for libpcap 1.10.3.
Changelog: https://git.tcpdump.org/libpcap/blob/95691ebe7564afa3faa5c6ba0dbd17e351be455a:/CHANGES
Reviewed by: emaste
Obtained from: https://www.tcpdump.org/release/libpcap-1.10.3.tar.gz
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'contrib/libpcap/pcap-bt-monitor-linux.c')
-rw-r--r-- | contrib/libpcap/pcap-bt-monitor-linux.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/contrib/libpcap/pcap-bt-monitor-linux.c b/contrib/libpcap/pcap-bt-monitor-linux.c index a693949d4618..206e65b52122 100644 --- a/contrib/libpcap/pcap-bt-monitor-linux.c +++ b/contrib/libpcap/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. */ @@ -119,12 +127,16 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch } while ((ret == -1) && (errno == EINTR)); if (ret < 0) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { + /* Nonblocking mode, no data */ + return 0; + } pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, errno, "Can't receive packet"); return -1; } - pkth.caplen = ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header); + pkth.caplen = (bpf_u_int32)(ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header)); pkth.len = pkth.caplen; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { @@ -139,7 +151,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch bthdr->opcode = htons(hdr.opcode); if (handle->fcode.bf_insns == NULL || - bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) { + pcap_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) { callback(user, &pkth, pktd); return 1; } @@ -147,21 +159,14 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch } static int -bt_monitor_inject(pcap_t *handle, const void *buf _U_, size_t size _U_) +bt_monitor_inject(pcap_t *handle, const void *buf _U_, int size _U_) { - pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Packet injection is not supported yet on Bluetooth monitor devices"); return -1; } static int -bt_monitor_setdirection(pcap_t *p, pcap_direction_t d) -{ - p->direction = d; - return 0; -} - -static int bt_monitor_stats(pcap_t *handle _U_, struct pcap_stat *stats) { stats->ps_recv = 0; @@ -200,7 +205,7 @@ bt_monitor_activate(pcap_t* handle) handle->read_op = bt_monitor_read; handle->inject_op = bt_monitor_inject; handle->setfilter_op = install_bpf_program; /* no kernel filtering */ - handle->setdirection_op = bt_monitor_setdirection; + handle->setdirection_op = NULL; /* Not implemented */ handle->set_datalink_op = NULL; /* can't change data link type */ handle->getnonblock_op = pcap_getnonblock_fd; handle->setnonblock_op = pcap_setnonblock_fd; @@ -263,7 +268,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; |