summaryrefslogtreecommitdiff
path: root/lib/libpcap
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpcap')
-rw-r--r--lib/libpcap/gencode.c9
-rw-r--r--lib/libpcap/pcap-filter.59
-rw-r--r--lib/libpcap/pcap.h8
3 files changed, 20 insertions, 6 deletions
diff --git a/lib/libpcap/gencode.c b/lib/libpcap/gencode.c
index a9fb14be943..5018b52266c 100644
--- a/lib/libpcap/gencode.c
+++ b/lib/libpcap/gencode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gencode.c,v 1.56 2020/09/12 09:27:22 kn Exp $ */
+/* $OpenBSD: gencode.c,v 1.57 2021/01/18 09:26:35 sthen Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
@@ -3103,6 +3103,13 @@ gen_broadcast(proto)
break;
case Q_IP:
+ /*
+ * We treat a netmask of PCAP_NETMASK_UNKNOWN (0xffffffff)
+ * as an indication that we don't know the netmask, and fail
+ * in that case.
+ */
+ if (netmask == PCAP_NETMASK_UNKNOWN)
+ bpf_error("netmask not known, so 'ip broadcast' not supported");
b0 = gen_linktype(ETHERTYPE_IP);
hostmask = ~netmask;
b1 = gen_mcmp_nl(16, BPF_W, (bpf_int32)0, hostmask);
diff --git a/lib/libpcap/pcap-filter.5 b/lib/libpcap/pcap-filter.5
index 5555ed0259b..8eac728f571 100644
--- a/lib/libpcap/pcap-filter.5
+++ b/lib/libpcap/pcap-filter.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pcap-filter.5,v 1.5 2020/08/03 03:40:02 dlg Exp $
+.\" $OpenBSD: pcap-filter.5,v 1.6 2021/01/18 09:26:35 sthen Exp $
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
@@ -20,7 +20,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.Dd $Mdocdate: August 3 2020 $
+.Dd $Mdocdate: January 18 2021 $
.Dt PCAP-FILTER 5
.Os
.Sh NAME
@@ -378,8 +378,9 @@ and looks up the subnet mask on the interface on which the capture is
being done.
.Pp
If the subnet mask of the interface on which the capture is being done
-is not available,
-this check will not work correctly.
+is not known, a value of PCAP_NETMASK_UNKNOWN can be supplied;
+tests for IPv4 broadcast addreses will fail to compile,
+but all other tests in the filter program will be OK.
.It Cm ether multicast
True if the packet is an Ethernet multicast packet.
The
diff --git a/lib/libpcap/pcap.h b/lib/libpcap/pcap.h
index 1a75590ae93..c15f77e786e 100644
--- a/lib/libpcap/pcap.h
+++ b/lib/libpcap/pcap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcap.h,v 1.21 2019/11/28 03:08:21 akoshibe Exp $ */
+/* $OpenBSD: pcap.h,v 1.22 2021/01/18 09:26:35 sthen Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -155,6 +155,12 @@ struct pcap_addr {
#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */
#define PCAP_WARNING_TSTAMP_TYPE_NOTSUP 3 /* the requested time stamp type is not supported */
+/*
+ * Value to pass to pcap_compile() as the netmask if you don't know what
+ * the netmask is.
+ */
+#define PCAP_NETMASK_UNKNOWN 0xffffffff
+
typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
const u_char *);