]> The Tcpdump Group git mirrors - libpcap/blob - pcap-filter.manmisc.in
ATM: Simplify protocol and message type handling.
[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@ "27 March 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 (a name, a number or something slightly more complex, such as a CIDR prefix)
43 preceded by one or more qualifiers.
44 There are three
45 different kinds of qualifier:
46 .IP \fIproto\fP
47 .I proto
48 qualifiers restrict the match to a particular protocol.
49 (This should not be confused with the
50 .B proto
51 type qualifier below.)
52 Possible
53 protocols are:
54 .BR ether ,
55 .BR link ,
56 .BR wlan ,
57 .BR ip ,
58 .BR ip6 ,
59 .BR arp ,
60 .BR tcp ,
61 .BR udp ,
62 .BR sctp ,
63 .BR iso ,
64 .BR isis ,
65 .BR rarp ,
66 .BR decnet ,
67 .BR fddi ,
68 .BR tr ,
69 .B ppp
70 and
71 .BR slip .
72 E.g., `\fBether src\fP foo', `\fBarp net\fP 128.3', `\fBtcp port\fP 21',
73 `\fBip proto\fP ospf', `\fBether proto\fP 0x88CC',
74 `\fBudp portrange\fP 7000-7009', `\fBwlan addr2\fP 0:2:3:4:5:6'.
75 If there is no
76 .I proto
77 qualifier, all protocols consistent with the type are assumed.
78 E.g., `\fBsrc\fP foo' means `\fB(ip6 or ip or arp or rarp) src\fP foo',
79 `\fBproto\fP tcp' means `\fB(ip6 or ip) proto\fP tcp'
80 `\fBnet\fP bar' means `\fB(ip6 or ip or arp or rarp) net\fP bar' and
81 `\fBport\fP 53' means `\fB(tcp or udp or sctp) port\fP 53'
82 (note that these examples use invalid syntax to illustrate the principle).
83 .IP \fIdir\fP
84 .I dir
85 qualifiers specify a particular transfer direction to and/or from
86 .IR id .
87 Possible directions are
88 .BR src ,
89 .BR dst ,
90 .BR "src or dst" ,
91 .BR "src and dst" ,
92 .BR ra ,
93 .BR ta ,
94 .BR addr1 ,
95 .BR addr2 ,
96 .BR addr3 ,
97 and
98 .BR addr4 .
99 E.g., `\fBsrc\fP foo', `\fBdst net\fP 128.3', `\fBsrc or dst port\fP ftp-data'.
100 If
101 there is no dir qualifier, `\fBsrc or dst\fP' is assumed.
102 The
103 .BR ra ,
104 .BR ta ,
105 .BR addr1 ,
106 .BR addr2 ,
107 .BR addr3 ,
108 and
109 .B addr4
110 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
111 .IP \fItype\fP
112 .I type
113 qualifiers say what kind of thing the id name or number refers to.
114 Possible types are
115 .BR host ,
116 .BR net ,
117 .BR \%proto ,
118 .BR port ,
119 .BR \%portrange ,
120 .B \%protochain
121 and
122 .B \%gateway.
123 E.g., `\fBhost\fP foo', `\fBnet\fP 128.3', `\fBport\fP 20', `\fBportrange\fP 6000-6008',
124 `\fBproto \fP 17'.
125 If there is no type
126 qualifier,
127 .B host
128 is assumed.
129 .LP
130 In primitives that follow this pattern each qualifier kind may be present at
131 most once, and if more than one kind is present, any
132 .I proto
133 qualifier must be the first qualifier and any
134 .I type
135 qualifier must be the last qualifier, for example, `\fBtcp dst port\fP 80'.
136 Also not all combinations of these qualifier kinds are valid syntax. Some
137 make no sense in network protocols space, for example:
138 .B "ether port"
139 (Ethernet header has no ports),
140 .B "tcp net"
141 (TCP header does not have layer 3 fields),
142 .B "dst proto"
143 (in a protocol header the same protocol applies to both the source and the
144 destination), and so on. Some other combinations are not valid syntax because
145 they are not implemented, even though hypothetically could make sense, for
146 example:
147 .BR "iso net" ,
148 .B "aarp host"
149 and so on.
150 .LP
151 [\fBfddi\fP is actually an alias for \fBether\fP; the parser treats them
152 identically as meaning ``the data link level used on the specified
153 network interface''. FDDI headers contain Ethernet-like source
154 and destination addresses, and often contain Ethernet-like packet
155 types, so you can filter on these FDDI fields just as with the
156 analogous Ethernet fields.
157 FDDI headers also contain other fields,
158 but you cannot name them explicitly in a filter expression.
159 Similarly, \fBtr\fP and \fBwlan\fP are aliases for \fBether\fP; the
160 statements about FDDI headers also apply to Token Ring and 802.11 wireless
161 LAN headers. The same stands for the
162 .BR link ,
163 .B ppp
164 and
165 .B slip
166 keywords.]
167 .LP
168 For IEEE 802.11 headers, the destination address is the DA field and the
169 source address is the SA field. For both ARP and RARP headers, the
170 destination address is the TPA (Target Protocol Address) field and the
171 source address is the SPA (Sender Protocol Address) field.
172 .LP
173 In addition to the above, there are some special `primitive' keywords
174 that don't follow the pattern (for example:
175 .BR broadcast ,
176 .BR multicast ,
177 .BR inbound ,
178 .BR outbound ,
179 .BR ifindex ,
180 .BR llc ,
181 .BR vlan ,
182 .BR mpls ,
183 .BR less ,
184 .BR greater ),
185 packet data accessors and relations of two arithmetic expressions.
186 All of these are described below.
187 .LP
188 More complex filter expressions are built up by using the words
189 .BR and ,
190 .B or
191 and
192 .B not
193 (or equivalently: `\fB&&\fP', `\fB||\fP' and `\fB!\fP' respectively)
194 to combine primitives.
195 E.g., `\fBhost\fP foo \fBand not port\fP ftp \fBand not port\fP ftp-data'.
196 To save typing, identical qualifier lists can be omitted.
197 E.g.,
198 `\fBtcp dst port\fP ftp \fBor\fP ftp-data \fBor\fP domain' is exactly the same as
199 `\fBtcp dst port\fP ftp \fBor tcp dst port\fP ftp-data \fBor tcp dst port\fP domain'.
200 .SH PRIMITIVES
201 .IP "\fBhost \fIhostnameaddr\fR"
202 True if the source or the destination ARP/IPv4/IPv6/RARP address of the packet is
203 .IR hostnameaddr .
204 May be qualified with a specific protocol
205 .RB ( arp ,
206 .BR ip ,
207 .BR ip6 ,
208 .BR rarp )
209 and/or a different direction
210 .RB ( src ,
211 .BR dst ,
212 .BR "src and dst" ),
213 in the latter case the
214 .B host
215 keyword is optional. For example,
216 .in +.5i
217 .nf
218 \fBip src \fIhostnameaddr\fR
219 .fi
220 .in -.5i
221 for Ethernet-like link-layer types is equivalent to
222 .in +.5i
223 .nf
224 \fBether proto \\\fRip \fBand ip src host \fIhostnameaddr\fR
225 .fi
226 .in -.5i
227 .IP
228 .I hostnameaddr
229 may be either an address or a name. If it is a name with multiple IPv4/IPv6 addresses,
230 each address will be checked for a match.
231 .IP "\fBether host \fIethernameaddr\fP"
232 True if the source or the destination Ethernet/802.11/IPFC/ATM LANE/FDDI/Token Ring
233 address of the packet is
234 .IR ethernameaddr .
235 May be qualified with a different direction
236 .RB ( src ,
237 .BR dst ,
238 .BR "src and dst" ),
239 in which case the
240 .B host
241 keyword is optional.
242 .IP
243 \fIethernameaddr\fP
244 may be either a name from /etc/ethers or a numerical MAC address of the
245 form "xx:xx:xx:xx:xx:xx", "xx.xx.xx.xx.xx.xx", "xx-xx-xx-xx-xx-xx",
246 "xxxx.xxxx.xxxx" or "xxxxxxxxxxxx",
247 where each "x" is a hex digit (0-9, a-f, or A-F).
248 .IP "\fBgateway\fP \fIhost\fP"
249 True if the packet used \fIhost\fP as a gateway.
250 I.e., the source or the destination Ethernet address was
251 .I host
252 but neither the source nor the destination ARP/IPv4/RARP address was
253 .IR host .
254 In this implementation this primitive is not available in IPv6-enabled
255 configuration. May be qualified with a specific protocol
256 .RB ( arp ,
257 .BR ip ,
258 .BR rarp ).
259 For example,
260 .in +.5i
261 .nf
262 \fBip gateway \fIhost\fR
263 .fi
264 .in -.5i
265 is equivalent to
266 .in +.5i
267 .nf
268 \fBether host \fIethernameaddr \fBand not ip host \fIhostnameaddr\fR
269 .fi
270 .in -.5i
271 which can be used with either names or numbers for
272 .I hostnameaddr
273 and
274 .IR ethernameaddr .
275 .IP
276 \fIHost\fP must be a name and
277 must be found both by the machine's host-name-to-IP-address resolution
278 mechanisms (host name file, DNS, NIS, etc.) and by the machine's
279 host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
280 .IP "\fBnet \fInetnameaddr\fR"
281 True if the source or the destination ARP/IPv4/IPv6/RARP address of the packet
282 belongs to the specified network. May be qualified with a specific protocol
283 .RB ( arp ,
284 .BR ip ,
285 .BR ip6 ,
286 .BR rarp )
287 and/or a different direction
288 .RB ( src ,
289 .BR dst ,
290 .BR "src and dst" ),
291 in the latter case the
292 .B net
293 keyword remains mandatory.
294 .I netnameaddr
295 may be either a name from the networks database
296 (/etc/networks, etc.) or a network number.
297 .IP
298 An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0),
299 dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single
300 number (e.g., 10); the netmask is 255.255.255.255 (/32) for a dotted quad
301 (which means that it's really a host match), 255.255.255.0 (/24) for a dotted
302 triple, 255.255.0.0 (/16) for a dotted pair, or 255.0.0.0 (/8) for a single number.
303 An IPv6 network number must be written out fully; the netmask is
304 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (/128), so in this primitive IPv6
305 "network" matches are really always host matches. For an actual IPv6 network
306 match see the `\fBnet \fInetaddr\fR/\fIlen\fR' primitive below.
307 .IP "\fBnet \fInetaddr\fR \fBmask \fInetmask\fR"
308 True if the source or the destination ARP/IPv4/RARP address of the packet
309 belongs to \fInetaddr\fR with the specified \fInetmask\fR. May be qualified
310 with a specific protocol
311 .RB ( arp ,
312 .BR ip ,
313 .BR rarp )
314 and/or a different direction
315 .RB ( src ,
316 .BR dst ,
317 .BR "src and dst" ),
318 in the latter case the
319 .B net
320 keyword remains mandatory. In this implementation this primitive does not
321 support IPv6 networks.
322 .IP
323 Both
324 .I netaddr
325 and
326 .I netmask
327 use the IPv4 network number notation described above, except the "single
328 number" form is not valid in this primitive. For example,
329 .in +.5i
330 .nf
331 \fBnet \fP192.168 \fBmask \fP255.255\fR
332 .fi
333 .in -.5i
334 is equivalent to
335 .in +.5i
336 .nf
337 \fBnet \fP192.168.0.0 \fBmask \fP255.255.0.0\fR
338 .fi
339 .in -.5i
340 .IP
341 The
342 .I netmask
343 can represent any 32-bit value, which is why the
344 `\fBnet \fI\%netaddr\fR/\fIlen\fR' primitive below is usually a better fit for
345 use cases that require the value to be strictly one of the 33 CIDR masks (from
346 /0 to /32).
347 .IP "\fBnet \fInetaddr\fR/\fIlen\fR"
348 True if the source or the destination ARP/IPv4/IPv6/RARP address of the packet
349 belongs to
350 .I netaddr
351 where the bit-length of the network mask equals
352 .I len
353 (in other words, the address belongs to the specified CIDR prefix). May be
354 qualified with a specific protocol
355 .RB ( arp ,
356 .BR ip ,
357 .BR ip6 ,
358 .BR rarp )
359 and/or a different direction
360 .RB ( src ,
361 .BR dst ,
362 .BR "src and dst" ),
363 in the latter case the
364 .B net
365 keyword is optional.
366 .IP
367 For IPv4,
368 .I len
369 is an integer between 0 and 32 (both inclusive) and
370 .I netaddr
371 is the same as the above. For IPv6,
372 .I len
373 is an integer between 0 and 128 (both inclusive) and
374 .I netaddr
375 is an IPv6 address. For the latter zero compression notation
376 .RB ( :: )
377 is valid, but IPv4-mapped notation
378 .RB ( x:x:x:x:x:x:d.d.d.d )
379 is not. For both IPv4 and IPv6 the maximum value of
380 .I len
381 is equivalent to a host match and the 0 value (which implies an all-zeroes
382 value of
383 .IR netaddr )
384 matches any address. In the latter case this primitive reduces to matching
385 the specified (or implied) protocols only.
386 .IP "\fBport \fIportnamenum\fR"
387 True if the source or the destination TCP/UDP/SCTP port of an IPv4/IPv6 packet
388 is
389 .IR portnamenum .
390 For IPv4 this also implies that the packet is the first fragment or is not
391 fragmented. May be qualified with a specific layer 4 protocol
392 .RB ( tcp ,
393 .BR udp ,
394 .BR sctp )
395 or a different direction
396 .RB ( src ,
397 .BR dst ,
398 .BR "src and dst" ),
399 in the latter case the
400 .B port
401 keyword remains mandatory. Cannot be qualified with a specific layer 3
402 protocol (IPv4/IPv6) in the same primitive, but can be trivially combined with
403 other primitives to achieve the required effect, for example:
404 .in +.5i
405 .nf
406 \fBip and tcp dst port \fP80\fR
407 .fi
408 .in -.5i
409 .IP
410 The \fIportnamenum\fP can be a number or a name used in /etc/services (see
411 .BR services (5)).
412 If a name is used, both the port
413 number and protocol are checked.
414 If a number or ambiguous name is used,
415 only the port number is checked (e.g., `\fBdst port\fR 513' will print both
416 tcp/login traffic and udp/who traffic, and `\fBport\fR domain' will print
417 both tcp/domain and udp/domain traffic).
418 .IP "\fBportrange \fIportnamenum1-portnamenum2\fR"
419 This is a more generic form of the above: true if the port number in the
420 packet is between
421 .I portnamenum1
422 and
423 .I portnamenum2
424 (both inclusive), everything else holds the same meaning.
425 In this predicate
426 .I portnamenum1
427 and
428 .I portnamenum2
429 can be specified in either order. If the two values are equal, this primitive
430 has the same effect as the
431 .B port
432 primitive above.
433 .IP "\fBless \fIlength\fR"
434 True if the packet has a length less than or equal to \fIlength\fP.
435 This is equivalent to:
436 .in +.5i
437 .nf
438 \fBlen <= \fIlength\fP
439 .fi
440 .in -.5i
441 .IP "\fBgreater \fIlength\fR"
442 True if the packet has a length greater than or equal to \fIlength\fP.
443 This is equivalent to:
444 .in +.5i
445 .nf
446 \fBlen >= \fIlength\fP
447 .fi
448 .in -.5i
449 .IP "\fBip proto \fIprotocol\fR"
450 True if the packet is an IPv4 packet of protocol type \fIprotocol\fP.
451 \fIProtocol\fP can be a number or one of the names recognized by
452 .BR getprotobyname (3),
453 for example:
454 .BR ah ,
455 .BR esp ,
456 .B eigrp
457 (only in Linux with glibc, FreeBSD, NetBSD, DragonFly BSD, and macOS),
458 .BR icmp ,
459 .BR igmp ,
460 .B igrp
461 (only in Haiku and OpenBSD),
462 .BR pim ,
463 .BR sctp ,
464 .BR tcp ,
465 .B udp
466 or
467 .BR vrrp .
468 Note that most of these example identifiers
469 are also keywords and must be escaped via backslash (\\).
470 Note that this primitive does not chase the protocol header chain.
471 .IP
472 Typically
473 .BR getprotobyname (3)
474 parses the
475 .IR \%/etc/protocols
476 file to translate protocol names to numbers, and the
477 .B "getent protocols"
478 command lists the protocols recognised by the function. This is not entirely
479 so in AIX (which does not have the command), Haiku (which has the file at
480 .IR \%/system/data/network/protocols
481 and does not have the command), on Linux with musl libc (which hard-codes the
482 list of protocols) and on hosts that use a network database to resolve
483 protocol names to numbers (see
484 .BR nsswitch.conf (5)).
485 If a protocol name fails to translate to a number, this version of libpcap
486 will treat the filter expression as invalid.
487 .IP "\fBcarp\fR, \fBvrrp\fR"
488 Abbreviations for:
489 .in +.5i
490 .nf
491 \fBip proto\fR 112
492 .fi
493 .in -.5i
494 .IP "\fBicmp\fR"
495 Abbreviation for:
496 .in +.5i
497 .nf
498 \fBip proto\fR 1
499 .fi
500 .in -.5i
501 .IP "\fBigmp\fR"
502 Abbreviation for:
503 .in +.5i
504 .nf
505 \fBip proto\fR 2
506 .fi
507 .in -.5i
508 .IP "\fBigrp\fR"
509 Abbreviation for:
510 .in +.5i
511 .nf
512 \fBip proto \fIigrpval\fR
513 .fi
514 .in -.5i
515 where
516 .I igrpval
517 is 88 on DragonFly BSD, FreeBSD and macOS, and 9 on all other OSes. This
518 abbreviation should not be used in portable applications and may be removed
519 in future.
520 .IP "\fBip6 proto \fIprotocol\fR"
521 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
522 (See `\fBip proto\fP' above for the meaning of \fIprotocol\fR.)
523 Note that the IPv6 variant of ICMP uses a different protocol number, named
524 .B \%ipv6-icmp
525 in AIX, FreeBSD, illumos, Haiku, GNU/Hurd, Linux, macOS, NetBSD, OpenBSD,
526 Solaris and Windows.
527 Note that this primitive does not chase the protocol header chain.
528 .IP "\fBicmp6\fR"
529 Abbreviation for:
530 .in +.5i
531 .nf
532 \fBip6 proto\fR 58
533 .fi
534 .in -.5i
535 .IP "\fBproto \fIprotocol\fR"
536 True if the packet is an IPv4 or IPv6 packet of protocol type
537 \fIprotocol\fP. (See `\fBip proto\fP' above for the meaning of
538 \fIprotocol\fP.) Note that this primitive does not chase the protocol
539 header chain.
540 .IP "\fBah\fR, \fBesp\fR, \fBpim\fR, \fBsctp\fR, \fBtcp\fR, \fBudp\fR"
541 Abbreviations for:
542 .in +.5i
543 .nf
544 \fBproto \\\fIprotocol\fR
545 .fi
546 .in -.5i
547 where \fIprotocol\fR is one of the above protocols.
548 .IP "\fBip6 protochain \fIprotocol\fR"
549 True if the packet is IPv6 packet,
550 and contains protocol header with type \fIprotocol\fR
551 in its protocol header chain.
552 (See `\fBip proto\fP' above for the meaning of \fIprotocol\fP.)
553 For example,
554 .in +.5i
555 .nf
556 \fBip6 protochain\fR 6
557 .fi
558 .in -.5i
559 matches any IPv6 packet with TCP protocol header in the protocol header chain.
560 The packet may contain, for example,
561 authentication header, routing header, or hop-by-hop option header,
562 between IPv6 header and TCP header.
563 The BPF code emitted by this primitive is complex and
564 cannot be optimized by the BPF optimizer code, and is not supported by
565 filter engines in the kernel, so this can be somewhat slow, and may
566 cause more packets to be dropped.
567 .IP "\fBip protochain \fIprotocol\fR"
568 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
569 (See `\fBip proto\fP' above for the meaning of \fIprotocol\fP.)
570 .IP "\fBprotochain \fIprotocol\fR"
571 True if the packet is an IPv4 or IPv6 packet of protocol type
572 \fIprotocol\fP. (See `\fBip proto\fP' above for the meaning of
573 \fIprotocol\fP.) Note that this primitive chases the protocol
574 header chain.
575 .IP "\fBether broadcast\fR"
576 True if the destination Ethernet/802.11/IPFC/ARCnet/ATM LANE/FDDI/Token Ring address of
577 the packet is the broadcast address (e.g.
578 .B FF:FF:FF:FF:FF:FF
579 for Ethernet). The
580 .B ether
581 keyword is optional.
582 .IP "\fBip broadcast\fR"
583 True if the packet is an IPv4 packet with the host part of the destination
584 address being either all-ones or all-zeroes. This primitive requires to
585 specify the netmask, which cannot be done in the filter expression; the only
586 way to specify a netmask is via the
587 .B \%netmask
588 argument of the
589 .BR \%pcap_compile ()
590 function. If a netmask has not been specified, an attempt to compile a
591 filter expression with this primitive will return an error.
592 .IP
593 Note that this primitive ignores the network part of the destination address,
594 thus it can match more packets than expected, especially if the interface has
595 multiple IPv4 addresses with different netmasks. For example, if the
596 interface has addresses 10.1.2.100/29 and 192.168.202.200/24 configured and
597 the
598 .B \%netmask
599 argument corresponds to the first address, its value will be
600 .BR \%0xFFFFFFF8
601 and the host mask value will be
602 .BR \%0x00000007 .
603 This will match the expected two addresses in the first prefix (10.1.2.96 and
604 10.1.2.103), as well as 64 addresses in the second prefix (192.168.202.0,
605 192.168.202.7, 192.168.202.8, 192.168.202.15, 192.168.202.16 and so on), as
606 well as any other IPv4 address with the lowest 3 bits being all-ones or
607 all-zeroes (for example: 10.73.74.151, 192.168.50.63, 172.19.0.128) -- in
608 other words, 25% of the complete IPv4 address space. This is why in use
609 cases that require more precision it would be better to match the required
610 address(es) explicitly, for example:
611 .in +.5i
612 .nf
613 \fBip dst host 10.1.2.96 or 10.1.2.103\fR
614 .fi
615 .in -.5i
616 .IP "\fBether multicast\fR"
617 True if the destination Ethernet/802.11/IPFC/ARCnet/ATM LANE/FDDI/Token Ring address of
618 the packet is a multicast address (e.g.
619 .B "\%ether[0] & 1 != 0"
620 for Ethernet). The
621 .B ether
622 keyword is optional.
623 .IP "\fBip multicast\fR"
624 True if the packet is an IPv4 multicast packet.
625 .IP "\fBip6 multicast\fR"
626 True if the packet is an IPv6 multicast packet.
627 .IP "\fBether proto \fIprotocol\fR"
628 True if the packet is of ether type \fIprotocol\fR.
629 \fIProtocol\fP can be a number or one of the names
630 \fBaarp\fP, \fBarp\fP, \fBatalk\fP, \fBdecnet\fP, \fBip\fP, \fBip6\fP,
631 \fBipx\fP, \fBiso\fP, \fBlat\fP, \fBloopback\fP, \fBmopdl\fP, \fBmoprc\fP, \fBnetbeui\fP,
632 \fBrarp\fP, \fBsca\fP or \fBstp\fP.
633 Note these identifiers (except \fBloopback\fP) are also keywords
634 and must be escaped via backslash (\\).
635 .IP
636 [In the case of FDDI (e.g., `\fBfddi proto \\arp\fR'), Token Ring
637 (e.g., `\fBtr proto \\arp\fR'), and IEEE 802.11 wireless LANs (e.g.,
638 `\fBwlan proto \\arp\fR'), for most of those protocols, the
639 protocol identification comes from the 802.2 Logical Link Control (LLC)
640 header, which is usually layered on top of the FDDI, Token Ring, or
641 802.11 header.
642 .IP
643 When filtering for most protocol identifiers on FDDI, Token Ring, or
644 802.11, the filter checks only the protocol ID field of an LLC header
645 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
646 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
647 is in SNAP format with an OUI of 0x000000.
648 The exceptions are:
649 .RS
650 .TP
651 \fBiso\fP
652 the filter checks the DSAP (Destination Service Access Point) and
653 SSAP (Source Service Access Point) fields of the LLC header;
654 .TP
655 \fBstp\fP and \fBnetbeui\fP
656 the filter checks the DSAP of the LLC header;
657 .TP
658 \fBatalk\fP
659 the filter checks for a SNAP-format packet with an OUI of 0x080007
660 and the AppleTalk etype.
661 .RE
662 .IP
663 In the case of Ethernet, the filter checks the Ethernet type field
664 for most of those protocols. The exceptions are:
665 .RS
666 .TP
667 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
668 the filter checks for an 802.3 frame and then checks the LLC header as
669 it does for FDDI, Token Ring, and 802.11;
670 .TP
671 \fBatalk\fP
672 the filter checks both for the AppleTalk etype in an Ethernet frame and
673 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
674 .TP
675 \fBaarp\fP
676 the filter checks for the AppleTalk ARP etype in either an Ethernet
677 frame or an 802.2 SNAP frame with an OUI of 0x000000;
678 .TP
679 \fBipx\fP
680 the filter checks for the IPX etype in an Ethernet frame, the IPX
681 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
682 IPX, and the IPX etype in a SNAP frame.
683 .RE
684 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
685 Abbreviations for:
686 .in +.5i
687 .nf
688 \fBether proto \\\fIprotocol\fR
689 .fi
690 .in -.5i
691 where \fIprotocol\fR is one of the above protocols.
692 .IP "\fBlat\fR, \fBmopdl\fR, \fBmoprc\fR, \fBsca\fR"
693 Abbreviations for:
694 .in +.5i
695 .nf
696 \fBether proto \\\fIprotocol\fR
697 .fi
698 .in -.5i
699 where \fIprotocol\fR is one of the above protocols, all of which originated
700 at DEC, but are not the same as DECnet. Namely,
701 .B lat
702 is Local Area Transport (LAT),
703 .B mopdl
704 is DNA Dump/Load (MOP),
705 .B moprc
706 is DNA Remote Console (MOP) and
707 .B sca
708 is System Communication Architecture (SCA).
709 .IP "\fBdecnet host \fIdecnetaddr\fR"
710 True if the source or the destination DECnet address of the packet is
711 .IR decnetaddr .
712 May be qualified with a different direction
713 .RB ( src ,
714 .BR dst ,
715 .BR "src and dst" ),
716 in which case the
717 .B host
718 keyword is optional.
719 .IP
720 .I decnetaddr
721 is an address of the form
722 .BR AREANUMBER.NODENUMBER ,
723 where the area number can be between 0 and 63 (both inclusive) and the node
724 number can be between 0 and 1023 (both inclusive) and both numbers always use
725 decimal base. For example:
726 .in +.5i
727 .nf
728 \fBdecnet src \fP10.123\fR
729 .fi
730 .in -.5i
731 .IP \fBllc\fP
732 True if the packet has an 802.2 LLC header. This includes:
733 .IP
734 Ethernet packets with a length field rather than a type field that
735 aren't raw NetWare-over-802.3 packets;
736 .IP
737 IEEE 802.11 data packets;
738 .IP
739 Token Ring packets (no check is done for LLC frames);
740 .IP
741 FDDI packets (no check is done for LLC frames);
742 .IP
743 LLC-encapsulated ATM packets, for SunATM on Solaris.
744 .IP "\fBllc\fP \fItype\fR"
745 True if the packet has an 802.2 LLC header and has the specified
746 .IR type .
747 .I type
748 can be one of:
749 .RS
750 .TP
751 \fBi\fR
752 Information (I) PDUs
753 .TP
754 \fBs\fR
755 Supervisory (S) PDUs
756 .TP
757 \fBu\fR
758 Unnumbered (U) PDUs
759 .TP
760 \fBrr\fR
761 Receiver Ready (RR) S PDUs
762 .TP
763 \fBrnr\fR
764 Receiver Not Ready (RNR) S PDUs
765 .TP
766 \fBrej\fR
767 Reject (REJ) S PDUs
768 .TP
769 \fBui\fR
770 Unnumbered Information (UI) U PDUs
771 .TP
772 \fBua\fR
773 Unnumbered Acknowledgment (UA) U PDUs
774 .TP
775 \fBdisc\fR
776 Disconnect (DISC) U PDUs
777 .TP
778 \fBdm\fR
779 Disconnected Mode (DM) U PDUs
780 .TP
781 \fBsabme\fR
782 Set Asynchronous Balanced Mode Extended (SABME) U PDUs
783 .TP
784 \fBtest\fR
785 Test (TEST) U PDUs
786 .TP
787 \fBxid\fR
788 Exchange Identification (XID) U PDUs
789 .TP
790 \fBfrmr\fR
791 Frame Reject (FRMR) U PDUs
792 .RE
793 .IP \fBinbound\fP
794 Packet was received by the host performing the capture rather than being
795 sent by that host. This is only supported for certain link-layer types,
796 such as SLIP and the ``cooked'' Linux capture mode
797 used for the ``any'' device and for some other device types.
798 .IP \fBoutbound\fP
799 Packet was sent by the host performing the capture rather than being
800 received by that host. This is only supported for certain link-layer types,
801 such as SLIP and the ``cooked'' Linux capture mode
802 used for the ``any'' device and for some other device types.
803 .IP "\fBifindex \fIinterface_index\fR"
804 True if the packet was logged via the specified interface (applies only to
805 packets logged by the Linux "any" cooked v2 interface).
806 .IP "\fBifname \fIinterface\fR"
807 True, for
808 .BR DLT_PFLOG
809 only, if the packet was logged as coming from the specified interface.
810 .IP "\fBon \fIinterface\fR"
811 Synonymous with the
812 .B ifname
813 primitive.
814 .IP "\fBrnr \fInum\fR"
815 True, for
816 .BR DLT_PFLOG
817 only, if the packet was logged as matching the specified PF rule number.
818 .IP "\fBrulenum \fInum\fR"
819 Synonymous with the
820 .B rnr
821 primitive.
822 .IP "\fBreason \fIcode\fR"
823 True, for
824 .BR DLT_PFLOG
825 only, if the packet was logged with the specified PF reason code. Valid
826 codes are:
827 .BR \%match ,
828 .BR \%bad-offset ,
829 .BR \%fragment ,
830 .BR \%short ,
831 .BR \%normalize ,
832 .BR \%memory ,
833 .BR \%bad-timestamp ,
834 .BR \%congestion ,
835 .BR \%ip-option ,
836 .BR \%proto-cksum ,
837 .BR \%state-mismatch ,
838 .BR \%state-insert ,
839 .BR \%state-limit ,
840 .BR \%src-limit ,
841 .BR \%synproxy ,
842 .B \%map-failed
843 (on FreeBSD only),
844 .B \%state-locked
845 (on NetBSD only),
846 .B \%translate
847 (on OpenBSD only),
848 .B \%no-route
849 (on OpenBSD only) and
850 .B \%dummynet
851 (on macOS only).
852 .IP "\fBrset \fIname\fR"
853 True, for
854 .BR DLT_PFLOG
855 only, if the packet was logged as matching the specified PF ruleset
856 name of an anchored ruleset.
857 .IP "\fBruleset \fIname\fR"
858 Synonymous with the
859 .B rset
860 primitive.
861 .IP "\fBsrnr \fInum\fR"
862 True, for
863 .BR DLT_PFLOG
864 only, if the packet was logged as matching the specified PF rule number
865 of an anchored ruleset.
866 .IP "\fBsubrulenum \fInum\fR"
867 Synonymous with the
868 .B srnr
869 primitive.
870 .IP "\fBaction \fIact\fR"
871 True, for
872 .BR DLT_PFLOG
873 only, if PF took the specified action when the packet was logged. Valid
874 actions are:
875 .B pass
876 (or
877 .BR \%accept ),
878 .B block
879 (or
880 .BR drop )
881 and, with later versions of
882 .BR pf (4),
883 .BR scrub ,
884 .BR \%noscrub ,
885 .BR nat ,
886 .BR \%nonat ,
887 .BR \%binat ,
888 .BR \%nobinat ,
889 .BR rdr ,
890 .BR nordr ,
891 .BR \%synproxy-drop ,
892 .B \%defer
893 (on FreeBSD and OpenBSD only),
894 .B match
895 (on OpenBSD only),
896 .B \%divert
897 (on OpenBSD only),
898 .B rt
899 (on OpenBSD only),
900 .B afrt
901 (on OpenBSD only),
902 .B \%dummynet
903 (on macOS only),
904 .B \%nodummynet
905 (on macOS only),
906 .B nat64
907 (on macOS only) and
908 .B \%nonat64
909 (on macOS only).
910 .IP "\fBwlan ra \fIehost\fR"
911 True if the IEEE 802.11 RA is
912 .IR ehost .
913 The RA field is used in all frames except for management frames.
914 .IP "\fBwlan ta \fIehost\fR"
915 True if the IEEE 802.11 TA is
916 .IR ehost .
917 The TA field is used in all frames except for management frames and
918 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
919 .IP "\fBwlan addr1 \fIehost\fR"
920 True if the first IEEE 802.11 address is
921 .IR ehost .
922 .IP "\fBwlan addr2 \fIehost\fR"
923 True if the second IEEE 802.11 address, if present, is
924 .IR ehost .
925 The second address field is used in all frames except for CTS (Clear To
926 Send) and ACK (Acknowledgment) control frames.
927 .IP "\fBwlan addr3 \fIehost\fR"
928 True if the third IEEE 802.11 address, if present, is
929 .IR ehost .
930 The third address field is used in management and data frames, but not
931 in control frames.
932 .IP "\fBwlan addr4 \fIehost\fR"
933 True if the fourth IEEE 802.11 address, if present, is
934 .IR ehost .
935 The fourth address field is only used for
936 WDS (Wireless Distribution System) frames.
937 .IP "\fBwlan type \fIwlan_type\fR"
938 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
939 Valid \fIwlan_type\fRs are:
940 \fBmgt\fP,
941 \fBctl\fP
942 and \fBdata\fP.
943 The
944 .B wlan
945 keyword is optional.
946 .IP "\fBwlan type \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
947 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
948 and frame subtype matches the specified \fIwlan_subtype\fR.
949 The
950 .B wlan
951 keyword is optional.
952 .IP
953 If the specified \fIwlan_type\fR is \fBmgt\fP,
954 then valid \fIwlan_subtype\fRs are:
955 \fBassoc-req\fP,
956 \fBassoc-resp\fP,
957 \fBreassoc-req\fP,
958 \fBreassoc-resp\fP,
959 \fBprobe-req\fP,
960 \fBprobe-resp\fP,
961 \fBbeacon\fP,
962 \fBatim\fP,
963 \fBdisassoc\fP,
964 \fBauth\fP and
965 \fBdeauth\fP.
966 .IP
967 If the specified \fIwlan_type\fR is \fBctl\fP,
968 then valid \fIwlan_subtype\fRs are:
969 \fBbar\fP,
970 \fBba\fP,
971 \fBps-poll\fP,
972 \fBrts\fP,
973 \fBcts\fP,
974 \fBack\fP,
975 \fBcf-end\fP and
976 \fBcf-end-ack\fP.
977 .IP
978 If the specified \fIwlan_type\fR is \fBdata\fP,
979 then valid \fIwlan_subtype\fRs are:
980 .BR \%data ,
981 .BR \%data-cf-ack ,
982 .BR \%data-cf-poll ,
983 .BR \%data-cf-ack-poll ,
984 .BR \%null ,
985 .BR \%cf-ack ,
986 .BR \%cf-poll ,
987 .BR \%cf-ack-poll ,
988 .BR \%qos-data ,
989 .BR \%qos-data-cf-ack ,
990 .BR \%qos-data-cf-poll ,
991 .BR \%qos-data-cf-ack-poll ,
992 .BR \%qos ,
993 .B \%qos-cf-poll
994 and
995 .BR \%qos-cf-ack-poll .
996 .IP "\fBwlan subtype \fIwlan_subtype\fR"
997 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
998 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
999 The
1000 .B wlan
1001 keyword is optional.
1002 .IP "\fBwlan dir \fIdirection\fR"
1003 True if the IEEE 802.11 frame direction matches the specified
1004 .IR direction .
1005 Valid directions are:
1006 .BR nods ,
1007 .BR tods ,
1008 .BR fromds ,
1009 .BR dstods ,
1010 or a numeric value.
1011 The
1012 .B wlan
1013 keyword is optional.
1014 .IP "\fBvlan \fI[vlan_id]\fR"
1015 True if the packet is an IEEE 802.1Q VLAN packet.
1016 If the optional \fIvlan_id\fR is specified, only true if the packet has the specified
1017 \fIvlan_id\fR.
1018 Note that the first \fBvlan\fR keyword encountered in an expression
1019 changes the decoding offsets for the remainder of the expression on
1020 the assumption that the packet is a VLAN packet. The `\fBvlan
1021 \fI[vlan_id]\fR` keyword may be used more than once, to filter on VLAN
1022 hierarchies. Each use of that keyword increments the filter offsets
1023 by 4.
1024 .IP
1025 For example:
1026 .in +.5i
1027 .nf
1028 \fBvlan\fP 100 \fB&& vlan\fR 200
1029 .fi
1030 .in -.5i
1031 filters on VLAN 200 encapsulated within VLAN 100, and
1032 .in +.5i
1033 .nf
1034 \fBvlan && vlan \fP300 \fB&& ip\fR
1035 .fi
1036 .in -.5i
1037 filters IPv4 protocol encapsulated in VLAN 300 encapsulated within any
1038 higher order VLAN.
1039 .IP "\fBmpls \fI[label_num]\fR"
1040 True if the packet is an MPLS packet.
1041 If the optional \fIlabel_num\fR is specified, only true if the packet has the specified
1042 \fIlabel_num\fR.
1043 Note that the first \fBmpls\fR keyword encountered in an expression
1044 changes the decoding offsets for the remainder of the expression on
1045 the assumption that the packet is a MPLS-encapsulated IP packet. The
1046 `\fBmpls \fI[label_num]\fR` keyword may be used more than once, to
1047 filter on MPLS hierarchies. Each use of that keyword increments the
1048 filter offsets by 4.
1049 .IP
1050 For example:
1051 .in +.5i
1052 .nf
1053 \fBmpls\fP 100000 \fB&& mpls\fR 1024
1054 .fi
1055 .in -.5i
1056 filters packets with an outer label of 100000 and an inner label of
1057 1024, and
1058 .in +.5i
1059 .nf
1060 \fBmpls && mpls\fP 1024 \fB&& host\fR 192.9.200.1
1061 .fi
1062 .in -.5i
1063 filters packets to or from 192.9.200.1 with an inner label of 1024 and
1064 any outer label.
1065 .IP \fBpppoed\fP
1066 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
1067 type 0x8863).
1068 .IP "\fBpppoes \fI[session_id]\fR"
1069 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
1070 type 0x8864).
1071 If the optional \fIsession_id\fR is specified, only true if the packet has the specified
1072 \fIsession_id\fR.
1073 Note that the first \fBpppoes\fR keyword encountered in an expression
1074 changes the decoding offsets for the remainder of the expression on
1075 the assumption that the packet is a PPPoE session packet.
1076 .IP
1077 For example:
1078 .in +.5i
1079 .nf
1080 \fBpppoes\fP 0x27 \fB&& ip\fR
1081 .fi
1082 .in -.5i
1083 filters IPv4 protocol encapsulated in PPPoE session id 0x27.
1084 .IP "\fBgeneve \fI[vni]\fR"
1085 True if the packet is a Geneve packet (UDP port 6081). If the optional \fIvni\fR
1086 is specified, only true if the packet has the specified \fIvni\fR.
1087 Note that when the \fBgeneve\fR keyword is encountered in
1088 an expression, it changes the decoding offsets for the remainder of
1089 the expression on the assumption that the packet is a Geneve packet.
1090 .IP
1091 For example:
1092 .in +.5i
1093 .nf
1094 \fBgeneve\fP 0xb \fB&& ip\fR
1095 .fi
1096 .in -.5i
1097 filters IPv4 protocol encapsulated in Geneve with VNI 0xb. This will
1098 match both IPv4 directly encapsulated in Geneve as well as IPv4 contained
1099 inside an Ethernet frame.
1100 .IP "\fBvxlan \fI[vni]\fR"
1101 True if the packet is a VXLAN packet (UDP port 4789). If the optional
1102 \fIvni\fR is specified, only true if the packet has the specified
1103 \fIvni\fR. Note that when the \fBvxlan\fR keyword is encountered in
1104 an expression, it changes the decoding offsets for the remainder of
1105 the expression on the assumption that the packet is a VXLAN packet.
1106 .IP
1107 For example:
1108 .in +.5i
1109 .nf
1110 \fBvxlan\fP 0x7 \fB&& ip6 \fR
1111 .fi
1112 .in -.5i
1113 filters IPv6 protocol encapsulated in VXLAN with VNI 0x7.
1114 .IP "\fBiso proto \fIprotocol\fR"
1115 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
1116 \fIProtocol\fP can be a number or one of the names
1117 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
1118 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
1119 Abbreviations for:
1120 .in +.5i
1121 .nf
1122 \fBiso proto \\\fIprotocol\fR
1123 .fi
1124 .in -.5i
1125 where \fIprotocol\fR is one of the above protocols. Also in this context
1126 .B \%es-is
1127 is an alias for
1128 .B esis
1129 and
1130 .B \%is-is
1131 is an alias for
1132 .BR isis .
1133 .IP "\fBisis proto \fIprotocol\fR"
1134 True if the packet is an IS-IS packet of protocol type
1135 .IR protocol ,
1136 which can be a number only.
1137 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
1138 Abbreviations for IS-IS PDU types.
1139 .IP "\fIatmfield relop val\fR"
1140 True if the packet is an ATM packet, for SunATM on Solaris, and the relation
1141 holds.
1142 .I atmfield
1143 is one of
1144 .RB { vpi ,
1145 .BR vci };
1146 .I relop
1147 is one of
1148 .RB { > ,
1149 .BR < ,
1150 .BR >= ,
1151 .BR <= ,
1152 .BR = ,
1153 .BR == ,
1154 .BR != }
1155 (where
1156 .B =
1157 means the same as
1158 .BR == );
1159 .I val
1160 is an integer.
1161 .B vpi
1162 and
1163 .B vci
1164 stand for the virtual path identifier (VPI) and the virtual channel
1165 identifier (VCI) fields respectively.
1166 .IP "\fIatmfield\fP \fIval\fR"
1167 Abbreviation for
1168 .in +.5i
1169 .nf
1170 \fIatmfield\fR == \fIval\fR
1171 .fi
1172 .in -.5i
1173 in the expression above.
1174 .IP "\fIatmfield\fP (\fIval1\fR \fBor\fP ... \fBor\fP \fIvalN\fR)"
1175 Abbreviation for
1176 .in +.5i
1177 .nf
1178 (\fIatmfield\fP == \fIval1\fP \fBor\fP ... \fBor\fP \fIatmfield\fP == \fIvalN\fR)
1179 .fi
1180 .in -.5i
1181 in the expression above.
1182 .IP \fBlane\fP
1183 True if the packet is an ATM packet, for SunATM on Solaris, and is
1184 an ATM LANE packet.
1185 Note that the first \fBlane\fR keyword encountered in an expression
1186 changes the tests done in the remainder of the expression
1187 on the assumption that the packet is either a LANE emulated Ethernet
1188 packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the
1189 tests are done under the assumption that the packet is an
1190 LLC-encapsulated packet.
1191 .IP
1192 Also the first
1193 .B lane
1194 keyword enables primitives that do not apply to ATM in general, such as
1195 .B "link host"
1196 and
1197 .BR "link multicast" .
1198 .IP \fBoamf4sc\fP
1199 True if the packet is an ATM packet, for SunATM on Solaris, and is
1200 a segment OAM F4 flow cell (VPI=0 & VCI=3).
1201 .IP \fBoamf4ec\fP
1202 True if the packet is an ATM packet, for SunATM on Solaris, and is
1203 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
1204 .IP \fBoamf4\fP
1205 True if the packet is an ATM packet, for SunATM on Solaris, and is
1206 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
1207 .IP \fBoam\fP
1208 True if the packet is an ATM packet, for SunATM on Solaris, and is
1209 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
1210 .IP \fBmetac\fP
1211 True if the packet is an ATM packet, for SunATM on Solaris, and is
1212 on a meta signaling circuit (VPI=0 & VCI=1).
1213 .IP \fBbcc\fP
1214 True if the packet is an ATM packet, for SunATM on Solaris, and is
1215 on a broadcast signaling circuit (VPI=0 & VCI=2).
1216 .IP \fBsc\fP
1217 True if the packet is an ATM packet, for SunATM on Solaris, and is
1218 on a signaling circuit (VPI=0 & VCI=5).
1219 .IP \fBilmic\fP
1220 True if the packet is an ATM packet, for SunATM on Solaris, and is
1221 on an ILMI circuit (VPI=0 & VCI=16).
1222 .IP \fBconnectmsg\fP
1223 True if the packet is an ATM packet, for SunATM on Solaris, and is
1224 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
1225 Connect Ack, Release, or Release Done message.
1226 .IP \fBmetaconnect\fP
1227 True if the packet is an ATM packet, for SunATM on Solaris, and is
1228 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
1229 Release, or Release Done message.
1230 .IP \fBfisu\fP
1231 True if the packet is a Fill-In Signal Unit (FISU) MTP2 packet.
1232 .IP \fBlssu\fP
1233 True if the packet is a Link Status Signal Unit (LSSU) MTP2 packet.
1234 .IP \fBmsu\fP
1235 True if the packet is a Message Signal Unit (MSU) MTP2 packet.
1236 .IP "\fImtpfield relop val\fR"
1237 True if the relation holds.
1238 .I mtpfield
1239 is one of
1240 .RB { sio ,
1241 .BR dpc ,
1242 .BR opc ,
1243 .BR sls };
1244 .I relop
1245 is one of
1246 .RB { > ,
1247 .BR < ,
1248 .BR >= ,
1249 .BR <= ,
1250 .BR = ,
1251 .BR == ,
1252 .BR != }
1253 (where
1254 .B =
1255 means the same as
1256 .BR == );
1257 .I val
1258 is an integer.
1259 .B sio
1260 stands for the Service Information Octet (SIO) field of the MTP2 MSU header.
1261 .BR dpc ,
1262 .B opc
1263 and
1264 .B sls
1265 stand for the Destination Point Code (DPC), Originating Point Code (OPC) and
1266 Signalling Link Selection (SLS) fields respectively of the MTP3 standard
1267 routing label.
1268 .IP "\fImtpfield\fP \fIval\fR"
1269 Abbreviation for
1270 .in +.5i
1271 .nf
1272 \fImtpfield\fR == \fIval\fR
1273 .fi
1274 .in -.5i
1275 in the expression above.
1276 .IP "\fImtpfield\fP (\fIval1\fR \fBor\fP ... \fBor\fP \fIvalN\fR)"
1277 Abbreviation for
1278 .in +.5i
1279 .nf
1280 (\fImtpfield\fP == \fIval1\fP \fBor\fP ... \fBor\fP \fImtpfield\fP == \fIvalN\fR)
1281 .fi
1282 .in -.5i
1283 in the expression above.
1284 .IP "\fBhfisu\fR, \fBhlssu\fR, \fBhmsu\fR, \fBhsio\fR, \fBhdpc\fR, \fBhopc\fR, \fBhsls\fP"
1285 Same as
1286 .BR fisu ,
1287 .BR lssu ,
1288 .BR msu ,
1289 .BR sio ,
1290 .BR dpc ,
1291 .B opc
1292 and
1293 .B sls
1294 respectively, but only if the MTP2 link uses the extended sequence numbers
1295 encoding specified for high speed signalling links (HSL) in ITU-T
1296 Recommendation Q.703 Annex A.
1297 .IP "\fBlink host \fIarcnetaddr\fR"
1298 True, only for
1299 .B \%DLT_ARCNET
1300 or
1301 .BR \%DLT_ARCNET_LINUX ,
1302 if the source or the destination ARCnet address of the packet is
1303 .IR \%arcnetaddr .
1304 May be qualified with a different direction
1305 .RB ( src ,
1306 .BR dst ,
1307 .BR "src and dst" ),
1308 in which case the
1309 .B host
1310 keyword is optional.
1311 .IP
1312 .I \%arcnetaddr
1313 is a string of the form
1314 .B $xx
1315 or
1316 .BR $x ,
1317 where "x" is a hexadecimal digit. For example:
1318 .in +.5i
1319 .nf
1320 \fBlink host \fP$2b\fR
1321 .fi
1322 .in -.5i
1323 .IP
1324 Also in ARCnet context
1325 .B \%broadcast
1326 and
1327 .B \%multicast
1328 are equivalent to
1329 .BR "\%link dst $0" .
1330 .IP
1331 Note that this address syntax clashes with the parameter expansion syntax
1332 in POSIX-compatible shells and elsewhere, so depending on the use case the
1333 filter string may require the use of single quotes or a backslash.
1334 .IP "\fBbyte \fIidx op val\fR"
1335 True if the value of the link layer byte number
1336 .I idx
1337 satisfies a condition with regard to
1338 .IR val ,
1339 which can be a number only. The condition is one of: "equals to" (if
1340 .I op
1341 is
1342 .BR = ),
1343 "less than" (if
1344 .I op
1345 is
1346 .BR < ),
1347 "greater than" (if
1348 .I op
1349 is
1350 .BR > ),
1351 "the result of bitwise AND is not zero" (if
1352 .I op
1353 is
1354 .BR & ),
1355 "the result of bitwise OR is not zero" (if
1356 .I op
1357 is
1358 .BR | ).
1359 .IP
1360 The arithmetic expressions and packet data accessors below implement all of
1361 these and many other things much better, so this primitive will be removed in
1362 a future release and should not be used in applications that require forward
1363 compatibility.
1364 .SH ARITHMETIC EXPRESSIONS
1365 Arithmetic expressions are the operands of a relational operator in a
1366 relation of the following form:
1367 .in +.5i
1368 .nf
1369 \fIexpr1 relop expr2\fR
1370 .fi
1371 .in -.5i
1372 This evaluates to true if and only if the relation holds.
1373 .I relop
1374 (the relational operator) is one of
1375 .RB { > ,
1376 .BR < ,
1377 .BR >= ,
1378 .BR <= ,
1379 .BR = ,
1380 .BR == ,
1381 .BR != }
1382 (where
1383 .B =
1384 means the same as
1385 .BR == ).
1386 Each of \fIexpr1\fR and \fIexpr2\fR is an arithmetic expression composed of
1387 integer constants (expressed in standard C syntax), the common arithmetic and
1388 bitwise binary operations
1389 .RB { + ,
1390 .BR - ,
1391 .BR * ,
1392 .BR / ,
1393 .BR % ,
1394 .BR & ,
1395 .BR | ,
1396 .BR ^ ,
1397 .BR << ,
1398 .BR >> },
1399 a length operator, and packet data accessors. All arithmetic expressions
1400 regardless of the complexity and composition resolve to an integer value.
1401 Note that all comparisons are unsigned, so that, for example, both 0x80000000
1402 and 0xffffffff are > 0.
1403 .LP
1404 The
1405 .B %
1406 and
1407 .B ^
1408 operators are currently only supported for filtering in the kernel on
1409 particular operating systems (for example: FreeBSD, Linux with 3.7 and later
1410 kernels, NetBSD); on all other systems (for example: AIX, Hurd, illumos, Solaris,
1411 OpenBSD), if
1412 those operators are used, filtering will be done in user mode, which
1413 will increase the overhead of capturing packets and may cause more
1414 packets to be dropped.
1415 .LP
1416 The length operator, indicated by the keyword \fBlen\fP, gives the
1417 length of the packet.
1418 .SH PACKET DATA ACCESSORS
1419 To use the packet data in an arithmetic expression, use the following syntax:
1420 .in +.5i
1421 .nf
1422 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
1423 .fi
1424 .in -.5i
1425 .I Proto
1426 is one of
1427 .BR arp ,
1428 .BR atalk ,
1429 .BR carp ,
1430 .BR decnet ,
1431 .BR ether ,
1432 .BR fddi ,
1433 .BR icmp ,
1434 .BR icmp6 ,
1435 .BR igmp ,
1436 .BR igrp ,
1437 .BR ip ,
1438 .BR ip6 ,
1439 .BR lat ,
1440 .BR link ,
1441 .BR mopdl ,
1442 .BR moprc ,
1443 .BR pim ,
1444 .BR ppp ,
1445 .BR radio ,
1446 .BR rarp ,
1447 .BR sca ,
1448 .BR sctp ,
1449 .BR slip ,
1450 .BR tcp ,
1451 .BR tr ,
1452 .BR udp ,
1453 .B vrrp
1454 or
1455 .BR wlan ,
1456 and
1457 indicates the protocol layer for the index operation.
1458 .RB ( ether ,
1459 .BR fddi ,
1460 .BR link ,
1461 .BR ppp ,
1462 .BR slip ,
1463 .B tr
1464 and
1465 .BR wlan
1466 all refer to the
1467 link layer, \fBradio\fR refers to the "radio header" added to some
1468 802.11 captures.)
1469 Note that \fBtcp\fR, \fBudp\fR and other upper-layer protocol types only
1470 apply to IPv4, not IPv6 (this will be fixed in the future).
1471 The byte offset, relative to the indicated protocol layer, is
1472 given by \fIexpr\fR, which can be an integer constant or any other valid
1473 arithmetic expression.
1474 \fISize\fR is optional and indicates the number of bytes in the
1475 field of interest; it can be either one, two, or four, and defaults to one;
1476 also it must be one of these valid integer constants only and cannot be a
1477 more complex expression.
1478
1479 For example, `\fBether[\fP0\fB] &\fP 1 \fB!=\fP 0' catches all multicast traffic.
1480 The expression `\fBip[\fP0\fB] &\fP 0xf \fB!=\fP 5'
1481 catches all IPv4 packets with options.
1482 The expression
1483 `\fBip[\fP6:2\fB] &\fP 0x1fff \fB=\fP 0'
1484 catches only unfragmented IPv4 datagrams and frag zero of fragmented
1485 IPv4 datagrams.
1486 This check is implicitly applied to the
1487 .BR tcp ,
1488 .BR udp ,
1489 .BR icmp ,
1490 .BR sctp ,
1491 .BR igmp ,
1492 .BR pim ,
1493 .BR igrp ,
1494 .BR vrrp
1495 and
1496 .BR carp
1497 index operations.
1498 For instance, \fBtcp[\fP0\fB]\fP always means the first
1499 byte of the TCP \fIheader\fP, and never means the first byte of an
1500 intervening fragment.
1501 .SH NAMED VALUES
1502 Some offsets and field values may be expressed as names rather than
1503 as numeric values.
1504 The following protocol header field offsets are
1505 available: \fBicmptype\fP (ICMP type field), \fBicmp6type\fP (ICMPv6 type field),
1506 \fBicmpcode\fP (ICMP code field), \fBicmp6code\fP (ICMPv6 code field) and
1507 \fBtcpflags\fP (TCP flags field).
1508 .LP
1509 The following ICMP type field values are available:
1510 .BR \%icmp-echoreply ,
1511 .BR \%icmp-unreach ,
1512 .BR \%icmp-sourcequench ,
1513 .BR \%icmp-redirect ,
1514 .BR \%icmp-echo ,
1515 .BR \%icmp-routeradvert ,
1516 .BR \%icmp-routersolicit ,
1517 .BR \%icmp-timxceed ,
1518 .BR \%icmp-paramprob ,
1519 .BR \%icmp-tstamp ,
1520 .BR \%icmp-tstampreply ,
1521 .BR \%icmp-ireq ,
1522 .BR \%icmp-ireqreply ,
1523 .BR \%icmp-maskreq ,
1524 .BR \%icmp-maskreply .
1525 .LP
1526 The following ICMPv6 type field values are available:
1527 .BR \%icmp6-destinationunreach ,
1528 .BR \%icmp6-packettoobig ,
1529 .BR \%icmp6-timeexceeded ,
1530 .BR \%icmp6-parameterproblem ,
1531 .BR \%icmp6-echo ,
1532 .BR \%icmp6-echoreply ,
1533 .BR \%icmp6-multicastlistenerquery ,
1534 .BR \%icmp6-multicastlistenerreportv1 ,
1535 .BR \%icmp6-multicastlistenerdone ,
1536 .BR \%icmp6-routersolicit ,
1537 .BR \%icmp6-routeradvert ,
1538 .BR \%icmp6-neighborsolicit ,
1539 .BR \%icmp6-neighboradvert ,
1540 .BR \%icmp6-redirect ,
1541 .BR \%icmp6-routerrenum ,
1542 .BR \%icmp6-nodeinformationquery ,
1543 .BR \%icmp6-nodeinformationresponse ,
1544 .BR \%icmp6-ineighbordiscoverysolicit ,
1545 .BR \%icmp6-ineighbordiscoveryadvert ,
1546 .BR \%icmp6-multicastlistenerreportv2 ,
1547 .BR \%icmp6-homeagentdiscoveryrequest ,
1548 .BR \%icmp6-homeagentdiscoveryreply ,
1549 .BR \%icmp6-mobileprefixsolicit ,
1550 .BR \%icmp6-mobileprefixadvert ,
1551 .BR \%icmp6-certpathsolicit ,
1552 .BR \%icmp6-certpathadvert ,
1553 .BR \%icmp6-multicastrouteradvert ,
1554 .BR \%icmp6-multicastroutersolicit ,
1555 .BR \%icmp6-multicastrouterterm .
1556 .LP
1557 The following TCP flags field values are available: \fBtcp-fin\fP,
1558 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
1559 \fBtcp-ack\fP, \fBtcp-urg\fP, \fBtcp-ece\fP,
1560 \fBtcp-cwr\fP.
1561 .SH COMPOUND EXPRESSIONS
1562 Primitives and relations may be combined using:
1563 .LP
1564 Parentheses.
1565 .LP
1566 Negation (`\fB!\fP' or `\fBnot\fP').
1567 .LP
1568 Concatenation (`\fB&&\fP' or `\fBand\fP').
1569 .LP
1570 Alternation (`\fB||\fP' or `\fBor\fP').
1571 .LP
1572 Negation has the highest precedence.
1573 Alternation and concatenation have equal precedence and associate
1574 left to right.
1575 .LP
1576 For primitives, if an identifier is given without a keyword, the most recent
1577 keyword is assumed. For example,
1578 .in +.5i
1579 .nf
1580 \fBnot host\fP vs \fBand\fR ace
1581 .fi
1582 .in -.5i
1583 is short for
1584 .in +.5i
1585 .nf
1586 \fBnot host\fP vs \fBand host\fR ace
1587 .fi
1588 .in -.5i
1589 which should not be confused with
1590 .in +.5i
1591 .nf
1592 \fBnot (host \fPvs\fB and host \fPace\fB)\fR
1593 .fi
1594 .in -.5i
1595 .SH PROTOCOL NAMES IN VARIOUS CONTEXTS
1596 The table below shows which protocol names can be used in which contexts of
1597 the currently implemented syntax. The "name" column contains a protocol name,
1598 which often can be used as an ID in primitives that take a protocol name
1599 argument; in all cases except
1600 .BR \%loopback
1601 the protocol name is also a keyword. If the keyword is an alias, the "see"
1602 column refers to the main keyword. The "abbr" column tells whether the
1603 keyword can be used as an abbreviation (that is, if the keyword is the only
1604 contents of a primitive, it means a more complex expression). The "PDA"
1605 column tells whether the keyword can be used in a packet data accessor. The
1606 "pqual" column tells whether the keyword can be used as a case of the
1607 .I proto
1608 qualifier kind. If the name can be used as an ID for the
1609 .B proto
1610 case of the
1611 .I type
1612 qualifier kind, the "tqual ID" column shows the valid context(s).
1613
1614 .TS
1615 box;
1616 l |l |l |l |l |l
1617 lB |lB |l |l |l |lB.
1618 name see abbr PDA pqual tqual ID
1619 _
1620 aarp yes no no link proto \\aarp
1621 ah yes no no [ip|ip6] proto \\ah
1622 arp yes yes yes link proto \\arp
1623 atalk yes yes no link proto \\atalk
1624 carp yes yes no ip proto \\carp
1625 clnp yes no no iso proto \\clnp
1626 csnp yes no no
1627 decnet yes yes yes link proto \\decnet
1628 esis yes no no iso proto \\esis
1629 es-is esis
1630 esp yes no no [ip|ip6] proto \\esp
1631 ether link
1632 fddi link
1633 icmp yes yes no ip proto \\icmp
1634 icmp6 yes yes no
1635 igmp yes yes no ip proto \\igmp
1636 igrp yes yes no ip proto \\igrp
1637 iih yes no no
1638 ip yes yes yes link proto \\ip
1639 ip6 yes yes yes link proto \\ip6
1640 ipx yes no no link proto \\ipx
1641 isis yes no yes iso proto \\isis
1642 is-is isis
1643 iso yes no yes link proto \\iso
1644 l1 yes no no
1645 l2 yes no no
1646 lat yes yes no link proto \\lat
1647 link no yes yes
1648 loopback link proto loopback
1649 lsp yes no no
1650 mopdl yes yes no link proto \\mopdl
1651 moprc yes yes no link proto \\moprc
1652 netbeui yes no no link proto \\netbeui
1653 pim yes yes no [ip|ip6] proto \\pim
1654 ppp link
1655 psnp yes no no
1656 radio no yes no
1657 rarp yes yes yes link proto \\rarp
1658 sca yes yes no link proto \\sca
1659 sctp yes yes yes [ip|ip6] proto \\sctp
1660 slip link
1661 snp yes no no
1662 stp yes no no link proto \\stp
1663 tcp yes yes yes [ip|ip6] proto \\tcp
1664 tr link
1665 udp yes yes yes [ip|ip6] proto \\udp
1666 vrrp yes yes no ip proto \\vrrp
1667 wlan link
1668 .TE
1669
1670 .SH EXAMPLES
1671 .LP
1672 To select all packets arriving at or departing from `sundown':
1673 .RS
1674 .nf
1675 \fBhost\fP sundown
1676 .fi
1677 .RE
1678 .LP
1679 To select traffic between `helios' and either `hot' or `ace':
1680 .RS
1681 .nf
1682 \fBhost\fP helios \fBand (\fPhot \fBor\fP ace\fB)\fP
1683 .fi
1684 .RE
1685 .LP
1686 To select all IPv4 packets between `ace' and any host except `helios':
1687 .RS
1688 .nf
1689 \fBip host\fP ace \fBand not\fP helios
1690 .fi
1691 .RE
1692 .LP
1693 To select all traffic between local hosts and hosts at Berkeley:
1694 .RS
1695 .nf
1696 \fBnet\fP ucb-ether
1697 .fi
1698 .RE
1699 .LP
1700 To select all FTP traffic through Internet gateway `snup':
1701 .RS
1702 .nf
1703 \fBgateway\fP snup \fBand (port\fP ftp \fBor\fP ftp-data\fB)\fP
1704 .fi
1705 .RE
1706 .LP
1707 To select IPv4 traffic neither sourced from nor destined for local hosts
1708 (if you gateway to one other net, this stuff should never make it
1709 onto your local net).
1710 .RS
1711 .nf
1712 \fBip and not net \fPlocalnet
1713 .fi
1714 .RE
1715 .LP
1716 To select the start and end packets (the SYN and FIN packets) of each
1717 TCP conversation that involves a non-local host.
1718 .RS
1719 .nf
1720 \fBtcp[tcpflags] & (tcp-syn|tcp-fin) !=\fP 0 \fBand not src and dst net\fP localnet
1721 .fi
1722 .RE
1723 .LP
1724 To select the TCP packets with flags RST and ACK both set.
1725 (i.e. select only the RST and ACK flags in the flags field, and if the result
1726 is "RST and ACK both set", match)
1727 .RS
1728 .nf
1729 .B
1730 tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)
1731 .fi
1732 .RE
1733 .LP
1734 To select all IPv4 HTTP packets to and from port 80, i.e. print only
1735 packets that contain data, not, for example, SYN and FIN packets and
1736 ACK-only packets. (IPv6 is left as an exercise for the reader.)
1737 .RS
1738 .nf
1739 \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)
1740 .fi
1741 .RE
1742 .LP
1743 To select IPv4 packets longer than 576 bytes sent through gateway `snup':
1744 .RS
1745 .nf
1746 \fBgateway\fP snup \fBand ip[\fP2:2\fB] >\fP 576
1747 .fi
1748 .RE
1749 .LP
1750 To select IPv4 broadcast or multicast packets that were
1751 .I not
1752 sent via Ethernet broadcast or multicast:
1753 .RS
1754 .nf
1755 \fBether[\fP0\fB] &\fP 1 \fB=\fP 0 \fBand ip[\fP16\fB] >=\fP 224
1756 .fi
1757 .RE
1758 .LP
1759 To select all ICMP packets that are not echo requests/replies (i.e., not
1760 ping packets):
1761 .RS
1762 .nf
1763 .B
1764 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
1765 .B
1766 icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply
1767 .fi
1768 .RE
1769 .SH BACKWARD COMPATIBILITY
1770 The
1771 .B carp
1772 keyword became available in libpcap 1.2.1.
1773 .PP
1774 The
1775 .BR hfisu ,
1776 .BR hlssu ,
1777 .BR hmsu ,
1778 .BR hsio ,
1779 .BR hopc ,
1780 .BR hdpc
1781 and
1782 .B hsls
1783 keywords became available in libpcap 1.5.3.
1784 .PP
1785 The modulo
1786 .RB ( % )
1787 and bitwise XOR
1788 .RB ( ^ )
1789 binary operators became available in libpcap 1.6.2.
1790 .PP
1791 The
1792 .B geneve
1793 keyword became available in libpcap 1.8.0.
1794 .PP
1795 The ICMPv6 type code names, as well as the
1796 .B tcp-ece
1797 and
1798 .B tcp-cwr
1799 TCP flag names became available in libpcap 1.9.0.
1800 .PP
1801 The
1802 .B ifindex
1803 keyword became available in libpcap 1.10.0.
1804 .PP
1805 The
1806 .B vxlan
1807 keyword became available in libpcap 1.11.0.
1808 .SH SEE ALSO
1809 .BR pcap (3PCAP)
1810 .SH BUGS
1811 To report a security issue please send an e-mail to \%security@tcpdump.org.
1812 .LP
1813 To report bugs and other problems, contribute patches, request a
1814 feature, provide generic feedback etc please see the file
1815 .I CONTRIBUTING.md
1816 in the libpcap source tree root.
1817 .LP
1818 Filter expressions on fields other than those in Token Ring headers will
1819 not correctly handle source-routed Token Ring packets.
1820 .LP
1821 Filter expressions on fields other than those in 802.11 headers will not
1822 correctly handle 802.11 data packets with both To DS and From DS set.
1823 .LP
1824 `\fBip6 proto\fP'
1825 should chase header chain, but at this moment it does not.
1826 `\fBip6 protochain\fP'
1827 is supplied for this behavior. For example, to match IPv6 fragments:
1828 `\fBip6 protochain\fP 44'
1829 .LP
1830 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
1831 does not work against IPv6 packets.
1832 It only looks at IPv4 packets.
1833 .LP
1834 The
1835 .B sio
1836 and
1837 .B hsio
1838 keywords do not test whether the packet is an MSU packet. The
1839 .BR dpc ,
1840 .BR opc ,
1841 .BR sls ,
1842 .BR hdpc ,
1843 .B hopc
1844 and
1845 .B hsls
1846 keywords do not test whether the packet is an MTP3 packet.
1847 .LP
1848 For ARP and RARP the current implementation assumes IPv4 over Ethernet and may
1849 incorrectly match packets that have a different combination of protocol and
1850 hardware.