drm/i915: Use the Linux workqueue API
[dragonfly.git] / contrib / libpcap / pcap-filter.manmisc.in
1 .\" @(#) $Header: /tcpdump/master/libpcap/pcap-filter.manmisc.in,v 1.1 2008-10-21 07:33:01 guy Exp $ (LBL)
2 .\"
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.
6 .\"
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.
22 .\"
23 .TH PCAP-FILTER @MAN_MISC_INFO@ "6 January 2008"
24 .SH NAME
25 pcap-filter \- packet filter syntax
26 .br
27 .ad
28 .SH DESCRIPTION
29 .LP
30 .B pcap_compile()
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
34 .BR pcap_loop() ,
35 .BR pcap_dispatch() ,
36 .BR pcap_next() ,
37 or
38 .BR pcap_next_ex() .
39 .LP
40 The \fIfilter expression\fP consists of one or more
41 .IR primitives .
42 Primitives usually consist of an
43 .I id
44 (name or number) preceded by one or more qualifiers.
45 There are three
46 different kinds of qualifier:
47 .IP \fItype\fP
48 qualifiers say what kind of thing the id name or number refers to.
49 Possible types are
50 .BR host ,
51 .B net ,
52 .B port
53 and
54 .BR portrange .
55 E.g., `host foo', `net 128.3', `port 20', `portrange 6000-6008'.
56 If there is no type
57 qualifier,
58 .B host
59 is assumed.
60 .IP \fIdir\fP
61 qualifiers specify a particular transfer direction to and/or from
62 .IR id .
63 Possible directions are
64 .BR src ,
65 .BR dst ,
66 .BR "src or dst" ,
67 .BR "src and dst" ,
68 .BR ra ,
69 .BR ta ,
70 .BR addr1 ,
71 .BR addr2 ,
72 .BR addr3 ,
73 and
74 .BR addr4 .
75 E.g., `src foo', `dst net 128.3', `src or dst port ftp-data'.
76 If
77 there is no dir qualifier,
78 .B "src or dst"
79 is assumed.
80 The
81 .BR ra ,
82 .BR ta ,
83 .BR addr1 ,
84 .BR addr2 ,
85 .BR addr3 ,
86 and
87 .B addr4
88 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
89 For some link layers, such as SLIP and the ``cooked'' Linux capture mode
90 used for the ``any'' device and for some other device types, the
91 .B inbound
92 and
93 .B outbound
94 qualifiers can be used to specify a desired direction.
95 .IP \fIproto\fP
96 qualifiers restrict the match to a particular protocol.
97 Possible
98 protos are:
99 .BR ether ,
100 .BR fddi ,
101 .BR tr ,
102 .BR wlan ,
103 .BR ip ,
104 .BR ip6 ,
105 .BR arp ,
106 .BR rarp ,
107 .BR decnet ,
108 .B tcp
109 and
110 .BR udp .
111 E.g., `ether src foo', `arp net 128.3', `tcp port 21', `udp portrange
112 7000-7009', `wlan addr2 0:2:3:4:5:6'.
113 If there is
114 no proto qualifier, all protocols consistent with the type are
115 assumed.
116 E.g., `src foo' means `(ip or arp or rarp) src foo'
117 (except the latter is not legal syntax), `net bar' means `(ip or
118 arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'.
119 .LP
120 [`fddi' is actually an alias for `ether'; the parser treats them
121 identically as meaning ``the data link level used on the specified
122 network interface.''  FDDI headers contain Ethernet-like source
123 and destination addresses, and often contain Ethernet-like packet
124 types, so you can filter on these FDDI fields just as with the
125 analogous Ethernet fields.
126 FDDI headers also contain other fields,
127 but you cannot name them explicitly in a filter expression.
128 .LP
129 Similarly, `tr' and `wlan' are aliases for `ether'; the previous
130 paragraph's statements about FDDI headers also apply to Token Ring
131 and 802.11 wireless LAN headers.  For 802.11 headers, the destination
132 address is the DA field and the source address is the SA field; the
133 BSSID, RA, and TA fields aren't tested.]
134 .LP
135 In addition to the above, there are some special `primitive' keywords
136 that don't follow the pattern:
137 .BR gateway ,
138 .BR broadcast ,
139 .BR less ,
140 .B greater
141 and arithmetic expressions.
142 All of these are described below.
143 .LP
144 More complex filter expressions are built up by using the words
145 .BR and ,
146 .B or
147 and
148 .B not
149 to combine primitives.
150 E.g., `host foo and not port ftp and not port ftp-data'.
151 To save typing, identical qualifier lists can be omitted.
152 E.g.,
153 `tcp dst port ftp or ftp-data or domain' is exactly the same as
154 `tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'.
155 .LP
156 Allowable primitives are:
157 .IP "\fBdst host \fIhost\fR"
158 True if the IPv4/v6 destination field of the packet is \fIhost\fP,
159 which may be either an address or a name.
160 .IP "\fBsrc host \fIhost\fR"
161 True if the IPv4/v6 source field of the packet is \fIhost\fP.
162 .IP "\fBhost \fIhost\fP
163 True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
164 .IP
165 Any of the above host expressions can be prepended with the keywords,
166 \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
167 .in +.5i
168 .nf
169 \fBip host \fIhost\fR
170 .fi
171 .in -.5i
172 which is equivalent to:
173 .in +.5i
174 .nf
175 \fBether proto \fI\\ip\fB and host \fIhost\fR
176 .fi
177 .in -.5i
178 If \fIhost\fR is a name with multiple IP addresses, each address will
179 be checked for a match.
180 .IP "\fBether dst \fIehost\fP
181 True if the Ethernet destination address is \fIehost\fP.
182 \fIEhost\fP
183 may be either a name from /etc/ethers or a number (see
184 .IR ethers (3N)
185 for numeric format).
186 .IP "\fBether src \fIehost\fP
187 True if the Ethernet source address is \fIehost\fP.
188 .IP "\fBether host \fIehost\fP
189 True if either the Ethernet source or destination address is \fIehost\fP.
190 .IP "\fBgateway\fP \fIhost\fP
191 True if the packet used \fIhost\fP as a gateway.
192 I.e., the Ethernet
193 source or destination address was \fIhost\fP but neither the IP source
194 nor the IP destination was \fIhost\fP.
195 \fIHost\fP must be a name and
196 must be found both by the machine's host-name-to-IP-address resolution
197 mechanisms (host name file, DNS, NIS, etc.) and by the machine's
198 host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
199 (An equivalent expression is
200 .in +.5i
201 .nf
202 \fBether host \fIehost \fBand not host \fIhost\fR
203 .fi
204 .in -.5i
205 which can be used with either names or numbers for \fIhost / ehost\fP.)
206 This syntax does not work in IPv6-enabled configuration at this moment.
207 .IP "\fBdst net \fInet\fR"
208 True if the IPv4/v6 destination address of the packet has a network
209 number of \fInet\fP.
210 \fINet\fP may be either a name from the networks database
211 (/etc/networks, etc.) or a network number.
212 An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0),
213 dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single
214 number (e.g., 10); the netmask is 255.255.255.255 for a dotted quad
215 (which means that it's really a host match), 255.255.255.0 for a dotted
216 triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number.
217 An IPv6 network number must be written out fully; the netmask is
218 ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always
219 host matches, and a network match requires a netmask length.
220 .IP "\fBsrc net \fInet\fR"
221 True if the IPv4/v6 source address of the packet has a network
222 number of \fInet\fP.
223 .IP "\fBnet \fInet\fR"
224 True if either the IPv4/v6 source or destination address of the packet has a network
225 number of \fInet\fP.
226 .IP "\fBnet \fInet\fR \fBmask \fInetmask\fR"
227 True if the IPv4 address matches \fInet\fR with the specific \fInetmask\fR.
228 May be qualified with \fBsrc\fR or \fBdst\fR.
229 Note that this syntax is not valid for IPv6 \fInet\fR.
230 .IP "\fBnet \fInet\fR/\fIlen\fR"
231 True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR
232 bits wide.
233 May be qualified with \fBsrc\fR or \fBdst\fR.
234 .IP "\fBdst port \fIport\fR"
235 True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
236 destination port value of \fIport\fP.
237 The \fIport\fP can be a number or a name used in /etc/services (see
238 .IR tcp (4P)
239 and
240 .IR udp (4P)).
241 If a name is used, both the port
242 number and protocol are checked.
243 If a number or ambiguous name is used,
244 only the port number is checked (e.g., \fBdst port 513\fR will print both
245 tcp/login traffic and udp/who traffic, and \fBport domain\fR will print
246 both tcp/domain and udp/domain traffic).
247 .IP "\fBsrc port \fIport\fR"
248 True if the packet has a source port value of \fIport\fP.
249 .IP "\fBport \fIport\fR"
250 True if either the source or destination port of the packet is \fIport\fP.
251 .IP "\fBdst portrange \fIport1\fB-\fIport2\fR"
252 True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
253 destination port value between \fIport1\fP and \fIport2\fP.
254 .I port1
255 and
256 .I port2
257 are interpreted in the same fashion as the
258 .I port
259 parameter for
260 .BR port .
261 .IP "\fBsrc portrange \fIport1\fB-\fIport2\fR"
262 True if the packet has a source port value between \fIport1\fP and
263 \fIport2\fP.
264 .IP "\fBportrange \fIport1\fB-\fIport2\fR"
265 True if either the source or destination port of the packet is between
266 \fIport1\fP and \fIport2\fP.
267 .IP
268 Any of the above port or port range expressions can be prepended with
269 the keywords, \fBtcp\fP or \fBudp\fP, as in:
270 .in +.5i
271 .nf
272 \fBtcp src port \fIport\fR
273 .fi
274 .in -.5i
275 which matches only tcp packets whose source port is \fIport\fP.
276 .IP "\fBless \fIlength\fR"
277 True if the packet has a length less than or equal to \fIlength\fP.
278 This is equivalent to:
279 .in +.5i
280 .nf
281 \fBlen <= \fIlength\fP.
282 .fi
283 .in -.5i
284 .IP "\fBgreater \fIlength\fR"
285 True if the packet has a length greater than or equal to \fIlength\fP.
286 This is equivalent to:
287 .in +.5i
288 .nf
289 \fBlen >= \fIlength\fP.
290 .fi
291 .in -.5i
292 .IP "\fBip proto \fIprotocol\fR"
293 True if the packet is an IPv4 packet (see
294 .IR ip (4P))
295 of protocol type \fIprotocol\fP.
296 \fIProtocol\fP can be a number or one of the names
297 \fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
298 \fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
299 Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
300 keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
301 Note that this primitive does not chase the protocol header chain.
302 .IP "\fBip6 proto \fIprotocol\fR"
303 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
304 Note that this primitive does not chase the protocol header chain.
305 .IP "\fBip6 protochain \fIprotocol\fR"
306 True if the packet is IPv6 packet,
307 and contains protocol header with type \fIprotocol\fR
308 in its protocol header chain.
309 For example,
310 .in +.5i
311 .nf
312 \fBip6 protochain 6\fR
313 .fi
314 .in -.5i
315 matches any IPv6 packet with TCP protocol header in the protocol header chain.
316 The packet may contain, for example,
317 authentication header, routing header, or hop-by-hop option header,
318 between IPv6 header and TCP header.
319 The BPF code emitted by this primitive is complex and
320 cannot be optimized by the BPF optimizer code, so this can be somewhat
321 slow.
322 .IP "\fBip protochain \fIprotocol\fR"
323 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
324 .IP "\fBether broadcast\fR"
325 True if the packet is an Ethernet broadcast packet.
326 The \fIether\fP
327 keyword is optional.
328 .IP "\fBip broadcast\fR"
329 True if the packet is an IPv4 broadcast packet.
330 It checks for both the all-zeroes and all-ones broadcast conventions,
331 and looks up the subnet mask on the interface on which the capture is
332 being done.
333 .IP
334 If the subnet mask of the interface on which the capture is being done
335 is not available, either because the interface on which capture is being
336 done has no netmask or because the capture is being done on the Linux
337 "any" interface, which can capture on more than one interface, this
338 check will not work correctly.
339 .IP "\fBether multicast\fR"
340 True if the packet is an Ethernet multicast packet.
341 The \fBether\fP
342 keyword is optional.
343 This is shorthand for `\fBether[0] & 1 != 0\fP'.
344 .IP "\fBip multicast\fR"
345 True if the packet is an IPv4 multicast packet.
346 .IP "\fBip6 multicast\fR"
347 True if the packet is an IPv6 multicast packet.
348 .IP  "\fBether proto \fIprotocol\fR"
349 True if the packet is of ether type \fIprotocol\fR.
350 \fIProtocol\fP can be a number or one of the names
351 \fBip\fP, \fBip6\fP, \fBarp\fP, \fBrarp\fP, \fBatalk\fP, \fBaarp\fP,
352 \fBdecnet\fP, \fBsca\fP, \fBlat\fP, \fBmopdl\fP, \fBmoprc\fP,
353 \fBiso\fP, \fBstp\fP, \fBipx\fP, or \fBnetbeui\fP.
354 Note these identifiers are also keywords
355 and must be escaped via backslash (\\).
356 .IP
357 [In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), Token Ring
358 (e.g., `\fBtr protocol arp\fR'), and IEEE 802.11 wireless LANS (e.g.,
359 `\fBwlan protocol arp\fR'), for most of those protocols, the
360 protocol identification comes from the 802.2 Logical Link Control (LLC)
361 header, which is usually layered on top of the FDDI, Token Ring, or
362 802.11 header.
363 .IP
364 When filtering for most protocol identifiers on FDDI, Token Ring, or
365 802.11, the filter checks only the protocol ID field of an LLC header
366 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
367 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
368 is in SNAP format with an OUI of 0x000000.
369 The exceptions are:
370 .RS
371 .TP
372 \fBiso\fP
373 the filter checks the DSAP (Destination Service Access Point) and
374 SSAP (Source Service Access Point) fields of the LLC header;
375 .TP
376 \fBstp\fP and \fBnetbeui\fP
377 the filter checks the DSAP of the LLC header;
378 .TP
379 \fBatalk\fP
380 the filter checks for a SNAP-format packet with an OUI of 0x080007
381 and the AppleTalk etype.
382 .RE
383 .IP
384 In the case of Ethernet, the filter checks the Ethernet type field
385 for most of those protocols.  The exceptions are:
386 .RS
387 .TP
388 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
389 the filter checks for an 802.3 frame and then checks the LLC header as
390 it does for FDDI, Token Ring, and 802.11;
391 .TP
392 \fBatalk\fP
393 the filter checks both for the AppleTalk etype in an Ethernet frame and
394 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
395 .TP
396 \fBaarp\fP
397 the filter checks for the AppleTalk ARP etype in either an Ethernet
398 frame or an 802.2 SNAP frame with an OUI of 0x000000;
399 .TP
400 \fBipx\fP
401 the filter checks for the IPX etype in an Ethernet frame, the IPX
402 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
403 IPX, and the IPX etype in a SNAP frame.
404 .RE
405 .IP "\fBdecnet src \fIhost\fR"
406 True if the DECNET source address is
407 .IR host ,
408 which may be an address of the form ``10.123'', or a DECNET host
409 name.
410 [DECNET host name support is only available on ULTRIX systems
411 that are configured to run DECNET.]
412 .IP "\fBdecnet dst \fIhost\fR"
413 True if the DECNET destination address is
414 .IR host .
415 .IP "\fBdecnet host \fIhost\fR"
416 True if either the DECNET source or destination address is
417 .IR host .
418 .IP "\fBifname \fIinterface\fR"
419 True if the packet was logged as coming from the specified interface (applies
420 only to packets logged by OpenBSD's or FreeBSD's
421 .BR pf (4)).
422 .IP "\fBon \fIinterface\fR"
423 Synonymous with the
424 .B ifname
425 modifier.
426 .IP "\fBrnr \fInum\fR"
427 True if the packet was logged as matching the specified PF rule number
428 (applies only to packets logged by OpenBSD's or FreeBSD's
429 .BR pf (4)).
430 .IP "\fBrulenum \fInum\fR"
431 Synonymous with the
432 .B rnr
433 modifier.
434 .IP "\fBreason \fIcode\fR"
435 True if the packet was logged with the specified PF reason code.  The known
436 codes are:
437 .BR match ,
438 .BR bad-offset ,
439 .BR fragment ,
440 .BR short ,
441 .BR normalize ,
442 and
443 .B memory
444 (applies only to packets logged by OpenBSD's or FreeBSD's
445 .BR pf (4)).
446 .IP "\fBrset \fIname\fR"
447 True if the packet was logged as matching the specified PF ruleset
448 name of an anchored ruleset (applies only to packets logged by OpenBSD's
449 or FreeBSD's
450 .BR pf (4)).
451 .IP "\fBruleset \fIname\fR"
452 Synonomous with the
453 .B rset
454 modifier.
455 .IP "\fBsrnr \fInum\fR"
456 True if the packet was logged as matching the specified PF rule number
457 of an anchored ruleset (applies only to packets logged by OpenBSD's or
458 FreeBSD's
459 .BR pf (4)).
460 .IP "\fBsubrulenum \fInum\fR"
461 Synonomous with the
462 .B srnr
463 modifier.
464 .IP "\fBaction \fIact\fR"
465 True if PF took the specified action when the packet was logged.  Known actions
466 are:
467 .B pass
468 and
469 .B block
470 and, with later versions of
471 .BR pf (4)),
472 .BR nat ,
473 .BR rdr ,
474 .B binat
475 and
476 .B scrub
477 (applies only to packets logged by OpenBSD's or FreeBSD's
478 .BR pf (4)).
479 .IP "\fBwlan ra \fIehost\fR"
480 True if the IEEE 802.11 RA is
481 .IR ehost .
482 The RA field is used in all frames except for management frames.
483 .IP "\fBwlan ta \fIehost\fR"
484 True if the IEEE 802.11 TA is
485 .IR ehost .
486 The TA field is used in all frames except for management frames and
487 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
488 .IP "\fBwlan addr1 \fIehost\fR"
489 True if the first IEEE 802.11 address is
490 .IR ehost .
491 .IP "\fBwlan addr2 \fIehost\fR"
492 True if the second IEEE 802.11 address, if present, is
493 .IR ehost .
494 The second address field is used in all frames except for CTS (Clear To
495 Send) and ACK (Acknowledgment) control frames.
496 .IP "\fBwlan addr3 \fIehost\fR"
497 True if the third IEEE 802.11 address, if present, is
498 .IR ehost .
499 The third address field is used in management and data frames, but not
500 in control frames.
501 .IP "\fBwlan addr4 \fIehost\fR"
502 True if the fourth IEEE 802.11 address, if present, is
503 .IR ehost .
504 The fourth address field is only used for
505 WDS (Wireless Distribution System) frames.
506 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
507 Abbreviations for:
508 .in +.5i
509 .nf
510 \fBether proto \fIp\fR
511 .fi
512 .in -.5i
513 where \fIp\fR is one of the above protocols.
514 .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
515 Abbreviations for:
516 .in +.5i
517 .nf
518 \fBether proto \fIp\fR
519 .fi
520 .in -.5i
521 where \fIp\fR is one of the above protocols.
522 Note that not all applications using
523 .BR pcap (3)
524 currently know how to parse these protocols.
525 .IP "\fBtype \fIwlan_type\fR"
526 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
527 Valid \fIwlan_type\fRs are:
528 \fBmgt\fP,
529 \fBctl\fP
530 and \fBdata\fP.
531 .IP "\fBtype \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
532 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
533 and frame subtype matches the specified \fIwlan_subtype\fR.
534 .IP
535 If the specified \fIwlan_type\fR is \fBmgt\fP,
536 then valid \fIwlan_subtype\fRs are:
537 \fBassoc-req\fP,
538 \fBassoc-resp\fP,
539 \fBreassoc-req\fP,
540 \fBreassoc-resp\fP,
541 \fBprobe-req\fP,
542 \fBprobe-resp\fP,
543 \fBbeacon\fP,
544 \fBatim\fP,
545 \fBdisassoc\fP,
546 \fBauth\fP and
547 \fBdeauth\fP.
548 .IP
549 If the specified \fIwlan_type\fR is \fBctl\fP,
550 then valid \fIwlan_subtype\fRs are:
551 \fBps-poll\fP,
552 \fBrts\fP,
553 \fBcts\fP,
554 \fBack\fP,
555 \fBcf-end\fP and
556 \fBcf-end-ack\fP.
557 .IP
558 If the specified \fIwlan_type\fR is \fBdata\fP,
559 then valid \fIwlan_subtype\fRs are:
560 \fBdata\fP,
561 \fBdata-cf-ack\fP,
562 \fBdata-cf-poll\fP,
563 \fBdata-cf-ack-poll\fP,
564 \fBnull\fP,
565 \fBcf-ack\fP,
566 \fBcf-poll\fP,
567 \fBcf-ack-poll\fP,
568 \fBqos-data\fP,
569 \fBqos-data-cf-ack\fP,
570 \fBqos-data-cf-poll\fP,
571 \fBqos-data-cf-ack-poll\fP,
572 \fBqos\fP,
573 \fBqos-cf-poll\fP and
574 \fBqos-cf-ack-poll\fP.
575 .IP "\fBsubtype \fIwlan_subtype\fR"
576 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
577 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
578 .IP "\fBdir \fIdir\fR"
579 True if the IEEE 802.11 frame direction matches the specified
580 .IR dir .
581 Valid directions are:
582 .BR nods ,
583 .BR tods ,
584 .BR fromds ,
585 .BR dstods ,
586 or a numeric value.
587 .IP "\fBvlan \fI[vlan_id]\fR"
588 True if the packet is an IEEE 802.1Q VLAN packet.
589 If \fI[vlan_id]\fR is specified, only true if the packet has the specified
590 \fIvlan_id\fR.
591 Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
592 changes the decoding offsets for the remainder of \fIexpression\fR on
593 the assumption that the packet is a VLAN packet.  The \fBvlan
594 \fI[vlan_id]\fR expression may be used more than once, to filter on VLAN
595 hierarchies.  Each use of that expression increments the filter offsets
596 by 4.
597 .IP
598 For example:
599 .in +.5i
600 .nf
601 \fBvlan 100 && vlan 200\fR
602 .fi
603 .in -.5i
604 filters on VLAN 200 encapsulated within VLAN 100, and
605 .in +.5i
606 .nf
607 \fBvlan && vlan 300 && ip\fR
608 .fi
609 .in -.5i
610 filters IPv4 protocols encapsulated in VLAN 300 encapsulated within any
611 higher order VLAN.
612 .IP "\fBmpls \fI[label_num]\fR"
613 True if the packet is an MPLS packet.
614 If \fI[label_num]\fR is specified, only true is the packet has the specified
615 \fIlabel_num\fR.
616 Note that the first \fBmpls\fR keyword encountered in \fIexpression\fR
617 changes the decoding offsets for the remainder of \fIexpression\fR on
618 the assumption that the packet is a MPLS-encapsulated IP packet.  The
619 \fBmpls \fI[label_num]\fR expression may be used more than once, to
620 filter on MPLS hierarchies.  Each use of that expression increments the
621 filter offsets by 4. 
622 .IP
623 For example:
624 .in +.5i
625 .nf
626 \fBmpls 100000 && mpls 1024\fR
627 .fi
628 .in -.5i
629 filters packets with an outer label of 100000 and an inner label of
630 1024, and
631 .in +.5i
632 .nf
633 \fBmpls && mpls 1024 && host 192.9.200.1\fR
634 .fi
635 .in -.5i
636 filters packets to or from 192.9.200.1 with an inner label of 1024 and
637 any outer label.
638 .IP \fBpppoed\fP
639 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
640 type 0x8863).
641 .IP \fBpppoes\fP
642 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
643 type 0x8864).
644 Note that the first \fBpppoes\fR keyword encountered in \fIexpression\fR
645 changes the decoding offsets for the remainder of \fIexpression\fR on
646 the assumption that the packet is a PPPoE session packet.
647 .IP
648 For example:
649 .in +.5i
650 .nf
651 \fBpppoes && ip\fR
652 .fi
653 .in -.5i
654 filters IPv4 protocols encapsulated in PPPoE.
655 .IP  "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
656 Abbreviations for:
657 .in +.5i
658 .nf
659 \fBip proto \fIp\fR\fB or ip6 proto \fIp\fR
660 .fi
661 .in -.5i
662 where \fIp\fR is one of the above protocols.
663 .IP "\fBiso proto \fIprotocol\fR"
664 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
665 \fIProtocol\fP can be a number or one of the names
666 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
667 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
668 Abbreviations for:
669 .in +.5i
670 .nf
671 \fBiso proto \fIp\fR
672 .fi
673 .in -.5i
674 where \fIp\fR is one of the above protocols.
675 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
676 Abbreviations for IS-IS PDU types.
677 .IP "\fBvpi\fP \fIn\fR
678 True if the packet is an ATM packet, for SunATM on Solaris, with a
679 virtual path identifier of
680 .IR n .
681 .IP "\fBvci\fP \fIn\fR
682 True if the packet is an ATM packet, for SunATM on Solaris, with a
683 virtual channel identifier of
684 .IR n .
685 .IP \fBlane\fP
686 True if the packet is an ATM packet, for SunATM on Solaris, and is
687 an ATM LANE packet.
688 Note that the first \fBlane\fR keyword encountered in \fIexpression\fR
689 changes the tests done in the remainder of \fIexpression\fR
690 on the assumption that the packet is either a LANE emulated Ethernet
691 packet or a LANE LE Control packet.  If \fBlane\fR isn't specified, the
692 tests are done under the assumption that the packet is an
693 LLC-encapsulated packet.
694 .IP \fBllc\fP
695 True if the packet is an ATM packet, for SunATM on Solaris, and is
696 an LLC-encapsulated packet.
697 .IP \fBoamf4s\fP
698 True if the packet is an ATM packet, for SunATM on Solaris, and is
699 a segment OAM F4 flow cell (VPI=0 & VCI=3).
700 .IP \fBoamf4e\fP
701 True if the packet is an ATM packet, for SunATM on Solaris, and is
702 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
703 .IP \fBoamf4\fP
704 True if the packet is an ATM packet, for SunATM on Solaris, and is
705 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
706 .IP \fBoam\fP
707 True if the packet is an ATM packet, for SunATM on Solaris, and is
708 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
709 .IP \fBmetac\fP
710 True if the packet is an ATM packet, for SunATM on Solaris, and is
711 on a meta signaling circuit (VPI=0 & VCI=1).
712 .IP \fBbcc\fP
713 True if the packet is an ATM packet, for SunATM on Solaris, and is
714 on a broadcast signaling circuit (VPI=0 & VCI=2).
715 .IP \fBsc\fP
716 True if the packet is an ATM packet, for SunATM on Solaris, and is
717 on a signaling circuit (VPI=0 & VCI=5).
718 .IP \fBilmic\fP
719 True if the packet is an ATM packet, for SunATM on Solaris, and is
720 on an ILMI circuit (VPI=0 & VCI=16).
721 .IP \fBconnectmsg\fP
722 True if the packet is an ATM packet, for SunATM on Solaris, and is
723 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
724 Connect Ack, Release, or Release Done message.
725 .IP \fBmetaconnect\fP
726 True if the packet is an ATM packet, for SunATM on Solaris, and is
727 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
728 Release, or Release Done message.
729 .IP  "\fIexpr relop expr\fR"
730 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
731 !=, and \fIexpr\fR is an arithmetic expression composed of integer
732 constants (expressed in standard C syntax), the normal binary operators
733 [+, -, *, /, &, |, <<, >>], a length operator, and special packet data
734 accessors.  Note that all comparisons are unsigned, so that, for example,
735 0x80000000 and 0xffffffff are > 0.
736 To access
737 data inside the packet, use the following syntax:
738 .in +.5i
739 .nf
740 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
741 .fi
742 .in -.5i
743 \fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
744 ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and
745 indicates the protocol layer for the index operation.
746 (\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
747 link layer. \fBradio\fR refers to the "radio header" added to some
748 802.11 captures.)
749 Note that \fItcp, udp\fR and other upper-layer protocol types only
750 apply to IPv4, not IPv6 (this will be fixed in the future).
751 The byte offset, relative to the indicated protocol layer, is
752 given by \fIexpr\fR.
753 \fISize\fR is optional and indicates the number of bytes in the
754 field of interest; it can be either one, two, or four, and defaults to one.
755 The length operator, indicated by the keyword \fBlen\fP, gives the
756 length of the packet.
757
758 For example, `\fBether[0] & 1 != 0\fP' catches all multicast traffic.
759 The expression `\fBip[0] & 0xf != 5\fP'
760 catches all IPv4 packets with options.
761 The expression
762 `\fBip[6:2] & 0x1fff = 0\fP'
763 catches only unfragmented IPv4 datagrams and frag zero of fragmented
764 IPv4 datagrams.
765 This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
766 index operations.
767 For instance, \fBtcp[0]\fP always means the first
768 byte of the TCP \fIheader\fP, and never means the first byte of an
769 intervening fragment.
770
771 Some offsets and field values may be expressed as names rather than
772 as numeric values.
773 The following protocol header field offsets are
774 available: \fBicmptype\fP (ICMP type field), \fBicmpcode\fP (ICMP
775 code field), and \fBtcpflags\fP (TCP flags field).
776
777 The following ICMP type field values are available: \fBicmp-echoreply\fP,
778 \fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP,
779 \fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP,
780 \fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP,
781 \fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP,
782 \fBicmp-maskreq\fP, \fBicmp-maskreply\fP.
783
784 The following TCP flags field values are available: \fBtcp-fin\fP,
785 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
786 \fBtcp-ack\fP, \fBtcp-urg\fP.
787 .LP
788 Primitives may be combined using:
789 .IP
790 A parenthesized group of primitives and operators
791 (parentheses are special to the Shell and must be escaped).
792 .IP
793 Negation (`\fB!\fP' or `\fBnot\fP').
794 .IP
795 Concatenation (`\fB&&\fP' or `\fBand\fP').
796 .IP
797 Alternation (`\fB||\fP' or `\fBor\fP').
798 .LP
799 Negation has highest precedence.
800 Alternation and concatenation have equal precedence and associate
801 left to right.
802 Note that explicit \fBand\fR tokens, not juxtaposition,
803 are now required for concatenation.
804 .LP
805 If an identifier is given without a keyword, the most recent keyword
806 is assumed.
807 For example,
808 .in +.5i
809 .nf
810 \fBnot host vs and ace\fR
811 .fi
812 .in -.5i
813 is short for
814 .in +.5i
815 .nf
816 \fBnot host vs and host ace\fR
817 .fi
818 .in -.5i
819 which should not be confused with
820 .in +.5i
821 .nf
822 \fBnot ( host vs or ace )\fR
823 .fi
824 .in -.5i
825 .SH EXAMPLES
826 .LP
827 To select all packets arriving at or departing from \fIsundown\fP:
828 .RS
829 .nf
830 \fBhost sundown\fP
831 .fi
832 .RE
833 .LP
834 To select traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR:
835 .RS
836 .nf
837 \fBhost helios and \\( hot or ace \\)\fP
838 .fi
839 .RE
840 .LP
841 To select all IP packets between \fIace\fR and any host except \fIhelios\fR:
842 .RS
843 .nf
844 \fBip host ace and not helios\fP
845 .fi
846 .RE
847 .LP
848 To select all traffic between local hosts and hosts at Berkeley:
849 .RS
850 .nf
851 .B
852 net ucb-ether
853 .fi
854 .RE
855 .LP
856 To select all ftp traffic through internet gateway \fIsnup\fP:
857 .RS
858 .nf
859 .B
860 gateway snup and (port ftp or ftp-data)
861 .fi
862 .RE
863 .LP
864 To select traffic neither sourced from nor destined for local hosts
865 (if you gateway to one other net, this stuff should never make it
866 onto your local net).
867 .RS
868 .nf
869 .B
870 ip and not net \fIlocalnet\fP
871 .fi
872 .RE
873 .LP
874 To select the start and end packets (the SYN and FIN packets) of each
875 TCP conversation that involves a non-local host.
876 .RS
877 .nf
878 .B
879 tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP
880 .fi
881 .RE
882 .LP
883 To select all IPv4 HTTP packets to and from port 80, i.e. print only
884 packets that contain data, not, for example, SYN and FIN packets and
885 ACK-only packets.  (IPv6 is left as an exercise for the reader.)
886 .RS
887 .nf
888 .B
889 tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)
890 .fi
891 .RE
892 .LP
893 To select IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
894 .RS
895 .nf
896 .B
897 gateway snup and ip[2:2] > 576
898 .fi
899 .RE
900 .LP
901 To select IP broadcast or multicast packets that were
902 .I not
903 sent via Ethernet broadcast or multicast:
904 .RS
905 .nf
906 .B
907 ether[0] & 1 = 0 and ip[16] >= 224
908 .fi
909 .RE
910 .LP
911 To select all ICMP packets that are not echo requests/replies (i.e., not
912 ping packets):
913 .RS
914 .nf
915 .B
916 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
917 .fi
918 .RE
919 .SH "SEE ALSO"
920 pcap(3PCAP)
921 .SH AUTHORS
922 The original authors are:
923 .LP
924 Van Jacobson,
925 Craig Leres and
926 Steven McCanne, all of the
927 Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
928 .LP
929 It is currently being maintained by tcpdump.org.
930 .LP
931 The current version of libpcap is available via http:
932 .LP
933 .RS
934 .I http://www.tcpdump.org/
935 .RE
936 .LP
937 The original distribution is available via anonymous ftp:
938 .LP
939 .RS
940 .I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
941 .RE
942 .SH BUGS
943 Please send problems, bugs, questions, desirable enhancements, etc. to:
944 .LP
945 .RS
946 tcpdump-workers@lists.tcpdump.org
947 .RE
948 .LP
949 Filter expressions on fields other than those in Token Ring headers will
950 not correctly handle source-routed Token Ring packets.
951 .LP
952 Filter expressions on fields other than those in 802.11 headers will not
953 correctly handle 802.11 data packets with both To DS and From DS set.
954 .LP
955 .BR "ip6 proto"
956 should chase header chain, but at this moment it does not.
957 .BR "ip6 protochain"
958 is supplied for this behavior.
959 .LP
960 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
961 does not work against IPv6 packets.
962 It only looks at IPv4 packets.