-/* $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
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);
-.\" $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.
.\" 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
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
-/* $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
#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 *);