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 iden‐
42       tically 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 para‐
50       graph's statements about FDDI headers also  apply  to  Token  Ring  and
51       802.11  wireless  LAN  headers.   For  802.11  headers, the destination
52       address is the DA field and the source address is  the  SA  field;  the
53       BSSID, RA, and TA 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 to combine primitives.  E.g., `host foo and not  port  ftp  and
61       not  port  ftp-data'.  To save typing, identical qualifier lists can be
62       omitted.  E.g., `tcp dst port ftp or ftp-data or domain' is exactly the
63       same  as  `tcp  dst  port  ftp or tcp dst port ftp-data or tcp dst port
64       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 IP addresses, each address will
85              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 ip/tcp, ip/udp, ip6/tcp or ip6/udp and has
148              a destination port value of port.  The port can be a number or a
149              name used in /etc/services (see tcp(4P) and udp(4P)).  If a name
150              is  used,  both  the port number and protocol are checked.  If a
151              number or ambiguous name  is  used,  only  the  port  number  is
152              checked  (e.g.,  dst  port 513 will print both tcp/login traffic
153              and udp/who traffic, and port domain will print both  tcp/domain
154              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 ip/tcp, ip/udp, ip6/tcp or ip6/udp and has
165              a  destination  port  value  between port1 and port2.  port1 and
166              port2 are interpreted in the same fashion as the port  parameter
167              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 p
213              where p 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 ip, ip6, arp, rarp, atalk, aarp, dec‐
266              net,  sca,  lat,  mopdl, moprc, iso, stp, ipx, or netbeui.  Note
267              these identifiers are also keywords  and  must  be  escaped  via
268              backslash (\).
269
270              [In the case of FDDI (e.g., `fddi proto arp'), Token Ring (e.g.,
271              `tr proto arp'), and IEEE  802.11  wireless  LANS  (e.g.,  `wlan
272              proto arp'), for most of those protocols, the protocol identifi‐
273              cation comes from the 802.2 Logical Link Control  (LLC)  header,
274              which  is  usually  layered  on  top of the FDDI, Token Ring, or
275              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 p
317              where p is one of the above protocols.
318
319       lat, moprc, mopdl
320              Abbreviations for:
321                   ether proto p
322              where p is one of the above protocols.  Note that not all appli‐
323              cations using pcap(3PCAP) currently know how to parse these pro‐
324              tocols.
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  [vlan_id]
499              is specified, only true if the packet has the specified vlan_id.
500              Note that the  first  vlan  keyword  encountered  in  expression
501              changes  the decoding offsets for the remainder of expression on
502              the assumption that the packet  is  a  VLAN  packet.   The  vlan
503              [vlan_id]  expression  may  be used more than once, to filter on
504              VLAN hierarchies.  Each use of that  expression  increments  the
505              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  protocols  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 [label_num] is  speci‐
516              fied, only true is the packet has the specified label_num.  Note
517              that the first mpls keyword encountered  in  expression  changes
518              the  decoding  offsets  for  the  remainder of expression on the
519              assumption that the packet is  a  MPLS-encapsulated  IP  packet.
520              The  mpls  [label_num] expression may be used more than once, to
521              filter on MPLS hierarchies.  Each use of that expression  incre‐
522              ments 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 [session_id] is specified, only true if
538              the packet has the specified session_id.  Note  that  the  first
539              pppoes  keyword  encountered  in expression changes the decoding
540              offsets for the remainder of expression on the  assumption  that
541              the packet is a PPPoE session packet.
542
543              For example:
544                   pppoes 0x27 && ip
545              filters IPv4 protocols encapsulated in PPPoE session id 0x27.
546
547       geneve [vni]
548              True  if the packet is a Geneve packet (UDP port 6081). If [vni]
549              is specified, only true if the packet  has  the  specified  vni.
550              Note  that when the geneve keyword is encountered in expression,
551              it changes the decoding offsets for the remainder of  expression
552              on the assumption that the packet is a Geneve packet.
553
554              For example:
555                   geneve 0xb && ip
556              filters IPv4 protocols encapsulated in Geneve with VNI 0xb. This
557              will match both IP directly encapsulated in Geneve as well as IP
558              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 p
568              where p 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  expression changes the tests done in the remainder of
582              expression on the assumption that the packet is  either  a  LANE
583              emulated  Ethernet  packet or a LANE LE Control packet.  If lane
584              isn't specified, the tests are done under  the  assumption  that
585              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
649              interest; it can be either one, two, or four,  and  defaults  to
650              one.   The  length operator, indicated by the keyword len, gives
651              the 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
656              unfragmented  IPv4  datagrams  and  frag zero of fragmented IPv4
657              datagrams.  This check is implicitly applied to the tcp and  udp
658              index  operations.   For instance, tcp[0] always means the first
659              byte of the TCP header, and never means the  first  byte  of  an
660              intervening 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              (ICMP v6 type field) icmpcode (ICMP code field), icmp6code (ICMP
666              v6 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-echo,
675              icmp6-echoreply,  icmp6-multicastlistenerquery,  icmp6-multicas‐
676              tlistenerreportv1,  icmp6-multicastlistenerdone, icmp6-routerso‐
677              licit, icmp6-routeradvert, icmp6-neighborsolicit, icmp6-neighbo‐
678              radvert,  icmp6-redirect,  icmp6-routerrenum, icmp6-nodeinforma‐
679              tionquery, icmp6-nodeinformationresponse, icmp6-ineighbordiscov‐
680              erysolicit,  icmp6-ineighbordiscoveryadvert, icmp6-multicastlis‐
681              tenerreportv2, icmp6-homeagentdiscoveryrequest, icmp6-homeagent‐
682              discoveryreply, icmp6-mobileprefixsolicit, icmp6-mobileprefixad‐
683              vert, icmp6-certpathsolicit, icmp6-certpathadvert,  icmp6-multi‐
684              castrouteradvert,  icmp6-multicastroutersolicit, icmp6-multicas‐
685              trouterterm.
686
687              The following TCP flags field  values  are  available:  tcp-fin,
688              tcp-syn, tcp-rst, tcp-push, tcp-ack, tcp-urg, tcp-ece, tcp-cwr.
689
690       Primitives may be combined using:
691
692              A parenthesized group of primitives and operators.
693
694              Negation (`!' or `not').
695
696              Concatenation (`&&' or `and').
697
698              Alternation (`||' or `or').
699
700       Negation  has  highest  precedence.  Alternation and concatenation have
701       equal precedence and associate left to right.  Note that  explicit  and
702       tokens, not juxtaposition, are now required for concatenation.
703
704       If an identifier is given without a keyword, the most recent keyword is
705       assumed.  For example,
706            not host vs and ace
707       is short for
708            not host vs and host ace
709       which should not be confused with
710            not ( host vs or ace )
711

EXAMPLES

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

SEE ALSO

754       pcap(3PCAP)
755

BUGS

757       To  report  a  security  issue  please  send an e-mail to security@tcp‐
758       dump.org.
759
760       To report bugs and other problems, contribute patches, request  a  fea‐
761       ture,  provide generic feedback etc please see the file CONTRIBUTING in
762       the libpcap source tree root.
763
764       Filter expressions on fields other than those  in  Token  Ring  headers
765       will not correctly handle source-routed Token Ring packets.
766
767       Filter  expressions  on  fields other than those in 802.11 headers will
768       not correctly handle 802.11 data packets with both To DS  and  From  DS
769       set.
770
771       ip6  proto  should  chase header chain, but at this moment it does not.
772       ip6 protochain is supplied for this behavior.
773
774       Arithmetic expression against transport  layer  headers,  like  tcp[0],
775       does not work against IPv6 packets.  It only looks at IPv4 packets.
776
777
778
779                                5 November 2017                 PCAP-FILTER(7)
Impressum