]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/libpcap/pcap-filter.manmisc.in
amd64: use register macros for gdb_cpu_getreg()
[FreeBSD/FreeBSD.git] / contrib / libpcap / pcap-filter.manmisc.in
1 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that: (1) source code distributions
7 .\" retain the above copyright notice and this paragraph in its entirety, (2)
8 .\" distributions including binary code include the above copyright notice and
9 .\" this paragraph in its entirety in the documentation or other materials
10 .\" provided with the distribution, and (3) all advertising materials mentioning
11 .\" features or use of this software display the following acknowledgement:
12 .\" ``This product includes software developed by the University of California,
13 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 .\" the University nor the names of its contributors may be used to endorse
15 .\" or promote products derived from this software without specific prior
16 .\" written permission.
17 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 .\"
21 .TH PCAP-FILTER @MAN_MISC_INFO@ "5 November 2017"
22 .SH NAME
23 pcap-filter \- packet filter syntax
24 .br
25 .ad
26 .SH DESCRIPTION
27 .LP
28 .B pcap_compile()
29 is used to compile a string into a filter program.
30 The resulting filter program can then be applied to
31 some stream of packets to determine which packets will be supplied to
32 .BR pcap_loop(3PCAP) ,
33 .BR pcap_dispatch(3PCAP) ,
34 .BR pcap_next(3PCAP) ,
35 or
36 .BR pcap_next_ex(3PCAP) .
37 .LP
38 The \fIfilter expression\fP consists of one or more
39 .IR primitives .
40 Primitives usually consist of an
41 .I id
42 (name or number) preceded by one or more qualifiers.
43 There are three
44 different kinds of qualifier:
45 .IP \fItype\fP
46 .I type
47 qualifiers say what kind of thing the id name or number refers to.
48 Possible types are
49 .BR host ,
50 .B net ,
51 .B port
52 and
53 .BR portrange .
54 E.g., `host foo', `net 128.3', `port 20', `portrange 6000-6008'.
55 If there is no type
56 qualifier,
57 .B host
58 is assumed.
59 .IP \fIdir\fP
60 .I dir
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 .IP \fIproto\fP
90 .I proto
91 qualifiers restrict the match to a particular protocol.
92 Possible
93 protos are:
94 .BR ether ,
95 .BR fddi ,
96 .BR tr ,
97 .BR wlan ,
98 .BR ip ,
99 .BR ip6 ,
100 .BR arp ,
101 .BR rarp ,
102 .BR decnet ,
103 .B tcp
104 and
105 .BR udp .
106 E.g., `ether src foo', `arp net 128.3', `tcp port 21', `udp portrange
107 7000-7009', `wlan addr2 0:2:3:4:5:6'.
108 If there is
109 no proto qualifier, all protocols consistent with the type are
110 assumed.
111 E.g., `src foo' means `(ip or arp or rarp) src foo'
112 (except the latter is not legal syntax), `net bar' means `(ip or
113 arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'.
114 .LP
115 [`fddi' is actually an alias for `ether'; the parser treats them
116 identically as meaning ``the data link level used on the specified
117 network interface.''  FDDI headers contain Ethernet-like source
118 and destination addresses, and often contain Ethernet-like packet
119 types, so you can filter on these FDDI fields just as with the
120 analogous Ethernet fields.
121 FDDI headers also contain other fields,
122 but you cannot name them explicitly in a filter expression.
123 .LP
124 Similarly, `tr' and `wlan' are aliases for `ether'; the previous
125 paragraph's statements about FDDI headers also apply to Token Ring
126 and 802.11 wireless LAN headers.  For 802.11 headers, the destination
127 address is the DA field and the source address is the SA field; the
128 BSSID, RA, and TA fields aren't tested.]
129 .LP
130 In addition to the above, there are some special `primitive' keywords
131 that don't follow the pattern:
132 .BR gateway ,
133 .BR broadcast ,
134 .BR less ,
135 .B greater
136 and arithmetic expressions.
137 All of these are described below.
138 .LP
139 More complex filter expressions are built up by using the words
140 .BR and ,
141 .B or
142 and
143 .B not
144 to combine primitives.
145 E.g., `host foo and not port ftp and not port ftp-data'.
146 To save typing, identical qualifier lists can be omitted.
147 E.g.,
148 `tcp dst port ftp or ftp-data or domain' is exactly the same as
149 `tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'.
150 .LP
151 Allowable primitives are:
152 .IP "\fBdst host \fIhost\fR"
153 True if the IPv4/v6 destination field of the packet is \fIhost\fP,
154 which may be either an address or a name.
155 .IP "\fBsrc host \fIhost\fR"
156 True if the IPv4/v6 source field of the packet is \fIhost\fP.
157 .IP "\fBhost \fIhost\fP"
158 True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
159 .IP
160 Any of the above host expressions can be prepended with the keywords,
161 \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
162 .in +.5i
163 .nf
164 \fBip host \fIhost\fR
165 .fi
166 .in -.5i
167 which is equivalent to:
168 .in +.5i
169 .nf
170 \fBether proto \fI\\ip\fB and host \fIhost\fR
171 .fi
172 .in -.5i
173 If \fIhost\fR is a name with multiple IP addresses, each address will
174 be checked for a match.
175 .IP "\fBether dst \fIehost\fP"
176 True if the Ethernet destination address is \fIehost\fP.
177 \fIEhost\fP
178 may be either a name from /etc/ethers or a numerical MAC address of the
179 form "xx:xx:xx:xx:xx:xx", "xx.xx.xx.xx.xx.xx", "xx-xx-xx-xx-xx-xx",
180 "xxxx.xxxx.xxxx", "xxxxxxxxxxxx", or various mixes of ':', '.', and '-',
181 where each "x" is a hex digit (0-9, a-f, or A-F).
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 (\\).
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 "\fBproto \fIprotocol\fR"
302 True if the packet is an IPv4 or IPv6 packet of protocol type
303 \fIprotocol\fP.  Note that this primitive does not chase the protocol
304 header chain.
305 .IP  "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
306 Abbreviations for:
307 .in +.5i
308 .nf
309 \fBproto \fIp\fR\fB
310 .fi
311 .in -.5i
312 where \fIp\fR is one of the above protocols.
313 .IP "\fBip6 protochain \fIprotocol\fR"
314 True if the packet is IPv6 packet,
315 and contains protocol header with type \fIprotocol\fR
316 in its protocol header chain.
317 For example,
318 .in +.5i
319 .nf
320 \fBip6 protochain 6\fR
321 .fi
322 .in -.5i
323 matches any IPv6 packet with TCP protocol header in the protocol header chain.
324 The packet may contain, for example,
325 authentication header, routing header, or hop-by-hop option header,
326 between IPv6 header and TCP header.
327 The BPF code emitted by this primitive is complex and
328 cannot be optimized by the BPF optimizer code, and is not supported by
329 filter engines in the kernel, so this can be somewhat slow, and may
330 cause more packets to be dropped.
331 .IP "\fBip protochain \fIprotocol\fR"
332 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
333 .IP "\fBprotochain \fIprotocol\fR"
334 True if the packet is an IPv4 or IPv6 packet of protocol type
335 \fIprotocol\fP.  Note that this primitive chases the protocol
336 header chain.
337 .IP "\fBether broadcast\fR"
338 True if the packet is an Ethernet broadcast packet.
339 The \fIether\fP
340 keyword is optional.
341 .IP "\fBip broadcast\fR"
342 True if the packet is an IPv4 broadcast packet.
343 It checks for both the all-zeroes and all-ones broadcast conventions,
344 and looks up the subnet mask on the interface on which the capture is
345 being done.
346 .IP
347 If the subnet mask of the interface on which the capture is being done
348 is not available, either because the interface on which capture is being
349 done has no netmask or because the capture is being done on the Linux
350 "any" interface, which can capture on more than one interface, this
351 check will not work correctly.
352 .IP "\fBether multicast\fR"
353 True if the packet is an Ethernet multicast packet.
354 The \fBether\fP
355 keyword is optional.
356 This is shorthand for `\fBether[0] & 1 != 0\fP'.
357 .IP "\fBip multicast\fR"
358 True if the packet is an IPv4 multicast packet.
359 .IP "\fBip6 multicast\fR"
360 True if the packet is an IPv6 multicast packet.
361 .IP  "\fBether proto \fIprotocol\fR"
362 True if the packet is of ether type \fIprotocol\fR.
363 \fIProtocol\fP can be a number or one of the names
364 \fBip\fP, \fBip6\fP, \fBarp\fP, \fBrarp\fP, \fBatalk\fP, \fBaarp\fP,
365 \fBdecnet\fP, \fBsca\fP, \fBlat\fP, \fBmopdl\fP, \fBmoprc\fP,
366 \fBiso\fP, \fBstp\fP, \fBipx\fP, or \fBnetbeui\fP.
367 Note these identifiers are also keywords
368 and must be escaped via backslash (\\).
369 .IP
370 [In the case of FDDI (e.g., `\fBfddi proto arp\fR'), Token Ring
371 (e.g., `\fBtr proto arp\fR'), and IEEE 802.11 wireless LANS (e.g.,
372 `\fBwlan proto arp\fR'), for most of those protocols, the
373 protocol identification comes from the 802.2 Logical Link Control (LLC)
374 header, which is usually layered on top of the FDDI, Token Ring, or
375 802.11 header.
376 .IP
377 When filtering for most protocol identifiers on FDDI, Token Ring, or
378 802.11, the filter checks only the protocol ID field of an LLC header
379 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
380 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
381 is in SNAP format with an OUI of 0x000000.
382 The exceptions are:
383 .RS
384 .TP
385 \fBiso\fP
386 the filter checks the DSAP (Destination Service Access Point) and
387 SSAP (Source Service Access Point) fields of the LLC header;
388 .TP
389 \fBstp\fP and \fBnetbeui\fP
390 the filter checks the DSAP of the LLC header;
391 .TP
392 \fBatalk\fP
393 the filter checks for a SNAP-format packet with an OUI of 0x080007
394 and the AppleTalk etype.
395 .RE
396 .IP
397 In the case of Ethernet, the filter checks the Ethernet type field
398 for most of those protocols.  The exceptions are:
399 .RS
400 .TP
401 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
402 the filter checks for an 802.3 frame and then checks the LLC header as
403 it does for FDDI, Token Ring, and 802.11;
404 .TP
405 \fBatalk\fP
406 the filter checks both for the AppleTalk etype in an Ethernet frame and
407 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
408 .TP
409 \fBaarp\fP
410 the filter checks for the AppleTalk ARP etype in either an Ethernet
411 frame or an 802.2 SNAP frame with an OUI of 0x000000;
412 .TP
413 \fBipx\fP
414 the filter checks for the IPX etype in an Ethernet frame, the IPX
415 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
416 IPX, and the IPX etype in a SNAP frame.
417 .RE
418 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
419 Abbreviations for:
420 .in +.5i
421 .nf
422 \fBether proto \fIp\fR
423 .fi
424 .in -.5i
425 where \fIp\fR is one of the above protocols.
426 .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
427 Abbreviations for:
428 .in +.5i
429 .nf
430 \fBether proto \fIp\fR
431 .fi
432 .in -.5i
433 where \fIp\fR is one of the above protocols.
434 Note that not all applications using
435 .BR pcap (3PCAP)
436 currently know how to parse these protocols.
437 .IP "\fBdecnet src \fIhost\fR"
438 True if the DECNET source address is
439 .IR host ,
440 which may be an address of the form ``10.123'', or a DECNET host
441 name.
442 [DECNET host name support is only available on ULTRIX systems
443 that are configured to run DECNET.]
444 .IP "\fBdecnet dst \fIhost\fR"
445 True if the DECNET destination address is
446 .IR host .
447 .IP "\fBdecnet host \fIhost\fR"
448 True if either the DECNET source or destination address is
449 .IR host .
450 .IP \fBllc\fP
451 True if the packet has an 802.2 LLC header.  This includes:
452 .IP
453 Ethernet packets with a length field rather than a type field that
454 aren't raw NetWare-over-802.3 packets;
455 .IP
456 IEEE 802.11 data packets;
457 .IP
458 Token Ring packets (no check is done for LLC frames);
459 .IP
460 FDDI packets (no check is done for LLC frames);
461 .IP
462 LLC-encapsulated ATM packets, for SunATM on Solaris.
463 .IP "\fBllc\fP \Fitype\fR"
464 True if the packet has an 802.2 LLC header and has the specified
465 .IR type .
466 .I type
467 can be one of:
468 .RS
469 .TP
470 \fBi\fR
471 Information (I) PDUs
472 .TP
473 \fBs\fR
474 Supervisory (S) PDUs
475 .TP
476 \fBu\fR
477 Unnumbered (U) PDUs
478 .TP
479 \fBrr\fR
480 Receiver Ready (RR) S PDUs
481 .TP
482 \fBrnr\fR
483 Receiver Not Ready (RNR) S PDUs
484 .TP
485 \fBrej\fR
486 Reject (REJ) S PDUs
487 .TP
488 \fBui\fR
489 Unnumbered Information (UI) U PDUs
490 .TP
491 \fBua\fR
492 Unnumbered Acknowledgment (UA) U PDUs
493 .TP
494 \fBdisc\fR
495 Disconnect (DISC) U PDUs
496 .TP
497 \fBsabme\fR
498 Set Asynchronous Balanced Mode Extended (SABME) U PDUs
499 .TP
500 \fBtest\fR
501 Test (TEST) U PDUs
502 .TP
503 \fBxid\fR
504 Exchange Identification (XID) U PDUs
505 .TP
506 \fBfrmr\fR
507 Frame Reject (FRMR) U PDUs
508 .RE
509 .IP \fBinbound\fP
510 Packet was received by the host performing the capture rather than being
511 sent by that host.  This is only supported for certain link-layer types,
512 such as SLIP and the ``cooked'' Linux capture mode
513 used for the ``any'' device and for some other device types.
514 .IP \fBoutbound\fP
515 Packet was sent by the host performing the capture rather than being
516 received by that host.  This is only supported for certain link-layer types,
517 such as SLIP and the ``cooked'' Linux capture mode
518 used for the ``any'' device and for some other device types.
519 .IP "\fBifname \fIinterface\fR"
520 True if the packet was logged as coming from the specified interface (applies
521 only to packets logged by OpenBSD's or FreeBSD's
522 .BR pf (4)).
523 .IP "\fBon \fIinterface\fR"
524 Synonymous with the
525 .B ifname
526 modifier.
527 .IP "\fBrnr \fInum\fR"
528 True if the packet was logged as matching the specified PF rule number
529 (applies only to packets logged by OpenBSD's or FreeBSD's
530 .BR pf (4)).
531 .IP "\fBrulenum \fInum\fR"
532 Synonymous with the
533 .B rnr
534 modifier.
535 .IP "\fBreason \fIcode\fR"
536 True if the packet was logged with the specified PF reason code.  The known
537 codes are:
538 .BR match ,
539 .BR bad-offset ,
540 .BR fragment ,
541 .BR short ,
542 .BR normalize ,
543 and
544 .B memory
545 (applies only to packets logged by OpenBSD's or FreeBSD's
546 .BR pf (4)).
547 .IP "\fBrset \fIname\fR"
548 True if the packet was logged as matching the specified PF ruleset
549 name of an anchored ruleset (applies only to packets logged by OpenBSD's
550 or FreeBSD's
551 .BR pf (4)).
552 .IP "\fBruleset \fIname\fR"
553 Synonymous with the
554 .B rset
555 modifier.
556 .IP "\fBsrnr \fInum\fR"
557 True if the packet was logged as matching the specified PF rule number
558 of an anchored ruleset (applies only to packets logged by OpenBSD's or
559 FreeBSD's
560 .BR pf (4)).
561 .IP "\fBsubrulenum \fInum\fR"
562 Synonymous with the
563 .B srnr
564 modifier.
565 .IP "\fBaction \fIact\fR"
566 True if PF took the specified action when the packet was logged.  Known actions
567 are:
568 .B pass
569 and
570 .B block
571 and, with later versions of
572 .BR pf (4),
573 .BR nat ,
574 .BR rdr ,
575 .B binat
576 and
577 .B scrub
578 (applies only to packets logged by OpenBSD's or FreeBSD's
579 .BR pf (4)).
580 .IP "\fBwlan ra \fIehost\fR"
581 True if the IEEE 802.11 RA is
582 .IR ehost .
583 The RA field is used in all frames except for management frames.
584 .IP "\fBwlan ta \fIehost\fR"
585 True if the IEEE 802.11 TA is
586 .IR ehost .
587 The TA field is used in all frames except for management frames and
588 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
589 .IP "\fBwlan addr1 \fIehost\fR"
590 True if the first IEEE 802.11 address is
591 .IR ehost .
592 .IP "\fBwlan addr2 \fIehost\fR"
593 True if the second IEEE 802.11 address, if present, is
594 .IR ehost .
595 The second address field is used in all frames except for CTS (Clear To
596 Send) and ACK (Acknowledgment) control frames.
597 .IP "\fBwlan addr3 \fIehost\fR"
598 True if the third IEEE 802.11 address, if present, is
599 .IR ehost .
600 The third address field is used in management and data frames, but not
601 in control frames.
602 .IP "\fBwlan addr4 \fIehost\fR"
603 True if the fourth IEEE 802.11 address, if present, is
604 .IR ehost .
605 The fourth address field is only used for
606 WDS (Wireless Distribution System) frames.
607 .IP "\fBtype \fIwlan_type\fR"
608 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
609 Valid \fIwlan_type\fRs are:
610 \fBmgt\fP,
611 \fBctl\fP
612 and \fBdata\fP.
613 .IP "\fBtype \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
614 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
615 and frame subtype matches the specified \fIwlan_subtype\fR.
616 .IP
617 If the specified \fIwlan_type\fR is \fBmgt\fP,
618 then valid \fIwlan_subtype\fRs are:
619 \fBassoc-req\fP,
620 \fBassoc-resp\fP,
621 \fBreassoc-req\fP,
622 \fBreassoc-resp\fP,
623 \fBprobe-req\fP,
624 \fBprobe-resp\fP,
625 \fBbeacon\fP,
626 \fBatim\fP,
627 \fBdisassoc\fP,
628 \fBauth\fP and
629 \fBdeauth\fP.
630 .IP
631 If the specified \fIwlan_type\fR is \fBctl\fP,
632 then valid \fIwlan_subtype\fRs are:
633 \fBps-poll\fP,
634 \fBrts\fP,
635 \fBcts\fP,
636 \fBack\fP,
637 \fBcf-end\fP and
638 \fBcf-end-ack\fP.
639 .IP
640 If the specified \fIwlan_type\fR is \fBdata\fP,
641 then valid \fIwlan_subtype\fRs are:
642 \fBdata\fP,
643 \fBdata-cf-ack\fP,
644 \fBdata-cf-poll\fP,
645 \fBdata-cf-ack-poll\fP,
646 \fBnull\fP,
647 \fBcf-ack\fP,
648 \fBcf-poll\fP,
649 \fBcf-ack-poll\fP,
650 \fBqos-data\fP,
651 \fBqos-data-cf-ack\fP,
652 \fBqos-data-cf-poll\fP,
653 \fBqos-data-cf-ack-poll\fP,
654 \fBqos\fP,
655 \fBqos-cf-poll\fP and
656 \fBqos-cf-ack-poll\fP.
657 .IP "\fBsubtype \fIwlan_subtype\fR"
658 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
659 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
660 .IP "\fBdir \fIdir\fR"
661 True if the IEEE 802.11 frame direction matches the specified
662 .IR dir .
663 Valid directions are:
664 .BR nods ,
665 .BR tods ,
666 .BR fromds ,
667 .BR dstods ,
668 or a numeric value.
669 .IP "\fBvlan \fI[vlan_id]\fR"
670 True if the packet is an IEEE 802.1Q VLAN packet.
671 If \fI[vlan_id]\fR is specified, only true if the packet has the specified
672 \fIvlan_id\fR.
673 Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
674 changes the decoding offsets for the remainder of \fIexpression\fR on
675 the assumption that the packet is a VLAN packet.  The \fBvlan
676 \fI[vlan_id]\fR expression may be used more than once, to filter on VLAN
677 hierarchies.  Each use of that expression increments the filter offsets
678 by 4.
679 .IP
680 For example:
681 .in +.5i
682 .nf
683 \fBvlan 100 && vlan 200\fR
684 .fi
685 .in -.5i
686 filters on VLAN 200 encapsulated within VLAN 100, and
687 .in +.5i
688 .nf
689 \fBvlan && vlan 300 && ip\fR
690 .fi
691 .in -.5i
692 filters IPv4 protocols encapsulated in VLAN 300 encapsulated within any
693 higher order VLAN.
694 .IP "\fBmpls \fI[label_num]\fR"
695 True if the packet is an MPLS packet.
696 If \fI[label_num]\fR is specified, only true is the packet has the specified
697 \fIlabel_num\fR.
698 Note that the first \fBmpls\fR keyword encountered in \fIexpression\fR
699 changes the decoding offsets for the remainder of \fIexpression\fR on
700 the assumption that the packet is a MPLS-encapsulated IP packet.  The
701 \fBmpls \fI[label_num]\fR expression may be used more than once, to
702 filter on MPLS hierarchies.  Each use of that expression increments the
703 filter offsets by 4.
704 .IP
705 For example:
706 .in +.5i
707 .nf
708 \fBmpls 100000 && mpls 1024\fR
709 .fi
710 .in -.5i
711 filters packets with an outer label of 100000 and an inner label of
712 1024, and
713 .in +.5i
714 .nf
715 \fBmpls && mpls 1024 && host 192.9.200.1\fR
716 .fi
717 .in -.5i
718 filters packets to or from 192.9.200.1 with an inner label of 1024 and
719 any outer label.
720 .IP \fBpppoed\fP
721 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
722 type 0x8863).
723 .IP "\fBpppoes \fI[session_id]\fR"
724 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
725 type 0x8864).
726 If \fI[session_id]\fR is specified, only true if the packet has the specified
727 \fIsession_id\fR.
728 Note that the first \fBpppoes\fR keyword encountered in \fIexpression\fR
729 changes the decoding offsets for the remainder of \fIexpression\fR on
730 the assumption that the packet is a PPPoE session packet.
731 .IP
732 For example:
733 .in +.5i
734 .nf
735 \fBpppoes 0x27 && ip\fR
736 .fi
737 .in -.5i
738 filters IPv4 protocols encapsulated in PPPoE session id 0x27.
739 .IP "\fBgeneve \fI[vni]\fR"
740 True if the packet is a Geneve packet (UDP port 6081). If \fI[vni]\fR
741 is specified, only true if the packet has the specified \fIvni\fR.
742 Note that when the \fBgeneve\fR keyword is encountered in
743 \fIexpression\fR, it changes the decoding offsets for the remainder of
744 \fIexpression\fR on the assumption that the packet is a Geneve packet.
745 .IP
746 For example:
747 .in +.5i
748 .nf
749 \fBgeneve 0xb && ip\fR
750 .fi
751 .in -.5i
752 filters IPv4 protocols encapsulated in Geneve with VNI 0xb. This will
753 match both IP directly encapsulated in Geneve as well as IP contained
754 inside an Ethernet frame.
755 .IP "\fBiso proto \fIprotocol\fR"
756 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
757 \fIProtocol\fP can be a number or one of the names
758 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
759 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
760 Abbreviations for:
761 .in +.5i
762 .nf
763 \fBiso proto \fIp\fR
764 .fi
765 .in -.5i
766 where \fIp\fR is one of the above protocols.
767 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
768 Abbreviations for IS-IS PDU types.
769 .IP "\fBvpi\fP \fIn\fR"
770 True if the packet is an ATM packet, for SunATM on Solaris, with a
771 virtual path identifier of
772 .IR n .
773 .IP "\fBvci\fP \fIn\fR"
774 True if the packet is an ATM packet, for SunATM on Solaris, with a
775 virtual channel identifier of
776 .IR n .
777 .IP \fBlane\fP
778 True if the packet is an ATM packet, for SunATM on Solaris, and is
779 an ATM LANE packet.
780 Note that the first \fBlane\fR keyword encountered in \fIexpression\fR
781 changes the tests done in the remainder of \fIexpression\fR
782 on the assumption that the packet is either a LANE emulated Ethernet
783 packet or a LANE LE Control packet.  If \fBlane\fR isn't specified, the
784 tests are done under the assumption that the packet is an
785 LLC-encapsulated packet.
786 .IP \fBoamf4s\fP
787 True if the packet is an ATM packet, for SunATM on Solaris, and is
788 a segment OAM F4 flow cell (VPI=0 & VCI=3).
789 .IP \fBoamf4e\fP
790 True if the packet is an ATM packet, for SunATM on Solaris, and is
791 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
792 .IP \fBoamf4\fP
793 True if the packet is an ATM packet, for SunATM on Solaris, and is
794 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
795 .IP \fBoam\fP
796 True if the packet is an ATM packet, for SunATM on Solaris, and is
797 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
798 .IP \fBmetac\fP
799 True if the packet is an ATM packet, for SunATM on Solaris, and is
800 on a meta signaling circuit (VPI=0 & VCI=1).
801 .IP \fBbcc\fP
802 True if the packet is an ATM packet, for SunATM on Solaris, and is
803 on a broadcast signaling circuit (VPI=0 & VCI=2).
804 .IP \fBsc\fP
805 True if the packet is an ATM packet, for SunATM on Solaris, and is
806 on a signaling circuit (VPI=0 & VCI=5).
807 .IP \fBilmic\fP
808 True if the packet is an ATM packet, for SunATM on Solaris, and is
809 on an ILMI circuit (VPI=0 & VCI=16).
810 .IP \fBconnectmsg\fP
811 True if the packet is an ATM packet, for SunATM on Solaris, and is
812 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
813 Connect Ack, Release, or Release Done message.
814 .IP \fBmetaconnect\fP
815 True if the packet is an ATM packet, for SunATM on Solaris, and is
816 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
817 Release, or Release Done message.
818 .IP  "\fIexpr relop expr\fR"
819 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
820 !=, and \fIexpr\fR is an arithmetic expression composed of integer
821 constants (expressed in standard C syntax), the normal binary operators
822 [+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data
823 accessors.  Note that all comparisons are unsigned, so that, for example,
824 0x80000000 and 0xffffffff are > 0.
825 .IP
826 The % and ^ operators are currently only supported for filtering in the
827 kernel on Linux with 3.7 and later kernels; on all other systems, if
828 those operators are used, filtering will be done in user mode, which
829 will increase the overhead of capturing packets and may cause more
830 packets to be dropped.
831 .IP
832 To access data inside the packet, use the following syntax:
833 .in +.5i
834 .nf
835 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
836 .fi
837 .in -.5i
838 \fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
839 ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and
840 indicates the protocol layer for the index operation.
841 (\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
842 link layer. \fBradio\fR refers to the "radio header" added to some
843 802.11 captures.)
844 Note that \fItcp, udp\fR and other upper-layer protocol types only
845 apply to IPv4, not IPv6 (this will be fixed in the future).
846 The byte offset, relative to the indicated protocol layer, is
847 given by \fIexpr\fR.
848 \fISize\fR is optional and indicates the number of bytes in the
849 field of interest; it can be either one, two, or four, and defaults to one.
850 The length operator, indicated by the keyword \fBlen\fP, gives the
851 length of the packet.
852
853 For example, `\fBether[0] & 1 != 0\fP' catches all multicast traffic.
854 The expression `\fBip[0] & 0xf != 5\fP'
855 catches all IPv4 packets with options.
856 The expression
857 `\fBip[6:2] & 0x1fff = 0\fP'
858 catches only unfragmented IPv4 datagrams and frag zero of fragmented
859 IPv4 datagrams.
860 This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
861 index operations.
862 For instance, \fBtcp[0]\fP always means the first
863 byte of the TCP \fIheader\fP, and never means the first byte of an
864 intervening fragment.
865
866 Some offsets and field values may be expressed as names rather than
867 as numeric values.
868 The following protocol header field offsets are
869 available: \fBicmptype\fP (ICMP type field), \fBicmp6type (ICMP v6 type field)
870 \fBicmpcode\fP (ICMP code field), \fBicmp6code\fP (ICMP v6 code field), and
871 \fBtcpflags\fP (TCP flags field).
872
873 The following ICMP type field values are available: \fBicmp-echoreply\fP,
874 \fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP,
875 \fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP,
876 \fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP,
877 \fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP,
878 \fBicmp-maskreq\fP, \fBicmp-maskreply\fP.
879
880 The following ICMPv6 type fields are available: \fBicmp6-echo\fP,
881 \fBicmp6-echoreply\fP, \fBicmp6-multicastlistenerquery\fP,
882 \fBicmp6-multicastlistenerreportv1\fP, \fBicmp6-multicastlistenerdone\fP,
883 \fBicmp6-routersolicit\fP, \fBicmp6-routeradvert\fP,
884 \fBicmp6-neighborsolicit\fP, \fBicmp6-neighboradvert\fP, \fBicmp6-redirect\fP,
885 \fBicmp6-routerrenum\fP, \fBicmp6-nodeinformationquery\fP,
886 \fBicmp6-nodeinformationresponse\fP, \fBicmp6-ineighbordiscoverysolicit\fP,
887 \fBicmp6-ineighbordiscoveryadvert\fP, \fBicmp6-multicastlistenerreportv2\fP,
888 \fBicmp6-homeagentdiscoveryrequest\fP, \fBicmp6-homeagentdiscoveryreply\fP,
889 \fBicmp6-mobileprefixsolicit\fP, \fBicmp6-mobileprefixadvert\fP,
890 \fBicmp6-certpathsolicit\fP, \fBicmp6-certpathadvert\fP,
891 \fBicmp6-multicastrouteradvert\fP, \fBicmp6-multicastroutersolicit\fP,
892 \fBicmp6-multicastrouterterm\fP.
893
894 The following TCP flags field values are available: \fBtcp-fin\fP,
895 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
896 \fBtcp-ack\fP, \fBtcp-urg\fP, \fBtcp-ece\fP,
897 \fBtcp-cwr\fP.
898 .LP
899 Primitives may be combined using:
900 .IP
901 A parenthesized group of primitives and operators.
902 .IP
903 Negation (`\fB!\fP' or `\fBnot\fP').
904 .IP
905 Concatenation (`\fB&&\fP' or `\fBand\fP').
906 .IP
907 Alternation (`\fB||\fP' or `\fBor\fP').
908 .LP
909 Negation has highest precedence.
910 Alternation and concatenation have equal precedence and associate
911 left to right.
912 Note that explicit \fBand\fR tokens, not juxtaposition,
913 are now required for concatenation.
914 .LP
915 If an identifier is given without a keyword, the most recent keyword
916 is assumed.
917 For example,
918 .in +.5i
919 .nf
920 \fBnot host vs and ace\fR
921 .fi
922 .in -.5i
923 is short for
924 .in +.5i
925 .nf
926 \fBnot host vs and host ace\fR
927 .fi
928 .in -.5i
929 which should not be confused with
930 .in +.5i
931 .nf
932 \fBnot ( host vs or ace )\fR
933 .fi
934 .in -.5i
935 .SH EXAMPLES
936 .LP
937 To select all packets arriving at or departing from \fIsundown\fP:
938 .RS
939 .nf
940 \fBhost sundown\fP
941 .fi
942 .RE
943 .LP
944 To select traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR:
945 .RS
946 .nf
947 \fBhost helios and \\( hot or ace \\)\fP
948 .fi
949 .RE
950 .LP
951 To select all IP packets between \fIace\fR and any host except \fIhelios\fR:
952 .RS
953 .nf
954 \fBip host ace and not helios\fP
955 .fi
956 .RE
957 .LP
958 To select all traffic between local hosts and hosts at Berkeley:
959 .RS
960 .nf
961 .B
962 net ucb-ether
963 .fi
964 .RE
965 .LP
966 To select all ftp traffic through internet gateway \fIsnup\fP:
967 .RS
968 .nf
969 .B
970 gateway snup and (port ftp or ftp-data)
971 .fi
972 .RE
973 .LP
974 To select traffic neither sourced from nor destined for local hosts
975 (if you gateway to one other net, this stuff should never make it
976 onto your local net).
977 .RS
978 .nf
979 .B
980 ip and not net \fIlocalnet\fP
981 .fi
982 .RE
983 .LP
984 To select the start and end packets (the SYN and FIN packets) of each
985 TCP conversation that involves a non-local host.
986 .RS
987 .nf
988 .B
989 tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP
990 .fi
991 .RE
992 .LP
993 To select all IPv4 HTTP packets to and from port 80, i.e. print only
994 packets that contain data, not, for example, SYN and FIN packets and
995 ACK-only packets.  (IPv6 is left as an exercise for the reader.)
996 .RS
997 .nf
998 .B
999 tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)
1000 .fi
1001 .RE
1002 .LP
1003 To select IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
1004 .RS
1005 .nf
1006 .B
1007 gateway snup and ip[2:2] > 576
1008 .fi
1009 .RE
1010 .LP
1011 To select IP broadcast or multicast packets that were
1012 .I not
1013 sent via Ethernet broadcast or multicast:
1014 .RS
1015 .nf
1016 .B
1017 ether[0] & 1 = 0 and ip[16] >= 224
1018 .fi
1019 .RE
1020 .LP
1021 To select all ICMP packets that are not echo requests/replies (i.e., not
1022 ping packets):
1023 .RS
1024 .nf
1025 .B
1026 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
1027 .fi
1028 .RE
1029 .SH "SEE ALSO"
1030 pcap(3PCAP)
1031 .SH BUGS
1032 To report a security issue please send an e-mail to security@tcpdump.org.
1033 .LP
1034 To report bugs and other problems, contribute patches, request a
1035 feature, provide generic feedback etc please see the file
1036 .I CONTRIBUTING
1037 in the libpcap source tree root.
1038 .LP
1039 Filter expressions on fields other than those in Token Ring headers will
1040 not correctly handle source-routed Token Ring packets.
1041 .LP
1042 Filter expressions on fields other than those in 802.11 headers will not
1043 correctly handle 802.11 data packets with both To DS and From DS set.
1044 .LP
1045 .BR "ip6 proto"
1046 should chase header chain, but at this moment it does not.
1047 .BR "ip6 protochain"
1048 is supplied for this behavior.
1049 .LP
1050 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
1051 does not work against IPv6 packets.
1052 It only looks at IPv4 packets.