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.
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.
21 .TH PCAP-FILTER @MAN_MISC_INFO@ "12 June 2022"
23 pcap-filter \- packet filter syntax
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),
36 .BR pcap_next_ex (3PCAP).
38 The \fIfilter expression\fP consists of one or more
40 Primitives usually consist of an
42 (name or number) preceded by one or more qualifiers.
44 different kinds of qualifier:
47 qualifiers say what kind of thing the id name or number refers to.
54 E.g., `\fBhost\fP foo', `\fBnet\fP 128.3', `\fBport\fP 20', `\fBportrange\fP 6000-6008'.
61 qualifiers specify a particular transfer direction to and/or from
63 Possible directions are
75 E.g., `\fBsrc\fP foo', `\fBdst net\fP 128.3', `\fBsrc or dst port\fP ftp-data'.
77 there is no dir qualifier, `\fBsrc or dst\fP' is assumed.
86 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
89 qualifiers restrict the match to a particular protocol.
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'.
109 qualifier, all protocols consistent with the type are assumed.
110 E.g., `\fBsrc\fP foo' means `\fB(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).
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.
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.]
130 In addition to the above, there are some special `primitive' keywords
131 that don't follow the pattern:
136 and arithmetic expressions.
137 All of these are described below.
139 More complex filter expressions are built up by using the words
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.
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'.
152 Allowable primitives are:
153 .IP "\fBdst host \fIhost\fR"
154 True if the IPv4/v6 destination field of the packet is \fIhost\fP,
155 which may be either an address or a name.
156 .IP "\fBsrc host \fIhost\fR"
157 True if the IPv4/v6 source field of the packet is \fIhost\fP.
158 .IP "\fBhost \fIhost\fP"
159 True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
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:
165 \fBip host \fIhost\fR
168 which is equivalent to:
171 \fBether proto \\ip and host \fIhost\fR
174 If \fIhost\fR is a name with multiple IPv4 addresses, each address will
175 be checked for a match.
176 .IP "\fBether dst \fIehost\fP"
177 True if the Ethernet destination address is \fIehost\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", "xxxxxxxxxxxx", or various mixes of ':', '.', and '-',
182 where each "x" is a hex digit (0-9, a-f, or A-F).
183 .IP "\fBether src \fIehost\fP"
184 True if the Ethernet source address is \fIehost\fP.
185 .IP "\fBether host \fIehost\fP"
186 True if either the Ethernet source or destination address is \fIehost\fP.
187 .IP "\fBgateway\fP \fIhost\fP"
188 True if the packet used \fIhost\fP as a gateway.
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
199 \fBether host \fIehost \fBand not host \fIhost\fR
202 which can be used with either names or numbers for \fIhost / ehost\fP.)
203 This syntax does not work in IPv6-enabled configuration at this moment.
204 .IP "\fBdst net \fInet\fR"
205 True if the IPv4/v6 destination address of the packet has a network
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 ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always
216 host matches, and a network match requires a netmask length.
217 .IP "\fBsrc net \fInet\fR"
218 True if the IPv4/v6 source address of the packet has a network
220 .IP "\fBnet \fInet\fR"
221 True if either the IPv4/v6 source or destination address of the packet has a network
223 .IP "\fBnet \fInet\fR \fBmask \fInetmask\fR"
224 True if the IPv4 address matches \fInet\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 \fInet\fR.
227 .IP "\fBnet \fInet\fR/\fIlen\fR"
228 True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR
230 May be qualified with \fBsrc\fR or \fBdst\fR.
231 .IP "\fBdst port \fIport\fR"
232 True if the packet is IPv4/v6 TCP, UDP or SCTP and has a
233 destination port value of \fIport\fP.
234 The \fIport\fP can be a number or a name used in /etc/services (see
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 domain\fR' will print
243 both tcp/domain and udp/domain traffic).
244 .IP "\fBsrc port \fIport\fR"
245 True if the packet has a source port value of \fIport\fP.
246 .IP "\fBport \fIport\fR"
247 True if either the source or destination port of the packet is \fIport\fP.
248 .IP "\fBdst portrange \fIport1-port2\fR"
249 True if the packet is IPv4/v6 TCP, UDP or SCTP and has a
250 destination port value between \fIport1\fP and \fIport2\fP (both inclusive).
254 are interpreted in the same fashion as the
258 .IP "\fBsrc portrange \fIport1-port2\fR"
259 True if the packet has a source port value between \fIport1\fP and
260 \fIport2\fP (both inclusive).
261 .IP "\fBportrange \fIport1-port2\fR"
262 True if either the source or destination port of the packet is between
263 \fIport1\fP and \fIport2\fP (both inclusive).
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:
269 \fBtcp src port \fIport\fR
272 which matches only TCP packets whose source port is \fIport\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:
278 \fBlen <= \fIlength\fP
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:
286 \fBlen >= \fIlength\fP
289 .IP "\fBip proto \fIprotocol\fR"
290 True if the packet is an IPv4 packet (see
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 (as in e.g. `\fBgetent\fR(1) protocols'), typically from an entry in
296 .IR \%/etc/protocols ,
301 (only in Linux, FreeBSD and NetBSD),
312 Note that most of these example identifiers
313 are also keywords and must be escaped via backslash (\\).
314 Note that this primitive does not chase the protocol header chain.
322 .IP "\fBip6 proto \fIprotocol\fR"
323 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
324 Note that the IPv6 variant of ICMP uses a different protocol number, named
326 in Linux, FreeBSD, NetBSD, OpenBSD, illumos and Solaris.
327 Note that this primitive does not chase the protocol header chain.
335 .IP "\fBproto \fIprotocol\fR"
336 True if the packet is an IPv4 or IPv6 packet of protocol type
337 \fIprotocol\fP. Note that this primitive does not chase the protocol
339 .IP "\fBah\fR, \fBesp\fR, \fBpim\fR, \fBsctp\fR, \fBtcp\fR, \fBudp\fR"
343 \fBproto \\\fIprotocol\fR
346 where \fIprotocol\fR is one of the above protocols.
347 .IP "\fBip6 protochain \fIprotocol\fR"
348 True if the packet is IPv6 packet,
349 and contains protocol header with type \fIprotocol\fR
350 in its protocol header chain.
354 \fBip6 protochain\fR 6
357 matches any IPv6 packet with TCP protocol header in the protocol header chain.
358 The packet may contain, for example,
359 authentication header, routing header, or hop-by-hop option header,
360 between IPv6 header and TCP header.
361 The BPF code emitted by this primitive is complex and
362 cannot be optimized by the BPF optimizer code, and is not supported by
363 filter engines in the kernel, so this can be somewhat slow, and may
364 cause more packets to be dropped.
365 .IP "\fBip protochain \fIprotocol\fR"
366 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
367 .IP "\fBprotochain \fIprotocol\fR"
368 True if the packet is an IPv4 or IPv6 packet of protocol type
369 \fIprotocol\fP. Note that this primitive chases the protocol
371 .IP "\fBether broadcast\fR"
372 True if the packet is an Ethernet broadcast packet.
375 .IP "\fBip broadcast\fR"
376 True if the packet is an IPv4 broadcast packet.
377 It checks for both the all-zeroes and all-ones broadcast conventions,
378 and looks up the subnet mask on the interface on which the capture is
381 If the subnet mask of the interface on which the capture is being done
382 is not available, either because the interface on which capture is being
383 done has no netmask or because the capture is being done on the Linux
384 "any" interface, which can capture on more than one interface, this
385 check will not work correctly.
386 .IP "\fBether multicast\fR"
387 True if the packet is an Ethernet multicast packet.
390 This is shorthand for `\fBether[\fP0\fB] & \fP1\fB != \fP0'.
391 .IP "\fBip multicast\fR"
392 True if the packet is an IPv4 multicast packet.
393 .IP "\fBip6 multicast\fR"
394 True if the packet is an IPv6 multicast packet.
395 .IP "\fBether proto \fIprotocol\fR"
396 True if the packet is of ether type \fIprotocol\fR.
397 \fIProtocol\fP can be a number or one of the names
398 \fBaarp\fP, \fBarp\fP, \fBatalk\fP, \fBdecnet\fP, \fBip\fP, \fBip6\fP,
399 \fBipx\fP, \fBiso\fP, \fBlat\fP, \fBloopback\fP, \fBmopdl\fP, \fBmoprc\fP, \fBnetbeui\fP,
400 \fBrarp\fP, \fBsca\fP or \fBstp\fP.
401 Note these identifiers (except \fBloopback\fP) are also keywords
402 and must be escaped via backslash (\\).
404 [In the case of FDDI (e.g., `\fBfddi proto \\arp\fR'), Token Ring
405 (e.g., `\fBtr proto \\arp\fR'), and IEEE 802.11 wireless LANs (e.g.,
406 `\fBwlan proto \\arp\fR'), for most of those protocols, the
407 protocol identification comes from the 802.2 Logical Link Control (LLC)
408 header, which is usually layered on top of the FDDI, Token Ring, or
411 When filtering for most protocol identifiers on FDDI, Token Ring, or
412 802.11, the filter checks only the protocol ID field of an LLC header
413 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
414 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
415 is in SNAP format with an OUI of 0x000000.
420 the filter checks the DSAP (Destination Service Access Point) and
421 SSAP (Source Service Access Point) fields of the LLC header;
423 \fBstp\fP and \fBnetbeui\fP
424 the filter checks the DSAP of the LLC header;
427 the filter checks for a SNAP-format packet with an OUI of 0x080007
428 and the AppleTalk etype.
431 In the case of Ethernet, the filter checks the Ethernet type field
432 for most of those protocols. The exceptions are:
435 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
436 the filter checks for an 802.3 frame and then checks the LLC header as
437 it does for FDDI, Token Ring, and 802.11;
440 the filter checks both for the AppleTalk etype in an Ethernet frame and
441 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
444 the filter checks for the AppleTalk ARP etype in either an Ethernet
445 frame or an 802.2 SNAP frame with an OUI of 0x000000;
448 the filter checks for the IPX etype in an Ethernet frame, the IPX
449 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
450 IPX, and the IPX etype in a SNAP frame.
452 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
456 \fBether proto \\\fIprotocol\fR
459 where \fIprotocol\fR is one of the above protocols.
460 .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
464 \fBether proto \\\fIprotocol\fR
467 where \fIprotocol\fR is one of the above protocols.
468 Note that not all applications using
470 currently know how to parse these protocols.
471 .IP "\fBdecnet src \fIhost\fR"
472 True if the DECnet source address is
474 which may be an address of the form ``10.123'', or a DECnet host
476 [DECnet host name support is only available on ULTRIX systems
477 that are configured to run DECnet.]
478 .IP "\fBdecnet dst \fIhost\fR"
479 True if the DECnet destination address is
481 .IP "\fBdecnet host \fIhost\fR"
482 True if either the DECnet source or destination address is
485 True if the packet has an 802.2 LLC header. This includes:
487 Ethernet packets with a length field rather than a type field that
488 aren't raw NetWare-over-802.3 packets;
490 IEEE 802.11 data packets;
492 Token Ring packets (no check is done for LLC frames);
494 FDDI packets (no check is done for LLC frames);
496 LLC-encapsulated ATM packets, for SunATM on Solaris.
497 .IP "\fBllc\fP \fItype\fR"
498 True if the packet has an 802.2 LLC header and has the specified
514 Receiver Ready (RR) S PDUs
517 Receiver Not Ready (RNR) S PDUs
523 Unnumbered Information (UI) U PDUs
526 Unnumbered Acknowledgment (UA) U PDUs
529 Disconnect (DISC) U PDUs
532 Set Asynchronous Balanced Mode Extended (SABME) U PDUs
538 Exchange Identification (XID) U PDUs
541 Frame Reject (FRMR) U PDUs
544 Packet was received by the host performing the capture rather than being
545 sent by that host. This is only supported for certain link-layer types,
546 such as SLIP and the ``cooked'' Linux capture mode
547 used for the ``any'' device and for some other device types.
549 Packet was sent by the host performing the capture rather than being
550 received by that host. This is only supported for certain link-layer types,
551 such as SLIP and the ``cooked'' Linux capture mode
552 used for the ``any'' device and for some other device types.
553 .IP "\fBifname \fIinterface\fR"
554 True if the packet was logged as coming from the specified interface (applies
555 only to packets logged by OpenBSD's or FreeBSD's
557 .IP "\fBon \fIinterface\fR"
561 .IP "\fBrnr \fInum\fR"
562 True if the packet was logged as matching the specified PF rule number
563 (applies only to packets logged by OpenBSD's or FreeBSD's
565 .IP "\fBrulenum \fInum\fR"
569 .IP "\fBreason \fIcode\fR"
570 True if the packet was logged with the specified PF reason code. The known
579 (applies only to packets logged by OpenBSD's or FreeBSD's
581 .IP "\fBrset \fIname\fR"
582 True if the packet was logged as matching the specified PF ruleset
583 name of an anchored ruleset (applies only to packets logged by OpenBSD's
586 .IP "\fBruleset \fIname\fR"
590 .IP "\fBsrnr \fInum\fR"
591 True if the packet was logged as matching the specified PF rule number
592 of an anchored ruleset (applies only to packets logged by OpenBSD's or
595 .IP "\fBsubrulenum \fInum\fR"
599 .IP "\fBaction \fIact\fR"
600 True if PF took the specified action when the packet was logged. Known actions
605 and, with later versions of
612 (applies only to packets logged by OpenBSD's or FreeBSD's
614 .IP "\fBwlan ra \fIehost\fR"
615 True if the IEEE 802.11 RA is
617 The RA field is used in all frames except for management frames.
618 .IP "\fBwlan ta \fIehost\fR"
619 True if the IEEE 802.11 TA is
621 The TA field is used in all frames except for management frames and
622 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
623 .IP "\fBwlan addr1 \fIehost\fR"
624 True if the first IEEE 802.11 address is
626 .IP "\fBwlan addr2 \fIehost\fR"
627 True if the second IEEE 802.11 address, if present, is
629 The second address field is used in all frames except for CTS (Clear To
630 Send) and ACK (Acknowledgment) control frames.
631 .IP "\fBwlan addr3 \fIehost\fR"
632 True if the third IEEE 802.11 address, if present, is
634 The third address field is used in management and data frames, but not
636 .IP "\fBwlan addr4 \fIehost\fR"
637 True if the fourth IEEE 802.11 address, if present, is
639 The fourth address field is only used for
640 WDS (Wireless Distribution System) frames.
641 .IP "\fBtype \fIwlan_type\fR"
642 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
643 Valid \fIwlan_type\fRs are:
647 .IP "\fBtype \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
648 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
649 and frame subtype matches the specified \fIwlan_subtype\fR.
651 If the specified \fIwlan_type\fR is \fBmgt\fP,
652 then valid \fIwlan_subtype\fRs are:
665 If the specified \fIwlan_type\fR is \fBctl\fP,
666 then valid \fIwlan_subtype\fRs are:
676 If the specified \fIwlan_type\fR is \fBdata\fP,
677 then valid \fIwlan_subtype\fRs are:
681 \fBdata-cf-ack-poll\fP,
687 \fBqos-data-cf-ack\fP,
688 \fBqos-data-cf-poll\fP,
689 \fBqos-data-cf-ack-poll\fP,
691 \fBqos-cf-poll\fP and
692 \fBqos-cf-ack-poll\fP.
693 .IP "\fBsubtype \fIwlan_subtype\fR"
694 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
695 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
696 .IP "\fBdir \fIdir\fR"
697 True if the IEEE 802.11 frame direction matches the specified
699 Valid directions are:
705 .IP "\fBvlan \fI[vlan_id]\fR"
706 True if the packet is an IEEE 802.1Q VLAN packet.
707 If the optional \fIvlan_id\fR is specified, only true if the packet has the specified
709 Note that the first \fBvlan\fR keyword encountered in an expression
710 changes the decoding offsets for the remainder of the expression on
711 the assumption that the packet is a VLAN packet. The `\fBvlan
712 \fI[vlan_id]\fR` keyword may be used more than once, to filter on VLAN
713 hierarchies. Each use of that keyword increments the filter offsets
719 \fBvlan\fP 100 \fB&& vlan\fR 200
722 filters on VLAN 200 encapsulated within VLAN 100, and
725 \fBvlan && vlan \fP300 \fB&& ip\fR
728 filters IPv4 protocol encapsulated in VLAN 300 encapsulated within any
730 .IP "\fBmpls \fI[label_num]\fR"
731 True if the packet is an MPLS packet.
732 If the optional \fIlabel_num\fR is specified, only true if the packet has the specified
734 Note that the first \fBmpls\fR keyword encountered in an expression
735 changes the decoding offsets for the remainder of the expression on
736 the assumption that the packet is a MPLS-encapsulated IP packet. The
737 `\fBmpls \fI[label_num]\fR` keyword may be used more than once, to
738 filter on MPLS hierarchies. Each use of that keyword increments the
744 \fBmpls\fP 100000 \fB&& mpls\fR 1024
747 filters packets with an outer label of 100000 and an inner label of
751 \fBmpls && mpls\fP 1024 \fB&& host\fR 192.9.200.1
754 filters packets to or from 192.9.200.1 with an inner label of 1024 and
757 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
759 .IP "\fBpppoes \fI[session_id]\fR"
760 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
762 If the optional \fIsession_id\fR is specified, only true if the packet has the specified
764 Note that the first \fBpppoes\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 PPPoE session packet.
771 \fBpppoes\fP 0x27 \fB&& ip\fR
774 filters IPv4 protocol encapsulated in PPPoE session id 0x27.
775 .IP "\fBgeneve \fI[vni]\fR"
776 True if the packet is a Geneve packet (UDP port 6081). If the optional \fIvni\fR
777 is specified, only true if the packet has the specified \fIvni\fR.
778 Note that when the \fBgeneve\fR keyword is encountered in
779 an expression, it changes the decoding offsets for the remainder of
780 the expression on the assumption that the packet is a Geneve packet.
785 \fBgeneve\fP 0xb \fB&& ip\fR
788 filters IPv4 protocol encapsulated in Geneve with VNI 0xb. This will
789 match both IPv4 directly encapsulated in Geneve as well as IPv4 contained
790 inside an Ethernet frame.
791 .IP "\fBiso proto \fIprotocol\fR"
792 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
793 \fIProtocol\fP can be a number or one of the names
794 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
795 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
799 \fBiso proto \\\fIprotocol\fR
802 where \fIprotocol\fR is one of the above protocols.
803 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
804 Abbreviations for IS-IS PDU types.
805 .IP "\fBvpi\fP \fIn\fR"
806 True if the packet is an ATM packet, for SunATM on Solaris, with a
807 virtual path identifier of
809 .IP "\fBvci\fP \fIn\fR"
810 True if the packet is an ATM packet, for SunATM on Solaris, with a
811 virtual channel identifier of
814 True if the packet is an ATM packet, for SunATM on Solaris, and is
816 Note that the first \fBlane\fR keyword encountered in an expression
817 changes the tests done in the remainder of the expression
818 on the assumption that the packet is either a LANE emulated Ethernet
819 packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the
820 tests are done under the assumption that the packet is an
821 LLC-encapsulated packet.
823 True if the packet is an ATM packet, for SunATM on Solaris, and is
824 a segment OAM F4 flow cell (VPI=0 & VCI=3).
826 True if the packet is an ATM packet, for SunATM on Solaris, and is
827 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
829 True if the packet is an ATM packet, for SunATM on Solaris, and is
830 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
832 True if the packet is an ATM packet, for SunATM on Solaris, and is
833 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
835 True if the packet is an ATM packet, for SunATM on Solaris, and is
836 on a meta signaling circuit (VPI=0 & VCI=1).
838 True if the packet is an ATM packet, for SunATM on Solaris, and is
839 on a broadcast signaling circuit (VPI=0 & VCI=2).
841 True if the packet is an ATM packet, for SunATM on Solaris, and is
842 on a signaling circuit (VPI=0 & VCI=5).
844 True if the packet is an ATM packet, for SunATM on Solaris, and is
845 on an ILMI circuit (VPI=0 & VCI=16).
847 True if the packet is an ATM packet, for SunATM on Solaris, and is
848 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
849 Connect Ack, Release, or Release Done message.
850 .IP \fBmetaconnect\fP
851 True if the packet is an ATM packet, for SunATM on Solaris, and is
852 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
853 Release, or Release Done message.
854 .IP "\fIexpr relop expr\fR"
855 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =
856 or ==, !=, and \fIexpr\fR is an arithmetic expression composed of integer
857 constants (expressed in standard C syntax), the normal binary operators
858 [+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data
859 accessors. Note that all comparisons are unsigned, so that, for example,
860 0x80000000 and 0xffffffff are > 0.
862 The % and ^ operators are currently only supported for filtering in the
863 kernel on Linux with 3.7 and later kernels; on all other systems, if
864 those operators are used, filtering will be done in user mode, which
865 will increase the overhead of capturing packets and may cause more
866 packets to be dropped.
868 To access data inside the packet, use the following syntax:
871 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
895 indicates the protocol layer for the index operation.
905 link layer. \fBradio\fR refers to the "radio header" added to some
907 Note that \fBtcp\fR, \fBudp\fR and other upper-layer protocol types only
908 apply to IPv4, not IPv6 (this will be fixed in the future).
909 The byte offset, relative to the indicated protocol layer, is
911 \fISize\fR is optional and indicates the number of bytes in the
912 field of interest; it can be either one, two, or four, and defaults to one.
913 The length operator, indicated by the keyword \fBlen\fP, gives the
914 length of the packet.
916 For example, `\fBether[\fP0\fB] &\fP 1 \fB!=\fP 0' catches all multicast traffic.
917 The expression `\fBip[\fP0\fB] &\fP 0xf \fB!=\fP 5'
918 catches all IPv4 packets with options.
920 `\fBip[\fP6:2\fB] &\fP 0x1fff \fB=\fP 0'
921 catches only unfragmented IPv4 datagrams and frag zero of fragmented
923 This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
925 For instance, \fBtcp[\fP0\fB]\fP always means the first
926 byte of the TCP \fIheader\fP, and never means the first byte of an
927 intervening fragment.
929 Some offsets and field values may be expressed as names rather than
931 The following protocol header field offsets are
932 available: \fBicmptype\fP (ICMP type field), \fBicmp6type\fP (ICMPv6 type field),
933 \fBicmpcode\fP (ICMP code field), \fBicmp6code\fP (ICMPv6 code field) and
934 \fBtcpflags\fP (TCP flags field).
936 The following ICMP type field values are available: \fBicmp-echoreply\fP,
937 \fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP,
938 \fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP,
939 \fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP,
940 \fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP,
941 \fBicmp-maskreq\fP, \fBicmp-maskreply\fP.
943 The following ICMPv6 type fields are available: \fBicmp6-destinationrunreach\fP,
944 \fBicmp6-packettoobig\fP, \fBicmp6-timeexceeded\fP,
945 \fBicmp6-parameterproblem\fP, \fBicmp6-echo\fP,
946 \fBicmp6-echoreply\fP, \fBicmp6-multicastlistenerquery\fP,
947 \fBicmp6-multicastlistenerreportv1\fP, \fBicmp6-multicastlistenerdone\fP,
948 \fBicmp6-routersolicit\fP, \fBicmp6-routeradvert\fP,
949 \fBicmp6-neighborsolicit\fP, \fBicmp6-neighboradvert\fP, \fBicmp6-redirect\fP,
950 \fBicmp6-routerrenum\fP, \fBicmp6-nodeinformationquery\fP,
951 \fBicmp6-nodeinformationresponse\fP, \fBicmp6-ineighbordiscoverysolicit\fP,
952 \fBicmp6-ineighbordiscoveryadvert\fP, \fBicmp6-multicastlistenerreportv2\fP,
953 \fBicmp6-homeagentdiscoveryrequest\fP, \fBicmp6-homeagentdiscoveryreply\fP,
954 \fBicmp6-mobileprefixsolicit\fP, \fBicmp6-mobileprefixadvert\fP,
955 \fBicmp6-certpathsolicit\fP, \fBicmp6-certpathadvert\fP,
956 \fBicmp6-multicastrouteradvert\fP, \fBicmp6-multicastroutersolicit\fP,
957 \fBicmp6-multicastrouterterm\fP.
959 The following TCP flags field values are available: \fBtcp-fin\fP,
960 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
961 \fBtcp-ack\fP, \fBtcp-urg\fP, \fBtcp-ece\fP,
964 Primitives may be combined using:
966 A parenthesized group of primitives and operators.
968 Negation (`\fB!\fP' or `\fBnot\fP').
970 Concatenation (`\fB&&\fP' or `\fBand\fP').
972 Alternation (`\fB||\fP' or `\fBor\fP').
974 Negation has the highest precedence.
975 Alternation and concatenation have equal precedence and associate
977 Note that explicit \fBand\fR tokens, not juxtaposition,
978 are now required for concatenation.
980 If an identifier is given without a keyword, the most recent keyword
985 \fBnot host\fP vs \fBand\fR ace
991 \fBnot host\fP vs \fBand host\fR ace
994 which should not be confused with
997 \fBnot (host \fPvs\fB or \fPace\fB)\fR
1002 To select all packets arriving at or departing from `sundown':
1009 To select traffic between `helios' and either `hot' or `ace':
1012 \fBhost\fP helios \fBand (\fPhot \fBor\fP ace\fB)\fP
1016 To select all IPv4 packets between `ace' and any host except `helios':
1019 \fBip host\fP ace \fBand not\fP helios
1023 To select all traffic between local hosts and hosts at Berkeley:
1030 To select all FTP traffic through Internet gateway `snup':
1033 \fBgateway\fP snup \fBand (port\fP ftp \fBor\fP ftp-data\fB)\fP
1037 To select IPv4 traffic neither sourced from nor destined for local hosts
1038 (if you gateway to one other net, this stuff should never make it
1039 onto your local net).
1042 \fBip and not net \fPlocalnet
1046 To select the start and end packets (the SYN and FIN packets) of each
1047 TCP conversation that involves a non-local host.
1050 \fBtcp[tcpflags] & (tcp-syn|tcp-fin) !=\fP 0 \fBand not src and dst net\fP localnet
1054 To select the TCP packets with flags RST and ACK both set.
1055 (i.e. select only the RST and ACK flags in the flags field, and if the result
1056 is "RST and ACK both set", match)
1060 tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)
1064 To select all IPv4 HTTP packets to and from port 80, i.e. print only
1065 packets that contain data, not, for example, SYN and FIN packets and
1066 ACK-only packets. (IPv6 is left as an exercise for the reader.)
1069 \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)
1073 To select IPv4 packets longer than 576 bytes sent through gateway `snup':
1076 \fBgateway\fP snup \fBand ip[\fP2:2\fB] >\fP 576
1080 To select IPv4 broadcast or multicast packets that were
1082 sent via Ethernet broadcast or multicast:
1085 \fBether[\fP0\fB] &\fP 1 \fB=\fP 0 \fBand ip[\fP16\fB] >=\fP 224
1089 To select all ICMP packets that are not echo requests/replies (i.e., not
1094 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
1096 icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply
1102 To report a security issue please send an e-mail to \%security@tcpdump.org.
1104 To report bugs and other problems, contribute patches, request a
1105 feature, provide generic feedback etc please see the file
1107 in the libpcap source tree root.
1109 Filter expressions on fields other than those in Token Ring headers will
1110 not correctly handle source-routed Token Ring packets.
1112 Filter expressions on fields other than those in 802.11 headers will not
1113 correctly handle 802.11 data packets with both To DS and From DS set.
1116 should chase header chain, but at this moment it does not.
1117 `\fBip6 protochain\fP'
1118 is supplied for this behavior. For example, to match IPv6 fragments:
1119 `\fBip6 protochain\fP 44'
1121 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
1122 does not work against IPv6 packets.
1123 It only looks at IPv4 packets.