2 * Copyright (c) 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from the Stanford/CMU enet packet filter,
6 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)bpf.h 8.1 (Berkeley) 6/10/93
35 * @(#)bpf.h 1.34 (LBL) 6/16/96
43 /* BSD style release date */
44 #define BPF_RELEASE 199606
46 typedef int32_t bpf_int32;
47 typedef u_int32_t bpf_u_int32;
50 * Alignment macros. BPF_WORDALIGN rounds up to the next
51 * even multiple of BPF_ALIGNMENT.
53 #define BPF_ALIGNMENT sizeof(long)
54 #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
56 #define BPF_MAXINSNS 512
57 #define BPF_MAXBUFSIZE 0x80000
58 #define BPF_MINBUFSIZE 32
61 * Structure for BIOCSETF.
65 struct bpf_insn *bf_insns;
69 * Struct returned by BIOCGSTATS.
72 u_int bs_recv; /* number of packets received */
73 u_int bs_drop; /* number of packets dropped */
77 * Struct return by BIOCVERSION. This represents the version number of
78 * the filter language described by the instruction encodings below.
79 * bpf understands a program iff kernel_major == filter_major &&
80 * kernel_minor >= filter_minor, that is, if the value returned by the
81 * running kernel has the same major number and a minor number equal
82 * equal to or less than the filter being downloaded. Otherwise, the
83 * results are undefined, meaning an error may be returned or packets
84 * may be accepted haphazardly.
85 * It has nothing to do with the source code version.
91 /* Current version number of filter architecture. */
92 #define BPF_MAJOR_VERSION 1
93 #define BPF_MINOR_VERSION 1
95 #define BIOCGBLEN _IOR('B',102, u_int)
96 #define BIOCSBLEN _IOWR('B',102, u_int)
97 #define BIOCSETF _IOW('B',103, struct bpf_program)
98 #define BIOCFLUSH _IO('B',104)
99 #define BIOCPROMISC _IO('B',105)
100 #define BIOCGDLT _IOR('B',106, u_int)
101 #define BIOCGETIF _IOR('B',107, struct ifreq)
102 #define BIOCSETIF _IOW('B',108, struct ifreq)
103 #define BIOCSRTIMEOUT _IOW('B',109, struct timeval)
104 #define BIOCGRTIMEOUT _IOR('B',110, struct timeval)
105 #define BIOCGSTATS _IOR('B',111, struct bpf_stat)
106 #define BIOCIMMEDIATE _IOW('B',112, u_int)
107 #define BIOCVERSION _IOR('B',113, struct bpf_version)
108 #define BIOCGRSIG _IOR('B',114, u_int)
109 #define BIOCSRSIG _IOW('B',115, u_int)
110 #define BIOCGHDRCMPLT _IOR('B',116, u_int)
111 #define BIOCSHDRCMPLT _IOW('B',117, u_int)
112 #define BIOCGDIRECTION _IOR('B',118, u_int)
113 #define BIOCSDIRECTION _IOW('B',119, u_int)
114 #define BIOCSDLT _IOW('B',120, u_int)
115 #define BIOCGDLTLIST _IOWR('B',121, struct bpf_dltlist)
116 #define BIOCLOCK _IO('B', 122)
117 #define BIOCSETWF _IOW('B',123, struct bpf_program)
118 #define BIOCFEEDBACK _IOW('B',124, u_int)
119 #define BIOCSETFNR _IOW('B',130, struct bpf_program)
122 #define BIOCGSEESENT BIOCGDIRECTION
123 #define BIOCSSEESENT BIOCSDIRECTION
125 /* Packet directions */
127 BPF_D_IN, /* See incoming packets */
128 BPF_D_INOUT, /* See incoming and outgoing packets */
129 BPF_D_OUT /* See outgoing packets */
133 * Structure prepended to each packet.
136 struct timeval bh_tstamp; /* time stamp */
137 bpf_u_int32 bh_caplen; /* length of captured portion */
138 bpf_u_int32 bh_datalen; /* original length of packet */
139 u_short bh_hdrlen; /* length of bpf header (this struct
140 plus alignment padding) */
143 * Because the structure above is not a multiple of 4 bytes, some compilers
144 * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work.
145 * Only the kernel needs to know about it; applications use bh_hdrlen.
148 #define SIZEOF_BPF_HDR (sizeof(struct bpf_hdr) <= 20 ? 18 : \
149 sizeof(struct bpf_hdr))
153 * Data-link level type codes.
155 #define DLT_NULL 0 /* BSD loopback encapsulation */
156 #define DLT_EN10MB 1 /* Ethernet (10Mb) */
157 #define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
158 #define DLT_AX25 3 /* Amateur Radio AX.25 */
159 #define DLT_PRONET 4 /* Proteon ProNET Token Ring */
160 #define DLT_CHAOS 5 /* Chaos */
161 #define DLT_IEEE802 6 /* IEEE 802 Networks */
162 #define DLT_ARCNET 7 /* ARCNET */
163 #define DLT_SLIP 8 /* Serial Line IP */
164 #define DLT_PPP 9 /* Point-to-point Protocol */
165 #define DLT_FDDI 10 /* FDDI */
166 #define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */
167 #define DLT_RAW 12 /* raw IP */
170 * These are values from BSD/OS's "bpf.h".
171 * These are not the same as the values from the traditional libpcap
172 * "bpf.h"; however, these values shouldn't be generated by any
173 * OS other than BSD/OS, so the correct values to use here are the
176 * Platforms that have already assigned these values to other
177 * DLT_ codes, however, should give these codes the values
178 * from that platform, so that programs that use these codes will
179 * continue to compile - even though they won't correctly read
180 * files of these types.
182 #define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */
183 #define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */
185 #define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */
188 * These values are defined by NetBSD; other platforms should refrain from
189 * using them for other purposes, so that NetBSD savefiles with link
190 * types of 50 or 51 can be read as this type on all platforms.
192 #define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */
193 #define DLT_PPP_ETHER 51 /* PPP over Ethernet */
196 * Reserved for the Symantec Enterprise Firewall.
198 #define DLT_SYMANTEC_FIREWALL 99
202 * This value was defined by libpcap 0.5; platforms that have defined
203 * it with a different value should define it here with that value -
204 * a link type of 104 in a save file will be mapped to DLT_C_HDLC,
205 * whatever value that happens to be, so programs will correctly
206 * handle files with that link type regardless of the value of
209 * The name DLT_C_HDLC was used by BSD/OS; we use that name for source
210 * compatibility with programs written for BSD/OS.
212 * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
213 * for source compatibility with programs written for libpcap 0.5.
215 #define DLT_C_HDLC 104 /* Cisco HDLC */
216 #define DLT_CHDLC DLT_C_HDLC
218 #define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */
221 * Values between 106 and 107 are used in capture file headers as
222 * link-layer types corresponding to DLT_ types that might differ
223 * between platforms; don't use those values for new DLT_ new types.
227 * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides
229 * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header
232 #define DLT_FRELAY 107
235 * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
236 * that the AF_ type in the link-layer header is in network byte order.
238 * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
239 * define it as 108 here. If OpenBSD picks up this file, it should
240 * define DLT_LOOP as 12 in its version, as per the comment above -
241 * and should not use 108 as a DLT_ value.
246 * Values between 109 and 112 are used in capture file headers as
247 * link-layer types corresponding to DLT_ types that might differ
248 * between platforms; don't use those values for new DLT_ new types.
252 * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
253 * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other
259 * This is for Linux cooked sockets.
261 #define DLT_LINUX_SLL 113
264 * Apple LocalTalk hardware.
266 #define DLT_LTALK 114
271 #define DLT_ECONET 115
274 * Reserved for use with OpenBSD ipfilter.
276 #define DLT_IPFILTER 116
279 * Reserved for use in capture-file headers as a link-layer type
280 * corresponding to OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD,
281 * but that's DLT_LANE8023 in SuSE 6.3, so we can't use 17 for it
282 * in capture-file headers.
284 #define DLT_PFLOG 117
287 * Registered for Cisco-internal use.
289 #define DLT_CISCO_IOS 118
292 * Reserved for 802.11 cards using the Prism II chips, with a link-layer
293 * header including Prism monitor mode information plus an 802.11
296 #define DLT_PRISM_HEADER 119
299 * Reserved for Aironet 802.11 cards, with an Aironet link-layer header
300 * (see Doug Ambrisko's FreeBSD patches).
302 #define DLT_AIRONET_HEADER 120
305 * Reserved for use by OpenBSD's pfsync device.
307 #define DLT_PFSYNC 121
310 * Reserved for Siemens HiPath HDLC. XXX
312 #define DLT_HHDLC 121
315 * Reserved for RFC 2625 IP-over-Fibre Channel.
317 #define DLT_IP_OVER_FC 122
320 * Reserved for Full Frontal ATM on Solaris.
322 #define DLT_SUNATM 123
325 * Reserved as per request from Kent Dahlgren <kent@praesum.com>
328 #define DLT_RIO 124 /* RapidIO */
329 #define DLT_PCI_EXP 125 /* PCI Express */
330 #define DLT_AURORA 126 /* Xilinx Aurora link layer */
333 * BSD header for 802.11 plus a number of bits of link-layer information
334 * including radio information.
336 #ifndef DLT_IEEE802_11_RADIO
337 #define DLT_IEEE802_11_RADIO 127
341 * Reserved for TZSP encapsulation.
343 #define DLT_TZSP 128 /* Tazmen Sniffer Protocol */
346 * Reserved for Linux ARCNET.
348 #define DLT_ARCNET_LINUX 129
351 * Juniper-private data link types.
353 #define DLT_JUNIPER_MLPPP 130
354 #define DLT_JUNIPER_MLFR 131
355 #define DLT_JUNIPER_ES 132
356 #define DLT_JUNIPER_GGSN 133
357 #define DLT_JUNIPER_MFR 134
358 #define DLT_JUNIPER_ATM2 135
359 #define DLT_JUNIPER_SERVICES 136
360 #define DLT_JUNIPER_ATM1 137
363 * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund
364 * <dieter@apple.com>. The header that's presented is an Ethernet-like
367 * #define FIREWIRE_EUI64_LEN 8
368 * struct firewire_header {
369 * u_char firewire_dhost[FIREWIRE_EUI64_LEN];
370 * u_char firewire_shost[FIREWIRE_EUI64_LEN];
371 * u_short firewire_type;
374 * with "firewire_type" being an Ethernet type value, rather than,
375 * for example, raw GASP frames being handed up.
377 #define DLT_APPLE_IP_OVER_IEEE1394 138
380 * Various SS7 encapsulations, as per a request from Jeff Morriss
381 * <jeff.morriss[AT]ulticom.com> and subsequent discussions.
383 #define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */
384 #define DLT_MTP2 140 /* MTP2, without pseudo-header */
385 #define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */
386 #define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */
389 * Reserved for DOCSIS.
391 #define DLT_DOCSIS 143
394 * Reserved for Linux IrDA.
396 #define DLT_LINUX_IRDA 144
399 * Reserved for IBM SP switch and IBM Next Federation switch.
401 #define DLT_IBM_SP 145
402 #define DLT_IBM_SN 146
405 * Reserved for private use. If you have some link-layer header type
406 * that you want to use within your organization, with the capture files
407 * using that link-layer header type not ever be sent outside your
408 * organization, you can use these values.
410 * No libpcap release will use these for any purpose, nor will any
411 * tcpdump release use them, either.
413 * Do *NOT* use these in capture files that you expect anybody not using
414 * your private versions of capture-file-reading tools to read; in
415 * particular, do *NOT* use them in products, otherwise you may find that
416 * people won't be able to use tcpdump, or snort, or Ethereal, or... to
417 * read capture files from your firewall/intrusion detection/traffic
418 * monitoring/etc. appliance, or whatever product uses that DLT_ value,
419 * and you may also find that the developers of those applications will
420 * not accept patches to let them read those files.
422 * Also, do not use them if somebody might send you a capture using them
423 * for *their* private type and tools using them for *your* private type
424 * would have to read them.
426 * Instead, ask "tcpdump-workers@tcpdump.org" for a new DLT_ value,
427 * as per the comment above, and use the type you're given.
429 #define DLT_USER0 147
430 #define DLT_USER1 148
431 #define DLT_USER2 149
432 #define DLT_USER3 150
433 #define DLT_USER4 151
434 #define DLT_USER5 152
435 #define DLT_USER6 153
436 #define DLT_USER7 154
437 #define DLT_USER8 155
438 #define DLT_USER9 156
439 #define DLT_USER10 157
440 #define DLT_USER11 158
441 #define DLT_USER12 159
442 #define DLT_USER13 160
443 #define DLT_USER14 161
444 #define DLT_USER15 162
447 * For future use with 802.11 captures - defined by AbsoluteValue
448 * Systems to store a number of bits of link-layer information
449 * including radio information:
451 * http://www.shaftnet.org/~pizza/software/capturefrm.txt
453 * but it might be used by some non-AVS drivers now or in the
456 #define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */
459 * Juniper-private data link type, as per request from
460 * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
461 * for passing on chassis-internal metainformation such as
462 * QOS profiles, etc..
464 #define DLT_JUNIPER_MONITOR 164
467 * Reserved for BACnet MS/TP.
469 #define DLT_BACNET_MS_TP 165
472 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
474 * This is used in some OSes to allow a kernel socket filter to distinguish
475 * between incoming and outgoing packets, on a socket intended to
476 * supply pppd with outgoing packets so it can do dial-on-demand and
477 * hangup-on-lack-of-demand; incoming packets are filtered out so they
478 * don't cause pppd to hold the connection up (you don't want random
479 * input packets such as port scans, packets from old lost connections,
480 * etc. to force the connection to stay up).
482 * The first byte of the PPP header (0xff03) is modified to accomodate
483 * the direction - 0x00 = IN, 0x01 = OUT.
485 #define DLT_PPP_PPPD 166
488 * Names for backwards compatibility with older versions of some PPP
489 * software; new software should use DLT_PPP_PPPD.
491 #define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD
492 #define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD
495 * Juniper-private data link type, as per request from
496 * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
497 * for passing on chassis-internal metainformation such as
498 * QOS profiles, cookies, etc..
500 #define DLT_JUNIPER_PPPOE 167
501 #define DLT_JUNIPER_PPPOE_ATM 168
503 #define DLT_GPRS_LLC 169 /* GPRS LLC */
504 #define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
505 #define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
508 * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
509 * monitoring equipment.
511 #define DLT_GCOM_T1E1 172
512 #define DLT_GCOM_SERIAL 173
515 * Juniper-private data link type, as per request from
516 * Hannes Gredler <hannes@juniper.net>. The DLT_ is used
517 * for internal communication to Physical Interface Cards (PIC)
519 #define DLT_JUNIPER_PIC_PEER 174
522 * Link types requested by Gregor Maier <gregor@endace.com> of Endace
523 * Measurement Systems. They add an ERF header (see
524 * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
525 * the link-layer header.
527 #define DLT_ERF_ETH 175 /* Ethernet */
528 #define DLT_ERF_POS 176 /* Packet-over-SONET */
531 * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
532 * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
533 * includes additional information before the LAPD header, so it's
534 * not necessarily a generic LAPD header.
536 #define DLT_LINUX_LAPD 177
539 * Juniper-private data link type, as per request from
540 * Hannes Gredler <hannes@juniper.net>.
541 * The DLT_ are used for prepending meta-information
542 * like interface index, interface name
543 * before standard Ethernet, PPP, Frelay & C-HDLC Frames
545 #define DLT_JUNIPER_ETHER 178
546 #define DLT_JUNIPER_PPP 179
547 #define DLT_JUNIPER_FRELAY 180
548 #define DLT_JUNIPER_CHDLC 181
551 * Multi Link Frame Relay (FRF.16)
556 * Juniper-private data link type, as per request from
557 * Hannes Gredler <hannes@juniper.net>.
558 * The DLT_ is used for internal communication with a
559 * voice Adapter Card (PIC)
561 #define DLT_JUNIPER_VP 183
565 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
566 * Every frame contains a 32bit A429 label.
567 * More documentation on Arinc 429 can be found at
568 * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
573 * Arinc 653 Interpartition Communication messages.
574 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
575 * Please refer to the A653-1 standard for more information.
577 #define DLT_A653_ICM 185
580 * USB packets, beginning with a USB setup header; requested by
581 * Paolo Abeni <paolo.abeni@email.it>.
586 * Bluetooth HCI UART transport layer (part H:4); requested by
589 #define DLT_BLUETOOTH_HCI_H4 187
592 * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
593 * <cruz_petagay@bah.com>.
595 #define DLT_IEEE802_16_MAC_CPS 188
598 * USB packets, beginning with a Linux USB header; requested by
599 * Paolo Abeni <paolo.abeni@email.it>.
601 #define DLT_USB_LINUX 189
604 * Controller Area Network (CAN) v. 2.0B packets.
605 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
606 * Used to dump CAN packets coming from a CAN Vector board.
607 * More documentation on the CAN v2.0B frames can be found at
608 * http://www.can-cia.org/downloads/?269
610 #define DLT_CAN20B 190
613 * IEEE 802.15.4, with address fields padded, as is done by Linux
614 * drivers; requested by Juergen Schimmer.
616 #define DLT_IEEE802_15_4_LINUX 191
619 * Per Packet Information encapsulated packets.
620 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
625 * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
626 * requested by Charles Clancy.
628 #define DLT_IEEE802_16_MAC_CPS_RADIO 193
631 * Juniper-private data link type, as per request from
632 * Hannes Gredler <hannes@juniper.net>.
633 * The DLT_ is used for internal communication with a
634 * integrated service module (ISM).
636 #define DLT_JUNIPER_ISM 194
639 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
640 * nothing); requested by Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
642 #define DLT_IEEE802_15_4 195
645 * Various link-layer types, with a pseudo-header, for SITA
646 * (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
651 * Various link-layer types, with a pseudo-header, for Endace DAG cards;
652 * encapsulates Endace ERF records. Requested by Stephen Donnelly
653 * <stephen@endace.com>.
658 * Special header prepended to Ethernet packets when capturing from a
659 * u10 Networks board. Requested by Phil Mulholland
660 * <phil@u10networks.com>.
662 #define DLT_RAIF1 198
665 * IPMB packet for IPMI, beginning with the I2C slave address, followed
666 * by the netFn and LUN, etc.. Requested by Chanthy Toeung
667 * <chanthy.toeung@ca.kontron.com>.
672 * Juniper-private data link type, as per request from
673 * Hannes Gredler <hannes@juniper.net>.
674 * The DLT_ is used for capturing data on a secure tunnel interface.
676 #define DLT_JUNIPER_ST 200
679 * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
680 * that includes direction information; requested by Paolo Abeni.
682 #define DLT_BLUETOOTH_HCI_H4_WITH_PHDR 201
685 * The instruction encodings.
687 /* instruction classes */
688 #define BPF_CLASS(code) ((code) & 0x07)
696 #define BPF_MISC 0x07
699 #define BPF_SIZE(code) ((code) & 0x18)
703 #define BPF_MODE(code) ((code) & 0xe0)
712 #define BPF_OP(code) ((code) & 0xf0)
726 #define BPF_JSET 0x40
727 #define BPF_SRC(code) ((code) & 0x08)
731 /* ret - BPF_K and BPF_X also apply */
732 #define BPF_RVAL(code) ((code) & 0x18)
736 #define BPF_MISCOP(code) ((code) & 0xf8)
741 * The instruction data structure.
751 * Macros for insn array initializers.
753 #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
754 #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
757 * Structure to retrieve available DLTs for the interface.
760 u_int bfl_len; /* number of bfd_list array */
761 u_int *bfl_list; /* array of DLTs */
766 * Descriptor associated with each attached hardware interface.
769 LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */
770 LIST_HEAD(, bpf_d) bif_dlist; /* descriptor list */
771 u_int bif_dlt; /* link layer type */
772 u_int bif_hdrlen; /* length of header (with padding) */
773 struct ifnet *bif_ifp; /* corresponding interface */
774 struct mtx bif_mtx; /* mutex for interface */
777 int bpf_validate(const struct bpf_insn *, int);
778 void bpf_tap(struct bpf_if *, u_char *, u_int);
779 void bpf_mtap(struct bpf_if *, struct mbuf *);
780 void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *);
781 void bpfattach(struct ifnet *, u_int, u_int);
782 void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **);
783 void bpfdetach(struct ifnet *);
785 void bpfilterattach(int);
786 u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int);
789 bpf_peers_present(struct bpf_if *bpf)
792 if (!LIST_EMPTY(&bpf->bif_dlist))
797 #define BPF_TAP(_ifp,_pkt,_pktlen) do { \
798 if (bpf_peers_present((_ifp)->if_bpf)) \
799 bpf_tap((_ifp)->if_bpf, (_pkt), (_pktlen)); \
801 #define BPF_MTAP(_ifp,_m) do { \
802 if (bpf_peers_present((_ifp)->if_bpf)) { \
804 bpf_mtap((_ifp)->if_bpf, (_m)); \
807 #define BPF_MTAP2(_ifp,_data,_dlen,_m) do { \
808 if (bpf_peers_present((_ifp)->if_bpf)) { \
810 bpf_mtap2((_ifp)->if_bpf,(_data),(_dlen),(_m)); \
816 * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
818 #define BPF_MEMWORDS 16
820 #endif /* _NET_BPF_H_ */