1 .\" @(#) $Header: /tcpdump/master/libpcap/pcap-filter.manmisc.in,v 1.1 2008-10-21 07:33:01 guy Exp $ (LBL)
3 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
4 .\" The Regents of the University of California. All rights reserved.
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that: (1) source code distributions
9 .\" retain the above copyright notice and this paragraph in its entirety, (2)
10 .\" distributions including binary code include the above copyright notice and
11 .\" this paragraph in its entirety in the documentation or other materials
12 .\" provided with the distribution, and (3) all advertising materials mentioning
13 .\" features or use of this software display the following acknowledgement:
14 .\" ``This product includes software developed by the University of California,
15 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 .\" the University nor the names of its contributors may be used to endorse
17 .\" or promote products derived from this software without specific prior
18 .\" written permission.
19 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 .TH PCAP-FILTER @MAN_MISC_INFO@ "6 January 2008"
25 pcap-filter \- packet filter syntax
31 is used to compile a string into a filter program.
32 The resulting filter program can then be applied to
33 some stream of packets to determine which packets will be supplied to
40 The \fIfilter expression\fP consists of one or more
42 Primitives usually consist of an
44 (name or number) preceded by one or more qualifiers.
46 different kinds of qualifier:
49 qualifiers say what kind of thing the id name or number refers to.
56 E.g., `host foo', `net 128.3', `port 20', `portrange 6000-6008'.
63 qualifiers specify a particular transfer direction to and/or from
65 Possible directions are
77 E.g., `src foo', `dst net 128.3', `src or dst port ftp-data'.
79 there is no dir qualifier,
90 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
91 For some link layers, such as SLIP and the ``cooked'' Linux capture mode
92 used for the ``any'' device and for some other device types, the
96 qualifiers can be used to specify a desired direction.
99 qualifiers restrict the match to a particular protocol.
114 E.g., `ether src foo', `arp net 128.3', `tcp port 21', `udp portrange
115 7000-7009', `wlan addr2 0:2:3:4:5:6'.
117 no proto qualifier, all protocols consistent with the type are
119 E.g., `src foo' means `(ip or arp or rarp) src foo'
120 (except the latter is not legal syntax), `net bar' means `(ip or
121 arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'.
123 [`fddi' is actually an alias for `ether'; the parser treats them
124 identically as meaning ``the data link level used on the specified
125 network interface.'' FDDI headers contain Ethernet-like source
126 and destination addresses, and often contain Ethernet-like packet
127 types, so you can filter on these FDDI fields just as with the
128 analogous Ethernet fields.
129 FDDI headers also contain other fields,
130 but you cannot name them explicitly in a filter expression.
132 Similarly, `tr' and `wlan' are aliases for `ether'; the previous
133 paragraph's statements about FDDI headers also apply to Token Ring
134 and 802.11 wireless LAN headers. For 802.11 headers, the destination
135 address is the DA field and the source address is the SA field; the
136 BSSID, RA, and TA fields aren't tested.]
138 In addition to the above, there are some special `primitive' keywords
139 that don't follow the pattern:
144 and arithmetic expressions.
145 All of these are described below.
147 More complex filter expressions are built up by using the words
152 to combine primitives.
153 E.g., `host foo and not port ftp and not port ftp-data'.
154 To save typing, identical qualifier lists can be omitted.
156 `tcp dst port ftp or ftp-data or domain' is exactly the same as
157 `tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'.
159 Allowable primitives are:
160 .IP "\fBdst host \fIhost\fR"
161 True if the IPv4/v6 destination field of the packet is \fIhost\fP,
162 which may be either an address or a name.
163 .IP "\fBsrc host \fIhost\fR"
164 True if the IPv4/v6 source field of the packet is \fIhost\fP.
165 .IP "\fBhost \fIhost\fP"
166 True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
168 Any of the above host expressions can be prepended with the keywords,
169 \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
172 \fBip host \fIhost\fR
175 which is equivalent to:
178 \fBether proto \fI\\ip\fB and host \fIhost\fR
181 If \fIhost\fR is a name with multiple IP addresses, each address will
182 be checked for a match.
183 .IP "\fBether dst \fIehost\fP"
184 True if the Ethernet destination address is \fIehost\fP.
186 may be either a name from /etc/ethers or a number (see
189 .IP "\fBether src \fIehost\fP"
190 True if the Ethernet source address is \fIehost\fP.
191 .IP "\fBether host \fIehost\fP"
192 True if either the Ethernet source or destination address is \fIehost\fP.
193 .IP "\fBgateway\fP \fIhost\fP"
194 True if the packet used \fIhost\fP as a gateway.
196 source or destination address was \fIhost\fP but neither the IP source
197 nor the IP destination was \fIhost\fP.
198 \fIHost\fP must be a name and
199 must be found both by the machine's host-name-to-IP-address resolution
200 mechanisms (host name file, DNS, NIS, etc.) and by the machine's
201 host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
202 (An equivalent expression is
205 \fBether host \fIehost \fBand not host \fIhost\fR
208 which can be used with either names or numbers for \fIhost / ehost\fP.)
209 This syntax does not work in IPv6-enabled configuration at this moment.
210 .IP "\fBdst net \fInet\fR"
211 True if the IPv4/v6 destination address of the packet has a network
213 \fINet\fP may be either a name from the networks database
214 (/etc/networks, etc.) or a network number.
215 An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0),
216 dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single
217 number (e.g., 10); the netmask is 255.255.255.255 for a dotted quad
218 (which means that it's really a host match), 255.255.255.0 for a dotted
219 triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number.
220 An IPv6 network number must be written out fully; the netmask is
221 ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always
222 host matches, and a network match requires a netmask length.
223 .IP "\fBsrc net \fInet\fR"
224 True if the IPv4/v6 source address of the packet has a network
226 .IP "\fBnet \fInet\fR"
227 True if either the IPv4/v6 source or destination address of the packet has a network
229 .IP "\fBnet \fInet\fR \fBmask \fInetmask\fR"
230 True if the IPv4 address matches \fInet\fR with the specific \fInetmask\fR.
231 May be qualified with \fBsrc\fR or \fBdst\fR.
232 Note that this syntax is not valid for IPv6 \fInet\fR.
233 .IP "\fBnet \fInet\fR/\fIlen\fR"
234 True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR
236 May be qualified with \fBsrc\fR or \fBdst\fR.
237 .IP "\fBdst port \fIport\fR"
238 True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
239 destination port value of \fIport\fP.
240 The \fIport\fP can be a number or a name used in /etc/services (see
244 If a name is used, both the port
245 number and protocol are checked.
246 If a number or ambiguous name is used,
247 only the port number is checked (e.g., \fBdst port 513\fR will print both
248 tcp/login traffic and udp/who traffic, and \fBport domain\fR will print
249 both tcp/domain and udp/domain traffic).
250 .IP "\fBsrc port \fIport\fR"
251 True if the packet has a source port value of \fIport\fP.
252 .IP "\fBport \fIport\fR"
253 True if either the source or destination port of the packet is \fIport\fP.
254 .IP "\fBdst portrange \fIport1\fB-\fIport2\fR"
255 True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
256 destination port value between \fIport1\fP and \fIport2\fP.
260 are interpreted in the same fashion as the
264 .IP "\fBsrc portrange \fIport1\fB-\fIport2\fR"
265 True if the packet has a source port value between \fIport1\fP and
267 .IP "\fBportrange \fIport1\fB-\fIport2\fR"
268 True if either the source or destination port of the packet is between
269 \fIport1\fP and \fIport2\fP.
271 Any of the above port or port range expressions can be prepended with
272 the keywords, \fBtcp\fP or \fBudp\fP, as in:
275 \fBtcp src port \fIport\fR
278 which matches only tcp packets whose source port is \fIport\fP.
279 .IP "\fBless \fIlength\fR"
280 True if the packet has a length less than or equal to \fIlength\fP.
281 This is equivalent to:
284 \fBlen <= \fIlength\fP.
287 .IP "\fBgreater \fIlength\fR"
288 True if the packet has a length greater than or equal to \fIlength\fP.
289 This is equivalent to:
292 \fBlen >= \fIlength\fP.
295 .IP "\fBip proto \fIprotocol\fR"
296 True if the packet is an IPv4 packet (see
298 of protocol type \fIprotocol\fP.
299 \fIProtocol\fP can be a number or one of the names
300 \fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
301 \fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
302 Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
303 keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
304 Note that this primitive does not chase the protocol header chain.
305 .IP "\fBip6 proto \fIprotocol\fR"
306 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
307 Note that this primitive does not chase the protocol header chain.
308 .IP "\fBproto \fIprotocol\fR"
309 True if the packet is an IPv4 or IPv6 packet of protocol type
310 \fIprotocol\fP. Note that this primitive does not chase the protocol
312 .IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
319 where \fIp\fR is one of the above protocols.
320 .IP "\fBip6 protochain \fIprotocol\fR"
321 True if the packet is IPv6 packet,
322 and contains protocol header with type \fIprotocol\fR
323 in its protocol header chain.
327 \fBip6 protochain 6\fR
330 matches any IPv6 packet with TCP protocol header in the protocol header chain.
331 The packet may contain, for example,
332 authentication header, routing header, or hop-by-hop option header,
333 between IPv6 header and TCP header.
334 The BPF code emitted by this primitive is complex and
335 cannot be optimized by the BPF optimizer code, so this can be somewhat
337 .IP "\fBip protochain \fIprotocol\fR"
338 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
339 .IP "\fBprotochain \fIprotocol\fR"
340 True if the packet is an IPv4 or IPv6 packet of protocol type
341 \fIprotocol\fP. Note that this primitive chases the protocol
343 .IP "\fBether broadcast\fR"
344 True if the packet is an Ethernet broadcast packet.
347 .IP "\fBip broadcast\fR"
348 True if the packet is an IPv4 broadcast packet.
349 It checks for both the all-zeroes and all-ones broadcast conventions,
350 and looks up the subnet mask on the interface on which the capture is
353 If the subnet mask of the interface on which the capture is being done
354 is not available, either because the interface on which capture is being
355 done has no netmask or because the capture is being done on the Linux
356 "any" interface, which can capture on more than one interface, this
357 check will not work correctly.
358 .IP "\fBether multicast\fR"
359 True if the packet is an Ethernet multicast packet.
362 This is shorthand for `\fBether[0] & 1 != 0\fP'.
363 .IP "\fBip multicast\fR"
364 True if the packet is an IPv4 multicast packet.
365 .IP "\fBip6 multicast\fR"
366 True if the packet is an IPv6 multicast packet.
367 .IP "\fBether proto \fIprotocol\fR"
368 True if the packet is of ether type \fIprotocol\fR.
369 \fIProtocol\fP can be a number or one of the names
370 \fBip\fP, \fBip6\fP, \fBarp\fP, \fBrarp\fP, \fBatalk\fP, \fBaarp\fP,
371 \fBdecnet\fP, \fBsca\fP, \fBlat\fP, \fBmopdl\fP, \fBmoprc\fP,
372 \fBiso\fP, \fBstp\fP, \fBipx\fP, or \fBnetbeui\fP.
373 Note these identifiers are also keywords
374 and must be escaped via backslash (\\).
376 [In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), Token Ring
377 (e.g., `\fBtr protocol arp\fR'), and IEEE 802.11 wireless LANS (e.g.,
378 `\fBwlan protocol arp\fR'), for most of those protocols, the
379 protocol identification comes from the 802.2 Logical Link Control (LLC)
380 header, which is usually layered on top of the FDDI, Token Ring, or
383 When filtering for most protocol identifiers on FDDI, Token Ring, or
384 802.11, the filter checks only the protocol ID field of an LLC header
385 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
386 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
387 is in SNAP format with an OUI of 0x000000.
392 the filter checks the DSAP (Destination Service Access Point) and
393 SSAP (Source Service Access Point) fields of the LLC header;
395 \fBstp\fP and \fBnetbeui\fP
396 the filter checks the DSAP of the LLC header;
399 the filter checks for a SNAP-format packet with an OUI of 0x080007
400 and the AppleTalk etype.
403 In the case of Ethernet, the filter checks the Ethernet type field
404 for most of those protocols. The exceptions are:
407 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
408 the filter checks for an 802.3 frame and then checks the LLC header as
409 it does for FDDI, Token Ring, and 802.11;
412 the filter checks both for the AppleTalk etype in an Ethernet frame and
413 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
416 the filter checks for the AppleTalk ARP etype in either an Ethernet
417 frame or an 802.2 SNAP frame with an OUI of 0x000000;
420 the filter checks for the IPX etype in an Ethernet frame, the IPX
421 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
422 IPX, and the IPX etype in a SNAP frame.
424 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
428 \fBether proto \fIp\fR
431 where \fIp\fR is one of the above protocols.
432 .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
436 \fBether proto \fIp\fR
439 where \fIp\fR is one of the above protocols.
440 Note that not all applications using
442 currently know how to parse these protocols.
443 .IP "\fBdecnet src \fIhost\fR"
444 True if the DECNET source address is
446 which may be an address of the form ``10.123'', or a DECNET host
448 [DECNET host name support is only available on ULTRIX systems
449 that are configured to run DECNET.]
450 .IP "\fBdecnet dst \fIhost\fR"
451 True if the DECNET destination address is
453 .IP "\fBdecnet host \fIhost\fR"
454 True if either the DECNET source or destination address is
456 .IP "\fBifname \fIinterface\fR"
457 True if the packet was logged as coming from the specified interface (applies
458 only to packets logged by OpenBSD's or FreeBSD's
460 .IP "\fBon \fIinterface\fR"
464 .IP "\fBrnr \fInum\fR"
465 True if the packet was logged as matching the specified PF rule number
466 (applies only to packets logged by OpenBSD's or FreeBSD's
468 .IP "\fBrulenum \fInum\fR"
472 .IP "\fBreason \fIcode\fR"
473 True if the packet was logged with the specified PF reason code. The known
482 (applies only to packets logged by OpenBSD's or FreeBSD's
484 .IP "\fBrset \fIname\fR"
485 True if the packet was logged as matching the specified PF ruleset
486 name of an anchored ruleset (applies only to packets logged by OpenBSD's
489 .IP "\fBruleset \fIname\fR"
493 .IP "\fBsrnr \fInum\fR"
494 True if the packet was logged as matching the specified PF rule number
495 of an anchored ruleset (applies only to packets logged by OpenBSD's or
498 .IP "\fBsubrulenum \fInum\fR"
502 .IP "\fBaction \fIact\fR"
503 True if PF took the specified action when the packet was logged. Known actions
508 and, with later versions of
515 (applies only to packets logged by OpenBSD's or FreeBSD's
517 .IP "\fBwlan ra \fIehost\fR"
518 True if the IEEE 802.11 RA is
520 The RA field is used in all frames except for management frames.
521 .IP "\fBwlan ta \fIehost\fR"
522 True if the IEEE 802.11 TA is
524 The TA field is used in all frames except for management frames and
525 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
526 .IP "\fBwlan addr1 \fIehost\fR"
527 True if the first IEEE 802.11 address is
529 .IP "\fBwlan addr2 \fIehost\fR"
530 True if the second IEEE 802.11 address, if present, is
532 The second address field is used in all frames except for CTS (Clear To
533 Send) and ACK (Acknowledgment) control frames.
534 .IP "\fBwlan addr3 \fIehost\fR"
535 True if the third IEEE 802.11 address, if present, is
537 The third address field is used in management and data frames, but not
539 .IP "\fBwlan addr4 \fIehost\fR"
540 True if the fourth IEEE 802.11 address, if present, is
542 The fourth address field is only used for
543 WDS (Wireless Distribution System) frames.
544 .IP "\fBtype \fIwlan_type\fR"
545 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
546 Valid \fIwlan_type\fRs are:
550 .IP "\fBtype \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
551 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
552 and frame subtype matches the specified \fIwlan_subtype\fR.
554 If the specified \fIwlan_type\fR is \fBmgt\fP,
555 then valid \fIwlan_subtype\fRs are:
568 If the specified \fIwlan_type\fR is \fBctl\fP,
569 then valid \fIwlan_subtype\fRs are:
577 If the specified \fIwlan_type\fR is \fBdata\fP,
578 then valid \fIwlan_subtype\fRs are:
582 \fBdata-cf-ack-poll\fP,
588 \fBqos-data-cf-ack\fP,
589 \fBqos-data-cf-poll\fP,
590 \fBqos-data-cf-ack-poll\fP,
592 \fBqos-cf-poll\fP and
593 \fBqos-cf-ack-poll\fP.
594 .IP "\fBsubtype \fIwlan_subtype\fR"
595 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
596 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
597 .IP "\fBdir \fIdir\fR"
598 True if the IEEE 802.11 frame direction matches the specified
600 Valid directions are:
606 .IP "\fBvlan \fI[vlan_id]\fR"
607 True if the packet is an IEEE 802.1Q VLAN packet.
608 If \fI[vlan_id]\fR is specified, only true if the packet has the specified
610 Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
611 changes the decoding offsets for the remainder of \fIexpression\fR on
612 the assumption that the packet is a VLAN packet. The \fBvlan
613 \fI[vlan_id]\fR expression may be used more than once, to filter on VLAN
614 hierarchies. Each use of that expression increments the filter offsets
620 \fBvlan 100 && vlan 200\fR
623 filters on VLAN 200 encapsulated within VLAN 100, and
626 \fBvlan && vlan 300 && ip\fR
629 filters IPv4 protocols encapsulated in VLAN 300 encapsulated within any
631 .IP "\fBmpls \fI[label_num]\fR"
632 True if the packet is an MPLS packet.
633 If \fI[label_num]\fR is specified, only true is the packet has the specified
635 Note that the first \fBmpls\fR keyword encountered in \fIexpression\fR
636 changes the decoding offsets for the remainder of \fIexpression\fR on
637 the assumption that the packet is a MPLS-encapsulated IP packet. The
638 \fBmpls \fI[label_num]\fR expression may be used more than once, to
639 filter on MPLS hierarchies. Each use of that expression increments the
645 \fBmpls 100000 && mpls 1024\fR
648 filters packets with an outer label of 100000 and an inner label of
652 \fBmpls && mpls 1024 && host 192.9.200.1\fR
655 filters packets to or from 192.9.200.1 with an inner label of 1024 and
658 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
661 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
663 Note that the first \fBpppoes\fR keyword encountered in \fIexpression\fR
664 changes the decoding offsets for the remainder of \fIexpression\fR on
665 the assumption that the packet is a PPPoE session packet.
673 filters IPv4 protocols encapsulated in PPPoE.
674 .IP "\fBiso proto \fIprotocol\fR"
675 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
676 \fIProtocol\fP can be a number or one of the names
677 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
678 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
685 where \fIp\fR is one of the above protocols.
686 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
687 Abbreviations for IS-IS PDU types.
688 .IP "\fBvpi\fP \fIn\fR"
689 True if the packet is an ATM packet, for SunATM on Solaris, with a
690 virtual path identifier of
692 .IP "\fBvci\fP \fIn\fR"
693 True if the packet is an ATM packet, for SunATM on Solaris, with a
694 virtual channel identifier of
697 True if the packet is an ATM packet, for SunATM on Solaris, and is
699 Note that the first \fBlane\fR keyword encountered in \fIexpression\fR
700 changes the tests done in the remainder of \fIexpression\fR
701 on the assumption that the packet is either a LANE emulated Ethernet
702 packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the
703 tests are done under the assumption that the packet is an
704 LLC-encapsulated packet.
706 True if the packet is an ATM packet, for SunATM on Solaris, and is
707 an LLC-encapsulated packet.
709 True if the packet is an ATM packet, for SunATM on Solaris, and is
710 a segment OAM F4 flow cell (VPI=0 & VCI=3).
712 True if the packet is an ATM packet, for SunATM on Solaris, and is
713 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
715 True if the packet is an ATM packet, for SunATM on Solaris, and is
716 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
718 True if the packet is an ATM packet, for SunATM on Solaris, and is
719 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
721 True if the packet is an ATM packet, for SunATM on Solaris, and is
722 on a meta signaling circuit (VPI=0 & VCI=1).
724 True if the packet is an ATM packet, for SunATM on Solaris, and is
725 on a broadcast signaling circuit (VPI=0 & VCI=2).
727 True if the packet is an ATM packet, for SunATM on Solaris, and is
728 on a signaling circuit (VPI=0 & VCI=5).
730 True if the packet is an ATM packet, for SunATM on Solaris, and is
731 on an ILMI circuit (VPI=0 & VCI=16).
733 True if the packet is an ATM packet, for SunATM on Solaris, and is
734 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
735 Connect Ack, Release, or Release Done message.
736 .IP \fBmetaconnect\fP
737 True if the packet is an ATM packet, for SunATM on Solaris, and is
738 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
739 Release, or Release Done message.
740 .IP "\fIexpr relop expr\fR"
741 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
742 !=, and \fIexpr\fR is an arithmetic expression composed of integer
743 constants (expressed in standard C syntax), the normal binary operators
744 [+, -, *, /, &, |, <<, >>], a length operator, and special packet data
745 accessors. Note that all comparisons are unsigned, so that, for example,
746 0x80000000 and 0xffffffff are > 0.
748 data inside the packet, use the following syntax:
751 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
754 \fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
755 ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and
756 indicates the protocol layer for the index operation.
757 (\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
758 link layer. \fBradio\fR refers to the "radio header" added to some
760 Note that \fItcp, udp\fR and other upper-layer protocol types only
761 apply to IPv4, not IPv6 (this will be fixed in the future).
762 The byte offset, relative to the indicated protocol layer, is
764 \fISize\fR is optional and indicates the number of bytes in the
765 field of interest; it can be either one, two, or four, and defaults to one.
766 The length operator, indicated by the keyword \fBlen\fP, gives the
767 length of the packet.
769 For example, `\fBether[0] & 1 != 0\fP' catches all multicast traffic.
770 The expression `\fBip[0] & 0xf != 5\fP'
771 catches all IPv4 packets with options.
773 `\fBip[6:2] & 0x1fff = 0\fP'
774 catches only unfragmented IPv4 datagrams and frag zero of fragmented
776 This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
778 For instance, \fBtcp[0]\fP always means the first
779 byte of the TCP \fIheader\fP, and never means the first byte of an
780 intervening fragment.
782 Some offsets and field values may be expressed as names rather than
784 The following protocol header field offsets are
785 available: \fBicmptype\fP (ICMP type field), \fBicmpcode\fP (ICMP
786 code field), and \fBtcpflags\fP (TCP flags field).
788 The following ICMP type field values are available: \fBicmp-echoreply\fP,
789 \fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP,
790 \fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP,
791 \fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP,
792 \fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP,
793 \fBicmp-maskreq\fP, \fBicmp-maskreply\fP.
795 The following TCP flags field values are available: \fBtcp-fin\fP,
796 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
797 \fBtcp-ack\fP, \fBtcp-urg\fP.
799 Primitives may be combined using:
801 A parenthesized group of primitives and operators
802 (parentheses are special to the Shell and must be escaped).
804 Negation (`\fB!\fP' or `\fBnot\fP').
806 Concatenation (`\fB&&\fP' or `\fBand\fP').
808 Alternation (`\fB||\fP' or `\fBor\fP').
810 Negation has highest precedence.
811 Alternation and concatenation have equal precedence and associate
813 Note that explicit \fBand\fR tokens, not juxtaposition,
814 are now required for concatenation.
816 If an identifier is given without a keyword, the most recent keyword
821 \fBnot host vs and ace\fR
827 \fBnot host vs and host ace\fR
830 which should not be confused with
833 \fBnot ( host vs or ace )\fR
838 To select all packets arriving at or departing from \fIsundown\fP:
845 To select traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR:
848 \fBhost helios and \\( hot or ace \\)\fP
852 To select all IP packets between \fIace\fR and any host except \fIhelios\fR:
855 \fBip host ace and not helios\fP
859 To select all traffic between local hosts and hosts at Berkeley:
867 To select all ftp traffic through internet gateway \fIsnup\fP:
871 gateway snup and (port ftp or ftp-data)
875 To select traffic neither sourced from nor destined for local hosts
876 (if you gateway to one other net, this stuff should never make it
877 onto your local net).
881 ip and not net \fIlocalnet\fP
885 To select the start and end packets (the SYN and FIN packets) of each
886 TCP conversation that involves a non-local host.
890 tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP
894 To select all IPv4 HTTP packets to and from port 80, i.e. print only
895 packets that contain data, not, for example, SYN and FIN packets and
896 ACK-only packets. (IPv6 is left as an exercise for the reader.)
900 tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)
904 To select IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
908 gateway snup and ip[2:2] > 576
912 To select IP broadcast or multicast packets that were
914 sent via Ethernet broadcast or multicast:
918 ether[0] & 1 = 0 and ip[16] >= 224
922 To select all ICMP packets that are not echo requests/replies (i.e., not
927 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
933 Please send problems, bugs, questions, desirable enhancements, etc. to:
936 tcpdump-workers@lists.tcpdump.org
939 Filter expressions on fields other than those in Token Ring headers will
940 not correctly handle source-routed Token Ring packets.
942 Filter expressions on fields other than those in 802.11 headers will not
943 correctly handle 802.11 data packets with both To DS and From DS set.
946 should chase header chain, but at this moment it does not.
948 is supplied for this behavior.
950 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
951 does not work against IPv6 packets.
952 It only looks at IPv4 packets.