1PCAP-FILTER(7)         Miscellaneous Information Manual         PCAP-FILTER(7)
2
3
4

NAME

6       pcap-filter - packet filter syntax
7

DESCRIPTION

9       pcap_compile()  is used to compile a string into a filter program.  The
10       resulting filter program can then be applied to some stream of  packets
11       to  determine  which  packets  will  be  supplied  to pcap_loop(3PCAP),
12       pcap_dispatch(3PCAP), pcap_next(3PCAP), or pcap_next_ex(3PCAP).
13
14       The filter expression consists of one or more  primitives.   Primitives
15       usually consist of an id (name or number) preceded by one or more qual‐
16       ifiers.  There are three different kinds of qualifier:
17
18       type   type qualifiers say what kind of thing the  id  name  or  number
19              refers  to.   Possible  types are host, net, port and portrange.
20              E.g., `host foo', `net 128.3', `port 20', `portrange 6000-6008'.
21              If there is no type qualifier, host is assumed.
22
23       dir    dir qualifiers specify a particular transfer direction to and/or
24              from id.  Possible directions are src, dst, src or dst, src  and
25              dst,  ra,  ta, addr1, addr2, addr3, and addr4.  E.g., `src foo',
26              `dst net 128.3', `src or dst port ftp-data'.  If there is no dir
27              qualifier,  `src  or dst' is assumed.  The ra, ta, addr1, addr2,
28              addr3, and addr4 qualifiers are only valid for IEEE 802.11 Wire‐
29              less LAN link layers.
30
31       proto  proto  qualifiers  restrict  the match to a particular protocol.
32              Possible protos are: ether, fddi, tr, wlan, ip, ip6, arp,  rarp,
33              decnet,  tcp  and  udp.  E.g., `ether src foo', `arp net 128.3',
34              `tcp  port  21',  `udp   portrange   7000-7009',   `wlan   addr2
35              0:2:3:4:5:6'.   If  there  is  no proto qualifier, all protocols
36              consistent with the type are assumed.   E.g.,  `src  foo'  means
37              `(ip  or  arp  or rarp) src foo' (except the latter is not legal
38              syntax), `net bar' means `(ip or arp or rarp) net bar' and `port
39              53' means `(tcp or udp) port 53'.
40
41       [fddi  is  actually  an alias for ether; the parser treats them identi‐
42       cally as meaning ``the data link level used on  the  specified  network
43       interface''.  FDDI headers contain Ethernet-like source and destination
44       addresses, and often contain Ethernet-like packet  types,  so  you  can
45       filter on these FDDI fields just as with the analogous Ethernet fields.
46       FDDI headers also contain other fields, but you cannot  name  them  ex‐
47       plicitly in a filter expression.
48
49       Similarly,  tr and wlan are aliases for ether; the previous paragraph's
50       statements about FDDI headers also apply to Token Ring and 802.11 wire‐
51       less  LAN  headers.  For 802.11 headers, the destination address is the
52       DA field and the source address is the SA field; the BSSID, RA, and  TA
53       fields aren't tested.]
54
55       In  addition  to the above, there are some special `primitive' keywords
56       that don't follow the pattern: gateway, broadcast,  less,  greater  and
57       arithmetic expressions.  All of these are described below.
58
59       More complex filter expressions are built up by using the words and, or
60       and not (or equivalently: `&&', `||' and `!' respectively)  to  combine
61       primitives.   E.g.,  `host foo and not port ftp and not port ftp-data'.
62       To save typing, identical qualifier lists can be omitted.   E.g.,  `tcp
63       dst  port  ftp  or  ftp-data or domain' is exactly the same as `tcp dst
64       port ftp or tcp dst port ftp-data or tcp dst port domain'.
65
66       Allowable primitives are:
67
68       dst host host
69              True if the IPv4/v6 destination field of  the  packet  is  host,
70              which may be either an address or a name.
71
72       src host host
73              True if the IPv4/v6 source field of the packet is host.
74
75       host host
76              True  if  either the IPv4/v6 source or destination of the packet
77              is host.
78
79              Any of the above host expressions can be prepended with the key‐
80              words, ip, arp, rarp, or ip6 as in:
81                   ip host host
82              which is equivalent to:
83                   ether proto \ip and host host
84              If  host  is  a  name with multiple IPv4 addresses, each address
85              will be checked for a match.
86
87       ether dst ehost
88              True if the Ethernet destination address is ehost.  Ehost may be
89              either a name from /etc/ethers or a numerical MAC address of the
90              form "xx:xx:xx:xx:xx:xx", "xx.xx.xx.xx.xx.xx",  "xx-xx-xx-xx-xx-
91              xx",  "xxxx.xxxx.xxxx", "xxxxxxxxxxxx", or various mixes of ':',
92              '.', and '-', where each "x" is a hex digit (0-9, a-f, or A-F).
93
94       ether src ehost
95              True if the Ethernet source address is ehost.
96
97       ether host ehost
98              True if either the Ethernet source  or  destination  address  is
99              ehost.
100
101       gateway host
102              True  if  the packet used host as a gateway.  I.e., the Ethernet
103              source or destination address was host but neither the IP source
104              nor  the  IP destination was host.  Host must be a name and must
105              be found both by the machine's  host-name-to-IP-address  resolu‐
106              tion  mechanisms (host name file, DNS, NIS, etc.) and by the ma‐
107              chine's   host-name-to-Ethernet-address   resolution   mechanism
108              (/etc/ethers, etc.).  (An equivalent expression is
109                   ether host ehost and not host host
110              which  can  be  used  with  either  names  or numbers for host /
111              ehost.)  This syntax does not work in IPv6-enabled configuration
112              at this moment.
113
114       dst net net
115              True if the IPv4/v6 destination address of the packet has a net‐
116              work number of net.  Net may be either a name from the  networks
117              database  (/etc/networks,  etc.)  or  a network number.  An IPv4
118              network  number  can  be  written  as  a  dotted   quad   (e.g.,
119              192.168.1.0), dotted triple (e.g., 192.168.1), dotted pair (e.g,
120              172.16),  or  single  number  (e.g.,   10);   the   netmask   is
121              255.255.255.255  for a dotted quad (which means that it's really
122              a host match), 255.255.255.0 for a  dotted  triple,  255.255.0.0
123              for  a  dotted  pair, or 255.0.0.0 for a single number.  An IPv6
124              network number  must  be  written  out  fully;  the  netmask  is
125              ff:ff:ff:ff:ff:ff:ff:ff,  so  IPv6  "network" matches are really
126              always host matches, and a  network  match  requires  a  netmask
127              length.
128
129       src net net
130              True  if  the IPv4/v6 source address of the packet has a network
131              number of net.
132
133       net net
134              True if either the IPv4/v6 source or destination address of  the
135              packet has a network number of net.
136
137       net net mask netmask
138              True  if the IPv4 address matches net with the specific netmask.
139              May be qualified with src or dst.  Note that this syntax is  not
140              valid for IPv6 net.
141
142       net net/len
143              True  if the IPv4/v6 address matches net with a netmask len bits
144              wide.  May be qualified with src or dst.
145
146       dst port port
147              True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or  IPv6  UDP
148              and  has  a  destination  port value of port.  The port can be a
149              number  or  a  name  used  in  /etc/services  (see  tcp(4P)  and
150              udp(4P)).   If a name is used, both the port number and protocol
151              are checked.  If a number or ambiguous name is  used,  only  the
152              port  number  is  checked  (e.g., `dst port 513' will print both
153              tcp/login traffic and udp/who traffic, and  `port  domain'  will
154              print both tcp/domain and udp/domain traffic).
155
156       src port port
157              True if the packet has a source port value of port.
158
159       port port
160              True  if  either the source or destination port of the packet is
161              port.
162
163       dst portrange port1-port2
164              True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or  IPv6  UDP
165              and  has  a destination port value between port1 and port2 (both
166              inclusive).  port1 and port2 are interpreted in the same fashion
167              as the port parameter for port.
168
169       src portrange port1-port2
170              True  if  the  packet  has a source port value between port1 and
171              port2 (both inclusive).
172
173       portrange port1-port2
174              True if either the source or destination port of the  packet  is
175              between port1 and port2 (both inclusive).
176
177              Any of the above port or port range expressions can be prepended
178              with the keywords, tcp or udp, as in:
179                   tcp src port port
180              which matches only TCP packets whose source port is port.
181
182       less length
183              True if the packet has a length less than or  equal  to  length.
184              This is equivalent to:
185                   len <= length
186
187       greater length
188              True if the packet has a length greater than or equal to length.
189              This is equivalent to:
190                   len >= length
191
192       ip proto protocol
193              True if the packet is an IPv4 packet (see  ip(4P))  of  protocol
194              type  protocol.   Protocol  can  be a number or one of the names
195              icmp, icmp6, igmp, igrp, pim, ah, esp, vrrp, udp, or tcp.   Note
196              that  the  identifiers  tcp, udp, and icmp are also keywords and
197              must be escaped via backslash (\).   Note  that  this  primitive
198              does not chase the protocol header chain.
199
200       ip6 proto protocol
201              True  if the packet is an IPv6 packet of protocol type protocol.
202              Note that this primitive does  not  chase  the  protocol  header
203              chain.
204
205       proto protocol
206              True  if  the  packet is an IPv4 or IPv6 packet of protocol type
207              protocol.  Note that this primitive does not chase the  protocol
208              header chain.
209
210       tcp, udp, icmp
211              Abbreviations for:
212                   proto \protocol
213              where protocol is one of the above protocols.
214
215       ip6 protochain protocol
216              True  if the packet is IPv6 packet, and contains protocol header
217              with type protocol in its protocol header chain.  For example,
218                   ip6 protochain 6
219              matches any IPv6 packet with TCP protocol header in the protocol
220              header  chain.  The packet may contain, for example, authentica‐
221              tion header, routing header, or hop-by-hop  option  header,  be‐
222              tween  IPv6 header and TCP header.  The BPF code emitted by this
223              primitive is complex and cannot be optimized by  the  BPF  opti‐
224              mizer  code,  and is not supported by filter engines in the ker‐
225              nel, so this can be somewhat slow, and may cause more packets to
226              be dropped.
227
228       ip protochain protocol
229              Equivalent to ip6 protochain protocol, but this is for IPv4.
230
231       protochain protocol
232              True  if  the  packet is an IPv4 or IPv6 packet of protocol type
233              protocol.  Note that this primitive chases the  protocol  header
234              chain.
235
236       ether broadcast
237              True  if  the packet is an Ethernet broadcast packet.  The ether
238              keyword is optional.
239
240       ip broadcast
241              True if the packet is an IPv4 broadcast packet.  It  checks  for
242              both  the  all-zeroes  and  all-ones  broadcast conventions, and
243              looks up the subnet mask on the interface on which  the  capture
244              is being done.
245
246              If  the subnet mask of the interface on which the capture is be‐
247              ing done is not available, either because the interface on which
248              capture  is  being done has no netmask or because the capture is
249              being done on the Linux "any" interface, which  can  capture  on
250              more than one interface, this check will not work correctly.
251
252       ether multicast
253              True  if  the packet is an Ethernet multicast packet.  The ether
254              keyword is optional.  This is shorthand for `ether[0] & 1 != 0'.
255
256       ip multicast
257              True if the packet is an IPv4 multicast packet.
258
259       ip6 multicast
260              True if the packet is an IPv6 multicast packet.
261
262       ether proto protocol
263              True if the packet is of ether type protocol.  Protocol can be a
264              number  or  one  of the names aarp, arp, atalk, decnet, ip, ip6,
265              ipx, iso, lat, loopback, mopdl, moprc,  netbeui,  rarp,  sca  or
266              stp.  Note these identifiers (except loopback) are also keywords
267              and must be escaped via backslash (\).
268
269              [In the case of FDDI  (e.g.,  `fddi  proto  \arp'),  Token  Ring
270              (e.g.,  `tr  proto  \arp'), and IEEE 802.11 wireless LANs (e.g.,
271              `wlan proto \arp'), for most of those  protocols,  the  protocol
272              identification  comes  from the 802.2 Logical Link Control (LLC)
273              header, which is usually layered on top of the FDDI, Token Ring,
274              or 802.11 header.
275
276              When  filtering  for  most  protocol  identifiers on FDDI, Token
277              Ring, or 802.11, the filter checks only the protocol ID field of
278              an  LLC  header  in so-called SNAP format with an Organizational
279              Unit Identifier (OUI) of 0x000000, for encapsulated Ethernet; it
280              doesn't  check  whether the packet is in SNAP format with an OUI
281              of 0x000000.  The exceptions are:
282
283              iso    the filter checks the DSAP  (Destination  Service  Access
284                     Point)  and  SSAP (Source Service Access Point) fields of
285                     the LLC header;
286
287              stp and netbeui
288                     the filter checks the DSAP of the LLC header;
289
290              atalk  the filter checks for a SNAP-format packet with an OUI of
291                     0x080007 and the AppleTalk etype.
292
293              In  the  case  of  Ethernet, the filter checks the Ethernet type
294              field for most of those protocols.  The exceptions are:
295
296              iso, stp, and netbeui
297                     the filter checks for an 802.3 frame and then checks  the
298                     LLC header as it does for FDDI, Token Ring, and 802.11;
299
300              atalk  the filter checks both for the AppleTalk etype in an Eth‐
301                     ernet frame and for a SNAP-format packet as it  does  for
302                     FDDI, Token Ring, and 802.11;
303
304              aarp   the  filter  checks for the AppleTalk ARP etype in either
305                     an Ethernet frame or an 802.2 SNAP frame with an  OUI  of
306                     0x000000;
307
308              ipx    the filter checks for the IPX etype in an Ethernet frame,
309                     the IPX DSAP in the LLC  header,  the  802.3-with-no-LLC-
310                     header  encapsulation of IPX, and the IPX etype in a SNAP
311                     frame.
312
313       ip, ip6, arp, rarp, atalk, aarp, decnet, iso, stp, ipx, netbeui
314              Abbreviations for:
315                   ether proto \protocol
316              where protocol is one of the above protocols.
317
318       lat, moprc, mopdl
319              Abbreviations for:
320                   ether proto \protocol
321              where protocol is one of the above protocols.  Note that not all
322              applications using pcap(3PCAP) currently know how to parse these
323              protocols.
324
325       decnet src host
326              True if the DECnet source address is host, which may be  an  ad‐
327              dress  of  the  form ``10.123'', or a DECnet host name.  [DECnet
328              host name support is only available on ULTRIX systems  that  are
329              configured to run DECnet.]
330
331       decnet dst host
332              True if the DECnet destination address is host.
333
334       decnet host host
335              True if either the DECnet source or destination address is host.
336
337       llc    True if the packet has an 802.2 LLC header.  This includes:
338
339              Ethernet  packets  with  a length field rather than a type field
340              that aren't raw NetWare-over-802.3 packets;
341
342              IEEE 802.11 data packets;
343
344              Token Ring packets (no check is done for LLC frames);
345
346              FDDI packets (no check is done for LLC frames);
347
348              LLC-encapsulated ATM packets, for SunATM on Solaris.
349
350       llc type
351              True if the packet has an 802.2 LLC header and has the specified
352              type.  type can be one of:
353
354              i      Information (I) PDUs
355
356              s      Supervisory (S) PDUs
357
358              u      Unnumbered (U) PDUs
359
360              rr     Receiver Ready (RR) S PDUs
361
362              rnr    Receiver Not Ready (RNR) S PDUs
363
364              rej    Reject (REJ) S PDUs
365
366              ui     Unnumbered Information (UI) U PDUs
367
368              ua     Unnumbered Acknowledgment (UA) U PDUs
369
370              disc   Disconnect (DISC) U PDUs
371
372              sabme  Set Asynchronous Balanced Mode Extended (SABME) U PDUs
373
374              test   Test (TEST) U PDUs
375
376              xid    Exchange Identification (XID) U PDUs
377
378              frmr   Frame Reject (FRMR) U PDUs
379
380       inbound
381              Packet  was  received  by the host performing the capture rather
382              than being sent by that host.  This is only supported  for  cer‐
383              tain  link-layer  types,  such  as SLIP and the ``cooked'' Linux
384              capture mode used for the ``any'' device and for some other  de‐
385              vice types.
386
387       outbound
388              Packet  was  sent by the host performing the capture rather than
389              being received by that host.  This is only supported for certain
390              link-layer  types, such as SLIP and the ``cooked'' Linux capture
391              mode used for the ``any''  device  and  for  some  other  device
392              types.
393
394       ifname interface
395              True  if  the packet was logged as coming from the specified in‐
396              terface (applies only to packets logged by  OpenBSD's  or  Free‐
397              BSD's pf(4)).
398
399       on interface
400              Synonymous with the ifname modifier.
401
402       rnr num
403              True  if the packet was logged as matching the specified PF rule
404              number (applies only to packets logged by OpenBSD's or FreeBSD's
405              pf(4)).
406
407       rulenum num
408              Synonymous with the rnr modifier.
409
410       reason code
411              True if the packet was logged with the specified PF reason code.
412              The known codes are: match, bad-offset, fragment, short, normal‐
413              ize,  and memory (applies only to packets logged by OpenBSD's or
414              FreeBSD's pf(4)).
415
416       rset name
417              True if the packet was logged as matching the specified PF rule‐
418              set  name of an anchored ruleset (applies only to packets logged
419              by OpenBSD's or FreeBSD's pf(4)).
420
421       ruleset name
422              Synonymous with the rset modifier.
423
424       srnr num
425              True if the packet was logged as matching the specified PF  rule
426              number of an anchored ruleset (applies only to packets logged by
427              OpenBSD's or FreeBSD's pf(4)).
428
429       subrulenum num
430              Synonymous with the srnr modifier.
431
432       action act
433              True if PF took the specified action when the packet was logged.
434              Known  actions  are:  pass and block and, with later versions of
435              pf(4), nat, rdr, binat and scrub (applies only to packets logged
436              by OpenBSD's or FreeBSD's pf(4)).
437
438       wlan ra ehost
439              True  if  the  IEEE 802.11 RA is ehost.  The RA field is used in
440              all frames except for management frames.
441
442       wlan ta ehost
443              True if the IEEE 802.11 TA is ehost.  The TA field  is  used  in
444              all  frames except for management frames and CTS (Clear To Send)
445              and ACK (Acknowledgment) control frames.
446
447       wlan addr1 ehost
448              True if the first IEEE 802.11 address is ehost.
449
450       wlan addr2 ehost
451              True if the second IEEE 802.11 address, if  present,  is  ehost.
452              The  second  address  field is used in all frames except for CTS
453              (Clear To Send) and ACK (Acknowledgment) control frames.
454
455       wlan addr3 ehost
456              True if the third IEEE 802.11 address,  if  present,  is  ehost.
457              The  third  address field is used in management and data frames,
458              but not in control frames.
459
460       wlan addr4 ehost
461              True if the fourth IEEE 802.11 address, if  present,  is  ehost.
462              The  fourth address field is only used for WDS (Wireless Distri‐
463              bution System) frames.
464
465       type wlan_type
466              True if  the  IEEE  802.11  frame  type  matches  the  specified
467              wlan_type.  Valid wlan_types are: mgt, ctl and data.
468
469       type wlan_type subtype wlan_subtype
470              True  if  the  IEEE  802.11  frame  type  matches  the specified
471              wlan_type and frame subtype matches the specified wlan_subtype.
472
473              If the specified wlan_type is mgt, then valid wlan_subtypes are:
474              assoc-req,  assoc-resp,  reassoc-req,  reassoc-resp,  probe-req,
475              probe-resp, beacon, atim, disassoc, auth and deauth.
476
477              If the specified wlan_type is ctl, then valid wlan_subtypes are:
478              ps-poll, rts, cts, ack, cf-end and cf-end-ack.
479
480              If  the  specified  wlan_type  is data, then valid wlan_subtypes
481              are: data, data-cf-ack,  data-cf-poll,  data-cf-ack-poll,  null,
482              cf-ack,  cf-poll,  cf-ack-poll,  qos-data, qos-data-cf-ack, qos-
483              data-cf-poll, qos-data-cf-ack-poll, qos, qos-cf-poll and qos-cf-
484              ack-poll.
485
486       subtype wlan_subtype
487              True  if  the  IEEE  802.11  frame subtype matches the specified
488              wlan_subtype and frame has  the  type  to  which  the  specified
489              wlan_subtype belongs.
490
491       dir dir
492              True  if  the  IEEE 802.11 frame direction matches the specified
493              dir.  Valid directions are: nods, tods, fromds, dstods, or a nu‐
494              meric value.
495
496       vlan [vlan_id]
497              True  if  the  packet is an IEEE 802.1Q VLAN packet.  If the op‐
498              tional vlan_id is specified, only true if  the  packet  has  the
499              specified vlan_id.  Note that the first vlan keyword encountered
500              in an expression changes the decoding offsets for the  remainder
501              of  the  expression  on the assumption that the packet is a VLAN
502              packet.  The `vlan [vlan_id]` keyword  may  be  used  more  than
503              once,  to  filter on VLAN hierarchies.  Each use of that keyword
504              increments the filter offsets by 4.
505
506              For example:
507                   vlan 100 && vlan 200
508              filters on VLAN 200 encapsulated within VLAN 100, and
509                   vlan && vlan 300 && ip
510              filters IPv4 protocol  encapsulated  in  VLAN  300  encapsulated
511              within any higher order VLAN.
512
513       mpls [label_num]
514              True if the packet is an MPLS packet.  If the optional label_num
515              is specified, only true if the  packet  has  the  specified  la‐
516              bel_num.  Note that the first mpls keyword encountered in an ex‐
517              pression changes the decoding offsets for the remainder  of  the
518              expression  on the assumption that the packet is a MPLS-encapsu‐
519              lated IP packet.  The `mpls [label_num]`  keyword  may  be  used
520              more than once, to filter on MPLS hierarchies.  Each use of that
521              keyword increments the filter offsets by 4.
522
523              For example:
524                   mpls 100000 && mpls 1024
525              filters packets with an outer label of 100000 and an inner label
526              of 1024, and
527                   mpls && mpls 1024 && host 192.9.200.1
528              filters  packets  to  or from 192.9.200.1 with an inner label of
529              1024 and any outer label.
530
531       pppoed True if the packet is a PPP-over-Ethernet Discovery packet (Eth‐
532              ernet type 0x8863).
533
534       pppoes [session_id]
535              True if the packet is a PPP-over-Ethernet Session packet (Ether‐
536              net type 0x8864).  If the optional session_id is specified, only
537              true  if the packet has the specified session_id.  Note that the
538              first pppoes keyword encountered in an  expression  changes  the
539              decoding  offsets for the remainder of the expression on the as‐
540              sumption that the packet is a PPPoE session packet.
541
542              For example:
543                   pppoes 0x27 && ip
544              filters IPv4 protocol encapsulated in PPPoE session id 0x27.
545
546       geneve [vni]
547              True if the packet is a Geneve packet (UDP port  6081).  If  the
548              optional vni is specified, only true if the packet has the spec‐
549              ified vni.  Note that when the geneve keyword is encountered  in
550              an expression, it changes the decoding offsets for the remainder
551              of the expression on the assumption that the packet is a  Geneve
552              packet.
553
554              For example:
555                   geneve 0xb && ip
556              filters  IPv4 protocol encapsulated in Geneve with VNI 0xb. This
557              will match both IPv4 directly encapsulated in Geneve as well  as
558              IPv4 contained inside an Ethernet frame.
559
560       iso proto protocol
561              True  if  the packet is an OSI packet of protocol type protocol.
562              Protocol can be a number or one of  the  names  clnp,  esis,  or
563              isis.
564
565       clnp, esis, isis
566              Abbreviations for:
567                   iso proto \protocol
568              where protocol is one of the above protocols.
569
570       l1, l2, iih, lsp, snp, csnp, psnp
571              Abbreviations for IS-IS PDU types.
572
573       vpi n  True if the packet is an ATM packet, for SunATM on Solaris, with
574              a virtual path identifier of n.
575
576       vci n  True if the packet is an ATM packet, for SunATM on Solaris, with
577              a virtual channel identifier of n.
578
579       lane   True  if the packet is an ATM packet, for SunATM on Solaris, and
580              is an ATM LANE packet.  Note that the first lane keyword encoun‐
581              tered  in  an expression changes the tests done in the remainder
582              of the expression on the assumption that the packet is either  a
583              LANE  emulated  Ethernet packet or a LANE LE Control packet.  If
584              lane isn't specified, the tests are done  under  the  assumption
585              that the packet is an LLC-encapsulated packet.
586
587       oamf4s True  if the packet is an ATM packet, for SunATM on Solaris, and
588              is a segment OAM F4 flow cell (VPI=0 & VCI=3).
589
590       oamf4e True if the packet is an ATM packet, for SunATM on Solaris,  and
591              is an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
592
593       oamf4  True  if the packet is an ATM packet, for SunATM on Solaris, and
594              is a segment or end-to-end OAM F4 flow cell (VPI=0  &  (VCI=3  |
595              VCI=4)).
596
597       oam    True  if the packet is an ATM packet, for SunATM on Solaris, and
598              is a segment or end-to-end OAM F4 flow cell (VPI=0  &  (VCI=3  |
599              VCI=4)).
600
601       metac  True  if the packet is an ATM packet, for SunATM on Solaris, and
602              is on a meta signaling circuit (VPI=0 & VCI=1).
603
604       bcc    True if the packet is an ATM packet, for SunATM on Solaris,  and
605              is on a broadcast signaling circuit (VPI=0 & VCI=2).
606
607       sc     True  if the packet is an ATM packet, for SunATM on Solaris, and
608              is on a signaling circuit (VPI=0 & VCI=5).
609
610       ilmic  True if the packet is an ATM packet, for SunATM on Solaris,  and
611              is on an ILMI circuit (VPI=0 & VCI=16).
612
613       connectmsg
614              True  if the packet is an ATM packet, for SunATM on Solaris, and
615              is on a signaling circuit and is a Q.2931 Setup,  Call  Proceed‐
616              ing, Connect, Connect Ack, Release, or Release Done message.
617
618       metaconnect
619              True  if the packet is an ATM packet, for SunATM on Solaris, and
620              is on a meta signaling circuit and is a Q.2931 Setup, Call  Pro‐
621              ceeding, Connect, Release, or Release Done message.
622
623       expr relop expr
624              True  if the relation holds, where relop is one of >, <, >=, <=,
625              =, !=, and expr is an arithmetic expression composed of  integer
626              constants  (expressed  in  standard C syntax), the normal binary
627              operators [+, -, *, /, %, &, |, ^, <<, >>], a  length  operator,
628              and  special  packet  data accessors.  Note that all comparisons
629              are unsigned, so that, for example,  0x80000000  and  0xffffffff
630              are > 0.
631
632              The % and ^ operators are currently only supported for filtering
633              in the kernel on Linux with 3.7 and later kernels; on all  other
634              systems,  if those operators are used, filtering will be done in
635              user mode, which will increase the overhead of capturing packets
636              and may cause more packets to be dropped.
637
638              To access data inside the packet, use the following syntax:
639                   proto [ expr : size ]
640              Proto is one of ether, fddi, tr, wlan, ppp, slip, link, ip, arp,
641              rarp, tcp, udp, icmp, ip6 or radio, and indicates  the  protocol
642              layer  for  the  index  operation.  (ether, fddi, wlan, tr, ppp,
643              slip and link all refer to the link layer. radio refers  to  the
644              "radio  header"  added to some 802.11 captures.)  Note that tcp,
645              udp and other upper-layer protocol types only apply to IPv4, not
646              IPv6 (this will be fixed in the future).  The byte offset, rela‐
647              tive to the indicated protocol layer, is given by expr.  Size is
648              optional  and  indicates the number of bytes in the field of in‐
649              terest; it can be either one, two, or four, and defaults to one.
650              The  length  operator,  indicated  by the keyword len, gives the
651              length of the packet.
652
653              For example, `ether[0] & 1 != 0' catches all multicast  traffic.
654              The  expression `ip[0] & 0xf != 5' catches all IPv4 packets with
655              options.  The expression `ip[6:2] & 0x1fff = 0' catches only un‐
656              fragmented IPv4 datagrams and frag zero of fragmented IPv4 data‐
657              grams.  This check is implicitly applied to the tcp and udp  in‐
658              dex  operations.   For  instance,  tcp[0] always means the first
659              byte of the TCP header, and never means the first byte of an in‐
660              tervening fragment.
661
662              Some  offsets  and field values may be expressed as names rather
663              than as numeric values.  The  following  protocol  header  field
664              offsets  are  available:  icmptype  (ICMP type field), icmp6type
665              (ICMPv6 type  field),  icmpcode  (ICMP  code  field),  icmp6code
666              (ICMPv6 code field) and tcpflags (TCP flags field).
667
668              The following ICMP type field values are available: icmp-echore‐
669              ply, icmp-unreach, icmp-sourcequench, icmp-redirect,  icmp-echo,
670              icmp-routeradvert,   icmp-routersolicit,   icmp-timxceed,  icmp-
671              paramprob, icmp-tstamp, icmp-tstampreply,  icmp-ireq,  icmp-ire‐
672              qreply, icmp-maskreq, icmp-maskreply.
673
674              The  following  ICMPv6 type fields are available: icmp6-destina‐
675              tionrunreach, icmp6-packettoobig, icmp6-timeexceeded,  icmp6-pa‐
676              rameterproblem, icmp6-echo, icmp6-echoreply, icmp6-multicastlis‐
677              tenerquery, icmp6-multicastlistenerreportv1, icmp6-multicastlis‐
678              tenerdone, icmp6-routersolicit, icmp6-routeradvert, icmp6-neigh‐
679              borsolicit, icmp6-neighboradvert, icmp6-redirect,  icmp6-router‐
680              renum,    icmp6-nodeinformationquery,   icmp6-nodeinformationre‐
681              sponse, icmp6-ineighbordiscoverysolicit,  icmp6-ineighbordiscov‐
682              eryadvert,  icmp6-multicastlistenerreportv2, icmp6-homeagentdis‐
683              coveryrequest,  icmp6-homeagentdiscoveryreply,  icmp6-mobilepre‐
684              fixsolicit,   icmp6-mobileprefixadvert,   icmp6-certpathsolicit,
685              icmp6-certpathadvert, icmp6-multicastrouteradvert,  icmp6-multi‐
686              castroutersolicit, icmp6-multicastrouterterm.
687
688              The  following  TCP  flags  field values are available: tcp-fin,
689              tcp-syn, tcp-rst, tcp-push, tcp-ack, tcp-urg, tcp-ece, tcp-cwr.
690
691       Primitives may be combined using:
692
693              A parenthesized group of primitives and operators.
694
695              Negation (`!' or `not').
696
697              Concatenation (`&&' or `and').
698
699              Alternation (`||' or `or').
700
701       Negation has the highest  precedence.   Alternation  and  concatenation
702       have  equal precedence and associate left to right.  Note that explicit
703       and tokens, not juxtaposition, are now required for concatenation.
704
705       If an identifier is given without a keyword, the most recent keyword is
706       assumed.  For example,
707            not host vs and ace
708       is short for
709            not host vs and host ace
710       which should not be confused with
711            not (host vs or ace)
712

EXAMPLES

714       To select all packets arriving at or departing from `sundown':
715              host sundown
716
717       To select traffic between `helios' and either `hot' or `ace':
718              host helios and (hot or ace)
719
720       To select all IPv4 packets between `ace' and any host except `helios':
721              ip host ace and not helios
722
723       To select all traffic between local hosts and hosts at Berkeley:
724              net ucb-ether
725
726       To select all FTP traffic through Internet gateway `snup':
727              gateway snup and (port ftp or ftp-data)
728
729       To  select  IPv4  traffic  neither  sourced from nor destined for local
730       hosts (if you gateway to one other net, this stuff should never make it
731       onto your local net).
732              ip and not net localnet
733
734       To  select  the start and end packets (the SYN and FIN packets) of each
735       TCP conversation that involves a non-local host.
736              tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet
737
738       To select the TCP packets with flags RST and ACK both set.   (i.e.  se‐
739       lect  only  the RST and ACK flags in the flags field, and if the result
740       is "RST and ACK both set", match)
741              tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)
742
743       To select all IPv4 HTTP packets to and from port 80,  i.e.  print  only
744       packets  that  contain  data, not, for example, SYN and FIN packets and
745       ACK-only packets.  (IPv6 is left as an exercise for the reader.)
746              tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)
747
748       To select IPv4 packets longer  than  576  bytes  sent  through  gateway
749       `snup':
750              gateway snup and ip[2:2] > 576
751
752       To  select  IPv4  broadcast or multicast packets that were not sent via
753       Ethernet broadcast or multicast:
754              ether[0] & 1 = 0 and ip[16] >= 224
755
756       To select all ICMP packets that are not  echo  requests/replies  (i.e.,
757       not ping packets):
758              icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
759              icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply
760

SEE ALSO

762       pcap(3PCAP)
763

BUGS

765       To  report  a  security  issue  please  send an e-mail to security@tcp‐
766       dump.org.
767
768       To report bugs and other problems, contribute patches, request  a  fea‐
769       ture,  provide generic feedback etc please see the file CONTRIBUTING.md
770       in the libpcap source tree root.
771
772       Filter expressions on fields other than those  in  Token  Ring  headers
773       will not correctly handle source-routed Token Ring packets.
774
775       Filter  expressions  on  fields other than those in 802.11 headers will
776       not correctly handle 802.11 data packets with both To DS  and  From  DS
777       set.
778
779       `ip6  proto' should chase header chain, but at this moment it does not.
780       `ip6 protochain' is supplied for this behavior.  For example, to  match
781       IPv6 fragments: `ip6 protochain 44'
782
783       Arithmetic  expression  against  transport  layer headers, like tcp[0],
784       does not work against IPv6 packets.  It only looks at IPv4 packets.
785
786
787
788                                6 February 2021                 PCAP-FILTER(7)
Impressum