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