]> The Tcpdump Group git mirrors - libpcap/blob - pcap-filter.manmisc.in
Fixup indentation in init_linktype().
[libpcap] / pcap-filter.manmisc.in
1 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
2 .\" The Regents of the University of California. All rights reserved.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that: (1) source code distributions
7 .\" retain the above copyright notice and this paragraph in its entirety, (2)
8 .\" distributions including binary code include the above copyright notice and
9 .\" this paragraph in its entirety in the documentation or other materials
10 .\" provided with the distribution, and (3) all advertising materials mentioning
11 .\" features or use of this software display the following acknowledgement:
12 .\" ``This product includes software developed by the University of California,
13 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 .\" the University nor the names of its contributors may be used to endorse
15 .\" or promote products derived from this software without specific prior
16 .\" written permission.
17 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 .\"
21 .TH PCAP-FILTER @MAN_MISC_INFO@ "4 January 2025"
22 .SH NAME
23 pcap-filter \- packet filter syntax
24 .br
25 .ad
26 .SH DESCRIPTION
27 .LP
28 .BR pcap_compile (3PCAP)
29 is used to compile a string into a filter program.
30 The resulting filter program can then be applied to
31 some stream of packets to determine which packets will be supplied to
32 .BR pcap_loop (3PCAP),
33 .BR pcap_dispatch (3PCAP),
34 .BR pcap_next (3PCAP),
35 or
36 .BR pcap_next_ex (3PCAP).
37 .LP
38 The \fIfilter expression\fP consists of one or more
39 .IR primitives .
40 Primitives usually consist of an
41 .I id
42 (name or number) preceded by one or more qualifiers.
43 There are three
44 different kinds of qualifier:
45 .IP \fItype\fP
46 .I type
47 qualifiers say what kind of thing the id name or number refers to.
48 Possible types are
49 .BR host ,
50 .BR net ,
51 .B port
52 and
53 .BR portrange .
54 E.g., `\fBhost\fP foo', `\fBnet\fP 128.3', `\fBport\fP 20', `\fBportrange\fP 6000-6008'.
55 If there is no type
56 qualifier,
57 .B host
58 is assumed.
59 .IP \fIdir\fP
60 .I dir
61 qualifiers specify a particular transfer direction to and/or from
62 .IR id .
63 Possible directions are
64 .BR src ,
65 .BR dst ,
66 .BR "src or dst" ,
67 .BR "src and dst" ,
68 .BR ra ,
69 .BR ta ,
70 .BR addr1 ,
71 .BR addr2 ,
72 .BR addr3 ,
73 and
74 .BR addr4 .
75 E.g., `\fBsrc\fP foo', `\fBdst net\fP 128.3', `\fBsrc or dst port\fP ftp-data'.
76 If
77 there is no dir qualifier, `\fBsrc or dst\fP' is assumed.
78 The
79 .BR ra ,
80 .BR ta ,
81 .BR addr1 ,
82 .BR addr2 ,
83 .BR addr3 ,
84 and
85 .B addr4
86 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
87 .IP \fIproto\fP
88 .I proto
89 qualifiers restrict the match to a particular protocol.
90 Possible
91 protocols are:
92 .BR ether ,
93 .BR fddi ,
94 .BR tr ,
95 .BR wlan ,
96 .BR ip ,
97 .BR ip6 ,
98 .BR arp ,
99 .BR rarp ,
100 .BR decnet ,
101 .BR sctp ,
102 .B tcp
103 and
104 .BR udp .
105 E.g., `\fBether src\fP foo', `\fBarp net\fP 128.3', `\fBtcp port\fP 21',
106 `\fBudp portrange\fP 7000-7009', `\fBwlan addr2\fP 0:2:3:4:5:6'.
107 If there is no
108 .I proto
109 qualifier, all protocols consistent with the type are assumed.
110 E.g., `\fBsrc\fP foo' means `\fB(ip6 or ip or arp or rarp) src\fP foo',
111 `\fBnet\fP bar' means `\fB(ip or arp or rarp) net\fP bar' and
112 `\fBport\fP 53' means `\fB(tcp or udp or sctp) port\fP 53'
113 (note that these examples use invalid syntax to illustrate the principle).
114 .LP
115 [\fBfddi\fP is actually an alias for \fBether\fP; the parser treats them
116 identically as meaning ``the data link level used on the specified
117 network interface''. FDDI headers contain Ethernet-like source
118 and destination addresses, and often contain Ethernet-like packet
119 types, so you can filter on these FDDI fields just as with the
120 analogous Ethernet fields.
121 FDDI headers also contain other fields,
122 but you cannot name them explicitly in a filter expression.
123 .LP
124 Similarly, \fBtr\fP and \fBwlan\fP are aliases for \fBether\fP; the previous
125 paragraph's statements about FDDI headers also apply to Token Ring
126 and 802.11 wireless LAN headers. For 802.11 headers, the destination
127 address is the DA field and the source address is the SA field; the
128 BSSID, RA, and TA fields aren't tested.]
129 .LP
130 In addition to the above, there are some special `primitive' keywords
131 that don't follow the pattern:
132 .BR gateway ,
133 .BR broadcast ,
134 .BR less ,
135 .B greater
136 and arithmetic expressions.
137 All of these are described below.
138 .LP
139 More complex filter expressions are built up by using the words
140 .BR and ,
141 .B or
142 and
143 .B not
144 (or equivalently: `\fB&&\fP', `\fB||\fP' and `\fB!\fP' respectively)
145 to combine primitives.
146 E.g., `\fBhost\fP foo \fBand not port\fP ftp \fBand not port\fP ftp-data'.
147 To save typing, identical qualifier lists can be omitted.
148 E.g.,
149 `\fBtcp dst port\fP ftp \fBor\fP ftp-data \fBor\fP domain' is exactly the same as
150 `\fBtcp dst port\fP ftp \fBor tcp dst port\fP ftp-data \fBor tcp dst port\fP domain'.
151 .LP
152 Allowable primitives are:
153 .IP "\fBdst host \fIhostnameaddr\fR"
154 True if the IPv4/v6 destination field of the packet is \fIhostnameaddr\fP,
155 which may be either an address or a name.
156 .IP "\fBsrc host \fIhostnameaddr\fR"
157 True if the IPv4/v6 source field of the packet is \fIhostnameaddr\fP.
158 .IP "\fBhost \fIhostnameaddr\fP"
159 True if either the IPv4/v6 source or destination of the packet is \fIhostnameaddr\fP.
160 .IP
161 Any of the above host expressions can be prepended with the keywords,
162 \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
163 .in +.5i
164 .nf
165 \fBip host \fIhostnameaddr\fR
166 .fi
167 .in -.5i
168 which is equivalent to:
169 .in +.5i
170 .nf
171 \fBether proto \\\fRip \fBand host \fIhostnameaddr\fR
172 .fi
173 .in -.5i
174 If \fIhostnameaddr\fR is a name with multiple IPv4/v6 addresses, each address will
175 be checked for a match.
176 .IP "\fBether dst \fIethernameaddr\fP"
177 True if the Ethernet destination address is \fIethernameaddr\fP.
178 \fIethernameaddr\fP
179 may be either a name from /etc/ethers or a numerical MAC address of the
180 form "xx:xx:xx:xx:xx:xx", "xx.xx.xx.xx.xx.xx", "xx-xx-xx-xx-xx-xx",
181 "xxxx.xxxx.xxxx" or "xxxxxxxxxxxx",
182 where each "x" is a hex digit (0-9, a-f, or A-F).
183 .IP "\fBether src \fIethernameaddr\fP"
184 True if the Ethernet source address is \fIethernameaddr\fP.
185 .IP "\fBether host \fIethernameaddr\fP"
186 True if either the Ethernet source or destination address is \fIethernameaddr\fP.
187 .IP "\fBgateway\fP \fIhost\fP"
188 True if the packet used \fIhost\fP as a gateway.
189 I.e., the Ethernet
190 source or destination address was \fIhost\fP but neither the IP source
191 nor the IP destination was \fIhost\fP.
192 \fIHost\fP must be a name and
193 must be found both by the machine's host-name-to-IP-address resolution
194 mechanisms (host name file, DNS, NIS, etc.) and by the machine's
195 host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
196 (An equivalent expression is
197 .in +.5i
198 .nf
199 \fBether host \fIethernameaddr \fBand not host \fIhostnameaddr\fR
200 .fi
201 .in -.5i
202 which can be used with either names or numbers for \fIhostnameaddr / ethernameaddr\fP.)
203 This syntax does not work in IPv6-enabled configuration at this moment.
204 .IP "\fBdst net \fInetnameaddr\fR"
205 True if the IPv4/v6 destination address of the packet has a network
206 number of \fInetnameaddr\fP.
207 \fINet\fP may be either a name from the networks database
208 (/etc/networks, etc.) or a network number.
209 An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0),
210 dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single
211 number (e.g., 10); the netmask is 255.255.255.255 for a dotted quad
212 (which means that it's really a host match), 255.255.255.0 for a dotted
213 triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number.
214 An IPv6 network number must be written out fully; the netmask is
215 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff, so IPv6 "network" matches are really always
216 host matches, and a network match requires a netmask length.
217 .IP "\fBsrc net \fInetnameaddr\fR"
218 True if the IPv4/v6 source address of the packet has a network
219 number of \fInetnameaddr\fP.
220 .IP "\fBnet \fInetnameaddr\fR"
221 True if either the IPv4/v6 source or destination address of the packet has a network
222 number of \fInetnameaddr\fP.
223 .IP "\fBnet \fInetaddr\fR \fBmask \fInetmask\fR"
224 True if the IPv4 address matches \fInetaddr\fR with the specific \fInetmask\fR.
225 May be qualified with \fBsrc\fR or \fBdst\fR.
226 Note that this syntax is not valid for IPv6 \fInetaddr\fR.
227 .IP "\fBnet \fInetaddr\fR/\fIlen\fR"
228 True if the IPv4/v6 address matches \fInetaddr\fR with a netmask \fIlen\fR
229 bits wide.
230 May be qualified with \fBsrc\fR or \fBdst\fR.
231 .IP "\fBdst port \fIportnamenum\fR"
232 True if the packet is IPv4/v6 TCP, UDP or SCTP and has a
233 destination port value of \fIportnamenum\fP.
234 The \fIportnamenum\fP can be a number or a name used in /etc/services (see
235 .BR tcp (4P)
236 and
237 .BR udp (4P)).
238 If a name is used, both the port
239 number and protocol are checked.
240 If a number or ambiguous name is used,
241 only the port number is checked (e.g., `\fBdst port\fR 513' will print both
242 tcp/login traffic and udp/who traffic, and `\fBport\fR domain' will print
243 both tcp/domain and udp/domain traffic).
244 .IP "\fBsrc port \fIportnamenum\fR"
245 True if the packet has a source port value of \fIportnamenum\fP.
246 .IP "\fBport \fIportnamenum\fR"
247 True if either the source or destination port of the packet is \fIportnamenum\fP.
248 .IP "\fBdst portrange \fIportnamenum1-portnamenum2\fR"
249 True if the packet is IPv4/v6 TCP, UDP or SCTP and has a
250 destination port value between \fIportnamenum1\fP and \fIportnamenum2\fP (both inclusive).
251 .I portnamenum1
252 and
253 .I portnamenum2
254 are interpreted in the same fashion as the
255 .I portnamenum
256 parameter for
257 .BR port .
258 .IP "\fBsrc portrange \fIportnamenum1-portnamenum2\fR"
259 True if the packet has a source port value between \fIportnamenum1\fP and
260 \fIportnamenum2\fP (both inclusive).
261 .IP "\fBportrange \fIportnamenum1-portnamenum2\fR"
262 True if either the source or destination port of the packet is between
263 \fIportnamenum1\fP and \fIportnamenum2\fP (both inclusive).
264 .IP
265 Any of the above port or port range expressions can be prepended with
266 the keywords, \fBtcp\fP, \fBudp\fP or \fBsctp\fP, as in:
267 .in +.5i
268 .nf
269 \fBtcp src port \fIportnamenum\fR
270 .fi
271 .in -.5i
272 which matches only TCP packets whose source port is \fIportnamenum\fP.
273 .IP "\fBless \fIlength\fR"
274 True if the packet has a length less than or equal to \fIlength\fP.
275 This is equivalent to:
276 .in +.5i
277 .nf
278 \fBlen <= \fIlength\fP
279 .fi
280 .in -.5i
281 .IP "\fBgreater \fIlength\fR"
282 True if the packet has a length greater than or equal to \fIlength\fP.
283 This is equivalent to:
284 .in +.5i
285 .nf
286 \fBlen >= \fIlength\fP
287 .fi
288 .in -.5i
289 .IP "\fBip proto \fIprotocol\fR"
290 True if the packet is an IPv4 packet (see
291 .BR ip (4P))
292 of protocol type \fIprotocol\fP.
293 \fIProtocol\fP can be a number or one of the names recognized by
294 .BR getprotobyname (3),
295 for example:
296 .BR ah ,
297 .BR esp ,
298 .B eigrp
299 (only in Linux with glibc, FreeBSD, NetBSD, DragonFly BSD, and macOS),
300 .BR icmp ,
301 .BR igmp ,
302 .B igrp
303 (only in Haiku and OpenBSD),
304 .BR pim ,
305 .BR sctp ,
306 .BR tcp ,
307 .B udp
308 or
309 .BR vrrp .
310 Note that most of these example identifiers
311 are also keywords and must be escaped via backslash (\\).
312 Note that this primitive does not chase the protocol header chain.
313 .IP
314 Typically
315 .BR getprotobyname (3)
316 parses the
317 .IR \%/etc/protocols
318 file to translate protocol names to numbers, and the
319 .B "getent protocols"
320 command lists the protocols recognised by the function. This is not entirely
321 so in AIX (which does not have the command), Haiku (which has the file at
322 .IR \%/system/data/network/protocols
323 and does not have the command), on Linux with musl libc (which hard-codes the
324 list of protocols) and on hosts that use a network database to resolve
325 protocol names to numbers (see
326 .BR nsswitch.conf (5)).
327 If a protocol name fails to translate to a number, this version of libpcap
328 will treat the filter expression as invalid.
329 .IP "\fBcarp\fR, \fBvrrp\fR"
330 Abbreviations for:
331 .in +.5i
332 .nf
333 \fBip proto\fR 112
334 .fi
335 .in -.5i
336 .IP "\fBicmp\fR"
337 Abbreviation for:
338 .in +.5i
339 .nf
340 \fBip proto\fR 1
341 .fi
342 .in -.5i
343 .IP "\fBigmp\fR"
344 Abbreviation for:
345 .in +.5i
346 .nf
347 \fBip proto\fR 2
348 .fi
349 .in -.5i
350 .IP "\fBigrp\fR"
351 Abbreviation for:
352 .in +.5i
353 .nf
354 \fBip proto\fR 9
355 .fi
356 .in -.5i
357 .IP "\fBip6 proto \fIprotocol\fR"
358 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
359 (See `\fBip proto\fP' above for the meaning of \fIprotocol\fR.)
360 Note that the IPv6 variant of ICMP uses a different protocol number, named
361 .B \%ipv6-icmp
362 in AIX, FreeBSD, illumos, Haiku, GNU/Hurd, Linux, macOS, NetBSD, OpenBSD,
363 Solaris and Windows.
364 Note that this primitive does not chase the protocol header chain.
365 .IP "\fBicmp6\fR"
366 Abbreviation for:
367 .in +.5i
368 .nf
369 \fBip6 proto\fR 58
370 .fi
371 .in -.5i
372 .IP "\fBproto \fIprotocol\fR"
373 True if the packet is an IPv4 or IPv6 packet of protocol type
374 \fIprotocol\fP. (See `\fBip proto\fP' above for the meaning of
375 \fIprotocol\fP.) Note that this primitive does not chase the protocol
376 header chain.
377 .IP "\fBah\fR, \fBesp\fR, \fBpim\fR, \fBsctp\fR, \fBtcp\fR, \fBudp\fR"
378 Abbreviations for:
379 .in +.5i
380 .nf
381 \fBproto \\\fIprotocol\fR
382 .fi
383 .in -.5i
384 where \fIprotocol\fR is one of the above protocols.
385 .IP "\fBip6 protochain \fIprotocol\fR"
386 True if the packet is IPv6 packet,
387 and contains protocol header with type \fIprotocol\fR
388 in its protocol header chain.
389 (See `\fBip proto\fP' above for the meaning of \fIprotocol\fP.)
390 For example,
391 .in +.5i
392 .nf
393 \fBip6 protochain\fR 6
394 .fi
395 .in -.5i
396 matches any IPv6 packet with TCP protocol header in the protocol header chain.
397 The packet may contain, for example,
398 authentication header, routing header, or hop-by-hop option header,
399 between IPv6 header and TCP header.
400 The BPF code emitted by this primitive is complex and
401 cannot be optimized by the BPF optimizer code, and is not supported by
402 filter engines in the kernel, so this can be somewhat slow, and may
403 cause more packets to be dropped.
404 .IP "\fBip protochain \fIprotocol\fR"
405 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
406 (See `\fBip proto\fP' above for the meaning of \fIprotocol\fP.)
407 .IP "\fBprotochain \fIprotocol\fR"
408 True if the packet is an IPv4 or IPv6 packet of protocol type
409 \fIprotocol\fP. (See `\fBip proto\fP' above for the meaning of
410 \fIprotocol\fP.) Note that this primitive chases the protocol
411 header chain.
412 .IP "\fBether broadcast\fR"
413 True if the packet is an Ethernet broadcast packet.
414 The \fBether\fP
415 keyword is optional.
416 .IP "\fBip broadcast\fR"
417 True if the packet is an IPv4 broadcast packet.
418 It checks for both the all-zeroes and all-ones broadcast conventions,
419 and looks up the subnet mask on the interface on which the capture is
420 being done.
421 .IP
422 If the subnet mask of the interface on which the capture is being done
423 is not available, either because the interface on which capture is being
424 done has no netmask or because the capture is being done on the Linux
425 "any" interface, which can capture on more than one interface, this
426 check will not work correctly.
427 .IP "\fBether multicast\fR"
428 True if the packet is an Ethernet multicast packet.
429 The \fBether\fP
430 keyword is optional.
431 This is shorthand for `\fBether[\fP0\fB] & \fP1\fB != \fP0'.
432 .IP "\fBip multicast\fR"
433 True if the packet is an IPv4 multicast packet.
434 .IP "\fBip6 multicast\fR"
435 True if the packet is an IPv6 multicast packet.
436 .IP "\fBether proto \fIprotocol\fR"
437 True if the packet is of ether type \fIprotocol\fR.
438 \fIProtocol\fP can be a number or one of the names
439 \fBaarp\fP, \fBarp\fP, \fBatalk\fP, \fBdecnet\fP, \fBip\fP, \fBip6\fP,
440 \fBipx\fP, \fBiso\fP, \fBlat\fP, \fBloopback\fP, \fBmopdl\fP, \fBmoprc\fP, \fBnetbeui\fP,
441 \fBrarp\fP, \fBsca\fP or \fBstp\fP.
442 Note these identifiers (except \fBloopback\fP) are also keywords
443 and must be escaped via backslash (\\).
444 .IP
445 [In the case of FDDI (e.g., `\fBfddi proto \\arp\fR'), Token Ring
446 (e.g., `\fBtr proto \\arp\fR'), and IEEE 802.11 wireless LANs (e.g.,
447 `\fBwlan proto \\arp\fR'), for most of those protocols, the
448 protocol identification comes from the 802.2 Logical Link Control (LLC)
449 header, which is usually layered on top of the FDDI, Token Ring, or
450 802.11 header.
451 .IP
452 When filtering for most protocol identifiers on FDDI, Token Ring, or
453 802.11, the filter checks only the protocol ID field of an LLC header
454 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
455 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
456 is in SNAP format with an OUI of 0x000000.
457 The exceptions are:
458 .RS
459 .TP
460 \fBiso\fP
461 the filter checks the DSAP (Destination Service Access Point) and
462 SSAP (Source Service Access Point) fields of the LLC header;
463 .TP
464 \fBstp\fP and \fBnetbeui\fP
465 the filter checks the DSAP of the LLC header;
466 .TP
467 \fBatalk\fP
468 the filter checks for a SNAP-format packet with an OUI of 0x080007
469 and the AppleTalk etype.
470 .RE
471 .IP
472 In the case of Ethernet, the filter checks the Ethernet type field
473 for most of those protocols. The exceptions are:
474 .RS
475 .TP
476 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
477 the filter checks for an 802.3 frame and then checks the LLC header as
478 it does for FDDI, Token Ring, and 802.11;
479 .TP
480 \fBatalk\fP
481 the filter checks both for the AppleTalk etype in an Ethernet frame and
482 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
483 .TP
484 \fBaarp\fP
485 the filter checks for the AppleTalk ARP etype in either an Ethernet
486 frame or an 802.2 SNAP frame with an OUI of 0x000000;
487 .TP
488 \fBipx\fP
489 the filter checks for the IPX etype in an Ethernet frame, the IPX
490 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
491 IPX, and the IPX etype in a SNAP frame.
492 .RE
493 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
494 Abbreviations for:
495 .in +.5i
496 .nf
497 \fBether proto \\\fIprotocol\fR
498 .fi
499 .in -.5i
500 where \fIprotocol\fR is one of the above protocols.
501 .IP "\fBlat\fR, \fBmopdl\fR, \fBmoprc\fR, \fBsca\fR"
502 Abbreviations for:
503 .in +.5i
504 .nf
505 \fBether proto \\\fIprotocol\fR
506 .fi
507 .in -.5i
508 where \fIprotocol\fR is one of the above protocols, all of which originated
509 at DEC, but are not the same as DECnet. Namely,
510 .B lat
511 is Local Area Transport (LAT),
512 .B mopdl
513 is DNA Dump/Load (MOP),
514 .B moprc
515 is DNA Remote Console (MOP) and
516 .B sca
517 is System Communication Architecture (SCA).
518 .IP "\fBdecnet src \fIdecnetaddr\fR"
519 True if the DECnet source address is
520 .IR decnetaddr ,
521 which is an address of the form
522 .B AREANUMBER.NODENUMBER
523 (for example, "10.123"), where the area number can be between 0 and 63
524 and the node number can be between 0 and 1023 and both numbers always use
525 decimal base.
526 .IP "\fBdecnet dst \fIdecnetaddr\fR"
527 True if the DECnet destination address is
528 .IR decnetaddr .
529 .IP "\fBdecnet host \fIdecnetaddr\fR"
530 True if either the DECnet source or destination address is
531 .IR decnetaddr .
532 .IP \fBllc\fP
533 True if the packet has an 802.2 LLC header. This includes:
534 .IP
535 Ethernet packets with a length field rather than a type field that
536 aren't raw NetWare-over-802.3 packets;
537 .IP
538 IEEE 802.11 data packets;
539 .IP
540 Token Ring packets (no check is done for LLC frames);
541 .IP
542 FDDI packets (no check is done for LLC frames);
543 .IP
544 LLC-encapsulated ATM packets, for SunATM on Solaris.
545 .IP "\fBllc\fP \fItype\fR"
546 True if the packet has an 802.2 LLC header and has the specified
547 .IR type .
548 .I type
549 can be one of:
550 .RS
551 .TP
552 \fBi\fR
553 Information (I) PDUs
554 .TP
555 \fBs\fR
556 Supervisory (S) PDUs
557 .TP
558 \fBu\fR
559 Unnumbered (U) PDUs
560 .TP
561 \fBrr\fR
562 Receiver Ready (RR) S PDUs
563 .TP
564 \fBrnr\fR
565 Receiver Not Ready (RNR) S PDUs
566 .TP
567 \fBrej\fR
568 Reject (REJ) S PDUs
569 .TP
570 \fBui\fR
571 Unnumbered Information (UI) U PDUs
572 .TP
573 \fBua\fR
574 Unnumbered Acknowledgment (UA) U PDUs
575 .TP
576 \fBdisc\fR
577 Disconnect (DISC) U PDUs
578 .TP
579 \fBdm\fR
580 Disconnected Mode (DM) U PDUs
581 .TP
582 \fBsabme\fR
583 Set Asynchronous Balanced Mode Extended (SABME) U PDUs
584 .TP
585 \fBtest\fR
586 Test (TEST) U PDUs
587 .TP
588 \fBxid\fR
589 Exchange Identification (XID) U PDUs
590 .TP
591 \fBfrmr\fR
592 Frame Reject (FRMR) U PDUs
593 .RE
594 .IP \fBinbound\fP
595 Packet was received by the host performing the capture rather than being
596 sent by that host. This is only supported for certain link-layer types,
597 such as SLIP and the ``cooked'' Linux capture mode
598 used for the ``any'' device and for some other device types.
599 .IP \fBoutbound\fP
600 Packet was sent by the host performing the capture rather than being
601 received by that host. This is only supported for certain link-layer types,
602 such as SLIP and the ``cooked'' Linux capture mode
603 used for the ``any'' device and for some other device types.
604 .IP "\fBifindex \fIinterface_index\fR"
605 True if the packet was logged via the specified interface (applies only to
606 packets logged by the Linux "any" cooked v2 interface).
607 .IP "\fBifname \fIinterface\fR"
608 True if the packet was logged as coming from the specified interface (applies
609 only to packets logged by OpenBSD's or FreeBSD's
610 .BR pf (4)).
611 .IP "\fBon \fIinterface\fR"
612 Synonymous with the
613 .B ifname
614 modifier.
615 .IP "\fBrnr \fInum\fR"
616 True if the packet was logged as matching the specified PF rule number
617 (applies only to packets logged by OpenBSD's or FreeBSD's
618 .BR pf (4)).
619 .IP "\fBrulenum \fInum\fR"
620 Synonymous with the
621 .B rnr
622 modifier.
623 .IP "\fBreason \fIcode\fR"
624 True if the packet was logged with the specified PF reason code. The known
625 codes are:
626 .BR \%match ,
627 .BR \%bad-offset ,
628 .BR \%fragment ,
629 .BR \%short ,
630 .BR \%normalize ,
631 and
632 .B memory
633 (applies only to packets logged by OpenBSD's or FreeBSD's
634 .BR pf (4)).
635 .IP "\fBrset \fIname\fR"
636 True if the packet was logged as matching the specified PF ruleset
637 name of an anchored ruleset (applies only to packets logged by OpenBSD's
638 or FreeBSD's
639 .BR pf (4)).
640 .IP "\fBruleset \fIname\fR"
641 Synonymous with the
642 .B rset
643 modifier.
644 .IP "\fBsrnr \fInum\fR"
645 True if the packet was logged as matching the specified PF rule number
646 of an anchored ruleset (applies only to packets logged by OpenBSD's or
647 FreeBSD's
648 .BR pf (4)).
649 .IP "\fBsubrulenum \fInum\fR"
650 Synonymous with the
651 .B srnr
652 modifier.
653 .IP "\fBaction \fIact\fR"
654 True if PF took the specified action when the packet was logged. Known actions
655 are:
656 .B pass
657 and
658 .B block
659 and, with later versions of
660 .BR pf (4),
661 .BR nat ,
662 .BR rdr ,
663 .B binat
664 and
665 .B scrub
666 (applies only to packets logged by OpenBSD's or FreeBSD's
667 .BR pf (4)).
668 .IP "\fBwlan ra \fIehost\fR"
669 True if the IEEE 802.11 RA is
670 .IR ehost .
671 The RA field is used in all frames except for management frames.
672 .IP "\fBwlan ta \fIehost\fR"
673 True if the IEEE 802.11 TA is
674 .IR ehost .
675 The TA field is used in all frames except for management frames and
676 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
677 .IP "\fBwlan addr1 \fIehost\fR"
678 True if the first IEEE 802.11 address is
679 .IR ehost .
680 .IP "\fBwlan addr2 \fIehost\fR"
681 True if the second IEEE 802.11 address, if present, is
682 .IR ehost .
683 The second address field is used in all frames except for CTS (Clear To
684 Send) and ACK (Acknowledgment) control frames.
685 .IP "\fBwlan addr3 \fIehost\fR"
686 True if the third IEEE 802.11 address, if present, is
687 .IR ehost .
688 The third address field is used in management and data frames, but not
689 in control frames.
690 .IP "\fBwlan addr4 \fIehost\fR"
691 True if the fourth IEEE 802.11 address, if present, is
692 .IR ehost .
693 The fourth address field is only used for
694 WDS (Wireless Distribution System) frames.
695 .IP "\fBtype \fIwlan_type\fR"
696 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
697 Valid \fIwlan_type\fRs are:
698 \fBmgt\fP,
699 \fBctl\fP
700 and \fBdata\fP.
701 .IP "\fBtype \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
702 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
703 and frame subtype matches the specified \fIwlan_subtype\fR.
704 .IP
705 If the specified \fIwlan_type\fR is \fBmgt\fP,
706 then valid \fIwlan_subtype\fRs are:
707 \fBassoc-req\fP,
708 \fBassoc-resp\fP,
709 \fBreassoc-req\fP,
710 \fBreassoc-resp\fP,
711 \fBprobe-req\fP,
712 \fBprobe-resp\fP,
713 \fBbeacon\fP,
714 \fBatim\fP,
715 \fBdisassoc\fP,
716 \fBauth\fP and
717 \fBdeauth\fP.
718 .IP
719 If the specified \fIwlan_type\fR is \fBctl\fP,
720 then valid \fIwlan_subtype\fRs are:
721 \fBbar\fP,
722 \fBba\fP,
723 \fBps-poll\fP,
724 \fBrts\fP,
725 \fBcts\fP,
726 \fBack\fP,
727 \fBcf-end\fP and
728 \fBcf-end-ack\fP.
729 .IP
730 If the specified \fIwlan_type\fR is \fBdata\fP,
731 then valid \fIwlan_subtype\fRs are:
732 .BR \%data ,
733 .BR \%data-cf-ack ,
734 .BR \%data-cf-poll ,
735 .BR \%data-cf-ack-poll ,
736 .BR \%null ,
737 .BR \%cf-ack ,
738 .BR \%cf-poll ,
739 .BR \%cf-ack-poll ,
740 .BR \%qos-data ,
741 .BR \%qos-data-cf-ack ,
742 .BR \%qos-data-cf-poll ,
743 .BR \%qos-data-cf-ack-poll ,
744 .BR \%qos ,
745 .B \%qos-cf-poll
746 and
747 .BR \%qos-cf-ack-poll .
748 .IP "\fBsubtype \fIwlan_subtype\fR"
749 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
750 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
751 .IP "\fBdir \fIdirection\fR"
752 True if the IEEE 802.11 frame direction matches the specified
753 .IR direction .
754 Valid directions are:
755 .BR nods ,
756 .BR tods ,
757 .BR fromds ,
758 .BR dstods ,
759 or a numeric value.
760 .IP "\fBvlan \fI[vlan_id]\fR"
761 True if the packet is an IEEE 802.1Q VLAN packet.
762 If the optional \fIvlan_id\fR is specified, only true if the packet has the specified
763 \fIvlan_id\fR.
764 Note that the first \fBvlan\fR keyword encountered in an expression
765 changes the decoding offsets for the remainder of the expression on
766 the assumption that the packet is a VLAN packet. The `\fBvlan
767 \fI[vlan_id]\fR` keyword may be used more than once, to filter on VLAN
768 hierarchies. Each use of that keyword increments the filter offsets
769 by 4.
770 .IP
771 For example:
772 .in +.5i
773 .nf
774 \fBvlan\fP 100 \fB&& vlan\fR 200
775 .fi
776 .in -.5i
777 filters on VLAN 200 encapsulated within VLAN 100, and
778 .in +.5i
779 .nf
780 \fBvlan && vlan \fP300 \fB&& ip\fR
781 .fi
782 .in -.5i
783 filters IPv4 protocol encapsulated in VLAN 300 encapsulated within any
784 higher order VLAN.
785 .IP "\fBmpls \fI[label_num]\fR"
786 True if the packet is an MPLS packet.
787 If the optional \fIlabel_num\fR is specified, only true if the packet has the specified
788 \fIlabel_num\fR.
789 Note that the first \fBmpls\fR keyword encountered in an expression
790 changes the decoding offsets for the remainder of the expression on
791 the assumption that the packet is a MPLS-encapsulated IP packet. The
792 `\fBmpls \fI[label_num]\fR` keyword may be used more than once, to
793 filter on MPLS hierarchies. Each use of that keyword increments the
794 filter offsets by 4.
795 .IP
796 For example:
797 .in +.5i
798 .nf
799 \fBmpls\fP 100000 \fB&& mpls\fR 1024
800 .fi
801 .in -.5i
802 filters packets with an outer label of 100000 and an inner label of
803 1024, and
804 .in +.5i
805 .nf
806 \fBmpls && mpls\fP 1024 \fB&& host\fR 192.9.200.1
807 .fi
808 .in -.5i
809 filters packets to or from 192.9.200.1 with an inner label of 1024 and
810 any outer label.
811 .IP \fBpppoed\fP
812 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
813 type 0x8863).
814 .IP "\fBpppoes \fI[session_id]\fR"
815 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
816 type 0x8864).
817 If the optional \fIsession_id\fR is specified, only true if the packet has the specified
818 \fIsession_id\fR.
819 Note that the first \fBpppoes\fR keyword encountered in an expression
820 changes the decoding offsets for the remainder of the expression on
821 the assumption that the packet is a PPPoE session packet.
822 .IP
823 For example:
824 .in +.5i
825 .nf
826 \fBpppoes\fP 0x27 \fB&& ip\fR
827 .fi
828 .in -.5i
829 filters IPv4 protocol encapsulated in PPPoE session id 0x27.
830 .IP "\fBgeneve \fI[vni]\fR"
831 True if the packet is a Geneve packet (UDP port 6081). If the optional \fIvni\fR
832 is specified, only true if the packet has the specified \fIvni\fR.
833 Note that when the \fBgeneve\fR keyword is encountered in
834 an expression, it changes the decoding offsets for the remainder of
835 the expression on the assumption that the packet is a Geneve packet.
836 .IP
837 For example:
838 .in +.5i
839 .nf
840 \fBgeneve\fP 0xb \fB&& ip\fR
841 .fi
842 .in -.5i
843 filters IPv4 protocol encapsulated in Geneve with VNI 0xb. This will
844 match both IPv4 directly encapsulated in Geneve as well as IPv4 contained
845 inside an Ethernet frame.
846 .IP "\fBvxlan \fI[vni]\fR"
847 True if the packet is a VXLAN packet (UDP port 4789). If the optional
848 \fIvni\fR is specified, only true if the packet has the specified
849 \fIvni\fR. Note that when the \fBvxlan\fR keyword is encountered in
850 an expression, it changes the decoding offsets for the remainder of
851 the expression on the assumption that the packet is a VXLAN packet.
852 .IP
853 For example:
854 .in +.5i
855 .nf
856 \fBvxlan\fP 0x7 \fB&& ip6 \fR
857 .fi
858 .in -.5i
859 filters IPv6 protocol encapsulated in VXLAN with VNI 0x7.
860 .IP "\fBiso proto \fIprotocol\fR"
861 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
862 \fIProtocol\fP can be a number or one of the names
863 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
864 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
865 Abbreviations for:
866 .in +.5i
867 .nf
868 \fBiso proto \\\fIprotocol\fR
869 .fi
870 .in -.5i
871 where \fIprotocol\fR is one of the above protocols.
872 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
873 Abbreviations for IS-IS PDU types.
874 .IP "\fBvpi\fP \fIn\fR"
875 True if the packet is an ATM packet, for SunATM on Solaris, with a
876 virtual path identifier of
877 .IR n .
878 .IP "\fBvci\fP \fIn\fR"
879 True if the packet is an ATM packet, for SunATM on Solaris, with a
880 virtual channel identifier of
881 .IR n .
882 .IP \fBlane\fP
883 True if the packet is an ATM packet, for SunATM on Solaris, and is
884 an ATM LANE packet.
885 Note that the first \fBlane\fR keyword encountered in an expression
886 changes the tests done in the remainder of the expression
887 on the assumption that the packet is either a LANE emulated Ethernet
888 packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the
889 tests are done under the assumption that the packet is an
890 LLC-encapsulated packet.
891 .IP \fBoamf4sc\fP
892 True if the packet is an ATM packet, for SunATM on Solaris, and is
893 a segment OAM F4 flow cell (VPI=0 & VCI=3).
894 .IP \fBoamf4ec\fP
895 True if the packet is an ATM packet, for SunATM on Solaris, and is
896 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
897 .IP \fBoamf4\fP
898 True if the packet is an ATM packet, for SunATM on Solaris, and is
899 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
900 .IP \fBoam\fP
901 True if the packet is an ATM packet, for SunATM on Solaris, and is
902 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
903 .IP \fBmetac\fP
904 True if the packet is an ATM packet, for SunATM on Solaris, and is
905 on a meta signaling circuit (VPI=0 & VCI=1).
906 .IP \fBbcc\fP
907 True if the packet is an ATM packet, for SunATM on Solaris, and is
908 on a broadcast signaling circuit (VPI=0 & VCI=2).
909 .IP \fBsc\fP
910 True if the packet is an ATM packet, for SunATM on Solaris, and is
911 on a signaling circuit (VPI=0 & VCI=5).
912 .IP \fBilmic\fP
913 True if the packet is an ATM packet, for SunATM on Solaris, and is
914 on an ILMI circuit (VPI=0 & VCI=16).
915 .IP \fBconnectmsg\fP
916 True if the packet is an ATM packet, for SunATM on Solaris, and is
917 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
918 Connect Ack, Release, or Release Done message.
919 .IP \fBmetaconnect\fP
920 True if the packet is an ATM packet, for SunATM on Solaris, and is
921 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
922 Release, or Release Done message.
923 .IP \fBfisu\fP
924 True if the packet is a Fill-In Signal Unit (FISU) MTP2 packet.
925 .IP \fBlssu\fP
926 True if the packet is a Link Status Signal Unit (LSSU) MTP2 packet.
927 .IP \fBmsu\fP
928 True if the packet is a Message Signal Unit (MSU) MTP2 packet.
929 .IP "\fBsio\fP \fIval\fR"
930 True if the packet has the Service Information Octet (SIO) field of the MTP2
931 MSU header set to the value
932 .IR val .
933 Note that this keyword does not test whether the packet is an MSU packet.
934 .IP "\fBdpc\fP \fIval\fR"
935 True if the packet has the Destination Point Code (DPC) field of the MTP3
936 standard routing label set to the value
937 .IR val .
938 Note that this keyword does not test whether the packet is an MTP3 packet.
939 .IP "\fBopc\fP \fIval\fR"
940 True if the packet has the Originating Point Code (OPC) field of the MTP3
941 standard routing label set to the value
942 .IR val .
943 Note that this keyword does not test whether the packet is an MTP3 packet.
944 .IP "\fBsls\fP \fIval\fR"
945 True if the packet has the Signalling Link Selection (SLS) field of the MTP3
946 standard routing label set to the value
947 .IR val .
948 Note that this keyword does not test whether the packet is an MTP3 packet.
949 .IP "\fBhfisu\fR, \fBhlssu\fR, \fBhmsu\fR, \fBhsio\fR, \fBhdpc\fR, \fBhopc\fR, \fBhsls\fP"
950 Same as
951 .BR fisu ,
952 .BR lssu ,
953 .BR msu ,
954 .BR sio ,
955 .BR dpc ,
956 .B opc
957 and
958 .B sls
959 respectively, but only if the MTP2 link uses the extended sequence numbers
960 encoding specified for high speed signalling links (HSL) in ITU-T
961 Recommendation Q.703 Annex A.
962 .IP "\fIexpr1 relop expr2\fR"
963 True if the relation holds. \fIRelop\fR is one of
964 .RB { > ,
965 .BR < ,
966 .BR >= ,
967 .BR <= ,
968 .BR = ,
969 .BR == ,
970 .BR != }
971 (where
972 .B =
973 means the same as
974 .BR == ).
975 Each of \fIexpr1\fR and \fIexpr2\fR is an arithmetic expression composed of
976 integer constants (expressed in standard C syntax), the normal binary operators
977 .RB { + ,
978 .BR - ,
979 .BR * ,
980 .BR / ,
981 .BR % ,
982 .BR & ,
983 .BR | ,
984 .BR ^ ,
985 .BR << ,
986 .BR >> },
987 a length operator, and special packet data
988 accessors. Note that all comparisons are unsigned, so that, for example,
989 0x80000000 and 0xffffffff are > 0.
990 .IP
991 The
992 .B %
993 and
994 .B ^
995 operators are currently only supported for filtering in the kernel on
996 particular operating systems (for example: FreeBSD, Linux with 3.7 and later
997 kernels, NetBSD); on all other systems (for example: AIX, Hurd, illumos, Solaris,
998 OpenBSD), if
999 those operators are used, filtering will be done in user mode, which
1000 will increase the overhead of capturing packets and may cause more
1001 packets to be dropped.
1002 .IP
1003 The length operator, indicated by the keyword \fBlen\fP, gives the
1004 length of the packet.
1005 .IP
1006 To access data inside the packet, use the following syntax:
1007 .in +.5i
1008 .nf
1009 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
1010 .fi
1011 .in -.5i
1012 .I Proto
1013 is one of
1014 .BR arp ,
1015 .BR atalk ,
1016 .BR carp ,
1017 .BR decnet ,
1018 .BR ether ,
1019 .BR fddi ,
1020 .BR icmp ,
1021 .BR icmp6 ,
1022 .BR igmp ,
1023 .BR igrp ,
1024 .BR ip ,
1025 .BR ip6 ,
1026 .BR lat ,
1027 .BR link ,
1028 .BR mopdl ,
1029 .BR moprc ,
1030 .BR pim ,
1031 .BR ppp ,
1032 .BR radio ,
1033 .BR rarp ,
1034 .BR sca ,
1035 .BR sctp ,
1036 .BR slip ,
1037 .BR tcp ,
1038 .BR tr ,
1039 .BR udp ,
1040 .B vrrp
1041 or
1042 .BR wlan ,
1043 and
1044 indicates the protocol layer for the index operation.
1045 .RB ( ether ,
1046 .BR fddi ,
1047 .BR link ,
1048 .BR ppp ,
1049 .BR slip ,
1050 .B tr
1051 and
1052 .BR wlan
1053 all refer to the
1054 link layer. \fBradio\fR refers to the "radio header" added to some
1055 802.11 captures.)
1056 Note that \fBtcp\fR, \fBudp\fR and other upper-layer protocol types only
1057 apply to IPv4, not IPv6 (this will be fixed in the future).
1058 The byte offset, relative to the indicated protocol layer, is
1059 given by \fIexpr\fR.
1060 \fISize\fR is optional and indicates the number of bytes in the
1061 field of interest; it can be either one, two, or four, and defaults to one.
1062
1063 For example, `\fBether[\fP0\fB] &\fP 1 \fB!=\fP 0' catches all multicast traffic.
1064 The expression `\fBip[\fP0\fB] &\fP 0xf \fB!=\fP 5'
1065 catches all IPv4 packets with options.
1066 The expression
1067 `\fBip[\fP6:2\fB] &\fP 0x1fff \fB=\fP 0'
1068 catches only unfragmented IPv4 datagrams and frag zero of fragmented
1069 IPv4 datagrams.
1070 This check is implicitly applied to the
1071 .BR tcp ,
1072 .BR udp ,
1073 .BR icmp ,
1074 .BR sctp ,
1075 .BR igmp ,
1076 .BR pim ,
1077 .BR igrp ,
1078 .BR vrrp
1079 and
1080 .BR carp
1081 index operations.
1082 For instance, \fBtcp[\fP0\fB]\fP always means the first
1083 byte of the TCP \fIheader\fP, and never means the first byte of an
1084 intervening fragment.
1085 .IP
1086 Some offsets and field values may be expressed as names rather than
1087 as numeric values.
1088 The following protocol header field offsets are
1089 available: \fBicmptype\fP (ICMP type field), \fBicmp6type\fP (ICMPv6 type field),
1090 \fBicmpcode\fP (ICMP code field), \fBicmp6code\fP (ICMPv6 code field) and
1091 \fBtcpflags\fP (TCP flags field).
1092 .IP
1093 The following ICMP type field values are available:
1094 .BR \%icmp-echoreply ,
1095 .BR \%icmp-unreach ,
1096 .BR \%icmp-sourcequench ,
1097 .BR \%icmp-redirect ,
1098 .BR \%icmp-echo ,
1099 .BR \%icmp-routeradvert ,
1100 .BR \%icmp-routersolicit ,
1101 .BR \%icmp-timxceed ,
1102 .BR \%icmp-paramprob ,
1103 .BR \%icmp-tstamp ,
1104 .BR \%icmp-tstampreply ,
1105 .BR \%icmp-ireq ,
1106 .BR \%icmp-ireqreply ,
1107 .BR \%icmp-maskreq ,
1108 .BR \%icmp-maskreply .
1109 .IP
1110 The following ICMPv6 type field values are available:
1111 .BR \%icmp6-destinationunreach ,
1112 .BR \%icmp6-packettoobig ,
1113 .BR \%icmp6-timeexceeded ,
1114 .BR \%icmp6-parameterproblem ,
1115 .BR \%icmp6-echo ,
1116 .BR \%icmp6-echoreply ,
1117 .BR \%icmp6-multicastlistenerquery ,
1118 .BR \%icmp6-multicastlistenerreportv1 ,
1119 .BR \%icmp6-multicastlistenerdone ,
1120 .BR \%icmp6-routersolicit ,
1121 .BR \%icmp6-routeradvert ,
1122 .BR \%icmp6-neighborsolicit ,
1123 .BR \%icmp6-neighboradvert ,
1124 .BR \%icmp6-redirect ,
1125 .BR \%icmp6-routerrenum ,
1126 .BR \%icmp6-nodeinformationquery ,
1127 .BR \%icmp6-nodeinformationresponse ,
1128 .BR \%icmp6-ineighbordiscoverysolicit ,
1129 .BR \%icmp6-ineighbordiscoveryadvert ,
1130 .BR \%icmp6-multicastlistenerreportv2 ,
1131 .BR \%icmp6-homeagentdiscoveryrequest ,
1132 .BR \%icmp6-homeagentdiscoveryreply ,
1133 .BR \%icmp6-mobileprefixsolicit ,
1134 .BR \%icmp6-mobileprefixadvert ,
1135 .BR \%icmp6-certpathsolicit ,
1136 .BR \%icmp6-certpathadvert ,
1137 .BR \%icmp6-multicastrouteradvert ,
1138 .BR \%icmp6-multicastroutersolicit ,
1139 .BR \%icmp6-multicastrouterterm .
1140 .IP
1141 The following TCP flags field values are available: \fBtcp-fin\fP,
1142 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
1143 \fBtcp-ack\fP, \fBtcp-urg\fP, \fBtcp-ece\fP,
1144 \fBtcp-cwr\fP.
1145 .LP
1146 Primitives may be combined using:
1147 .IP
1148 A parenthesized group of primitives and operators.
1149 .IP
1150 Negation (`\fB!\fP' or `\fBnot\fP').
1151 .IP
1152 Concatenation (`\fB&&\fP' or `\fBand\fP').
1153 .IP
1154 Alternation (`\fB||\fP' or `\fBor\fP').
1155 .LP
1156 Negation has the highest precedence.
1157 Alternation and concatenation have equal precedence and associate
1158 left to right.
1159 .LP
1160 If an identifier is given without a keyword, the most recent keyword
1161 is assumed.
1162 For example,
1163 .in +.5i
1164 .nf
1165 \fBnot host\fP vs \fBand\fR ace
1166 .fi
1167 .in -.5i
1168 is short for
1169 .in +.5i
1170 .nf
1171 \fBnot host\fP vs \fBand host\fR ace
1172 .fi
1173 .in -.5i
1174 which should not be confused with
1175 .in +.5i
1176 .nf
1177 \fBnot (host \fPvs\fB or \fPace\fB)\fR
1178 .fi
1179 .in -.5i
1180 .SH EXAMPLES
1181 .LP
1182 To select all packets arriving at or departing from `sundown':
1183 .RS
1184 .nf
1185 \fBhost\fP sundown
1186 .fi
1187 .RE
1188 .LP
1189 To select traffic between `helios' and either `hot' or `ace':
1190 .RS
1191 .nf
1192 \fBhost\fP helios \fBand (\fPhot \fBor\fP ace\fB)\fP
1193 .fi
1194 .RE
1195 .LP
1196 To select all IPv4 packets between `ace' and any host except `helios':
1197 .RS
1198 .nf
1199 \fBip host\fP ace \fBand not\fP helios
1200 .fi
1201 .RE
1202 .LP
1203 To select all traffic between local hosts and hosts at Berkeley:
1204 .RS
1205 .nf
1206 \fBnet\fP ucb-ether
1207 .fi
1208 .RE
1209 .LP
1210 To select all FTP traffic through Internet gateway `snup':
1211 .RS
1212 .nf
1213 \fBgateway\fP snup \fBand (port\fP ftp \fBor\fP ftp-data\fB)\fP
1214 .fi
1215 .RE
1216 .LP
1217 To select IPv4 traffic neither sourced from nor destined for local hosts
1218 (if you gateway to one other net, this stuff should never make it
1219 onto your local net).
1220 .RS
1221 .nf
1222 \fBip and not net \fPlocalnet
1223 .fi
1224 .RE
1225 .LP
1226 To select the start and end packets (the SYN and FIN packets) of each
1227 TCP conversation that involves a non-local host.
1228 .RS
1229 .nf
1230 \fBtcp[tcpflags] & (tcp-syn|tcp-fin) !=\fP 0 \fBand not src and dst net\fP localnet
1231 .fi
1232 .RE
1233 .LP
1234 To select the TCP packets with flags RST and ACK both set.
1235 (i.e. select only the RST and ACK flags in the flags field, and if the result
1236 is "RST and ACK both set", match)
1237 .RS
1238 .nf
1239 .B
1240 tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)
1241 .fi
1242 .RE
1243 .LP
1244 To select all IPv4 HTTP packets to and from port 80, i.e. print only
1245 packets that contain data, not, for example, SYN and FIN packets and
1246 ACK-only packets. (IPv6 is left as an exercise for the reader.)
1247 .RS
1248 .nf
1249 \fBtcp port\fP 80 \fBand (((ip[\fP2:2\fB] - ((ip[\fP0\fB]&\fP0xf\fB)<<\fP2\fB)) - ((tcp[\fP12\fB]&\fP0xf0\fB)>>\fP2\fB)) != \fP0\fB)
1250 .fi
1251 .RE
1252 .LP
1253 To select IPv4 packets longer than 576 bytes sent through gateway `snup':
1254 .RS
1255 .nf
1256 \fBgateway\fP snup \fBand ip[\fP2:2\fB] >\fP 576
1257 .fi
1258 .RE
1259 .LP
1260 To select IPv4 broadcast or multicast packets that were
1261 .I not
1262 sent via Ethernet broadcast or multicast:
1263 .RS
1264 .nf
1265 \fBether[\fP0\fB] &\fP 1 \fB=\fP 0 \fBand ip[\fP16\fB] >=\fP 224
1266 .fi
1267 .RE
1268 .LP
1269 To select all ICMP packets that are not echo requests/replies (i.e., not
1270 ping packets):
1271 .RS
1272 .nf
1273 .B
1274 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
1275 .B
1276 icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply
1277 .fi
1278 .RE
1279 .SH BACKWARD COMPATIBILITY
1280 The
1281 .B carp
1282 keyword became available in libpcap 1.2.1.
1283 .PP
1284 The
1285 .BR hfisu ,
1286 .BR hlssu ,
1287 .BR hmsu ,
1288 .BR hsio ,
1289 .BR hopc ,
1290 .BR hdpc
1291 and
1292 .B hsls
1293 keywords became available in libpcap 1.5.3.
1294 .PP
1295 The ICMPv6 type code names, as well as the
1296 .B tcp-ece
1297 and
1298 .B tcp-cwr
1299 TCP flag names became available in libpcap 1.9.0.
1300 .PP
1301 The
1302 .B geneve
1303 keyword became available in libpcap 1.8.0.
1304 .PP
1305 The
1306 .B ifindex
1307 keyword became available in libpcap 1.10.0.
1308 .PP
1309 The
1310 .B vxlan
1311 keyword became available in libpcap 1.11.0.
1312 .SH SEE ALSO
1313 .BR pcap (3PCAP)
1314 .SH BUGS
1315 To report a security issue please send an e-mail to \%security@tcpdump.org.
1316 .LP
1317 To report bugs and other problems, contribute patches, request a
1318 feature, provide generic feedback etc please see the file
1319 .I CONTRIBUTING.md
1320 in the libpcap source tree root.
1321 .LP
1322 Filter expressions on fields other than those in Token Ring headers will
1323 not correctly handle source-routed Token Ring packets.
1324 .LP
1325 Filter expressions on fields other than those in 802.11 headers will not
1326 correctly handle 802.11 data packets with both To DS and From DS set.
1327 .LP
1328 `\fBip6 proto\fP'
1329 should chase header chain, but at this moment it does not.
1330 `\fBip6 protochain\fP'
1331 is supplied for this behavior. For example, to match IPv6 fragments:
1332 `\fBip6 protochain\fP 44'
1333 .LP
1334 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
1335 does not work against IPv6 packets.
1336 It only looks at IPv4 packets.