Skip to content

Commit 0170672

Browse files
committed
pcap-filter(7): Document "ip broadcast" better. [skip ci]
Explain where the netmask comes from and how it works in this primitive. Make it clear which address bits it compares and which does not, provide an example and an alternative syntax. Remove "...looks up the subnet mask on the interface on which the capture is being done", which belongs to tcpdump(1).
1 parent a0b10e9 commit 0170672

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

pcap-filter.manmisc.in

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1919
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2020
.\"
21-
.TH PCAP-FILTER @MAN_MISC_INFO@ "9 February 2025"
21+
.TH PCAP-FILTER @MAN_MISC_INFO@ "22 February 2025"
2222
.SH NAME
2323
pcap-filter \- packet filter syntax
2424
.br
@@ -415,16 +415,39 @@ True if the packet is an Ethernet broadcast packet.
415415
The \fBether\fP
416416
keyword is optional.
417417
.IP "\fBip broadcast\fR"
418-
True if the packet is an IPv4 broadcast packet.
419-
It checks for both the all-zeroes and all-ones broadcast conventions,
420-
and looks up the subnet mask on the interface on which the capture is
421-
being done.
418+
True if the packet is an IPv4 packet with the host part of the destination
419+
address being either all-ones or all-zeroes. This primitive requires to
420+
specify the netmask, which cannot be done in the filter expression; the only
421+
way to specify a netmask is via the
422+
.B \%netmask
423+
argument of the
424+
.BR \%pcap_compile ()
425+
function. If a netmask has not been specified, an attempt to compile a
426+
filter expression with this primitive will return an error.
422427
.IP
423-
If the subnet mask of the interface on which the capture is being done
424-
is not available, either because the interface on which capture is being
425-
done has no netmask or because the capture is being done on the Linux
426-
"any" interface, which can capture on more than one interface, this
427-
check will not work correctly.
428+
Note that this primitive ignores the network part of the destination address,
429+
thus it can match more packets than expected, especially if the interface has
430+
multiple IPv4 addresses with different netmasks. For example, if the
431+
interface has addresses 10.1.2.100/29 and 192.168.202.200/24 configured and
432+
the
433+
.B \%netmask
434+
argument corresponds to the first address, its value will be
435+
.BR \%0xFFFFFFF8
436+
and the host mask value will be
437+
.BR \%0x00000007 .
438+
This will match the expected two addresses in the first prefix (10.1.2.96 and
439+
10.1.2.103), as well as 64 addresses in the second prefix (192.168.202.0,
440+
192.168.202.7, 192.168.202.8, 192.168.202.15, 192.168.202.16 and so on), as
441+
well as any other IPv4 address with the lowest 3 bits being all-ones or
442+
all-zeroes (for example: 10.73.74.151, 192.168.50.63, 172.19.0.128) -- in
443+
other words, 25% of the complete IPv4 address space. This is why in use
444+
cases that require more precision it would be better to match the required
445+
address(es) explicitly, for example:
446+
.in +.5i
447+
.nf
448+
\fBip dst host 10.1.2.96 or 10.1.2.103\fR
449+
.fi
450+
.in -.5i
428451
.IP "\fBether multicast\fR"
429452
True if the packet is an Ethernet multicast packet.
430453
The \fBether\fP

0 commit comments

Comments
 (0)