jcs's openbsd hax
openbsd

support PCAP_NETMASK_UNKNOWN, adapted from an old commit in upstream libpcap, ok dlg@

https://github.com/the-tcpdump-group/libpcap/commit/74b2de364f3443fc2414d0160b0b942f347c6fd4
https://github.com/the-tcpdump-group/libpcap/commit/117cb5eb2eb4fe212d3851f1205bb0b8f57873c6

sthen ff78d6ed 93e2f5d4

+20 -6
+8 -1
lib/libpcap/gencode.c
··· 1 - /* $OpenBSD: gencode.c,v 1.56 2020/09/12 09:27:22 kn Exp $ */ 1 + /* $OpenBSD: gencode.c,v 1.57 2021/01/18 09:26:35 sthen Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 ··· 3103 3103 break; 3104 3104 3105 3105 case Q_IP: 3106 + /* 3107 + * We treat a netmask of PCAP_NETMASK_UNKNOWN (0xffffffff) 3108 + * as an indication that we don't know the netmask, and fail 3109 + * in that case. 3110 + */ 3111 + if (netmask == PCAP_NETMASK_UNKNOWN) 3112 + bpf_error("netmask not known, so 'ip broadcast' not supported"); 3106 3113 b0 = gen_linktype(ETHERTYPE_IP); 3107 3114 hostmask = ~netmask; 3108 3115 b1 = gen_mcmp_nl(16, BPF_W, (bpf_int32)0, hostmask);
+5 -4
lib/libpcap/pcap-filter.5
··· 1 - .\" $OpenBSD: pcap-filter.5,v 1.5 2020/08/03 03:40:02 dlg Exp $ 1 + .\" $OpenBSD: pcap-filter.5,v 1.6 2021/01/18 09:26:35 sthen Exp $ 2 2 .\" 3 3 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997 4 4 .\" The Regents of the University of California. All rights reserved. ··· 20 20 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21 21 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 22 .\" 23 - .Dd $Mdocdate: August 3 2020 $ 23 + .Dd $Mdocdate: January 18 2021 $ 24 24 .Dt PCAP-FILTER 5 25 25 .Os 26 26 .Sh NAME ··· 378 378 being done. 379 379 .Pp 380 380 If the subnet mask of the interface on which the capture is being done 381 - is not available, 382 - this check will not work correctly. 381 + is not known, a value of PCAP_NETMASK_UNKNOWN can be supplied; 382 + tests for IPv4 broadcast addreses will fail to compile, 383 + but all other tests in the filter program will be OK. 383 384 .It Cm ether multicast 384 385 True if the packet is an Ethernet multicast packet. 385 386 The
+7 -1
lib/libpcap/pcap.h
··· 1 - /* $OpenBSD: pcap.h,v 1.21 2019/11/28 03:08:21 akoshibe Exp $ */ 1 + /* $OpenBSD: pcap.h,v 1.22 2021/01/18 09:26:35 sthen Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 1993, 1994, 1995, 1996, 1997 ··· 154 154 #define PCAP_WARNING 1 /* generic warning code */ 155 155 #define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */ 156 156 #define PCAP_WARNING_TSTAMP_TYPE_NOTSUP 3 /* the requested time stamp type is not supported */ 157 + 158 + /* 159 + * Value to pass to pcap_compile() as the netmask if you don't know what 160 + * the netmask is. 161 + */ 162 + #define PCAP_NETMASK_UNKNOWN 0xffffffff 157 163 158 164 typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, 159 165 const u_char *);