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
47       explicitly 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
107              machine'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.  port1
166              and port2 are interpreted in the same fashion as the port param‐
167              eter for port.
168
169       src portrange port1-port2
170              True  if  the  packet  has a source port value between port1 and
171              port2.
172
173       portrange port1-port2
174              True if either the source or destination port of the  packet  is
175              between port1 and port2.
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,
222              between  IPv6  header  and  TCP header.  The BPF code emitted by
223              this primitive is complex and cannot be  optimized  by  the  BPF
224              optimizer  code,  and  is not supported by filter engines in the
225              kernel, so this can be somewhat slow, and may cause more packets
226              to 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
247              being done is not available, either  because  the  interface  on
248              which  capture  is being done has no netmask or because the cap‐
249              ture is being done on the Linux "any" interface, which can  cap‐
250              ture  on  more than one interface, this check will not work cor‐
251              rectly.
252
253       ether multicast
254              True if the packet is an Ethernet multicast packet.   The  ether
255              keyword is optional.  This is shorthand for `ether[0] & 1 != 0'.
256
257       ip multicast
258              True if the packet is an IPv4 multicast packet.
259
260       ip6 multicast
261              True if the packet is an IPv6 multicast packet.
262
263       ether proto protocol
264              True if the packet is of ether type protocol.  Protocol can be a
265              number or one of the names aarp, arp, atalk,  decnet,  ip,  ip6,
266              ipx,  iso,  lat,  loopback,  mopdl, moprc, netbeui, rarp, sca or
267              stp.  Note these identifiers (except loopback) are also keywords
268              and must be escaped via backslash (\).
269
270              [In  the  case  of  FDDI  (e.g.,  `fddi proto \arp'), Token Ring
271              (e.g., `tr proto \arp'), and IEEE 802.11  wireless  LANs  (e.g.,
272              `wlan  proto  \arp'),  for most of those protocols, the protocol
273              identification comes from the 802.2 Logical Link  Control  (LLC)
274              header, which is usually layered on top of the FDDI, Token Ring,
275              or 802.11 header.
276
277              When filtering for most  protocol  identifiers  on  FDDI,  Token
278              Ring, or 802.11, the filter checks only the protocol ID field of
279              an LLC header in so-called SNAP format  with  an  Organizational
280              Unit Identifier (OUI) of 0x000000, for encapsulated Ethernet; it
281              doesn't check whether the packet is in SNAP format with  an  OUI
282              of 0x000000.  The exceptions are:
283
284              iso    the  filter  checks  the DSAP (Destination Service Access
285                     Point) and SSAP (Source Service Access Point)  fields  of
286                     the LLC header;
287
288              stp and netbeui
289                     the filter checks the DSAP of the LLC header;
290
291              atalk  the filter checks for a SNAP-format packet with an OUI of
292                     0x080007 and the AppleTalk etype.
293
294              In the case of Ethernet, the filter  checks  the  Ethernet  type
295              field for most of those protocols.  The exceptions are:
296
297              iso, stp, and netbeui
298                     the  filter checks for an 802.3 frame and then checks the
299                     LLC header as it does for FDDI, Token Ring, and 802.11;
300
301              atalk  the filter checks both for the AppleTalk etype in an Eth‐
302                     ernet  frame  and for a SNAP-format packet as it does for
303                     FDDI, Token Ring, and 802.11;
304
305              aarp   the filter checks for the AppleTalk ARP etype  in  either
306                     an  Ethernet  frame or an 802.2 SNAP frame with an OUI of
307                     0x000000;
308
309              ipx    the filter checks for the IPX etype in an Ethernet frame,
310                     the  IPX  DSAP  in the LLC header, the 802.3-with-no-LLC-
311                     header encapsulation of IPX, and the IPX etype in a  SNAP
312                     frame.
313
314       ip, ip6, arp, rarp, atalk, aarp, decnet, iso, stp, ipx, netbeui
315              Abbreviations for:
316                   ether proto \protocol
317              where protocol is one of the above protocols.
318
319       lat, moprc, mopdl
320              Abbreviations for:
321                   ether proto \protocol
322              where protocol is one of the above protocols.  Note that not all
323              applications using pcap(3PCAP) currently know how to parse these
324              protocols.
325
326       decnet src host
327              True  if  the  DECnet  source  address  is host, which may be an
328              address of the form ``10.123'', or a DECnet host name.   [DECnet
329              host  name  support is only available on ULTRIX systems that are
330              configured to run DECnet.]
331
332       decnet dst host
333              True if the DECnet destination address is host.
334
335       decnet host host
336              True if either the DECnet source or destination address is host.
337
338       llc    True if the packet has an 802.2 LLC header.  This includes:
339
340              Ethernet packets with a length field rather than  a  type  field
341              that aren't raw NetWare-over-802.3 packets;
342
343              IEEE 802.11 data packets;
344
345              Token Ring packets (no check is done for LLC frames);
346
347              FDDI packets (no check is done for LLC frames);
348
349              LLC-encapsulated ATM packets, for SunATM on Solaris.
350
351       llc type
352              True if the packet has an 802.2 LLC header and has the specified
353              type.  type can be one of:
354
355              i      Information (I) PDUs
356
357              s      Supervisory (S) PDUs
358
359              u      Unnumbered (U) PDUs
360
361              rr     Receiver Ready (RR) S PDUs
362
363              rnr    Receiver Not Ready (RNR) S PDUs
364
365              rej    Reject (REJ) S PDUs
366
367              ui     Unnumbered Information (UI) U PDUs
368
369              ua     Unnumbered Acknowledgment (UA) U PDUs
370
371              disc   Disconnect (DISC) U PDUs
372
373              sabme  Set Asynchronous Balanced Mode Extended (SABME) U PDUs
374
375              test   Test (TEST) U PDUs
376
377              xid    Exchange Identification (XID) U PDUs
378
379              frmr   Frame Reject (FRMR) U PDUs
380
381       inbound
382              Packet was received by the host performing  the  capture  rather
383              than  being  sent by that host.  This is only supported for cer‐
384              tain link-layer types, such as SLIP  and  the  ``cooked''  Linux
385              capture  mode  used  for  the  ``any'' device and for some other
386              device types.
387
388       outbound
389              Packet was sent by the host performing the capture  rather  than
390              being received by that host.  This is only supported for certain
391              link-layer types, such as SLIP and the ``cooked'' Linux  capture
392              mode  used  for  the  ``any''  device  and for some other device
393              types.
394
395       ifname interface
396              True if the packet was  logged  as  coming  from  the  specified
397              interface  (applies only to packets logged by OpenBSD's or Free‐
398              BSD's pf(4)).
399
400       on interface
401              Synonymous with the ifname modifier.
402
403       rnr num
404              True if the packet was logged as matching the specified PF  rule
405              number (applies only to packets logged by OpenBSD's or FreeBSD's
406              pf(4)).
407
408       rulenum num
409              Synonymous with the rnr modifier.
410
411       reason code
412              True if the packet was logged with the specified PF reason code.
413              The known codes are: match, bad-offset, fragment, short, normal‐
414              ize, and memory (applies only to packets logged by OpenBSD's  or
415              FreeBSD's pf(4)).
416
417       rset name
418              True if the packet was logged as matching the specified PF rule‐
419              set name of an anchored ruleset (applies only to packets  logged
420              by OpenBSD's or FreeBSD's pf(4)).
421
422       ruleset name
423              Synonymous with the rset modifier.
424
425       srnr num
426              True  if the packet was logged as matching the specified PF rule
427              number of an anchored ruleset (applies only to packets logged by
428              OpenBSD's or FreeBSD's pf(4)).
429
430       subrulenum num
431              Synonymous with the srnr modifier.
432
433       action act
434              True if PF took the specified action when the packet was logged.
435              Known actions are: pass and block and, with  later  versions  of
436              pf(4), nat, rdr, binat and scrub (applies only to packets logged
437              by OpenBSD's or FreeBSD's pf(4)).
438
439       wlan ra ehost
440              True if the IEEE 802.11 RA is ehost.  The RA field  is  used  in
441              all frames except for management frames.
442
443       wlan ta ehost
444              True  if  the  IEEE 802.11 TA is ehost.  The TA field is used in
445              all frames except for management frames and CTS (Clear To  Send)
446              and ACK (Acknowledgment) control frames.
447
448       wlan addr1 ehost
449              True if the first IEEE 802.11 address is ehost.
450
451       wlan addr2 ehost
452              True  if  the  second IEEE 802.11 address, if present, is ehost.
453              The second address field is used in all frames  except  for  CTS
454              (Clear To Send) and ACK (Acknowledgment) control frames.
455
456       wlan addr3 ehost
457              True  if  the  third  IEEE 802.11 address, if present, is ehost.
458              The third address field is used in management and  data  frames,
459              but not in control frames.
460
461       wlan addr4 ehost
462              True  if  the  fourth IEEE 802.11 address, if present, is ehost.
463              The fourth address field is only used for WDS (Wireless  Distri‐
464              bution System) frames.
465
466       type wlan_type
467              True  if  the  IEEE  802.11  frame  type  matches  the specified
468              wlan_type.  Valid wlan_types are: mgt, ctl and data.
469
470       type wlan_type subtype wlan_subtype
471              True if  the  IEEE  802.11  frame  type  matches  the  specified
472              wlan_type and frame subtype matches the specified wlan_subtype.
473
474              If the specified wlan_type is mgt, then valid wlan_subtypes are:
475              assoc-req,  assoc-resp,  reassoc-req,  reassoc-resp,  probe-req,
476              probe-resp, beacon, atim, disassoc, auth and deauth.
477
478              If the specified wlan_type is ctl, then valid wlan_subtypes are:
479              ps-poll, rts, cts, ack, cf-end and cf-end-ack.
480
481              If the specified wlan_type is  data,  then  valid  wlan_subtypes
482              are:  data,  data-cf-ack,  data-cf-poll, data-cf-ack-poll, null,
483              cf-ack, cf-poll, cf-ack-poll,  qos-data,  qos-data-cf-ack,  qos-
484              data-cf-poll, qos-data-cf-ack-poll, qos, qos-cf-poll and qos-cf-
485              ack-poll.
486
487       subtype wlan_subtype
488              True if the IEEE 802.11  frame  subtype  matches  the  specified
489              wlan_subtype  and  frame  has  the  type  to which the specified
490              wlan_subtype belongs.
491
492       dir dir
493              True if the IEEE 802.11 frame direction  matches  the  specified
494              dir.   Valid  directions  are:  nods, tods, fromds, dstods, or a
495              numeric value.
496
497       vlan [vlan_id]
498              True if the packet is  an  IEEE  802.1Q  VLAN  packet.   If  the
499              optional  vlan_id  is specified, only true if the packet has the
500              specified vlan_id.  Note that the first vlan keyword encountered
501              in  an expression changes the decoding offsets for the remainder
502              of the expression on the assumption that the packet  is  a  VLAN
503              packet.   The  `vlan  [vlan_id]`  keyword  may be used more than
504              once, to filter on VLAN hierarchies.  Each use of  that  keyword
505              increments the filter offsets by 4.
506
507              For example:
508                   vlan 100 && vlan 200
509              filters on VLAN 200 encapsulated within VLAN 100, and
510                   vlan && vlan 300 && ip
511              filters  IPv4  protocol  encapsulated  in  VLAN 300 encapsulated
512              within any higher order VLAN.
513
514       mpls [label_num]
515              True if the packet is an MPLS packet.  If the optional label_num
516              is  specified,  only  true  if  the  packet  has  the  specified
517              label_num.  Note that the first mpls keyword encountered  in  an
518              expression changes the decoding offsets for the remainder of the
519              expression on the assumption that the packet is a  MPLS-encapsu‐
520              lated  IP  packet.   The  `mpls [label_num]` keyword may be used
521              more than once, to filter on MPLS hierarchies.  Each use of that
522              keyword increments the filter offsets by 4.
523
524              For example:
525                   mpls 100000 && mpls 1024
526              filters packets with an outer label of 100000 and an inner label
527              of 1024, and
528                   mpls && mpls 1024 && host 192.9.200.1
529              filters packets to or from 192.9.200.1 with an  inner  label  of
530              1024 and any outer label.
531
532       pppoed True if the packet is a PPP-over-Ethernet Discovery packet (Eth‐
533              ernet type 0x8863).
534
535       pppoes [session_id]
536              True if the packet is a PPP-over-Ethernet Session packet (Ether‐
537              net type 0x8864).  If the optional session_id is specified, only
538              true if the packet has the specified session_id.  Note that  the
539              first  pppoes  keyword  encountered in an expression changes the
540              decoding offsets for the remainder  of  the  expression  on  the
541              assumption that the packet is a PPPoE session packet.
542
543              For example:
544                   pppoes 0x27 && ip
545              filters IPv4 protocol encapsulated in PPPoE session id 0x27.
546
547       geneve [vni]
548              True  if  the  packet is a Geneve packet (UDP port 6081). If the
549              optional vni is specified, only true if the packet has the spec‐
550              ified  vni.  Note that when the geneve keyword is encountered in
551              an expression, it changes the decoding offsets for the remainder
552              of  the expression on the assumption that the packet is a Geneve
553              packet.
554
555              For example:
556                   geneve 0xb && ip
557              filters IPv4 protocol encapsulated in Geneve with VNI 0xb.  This
558              will  match both IPv4 directly encapsulated in Geneve as well as
559              IPv4 contained inside an Ethernet frame.
560
561       iso proto protocol
562              True if the packet is an OSI packet of protocol  type  protocol.
563              Protocol  can  be  a  number  or one of the names clnp, esis, or
564              isis.
565
566       clnp, esis, isis
567              Abbreviations for:
568                   iso proto \protocol
569              where protocol is one of the above protocols.
570
571       l1, l2, iih, lsp, snp, csnp, psnp
572              Abbreviations for IS-IS PDU types.
573
574       vpi n  True if the packet is an ATM packet, for SunATM on Solaris, with
575              a virtual path identifier of n.
576
577       vci n  True if the packet is an ATM packet, for SunATM on Solaris, with
578              a virtual channel identifier of n.
579
580       lane   True if the packet is an ATM packet, for SunATM on Solaris,  and
581              is an ATM LANE packet.  Note that the first lane keyword encoun‐
582              tered in an expression changes the tests done in  the  remainder
583              of  the expression on the assumption that the packet is either a
584              LANE emulated Ethernet packet or a LANE LE Control  packet.   If
585              lane  isn't  specified,  the tests are done under the assumption
586              that the packet is an LLC-encapsulated packet.
587
588       oamf4s True if the packet is an ATM packet, for SunATM on Solaris,  and
589              is a segment OAM F4 flow cell (VPI=0 & VCI=3).
590
591       oamf4e True  if the packet is an ATM packet, for SunATM on Solaris, and
592              is an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
593
594       oamf4  True if the packet is an ATM packet, for SunATM on Solaris,  and
595              is  a  segment  or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 |
596              VCI=4)).
597
598       oam    True if the packet is an ATM packet, for SunATM on Solaris,  and
599              is  a  segment  or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 |
600              VCI=4)).
601
602       metac  True if the packet is an ATM packet, for SunATM on Solaris,  and
603              is on a meta signaling circuit (VPI=0 & VCI=1).
604
605       bcc    True  if the packet is an ATM packet, for SunATM on Solaris, and
606              is on a broadcast signaling circuit (VPI=0 & VCI=2).
607
608       sc     True if the packet is an ATM packet, for SunATM on Solaris,  and
609              is on a signaling circuit (VPI=0 & VCI=5).
610
611       ilmic  True  if the packet is an ATM packet, for SunATM on Solaris, and
612              is on an ILMI circuit (VPI=0 & VCI=16).
613
614       connectmsg
615              True if the packet is an ATM packet, for SunATM on Solaris,  and
616              is  on  a signaling circuit and is a Q.2931 Setup, Call Proceed‐
617              ing, Connect, Connect Ack, Release, or Release Done message.
618
619       metaconnect
620              True if the packet is an ATM packet, for SunATM on Solaris,  and
621              is  on a meta signaling circuit and is a Q.2931 Setup, Call Pro‐
622              ceeding, Connect, Release, or Release Done message.
623
624       expr relop expr
625              True if the relation holds, where relop is one of >, <, >=,  <=,
626              =,  !=, and expr is an arithmetic expression composed of integer
627              constants (expressed in standard C syntax),  the  normal  binary
628              operators  [+,  -, *, /, %, &, |, ^, <<, >>], a length operator,
629              and special packet data accessors.  Note  that  all  comparisons
630              are  unsigned,  so  that, for example, 0x80000000 and 0xffffffff
631              are > 0.
632
633              The % and ^ operators are currently only supported for filtering
634              in  the kernel on Linux with 3.7 and later kernels; on all other
635              systems, if those operators are used, filtering will be done  in
636              user mode, which will increase the overhead of capturing packets
637              and may cause more packets to be dropped.
638
639              To access data inside the packet, use the following syntax:
640                   proto [ expr : size ]
641              Proto is one of ether, fddi, tr, wlan, ppp, slip, link, ip, arp,
642              rarp,  tcp,  udp, icmp, ip6 or radio, and indicates the protocol
643              layer for the index operation.  (ether,  fddi,  wlan,  tr,  ppp,
644              slip  and  link all refer to the link layer. radio refers to the
645              "radio header" added to some 802.11 captures.)  Note  that  tcp,
646              udp and other upper-layer protocol types only apply to IPv4, not
647              IPv6 (this will be fixed in the future).  The byte offset, rela‐
648              tive to the indicated protocol layer, is given by expr.  Size is
649              optional and indicates the number  of  bytes  in  the  field  of
650              interest;  it  can  be either one, two, or four, and defaults to
651              one.  The length operator, indicated by the keyword  len,  gives
652              the length of the packet.
653
654              For  example, `ether[0] & 1 != 0' catches all multicast traffic.
655              The expression `ip[0] & 0xf != 5' catches all IPv4 packets  with
656              options.   The  expression  `ip[6:2]  & 0x1fff = 0' catches only
657              unfragmented IPv4 datagrams and frag  zero  of  fragmented  IPv4
658              datagrams.   This check is implicitly applied to the tcp and udp
659              index operations.  For instance, tcp[0] always means  the  first
660              byte  of  the  TCP  header, and never means the first byte of an
661              intervening fragment.
662
663              Some offsets and field values may be expressed as  names  rather
664              than  as  numeric  values.   The following protocol header field
665              offsets are available: icmptype  (ICMP  type  field),  icmp6type
666              (ICMPv6  type  field),  icmpcode  (ICMP  code  field), icmp6code
667              (ICMPv6 code field) and tcpflags (TCP flags field).
668
669              The following ICMP type field values are available: icmp-echore‐
670              ply,  icmp-unreach, icmp-sourcequench, icmp-redirect, icmp-echo,
671              icmp-routeradvert,  icmp-routersolicit,   icmp-timxceed,   icmp-
672              paramprob,  icmp-tstamp,  icmp-tstampreply, icmp-ireq, icmp-ire‐
673              qreply, icmp-maskreq, icmp-maskreply.
674
675              The following ICMPv6 type fields are  available:  icmp6-destina‐
676              tionrunreach,       icmp6-packettoobig,      icmp6-timeexceeded,
677              icmp6-parameterproblem, icmp6-echo, icmp6-echoreply,  icmp6-mul‐
678              ticastlistenerquery, icmp6-multicastlistenerreportv1, icmp6-mul‐
679              ticastlistenerdone,   icmp6-routersolicit,   icmp6-routeradvert,
680              icmp6-neighborsolicit,   icmp6-neighboradvert,   icmp6-redirect,
681              icmp6-routerrenum, icmp6-nodeinformationquery,  icmp6-nodeinfor‐
682              mationresponse,  icmp6-ineighbordiscoverysolicit,  icmp6-ineigh‐
683              bordiscoveryadvert, icmp6-multicastlistenerreportv2, icmp6-home‐
684              agentdiscoveryrequest,            icmp6-homeagentdiscoveryreply,
685              icmp6-mobileprefixsolicit, icmp6-mobileprefixadvert, icmp6-cert‐
686              pathsolicit,  icmp6-certpathadvert, icmp6-multicastrouteradvert,
687              icmp6-multicastroutersolicit, icmp6-multicastrouterterm.
688
689              The following TCP flags field  values  are  available:  tcp-fin,
690              tcp-syn, tcp-rst, tcp-push, tcp-ack, tcp-urg, tcp-ece, tcp-cwr.
691
692       Primitives may be combined using:
693
694              A parenthesized group of primitives and operators.
695
696              Negation (`!' or `not').
697
698              Concatenation (`&&' or `and').
699
700              Alternation (`||' or `or').
701
702       Negation  has  the  highest  precedence.  Alternation and concatenation
703       have equal precedence and associate left to right.  Note that  explicit
704       and tokens, not juxtaposition, are now required for concatenation.
705
706       If an identifier is given without a keyword, the most recent keyword is
707       assumed.  For example,
708            not host vs and ace
709       is short for
710            not host vs and host ace
711       which should not be confused with
712            not (host vs or ace)
713

EXAMPLES

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

SEE ALSO

763       pcap(3PCAP)
764

BUGS

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