xref: /xnu-12377.41.6/bsd/net/bpf.h (revision bbb1b6f9e71b8cdde6e5cd6f4841f207dee3d828)
1 /*
2  * Copyright (c) 2000-2025 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /*
29  * Copyright (c) 1990, 1991, 1993
30  *	The Regents of the University of California.  All rights reserved.
31  *
32  * This code is derived from the Stanford/CMU enet packet filter,
33  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
34  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
35  * Berkeley Laboratory.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  * 1. Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  * 2. Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in the
44  *    documentation and/or other materials provided with the distribution.
45  * 3. All advertising materials mentioning features or use of this software
46  *    must display the following acknowledgement:
47  *	This product includes software developed by the University of
48  *	California, Berkeley and its contributors.
49  * 4. Neither the name of the University nor the names of its contributors
50  *    may be used to endorse or promote products derived from this software
51  *    without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63  * SUCH DAMAGE.
64  *
65  *      @(#)bpf.h	8.1 (Berkeley) 6/10/93
66  *	@(#)bpf.h	1.34 (LBL)     6/16/96
67  *
68  * $FreeBSD: src/sys/net/bpf.h,v 1.21.2.3 2001/08/01 00:23:13 fenner Exp $
69  */
70 /*
71  * NOTICE: This file was modified by SPARTA, Inc. in 2006 to introduce
72  * support for mandatory and extensible security protections.  This notice
73  * is included in support of clause 2.2 (b) of the Apple Public License,
74  * Version 2.0.
75  */
76 
77 #ifndef _NET_BPF_H_
78 #define _NET_BPF_H_
79 
80 #include <stdint.h>
81 
82 #if !defined(DRIVERKIT)
83 #include <net/if.h>
84 #include <sys/param.h>
85 #include <sys/appleapiopts.h>
86 #include <sys/types.h>
87 #include <sys/time.h>
88 #include <sys/cdefs.h>
89 
90 #ifdef KERNEL
91 #include <sys/kernel_types.h>
92 
93 #if !defined(__i386__) && !defined(__x86_64__)
94 #define BPF_ALIGN 1
95 #else /* defined(__i386__) || defined(__x86_64__) */
96 #define BPF_ALIGN 0
97 #endif /* defined(__i386__) || defined(__x86_64__) */
98 
99 #if !BPF_ALIGN
100 #define EXTRACT_SHORT(p)        ((u_int16_t)ntohs(*(u_int16_t *)(void *)p))
101 #define EXTRACT_LONG(p)         (ntohl(*(u_int32_t *)(void *)p))
102 #else
103 #define EXTRACT_SHORT(p) \
104 	((u_int16_t)\
105 	        ((u_int16_t)*((u_char *)p+0)<<8|\
106 	         (u_int16_t)*((u_char *)p+1)<<0))
107 #define EXTRACT_LONG(p) \
108 	        ((u_int32_t)*((u_char *)p+0)<<24|\
109 	         (u_int32_t)*((u_char *)p+1)<<16|\
110 	         (u_int32_t)*((u_char *)p+2)<<8|\
111 	         (u_int32_t)*((u_char *)p+3)<<0)
112 #endif
113 
114 #endif /* KERNEL */
115 
116 /* BSD style release date */
117 #define BPF_RELEASE 199606
118 
119 typedef int32_t   bpf_int32;
120 typedef u_int32_t bpf_u_int32;
121 
122 /*
123  * Alignment macros.  BPF_WORDALIGN rounds up to the next
124  * even multiple of BPF_ALIGNMENT.
125  */
126 #define BPF_ALIGNMENT sizeof(int32_t)
127 #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
128 
129 #define BPF_MAXINSNS 512
130 #define BPF_MAXBUFSIZE 0x80000
131 #define BPF_MINBUFSIZE 32
132 
133 /*
134  *  Structure for BIOCSETF.
135  */
136 struct bpf_program {
137 	u_int bf_len;
138 	struct bpf_insn *bf_insns;
139 };
140 
141 /*
142  * Struct returned by BIOCGSTATS.
143  */
144 struct bpf_stat {
145 	u_int bs_recv;          /* number of packets received */
146 	u_int bs_drop;          /* number of packets dropped */
147 };
148 
149 /*
150  * Struct return by BIOCVERSION.  This represents the version number of
151  * the filter language described by the instruction encodings below.
152  * bpf understands a program iff kernel_major == filter_major &&
153  * kernel_minor >= filter_minor, that is, if the value returned by the
154  * running kernel has the same major number and a minor number equal
155  * equal to or less than the filter being downloaded.  Otherwise, the
156  * results are undefined, meaning an error may be returned or packets
157  * may be accepted haphazardly.
158  * It has nothing to do with the source code version.
159  */
160 struct bpf_version {
161 	u_short bv_major;
162 	u_short bv_minor;
163 };
164 
165 #if defined(__LP64__)
166 #include <sys/_types/_timeval32.h>
167 
168 #define BPF_TIMEVAL timeval32
169 #else
170 #define BPF_TIMEVAL timeval
171 #endif /* __LP64__ */
172 /* Current version number of filter architecture. */
173 #define BPF_MAJOR_VERSION 1
174 #define BPF_MINOR_VERSION 1
175 
176 #define BIOCGBLEN       _IOR('B',102, u_int)
177 #define BIOCSBLEN       _IOWR('B',102, u_int)
178 #define BIOCSETF        _IOW('B',103, struct bpf_program)
179 #define BIOCFLUSH       _IO('B',104)
180 #define BIOCPROMISC     _IO('B',105)
181 #define BIOCGDLT        _IOR('B',106, u_int)
182 #define BIOCGETIF       _IOR('B',107, struct ifreq)
183 #define BIOCSETIF       _IOW('B',108, struct ifreq)
184 #define BIOCSRTIMEOUT   _IOW('B',109, struct timeval)
185 #define BIOCGRTIMEOUT   _IOR('B',110, struct timeval)
186 #define BIOCGSTATS      _IOR('B',111, struct bpf_stat)
187 #define BIOCIMMEDIATE   _IOW('B',112, u_int)
188 #define BIOCVERSION     _IOR('B',113, struct bpf_version)
189 #define BIOCGRSIG       _IOR('B',114, u_int)
190 #define BIOCSRSIG       _IOW('B',115, u_int)
191 #define BIOCGHDRCMPLT   _IOR('B',116, u_int)
192 #define BIOCSHDRCMPLT   _IOW('B',117, u_int)
193 #define BIOCGSEESENT    _IOR('B',118, u_int)
194 #define BIOCSSEESENT    _IOW('B',119, u_int)
195 #define BIOCSDLT        _IOW('B',120, u_int)
196 #define BIOCGDLTLIST    _IOWR('B',121, struct bpf_dltlist)
197 #define BIOCSETFNR      _IOW('B', 126, struct bpf_program)
198 #ifdef PRIVATE
199 /* See bpf_private.h for additional ioctls */
200 #endif /* PRIVATE */
201 
202 /*
203  * Structure prepended to each packet.
204  */
205 struct bpf_hdr {
206 	struct BPF_TIMEVAL bh_tstamp;   /* time stamp */
207 	bpf_u_int32     bh_caplen;      /* length of captured portion */
208 	bpf_u_int32     bh_datalen;     /* original length of packet */
209 	u_short         bh_hdrlen;      /* length of bpf header (this struct
210 	                                 *  plus alignment padding) */
211 };
212 #ifdef KERNEL
213 /*
214  * Because the structure above is not a multiple of 4 bytes, some compilers
215  * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work.
216  * Only the kernel needs to know about it; applications use bh_hdrlen.
217  */
218 #define SIZEOF_BPF_HDR  (sizeof(struct bpf_hdr) <= 20 ? 18 : \
219     sizeof(struct bpf_hdr))
220 #endif
221 #endif /* !defined(DRIVERKIT) */
222 
223 /*
224  * Data-link level type codes.
225  */
226 #define DLT_NULL        0       /* no link-layer encapsulation */
227 #define DLT_EN10MB      1       /* Ethernet (10Mb) */
228 #define DLT_EN3MB       2       /* Experimental Ethernet (3Mb) */
229 #define DLT_AX25        3       /* Amateur Radio AX.25 */
230 #define DLT_PRONET      4       /* Proteon ProNET Token Ring */
231 #define DLT_CHAOS       5       /* Chaos */
232 #define DLT_IEEE802     6       /* IEEE 802 Networks */
233 #define DLT_ARCNET      7       /* ARCNET */
234 #define DLT_SLIP        8       /* Serial Line IP */
235 #define DLT_PPP         9       /* Point-to-point Protocol */
236 #define DLT_FDDI        10      /* FDDI */
237 #define DLT_ATM_RFC1483 11      /* LLC/SNAP encapsulated atm */
238 #define DLT_RAW         12      /* raw IP */
239 
240 /*
241  * These are values from BSD/OS's "bpf.h".
242  * These are not the same as the values from the traditional libpcap
243  * "bpf.h"; however, these values shouldn't be generated by any
244  * OS other than BSD/OS, so the correct values to use here are the
245  * BSD/OS values.
246  *
247  * Platforms that have already assigned these values to other
248  * DLT_ codes, however, should give these codes the values
249  * from that platform, so that programs that use these codes will
250  * continue to compile - even though they won't correctly read
251  * files of these types.
252  */
253 #define DLT_SLIP_BSDOS  15      /* BSD/OS Serial Line IP */
254 #define DLT_PPP_BSDOS   16      /* BSD/OS Point-to-point Protocol */
255 
256 /*
257  * 17 was used for DLT_PFLOG in OpenBSD; it no longer is.
258  *
259  * It was DLT_LANE8023 in SuSE 6.3, so we defined LINKTYPE_PFLOG
260  * as 117 so that pflog captures would use a link-layer header type
261  * value that didn't collide with any other values.  On all
262  * platforms other than OpenBSD, we defined DLT_PFLOG as 117,
263  * and we mapped between LINKTYPE_PFLOG and DLT_PFLOG.
264  *
265  * OpenBSD eventually switched to using 117 for DLT_PFLOG as well.
266  *
267  * Don't use 17 for anything else.
268  */
269 
270 /*
271  * 18 is used for DLT_PFSYNC in OpenBSD, NetBSD, DragonFly BSD and
272  * Mac OS X; don't use it for anything else.  (FreeBSD uses 121,
273  * which collides with DLT_HHDLC, even though it doesn't use 18
274  * for anything and doesn't appear to have ever used it for anything.)
275  *
276  * We define it as 18 on those platforms; it is, unfortunately, used
277  * for DLT_CIP in Suse 6.3, so we don't define it as DLT_PFSYNC
278  * in general.  As the packet format for it, like that for
279  * DLT_PFLOG, is not only OS-dependent but OS-version-dependent,
280  * we don't support printing it in tcpdump except on OSes that
281  * have the relevant header files, so it's not that useful on
282  * other platforms.
283  */
284 #define DLT_PFSYNC      18      /* Packet filter state syncing */
285 
286 #define DLT_ATM_CLIP    19      /* Linux Classical-IP over ATM */
287 
288 /*
289  * These values are defined by NetBSD; other platforms should refrain from
290  * using them for other purposes, so that NetBSD savefiles with link
291  * types of 50 or 51 can be read as this type on all platforms.
292  */
293 #define DLT_PPP_SERIAL  50      /* PPP over serial with HDLC encapsulation */
294 #define DLT_PPP_ETHER   51      /* PPP over Ethernet */
295 
296 /*
297  * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses
298  * a link-layer type of 99 for the tcpdump it supplies.  The link-layer
299  * header has 6 bytes of unknown data, something that appears to be an
300  * Ethernet type, and 36 bytes that appear to be 0 in at least one capture
301  * I've seen.
302  */
303 #define DLT_SYMANTEC_FIREWALL   99
304 
305 /*
306  * Values between 100 and 103 are used in capture file headers as
307  * link-layer header type LINKTYPE_ values corresponding to DLT_ types
308  * that differ between platforms; don't use those values for new DLT_
309  * new types.
310  */
311 
312 /*
313  * Values starting with 104 are used for newly-assigned link-layer
314  * header type values; for those link-layer header types, the DLT_
315  * value returned by pcap_datalink() and passed to pcap_open_dead(),
316  * and the LINKTYPE_ value that appears in capture files, are the
317  * same.
318  *
319  * DLT_MATCHING_MIN is the lowest such value; DLT_MATCHING_MAX is
320  * the highest such value.
321  */
322 #define DLT_MATCHING_MIN        104
323 
324 /*
325  * This value was defined by libpcap 0.5; platforms that have defined
326  * it with a different value should define it here with that value -
327  * a link type of 104 in a save file will be mapped to DLT_C_HDLC,
328  * whatever value that happens to be, so programs will correctly
329  * handle files with that link type regardless of the value of
330  * DLT_C_HDLC.
331  *
332  * The name DLT_C_HDLC was used by BSD/OS; we use that name for source
333  * compatibility with programs written for BSD/OS.
334  *
335  * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
336  * for source compatibility with programs written for libpcap 0.5.
337  */
338 #define DLT_C_HDLC      104     /* Cisco HDLC */
339 #define DLT_CHDLC       DLT_C_HDLC
340 
341 #define DLT_IEEE802_11  105     /* IEEE 802.11 wireless */
342 
343 /*
344  * Values between 106 and 107 are used in capture file headers as
345  * link-layer types corresponding to DLT_ types that might differ
346  * between platforms; don't use those values for new DLT_ new types.
347  */
348 
349 /*
350  * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides
351  * with other values.
352  * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header
353  * (DLCI, etc.).
354  */
355 #define DLT_FRELAY      107
356 
357 /*
358  * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
359  * that the AF_ type in the link-layer header is in network byte order.
360  *
361  * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
362  * define it as 108 here.  If OpenBSD picks up this file, it should
363  * define DLT_LOOP as 12 in its version, as per the comment above -
364  * and should not use 108 for any purpose.
365  */
366 #define DLT_LOOP        108
367 
368 /*
369  * Values between 109 and 112 are used in capture file headers as
370  * link-layer types corresponding to DLT_ types that might differ
371  * between platforms; don't use those values for new DLT_ new types.
372  */
373 
374 /*
375  * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
376  * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other
377  * than OpenBSD.
378  */
379 #define DLT_ENC 109
380 
381 /*
382  * This is for Linux cooked sockets.
383  */
384 #define DLT_LINUX_SLL   113
385 
386 /*
387  * Apple LocalTalk hardware.
388  */
389 #define DLT_LTALK       114
390 
391 /*
392  * Acorn Econet.
393  */
394 #define DLT_ECONET      115
395 
396 /*
397  * Reserved for use with OpenBSD ipfilter.
398  */
399 #define DLT_IPFILTER    116
400 
401 /*
402  * For use in capture-file headers as a link-layer type corresponding
403  * to OpenBSD PF (Packet Filter) log.
404  */
405 #define DLT_PFLOG       117
406 
407 /*
408  * Registered for Cisco-internal use.
409  */
410 #define DLT_CISCO_IOS   118
411 
412 /*
413  * Reserved for 802.11 cards using the Prism II chips, with a link-layer
414  * header including Prism monitor mode information plus an 802.11
415  * header.
416  */
417 #define DLT_PRISM_HEADER        119
418 
419 /*
420  * Reserved for Aironet 802.11 cards, with an Aironet link-layer header
421  * (see Doug Ambrisko's FreeBSD patches).
422  */
423 #define DLT_AIRONET_HEADER      120
424 
425 /*
426  * Reserved for Siemens HiPath HDLC. XXX
427  */
428 #define DLT_HHDLC       121
429 
430 /*
431  * Reserved for RFC 2625 IP-over-Fibre Channel.
432  */
433 #define DLT_IP_OVER_FC  122
434 
435 /*
436  * Reserved for Full Frontal ATM on Solaris.
437  */
438 #define DLT_SUNATM      123
439 
440 /*
441  * Reserved as per request from Kent Dahlgren <[email protected]>
442  * for private use.
443  */
444 #define DLT_RIO         124     /* RapidIO */
445 #define DLT_PCI_EXP     125     /* PCI Express */
446 #define DLT_AURORA      126     /* Xilinx Aurora link layer */
447 
448 /*
449  * BSD header for 802.11 plus a number of bits of link-layer information
450  * including radio information.
451  */
452 #ifndef DLT_IEEE802_11_RADIO
453 #define DLT_IEEE802_11_RADIO    127
454 #endif
455 
456 /*
457  * Reserved for TZSP encapsulation.
458  */
459 #define DLT_TZSP                128     /* Tazmen Sniffer Protocol */
460 
461 /*
462  * Reserved for Linux ARCNET.
463  */
464 #define DLT_ARCNET_LINUX        129
465 
466 /*
467  * Juniper-private data link types.
468  */
469 #define DLT_JUNIPER_MLPPP       130
470 #define DLT_JUNIPER_MLFR        131
471 #define DLT_JUNIPER_ES          132
472 #define DLT_JUNIPER_GGSN        133
473 #define DLT_JUNIPER_MFR         134
474 #define DLT_JUNIPER_ATM2        135
475 #define DLT_JUNIPER_SERVICES    136
476 #define DLT_JUNIPER_ATM1        137
477 
478 /*
479  * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund
480  * <[email protected]>.  The header that's presented is an Ethernet-like
481  * header:
482  *
483  *	#define FIREWIRE_EUI64_LEN	8
484  *	struct firewire_header {
485  *		u_char  firewire_dhost[FIREWIRE_EUI64_LEN];
486  *		u_char  firewire_shost[FIREWIRE_EUI64_LEN];
487  *		u_short firewire_type;
488  *	};
489  *
490  * with "firewire_type" being an Ethernet type value, rather than,
491  * for example, raw GASP frames being handed up.
492  */
493 #define DLT_APPLE_IP_OVER_IEEE1394      138
494 
495 /*
496  * Various SS7 encapsulations, as per a request from Jeff Morriss
497  * <jeff.morriss[AT]ulticom.com> and subsequent discussions.
498  */
499 #define DLT_MTP2_WITH_PHDR      139     /* pseudo-header with various info, followed by MTP2 */
500 #define DLT_MTP2                140     /* MTP2, without pseudo-header */
501 #define DLT_MTP3                141     /* MTP3, without pseudo-header or MTP2 */
502 #define DLT_SCCP                142     /* SCCP, without pseudo-header or MTP2 or MTP3 */
503 
504 /*
505  * Reserved for DOCSIS.
506  */
507 #define DLT_DOCSIS      143
508 
509 /*
510  * Reserved for Linux IrDA.
511  */
512 #define DLT_LINUX_IRDA  144
513 
514 /*
515  * Reserved for IBM SP switch and IBM Next Federation switch.
516  */
517 #define DLT_IBM_SP      145
518 #define DLT_IBM_SN      146
519 
520 /*
521  * Reserved for private use.  If you have some link-layer header type
522  * that you want to use within your organization, with the capture files
523  * using that link-layer header type not ever be sent outside your
524  * organization, you can use these values.
525  *
526  * No libpcap release will use these for any purpose, nor will any
527  * tcpdump release use them, either.
528  *
529  * Do *NOT* use these in capture files that you expect anybody not using
530  * your private versions of capture-file-reading tools to read; in
531  * particular, do *NOT* use them in products, otherwise you may find that
532  * people won't be able to use tcpdump, or snort, or Ethereal, or... to
533  * read capture files from your firewall/intrusion detection/traffic
534  * monitoring/etc. appliance, or whatever product uses that DLT_ value,
535  * and you may also find that the developers of those applications will
536  * not accept patches to let them read those files.
537  *
538  * Also, do not use them if somebody might send you a capture using them
539  * for *their* private type and tools using them for *your* private type
540  * would have to read them.
541  *
542  * Instead, ask "[email protected]" for a new DLT_ value,
543  * as per the comment above, and use the type you're given.
544  */
545 #define DLT_USER0               147
546 #define DLT_USER1               148
547 #define DLT_USER2               149
548 #define DLT_USER3               150
549 #define DLT_USER4               151
550 #define DLT_USER5               152
551 #define DLT_USER6               153
552 #define DLT_USER7               154
553 #define DLT_USER8               155
554 #define DLT_USER9               156
555 #define DLT_USER10              157
556 #define DLT_USER11              158
557 #define DLT_USER12              159
558 #define DLT_USER13              160
559 #define DLT_USER14              161
560 #define DLT_USER15              162
561 
562 /*
563  * For future use with 802.11 captures - defined by AbsoluteValue
564  * Systems to store a number of bits of link-layer information
565  * including radio information:
566  *
567  *	http://www.shaftnet.org/~pizza/software/capturefrm.txt
568  *
569  * but it might be used by some non-AVS drivers now or in the
570  * future.
571  */
572 #define DLT_IEEE802_11_RADIO_AVS 163    /* 802.11 plus AVS radio header */
573 
574 /*
575  * Juniper-private data link type, as per request from
576  * Hannes Gredler <[email protected]>.  The DLT_s are used
577  * for passing on chassis-internal metainformation such as
578  * QOS profiles, etc..
579  */
580 #define DLT_JUNIPER_MONITOR     164
581 
582 /*
583  * Reserved for BACnet MS/TP.
584  */
585 #define DLT_BACNET_MS_TP        165
586 
587 /*
588  * Another PPP variant as per request from Karsten Keil <[email protected]>.
589  *
590  * This is used in some OSes to allow a kernel socket filter to distinguish
591  * between incoming and outgoing packets, on a socket intended to
592  * supply pppd with outgoing packets so it can do dial-on-demand and
593  * hangup-on-lack-of-demand; incoming packets are filtered out so they
594  * don't cause pppd to hold the connection up (you don't want random
595  * input packets such as port scans, packets from old lost connections,
596  * etc. to force the connection to stay up).
597  *
598  * The first byte of the PPP header (0xff03) is modified to accomodate
599  * the direction - 0x00 = IN, 0x01 = OUT.
600  */
601 #define DLT_PPP_PPPD            166
602 
603 /*
604  * Names for backwards compatibility with older versions of some PPP
605  * software; new software should use DLT_PPP_PPPD.
606  */
607 #define DLT_PPP_WITH_DIRECTION  DLT_PPP_PPPD
608 #define DLT_LINUX_PPP_WITHDIRECTION     DLT_PPP_PPPD
609 
610 /*
611  * Juniper-private data link type, as per request from
612  * Hannes Gredler <[email protected]>.  The DLT_s are used
613  * for passing on chassis-internal metainformation such as
614  * QOS profiles, cookies, etc..
615  */
616 #define DLT_JUNIPER_PPPOE       167
617 #define DLT_JUNIPER_PPPOE_ATM   168
618 
619 #define DLT_GPRS_LLC            169     /* GPRS LLC */
620 #define DLT_GPF_T               170     /* GPF-T (ITU-T G.7041/Y.1303) */
621 #define DLT_GPF_F               171     /* GPF-F (ITU-T G.7041/Y.1303) */
622 
623 /*
624  * Requested by Oolan Zimmer <[email protected]> for use in Gcom's T1/E1 line
625  * monitoring equipment.
626  */
627 #define DLT_GCOM_T1E1           172
628 #define DLT_GCOM_SERIAL         173
629 
630 /*
631  * Juniper-private data link type, as per request from
632  * Hannes Gredler <[email protected]>.  The DLT_ is used
633  * for internal communication to Physical Interface Cards (PIC)
634  */
635 #define DLT_JUNIPER_PIC_PEER    174
636 
637 /*
638  * Link types requested by Gregor Maier <[email protected]> of Endace
639  * Measurement Systems.  They add an ERF header (see
640  * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
641  * the link-layer header.
642  */
643 #define DLT_ERF_ETH             175     /* Ethernet */
644 #define DLT_ERF_POS             176     /* Packet-over-SONET */
645 
646 /*
647  * Requested by Daniele Orlandi <[email protected]> for raw LAPD
648  * for vISDN (http://www.orlandi.com/visdn/).  Its link-layer header
649  * includes additional information before the LAPD header, so it's
650  * not necessarily a generic LAPD header.
651  */
652 #define DLT_LINUX_LAPD          177
653 
654 /*
655  * Juniper-private data link type, as per request from
656  * Hannes Gredler <[email protected]>.
657  * The DLT_ are used for prepending meta-information
658  * like interface index, interface name
659  * before standard Ethernet, PPP, Frelay & C-HDLC Frames
660  */
661 #define DLT_JUNIPER_ETHER       178
662 #define DLT_JUNIPER_PPP         179
663 #define DLT_JUNIPER_FRELAY      180
664 #define DLT_JUNIPER_CHDLC       181
665 
666 /*
667  * Multi Link Frame Relay (FRF.16)
668  */
669 #define DLT_MFR                 182
670 
671 /*
672  * Juniper-private data link type, as per request from
673  * Hannes Gredler <[email protected]>.
674  * The DLT_ is used for internal communication with a
675  * voice Adapter Card (PIC)
676  */
677 #define DLT_JUNIPER_VP          183
678 
679 /*
680  * Arinc 429 frames.
681  * DLT_ requested by Gianluca Varenni <[email protected]>.
682  * Every frame contains a 32bit A429 label.
683  * More documentation on Arinc 429 can be found at
684  * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
685  */
686 #define DLT_A429                184
687 
688 /*
689  * Arinc 653 Interpartition Communication messages.
690  * DLT_ requested by Gianluca Varenni <[email protected]>.
691  * Please refer to the A653-1 standard for more information.
692  */
693 #define DLT_A653_ICM            185
694 
695 /*
696  * USB packets, beginning with a USB setup header; requested by
697  * Paolo Abeni <[email protected]>.
698  */
699 #define DLT_USB                 186
700 
701 /*
702  * Bluetooth HCI UART transport layer (part H:4); requested by
703  * Paolo Abeni.
704  */
705 #define DLT_BLUETOOTH_HCI_H4    187
706 
707 /*
708  * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
709  * <[email protected]>.
710  */
711 #define DLT_IEEE802_16_MAC_CPS  188
712 
713 /*
714  * USB packets, beginning with a Linux USB header; requested by
715  * Paolo Abeni <[email protected]>.
716  */
717 #define DLT_USB_LINUX           189
718 
719 /*
720  * Controller Area Network (CAN) v. 2.0B packets.
721  * DLT_ requested by Gianluca Varenni <[email protected]>.
722  * Used to dump CAN packets coming from a CAN Vector board.
723  * More documentation on the CAN v2.0B frames can be found at
724  * http://www.can-cia.org/downloads/?269
725  */
726 #define DLT_CAN20B              190
727 
728 /*
729  * IEEE 802.15.4, with address fields padded, as is done by Linux
730  * drivers; requested by Juergen Schimmer.
731  */
732 #define DLT_IEEE802_15_4_LINUX  191
733 
734 /*
735  * Per Packet Information encapsulated packets.
736  * DLT_ requested by Gianluca Varenni <[email protected]>.
737  */
738 #define DLT_PPI                 192
739 
740 /*
741  * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
742  * requested by Charles Clancy.
743  */
744 #define DLT_IEEE802_16_MAC_CPS_RADIO    193
745 
746 /*
747  * Juniper-private data link type, as per request from
748  * Hannes Gredler <[email protected]>.
749  * The DLT_ is used for internal communication with a
750  * integrated service module (ISM).
751  */
752 #define DLT_JUNIPER_ISM         194
753 
754 /*
755  * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
756  * nothing); requested by Mikko Saarnivala <[email protected]>.
757  */
758 #define DLT_IEEE802_15_4        195
759 
760 /*
761  * Various link-layer types, with a pseudo-header, for SITA
762  * (http://www.sita.aero/); requested by Fulko Hew ([email protected]).
763  */
764 #define DLT_SITA                196
765 
766 /*
767  * Various link-layer types, with a pseudo-header, for Endace DAG cards;
768  * encapsulates Endace ERF records.  Requested by Stephen Donnelly
769  * <[email protected]>.
770  */
771 #define DLT_ERF                 197
772 
773 /*
774  * Special header prepended to Ethernet packets when capturing from a
775  * u10 Networks board.  Requested by Phil Mulholland
776  * <[email protected]>.
777  */
778 #define DLT_RAIF1               198
779 
780 /*
781  * IPMB packet for IPMI, beginning with the I2C slave address, followed
782  * by the netFn and LUN, etc..  Requested by Chanthy Toeung
783  * <[email protected]>.
784  */
785 #define DLT_IPMB                199
786 
787 /*
788  * Juniper-private data link type, as per request from
789  * Hannes Gredler <[email protected]>.
790  * The DLT_ is used for capturing data on a secure tunnel interface.
791  */
792 #define DLT_JUNIPER_ST          200
793 
794 /*
795  * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
796  * that includes direction information; requested by Paolo Abeni.
797  */
798 #define DLT_BLUETOOTH_HCI_H4_WITH_PHDR  201
799 
800 /*
801  * AX.25 packet with a 1-byte KISS header; see
802  *
803  *      http://www.ax25.net/kiss.htm
804  *
805  * as per Richard Stearn <[email protected]>.
806  */
807 #define DLT_AX25_KISS           202
808 
809 /*
810  * LAPD packets from an ISDN channel, starting with the address field,
811  * with no pseudo-header.
812  * Requested by Varuna De Silva <[email protected]>.
813  */
814 #define DLT_LAPD                203
815 
816 /*
817  * Variants of various link-layer headers, with a one-byte direction
818  * pseudo-header prepended - zero means "received by this host",
819  * non-zero (any non-zero value) means "sent by this host" - as per
820  * Will Barker <[email protected]>.
821  */
822 #define DLT_PPP_WITH_DIR        204     /* PPP - don't confuse with DLT_PPP_WITH_DIRECTION */
823 #define DLT_C_HDLC_WITH_DIR     205     /* Cisco HDLC */
824 #define DLT_FRELAY_WITH_DIR     206     /* Frame Relay */
825 #define DLT_LAPB_WITH_DIR       207     /* LAPB */
826 
827 /*
828  * 208 is reserved for an as-yet-unspecified proprietary link-layer
829  * type, as requested by Will Barker.
830  */
831 
832 /*
833  * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
834  * <[email protected]>.
835  */
836 #define DLT_IPMB_LINUX          209
837 
838 /*
839  * FlexRay automotive bus - http://www.flexray.com/ - as requested
840  * by Hannes Kaelber <[email protected]>.
841  */
842 #define DLT_FLEXRAY             210
843 
844 /*
845  * Media Oriented Systems Transport (MOST) bus for multimedia
846  * transport - http://www.mostcooperation.com/ - as requested
847  * by Hannes Kaelber <[email protected]>.
848  */
849 #define DLT_MOST                211
850 
851 /*
852  * Local Interconnect Network (LIN) bus for vehicle networks -
853  * http://www.lin-subbus.org/ - as requested by Hannes Kaelber
854  * <[email protected]>.
855  */
856 #define DLT_LIN                 212
857 
858 /*
859  * X2E-private data link type used for serial line capture,
860  * as requested by Hannes Kaelber <[email protected]>.
861  */
862 #define DLT_X2E_SERIAL          213
863 
864 /*
865  * X2E-private data link type used for the Xoraya data logger
866  * family, as requested by Hannes Kaelber <[email protected]>.
867  */
868 #define DLT_X2E_XORAYA          214
869 
870 /*
871  * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
872  * nothing), but with the PHY-level data for non-ASK PHYs (4 octets
873  * of 0 as preamble, one octet of SFD, one octet of frame length+
874  * reserved bit, and then the MAC-layer data, starting with the
875  * frame control field).
876  *
877  * Requested by Max Filippov <[email protected]>.
878  */
879 #define DLT_IEEE802_15_4_NONASK_PHY     215
880 
881 /*
882  * David Gibson <[email protected]> requested this for
883  * captures from the Linux kernel /dev/input/eventN devices. This
884  * is used to communicate keystrokes and mouse movements from the
885  * Linux kernel to display systems, such as Xorg.
886  */
887 #define DLT_LINUX_EVDEV         216
888 
889 /*
890  * GSM Um and Abis interfaces, preceded by a "gsmtap" header.
891  *
892  * Requested by Harald Welte <[email protected]>.
893  */
894 #define DLT_GSMTAP_UM           217
895 #define DLT_GSMTAP_ABIS         218
896 
897 /*
898  * MPLS, with an MPLS label as the link-layer header.
899  * Requested by Michele Marchetto <[email protected]> on behalf
900  * of OpenBSD.
901  */
902 #define DLT_MPLS                219
903 
904 /*
905  * USB packets, beginning with a Linux USB header, with the USB header
906  * padded to 64 bytes; required for memory-mapped access.
907  */
908 #define DLT_USB_LINUX_MMAPPED   220
909 
910 /*
911  * DECT packets, with a pseudo-header; requested by
912  * Matthias Wenzel <[email protected]>.
913  */
914 #define DLT_DECT                221
915 
916 /*
917  * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <[email protected]>
918  * Date: Mon, 11 May 2009 11:18:30 -0500
919  *
920  * DLT_AOS. We need it for AOS Space Data Link Protocol.
921  *   I have already written dissectors for but need an OK from
922  *   legal before I can submit a patch.
923  *
924  */
925 #define DLT_AOS                 222
926 
927 /*
928  * Wireless HART (Highway Addressable Remote Transducer)
929  * From the HART Communication Foundation
930  * IES/PAS 62591
931  *
932  * Requested by Sam Roberts <[email protected]>.
933  */
934 #define DLT_WIHART              223
935 
936 /*
937  * Fibre Channel FC-2 frames, beginning with a Frame_Header.
938  * Requested by Kahou Lei <[email protected]>.
939  */
940 #define DLT_FC_2                224
941 
942 /*
943  * Fibre Channel FC-2 frames, beginning with an encoding of the
944  * SOF, and ending with an encoding of the EOF.
945  *
946  * The encodings represent the frame delimiters as 4-byte sequences
947  * representing the corresponding ordered sets, with K28.5
948  * represented as 0xBC, and the D symbols as the corresponding
949  * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
950  * is represented as 0xBC 0xB5 0x55 0x55.
951  *
952  * Requested by Kahou Lei <[email protected]>.
953  */
954 #define DLT_FC_2_WITH_FRAME_DELIMS      225
955 
956 /*
957  * Solaris ipnet pseudo-header; requested by Darren Reed <[email protected]>.
958  *
959  * The pseudo-header starts with a one-byte version number; for version 2,
960  * the pseudo-header is:
961  *
962  * struct dl_ipnetinfo {
963  *     u_int8_t   dli_version;
964  *     u_int8_t   dli_family;
965  *     u_int16_t  dli_htype;
966  *     u_int32_t  dli_pktlen;
967  *     u_int32_t  dli_ifindex;
968  *     u_int32_t  dli_grifindex;
969  *     u_int32_t  dli_zsrc;
970  *     u_int32_t  dli_zdst;
971  * };
972  *
973  * dli_version is 2 for the current version of the pseudo-header.
974  *
975  * dli_family is a Solaris address family value, so it's 2 for IPv4
976  * and 26 for IPv6.
977  *
978  * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
979  * packets, and 2 for packets arriving from another zone on the same
980  * machine.
981  *
982  * dli_pktlen is the length of the packet data following the pseudo-header
983  * (so the captured length minus dli_pktlen is the length of the
984  * pseudo-header, assuming the entire pseudo-header was captured).
985  *
986  * dli_ifindex is the interface index of the interface on which the
987  * packet arrived.
988  *
989  * dli_grifindex is the group interface index number (for IPMP interfaces).
990  *
991  * dli_zsrc is the zone identifier for the source of the packet.
992  *
993  * dli_zdst is the zone identifier for the destination of the packet.
994  *
995  * A zone number of 0 is the global zone; a zone number of 0xffffffff
996  * means that the packet arrived from another host on the network, not
997  * from another zone on the same machine.
998  *
999  * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
1000  * which of those it is.
1001  */
1002 #define DLT_IPNET               226
1003 
1004 /*
1005  * CAN (Controller Area Network) frames, with a pseudo-header as supplied
1006  * by Linux SocketCAN.  See Documentation/networking/can.txt in the Linux
1007  * source.
1008  *
1009  * Requested by Felix Obenhuber <[email protected]>.
1010  */
1011 #define DLT_CAN_SOCKETCAN       227
1012 
1013 /*
1014  * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
1015  * whether it's v4 or v6.  Requested by Darren Reed <[email protected]>.
1016  */
1017 #define DLT_IPV4                228
1018 #define DLT_IPV6                229
1019 
1020 /*
1021  * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
1022  * nothing), and with no FCS at the end of the frame; requested by
1023  * Jon Smirl <[email protected]>.
1024  */
1025 #define DLT_IEEE802_15_4_NOFCS  230
1026 
1027 /*
1028  * Raw D-Bus:
1029  *
1030  *	http://www.freedesktop.org/wiki/Software/dbus
1031  *
1032  * messages:
1033  *
1034  *	http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
1035  *
1036  * starting with the endianness flag, followed by the message type, etc.,
1037  * but without the authentication handshake before the message sequence:
1038  *
1039  *	http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
1040  *
1041  * Requested by Martin Vidner <[email protected]>.
1042  */
1043 #define DLT_DBUS                231
1044 
1045 /*
1046  * Juniper-private data link type, as per request from
1047  * Hannes Gredler <[email protected]>.
1048  */
1049 #define DLT_JUNIPER_VS                  232
1050 #define DLT_JUNIPER_SRX_E2E             233
1051 #define DLT_JUNIPER_FIBRECHANNEL        234
1052 
1053 /*
1054  * DVB-CI (DVB Common Interface for communication between a PC Card
1055  * module and a DVB receiver).  See
1056  *
1057  *	http://www.kaiser.cx/pcap-dvbci.html
1058  *
1059  * for the specification.
1060  *
1061  * Requested by Martin Kaiser <[email protected]>.
1062  */
1063 #define DLT_DVB_CI              235
1064 
1065 /*
1066  * Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but
1067  * *not* the same as, 27.010).  Requested by Hans-Christoph Schemmel
1068  * <[email protected]>.
1069  */
1070 #define DLT_MUX27010            236
1071 
1072 /*
1073  * STANAG 5066 D_PDUs.  Requested by M. Baris Demiray
1074  * <[email protected]>.
1075  */
1076 #define DLT_STANAG_5066_D_PDU   237
1077 
1078 /*
1079  * Juniper-private data link type, as per request from
1080  * Hannes Gredler <[email protected]>.
1081  */
1082 #define DLT_JUNIPER_ATM_CEMIC   238
1083 
1084 /*
1085  * NetFilter LOG messages
1086  * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
1087  *
1088  * Requested by Jakub Zawadzki <[email protected]>
1089  */
1090 #define DLT_NFLOG               239
1091 
1092 /*
1093  * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
1094  * for Ethernet packets with a 4-byte pseudo-header and always
1095  * with the payload including the FCS, as supplied by their
1096  * netANALYZER hardware and software.
1097  *
1098  * Requested by Holger P. Frommer <[email protected]>
1099  */
1100 #define DLT_NETANALYZER         240
1101 
1102 /*
1103  * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
1104  * for Ethernet packets with a 4-byte pseudo-header and FCS and
1105  * with the Ethernet header preceded by 7 bytes of preamble and
1106  * 1 byte of SFD, as supplied by their netANALYZER hardware and
1107  * software.
1108  *
1109  * Requested by Holger P. Frommer <[email protected]>
1110  */
1111 #define DLT_NETANALYZER_TRANSPARENT     241
1112 
1113 /*
1114  * IP-over-Infiniband, as specified by RFC 4391.
1115  *
1116  * Requested by Petr Sumbera <[email protected]>.
1117  */
1118 #define DLT_IPOIB               242
1119 
1120 /*
1121  * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0).
1122  *
1123  * Requested by Guy Martin <[email protected]>.
1124  */
1125 #define DLT_MPEG_2_TS           243
1126 
1127 /*
1128  * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as
1129  * used by their ng40 protocol tester.
1130  *
1131  * Requested by Jens Grimmer <[email protected]>.
1132  */
1133 #define DLT_NG40                244
1134 
1135 /*
1136  * Pseudo-header giving adapter number and flags, followed by an NFC
1137  * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU,
1138  * as specified by NFC Forum Logical Link Control Protocol Technical
1139  * Specification LLCP 1.1.
1140  *
1141  * Requested by Mike Wakerly <[email protected]>.
1142  */
1143 #define DLT_NFC_LLCP            245
1144 
1145 /*
1146  * USB packets, beginning with a Darwin (macOS, etc.) USB header.
1147  */
1148 #define DLT_USB_DARWIN          266
1149 
1150 #define DLT_MATCHING_MAX        266     /* highest value in the "matching" range */
1151 
1152 #if !defined(DRIVERKIT)
1153 /*
1154  * The instruction encodings.
1155  */
1156 /* instruction classes */
1157 #define BPF_CLASS(code) ((code) & 0x07)
1158 #define         BPF_LD          0x00
1159 #define         BPF_LDX         0x01
1160 #define         BPF_ST          0x02
1161 #define         BPF_STX         0x03
1162 #define         BPF_ALU         0x04
1163 #define         BPF_JMP         0x05
1164 #define         BPF_RET         0x06
1165 #define         BPF_MISC        0x07
1166 
1167 /* ld/ldx fields */
1168 #define BPF_SIZE(code)  ((code) & 0x18)
1169 #define         BPF_W           0x00
1170 #define         BPF_H           0x08
1171 #define         BPF_B           0x10
1172 #define BPF_MODE(code)  ((code) & 0xe0)
1173 #define         BPF_IMM         0x00
1174 #define         BPF_ABS         0x20
1175 #define         BPF_IND         0x40
1176 #define         BPF_MEM         0x60
1177 #define         BPF_LEN         0x80
1178 #define         BPF_MSH         0xa0
1179 
1180 /* alu/jmp fields */
1181 #define BPF_OP(code)    ((code) & 0xf0)
1182 #define         BPF_ADD         0x00
1183 #define         BPF_SUB         0x10
1184 #define         BPF_MUL         0x20
1185 #define         BPF_DIV         0x30
1186 #define         BPF_OR          0x40
1187 #define         BPF_AND         0x50
1188 #define         BPF_LSH         0x60
1189 #define         BPF_RSH         0x70
1190 #define         BPF_NEG         0x80
1191 #define         BPF_JA          0x00
1192 #define         BPF_JEQ         0x10
1193 #define         BPF_JGT         0x20
1194 #define         BPF_JGE         0x30
1195 #define         BPF_JSET        0x40
1196 #define BPF_SRC(code)   ((code) & 0x08)
1197 #define         BPF_K           0x00
1198 #define         BPF_X           0x08
1199 
1200 /* ret - BPF_K and BPF_X also apply */
1201 #define BPF_RVAL(code)  ((code) & 0x18)
1202 #define         BPF_A           0x10
1203 
1204 /* misc */
1205 #define BPF_MISCOP(code) ((code) & 0xf8)
1206 #define         BPF_TAX         0x00
1207 #define         BPF_TXA         0x80
1208 
1209 /*
1210  * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
1211  */
1212 #define BPF_MEMWORDS 16
1213 
1214 /*
1215  * The instruction data structure.
1216  */
1217 struct bpf_insn {
1218 	u_short         code;
1219 	u_char          jt;
1220 	u_char          jf;
1221 	bpf_u_int32     k;
1222 };
1223 
1224 /*
1225  * Macros for insn array initializers.
1226  */
1227 #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
1228 #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
1229 
1230 #pragma pack(4)
1231 
1232 /*
1233  * Structure to retrieve available DLTs for the interface.
1234  */
1235 struct bpf_dltlist {
1236 	u_int32_t               bfl_len;        /* number of bfd_list array */
1237 	union {
1238 		u_int32_t       *bflu_list;     /* array of DLTs */
1239 		u_int64_t       bflu_pad;
1240 	} bfl_u;
1241 };
1242 #define bfl_list bfl_u.bflu_list
1243 
1244 #pragma pack()
1245 
1246 #endif /* !defined(DRIVERKIT) */
1247 
1248 #if defined(DRIVERKIT) || defined(KERNEL)
1249 #ifndef BPF_TAP_MODE_T
1250 #define BPF_TAP_MODE_T
1251 /*!
1252  *       @enum BPF tap mode
1253  *       @abstract Constants defining interface families.
1254  *       @constant BPF_MODE_DISABLED Disable bpf.
1255  *       @constant BPF_MODE_INPUT Enable input only.
1256  *       @constant BPF_MODE_OUTPUT Enable output only.
1257  *       @constant BPF_MODE_INPUT_OUTPUT Enable input and output.
1258  */
1259 
1260 enum {
1261 	BPF_MODE_DISABLED       = 0,
1262 	BPF_MODE_INPUT          = 1,
1263 	BPF_MODE_OUTPUT         = 2,
1264 	BPF_MODE_INPUT_OUTPUT   = 3
1265 };
1266 /*!
1267  *       @typedef bpf_tap_mode
1268  *       @abstract Mode for tapping. BPF_MODE_DISABLED/BPF_MODE_INPUT_OUTPUT etc.
1269  */
1270 typedef uint32_t bpf_tap_mode;
1271 #endif /* !BPF_TAP_MODE_T */
1272 #endif /* defined(DRIVERKIT) || defined(KERNEL) */
1273 
1274 #ifdef KERNEL
1275 /*!
1276  *       @typedef bpf_send_func
1277  *       @discussion bpf_send_func is called when a bpf file descriptor is
1278  *               used to send a raw packet on the interface. The mbuf and data
1279  *               link type are specified. The callback is responsible for
1280  *               releasing the mbuf whether or not it returns an error.
1281  *       @param interface The interface the packet is being sent on.
1282  *       @param data_link_type The data link type the bpf device is attached to.
1283  *       @param packet The packet to be sent.
1284  */
1285 typedef errno_t (*bpf_send_func)(ifnet_t interface, u_int32_t data_link_type,
1286     mbuf_t packet);
1287 
1288 /*!
1289  *       @typedef bpf_tap_func
1290  *       @discussion bpf_tap_func is called when the tap state of the
1291  *               interface changes. This happens when a bpf device attaches to an
1292  *               interface or detaches from an interface. The tap mode will join
1293  *               together (bit or) the modes of all bpf devices using that
1294  *               interface for that dlt. If you return an error from this
1295  *               function, the bpf device attach attempt that triggered the tap
1296  *               will fail. If this function was called bacuse the tap state was
1297  *               decreasing (tap in or out is stopping), the error will be
1298  *               ignored.
1299  *       @param interface The interface being tapped.
1300  *       @param data_link_type The data link type being tapped.
1301  *       @param direction The direction of the tap.
1302  */
1303 typedef errno_t (*bpf_tap_func)(ifnet_t interface, u_int32_t data_link_type,
1304     bpf_tap_mode direction);
1305 
1306 /*!
1307  *       @function bpfattach
1308  *       @discussion Registers an interface with BPF. This allows bpf devices
1309  *               to attach to your interface to capture packets. Your interface
1310  *               will be unregistered automatically when your interface is
1311  *               detached.
1312  *       @param interface The interface to register with BPF.
1313  *       @param data_link_type The data link type of the interface. See the
1314  *               DLT_* defines in bpf.h.
1315  *       @param header_length The length, in bytes, of the data link header.
1316  */
1317 extern void  bpfattach(ifnet_t interface, u_int data_link_type,
1318     u_int header_length);
1319 
1320 /*!
1321  *       @function bpf_attach
1322  *       @discussion Registers an interface with BPF. This allows bpf devices
1323  *               to attach to your interface to capture and transmit packets.
1324  *               Your interface will be unregistered automatically when your
1325  *               interface is detached. You may register multiple times with
1326  *               different data link types. An 802.11 interface would use this to
1327  *               allow clients to pick whether they want just an ethernet style
1328  *               frame or the 802.11 wireless headers as well. The first dlt you
1329  *               register will be considered the default. Any bpf device attaches
1330  *               that do not specify a data link type will use the default.
1331  *       @param interface The interface to register with BPF.
1332  *       @param data_link_type The data link type of the interface. See the
1333  *               DLT_* defines in bpf.h.
1334  *       @param header_length The length, in bytes, of the data link header.
1335  *       @param send See the bpf_send_func described above.
1336  *       @param tap See the bpf_tap_func described above.
1337  */
1338 extern errno_t  bpf_attach(ifnet_t interface, u_int32_t data_link_type,
1339     u_int32_t header_length, bpf_send_func send, bpf_tap_func tap);
1340 
1341 /*!
1342  *       @function bpf_tap_in
1343  *       @discussion Call this function when your interface receives a
1344  *               packet. This function will check if any bpf devices need a
1345  *               a copy of the packet.
1346  *       @param interface The interface the packet was received on.
1347  *       @param dlt The data link type of the packet.
1348  *       @param packet The packet received.
1349  *       @param header An optional pointer to a header that will be prepended.
1350  *       @param header_len If the header was specified, the length of the header.
1351  */
1352 extern void bpf_tap_in(ifnet_t interface, u_int32_t dlt, mbuf_t packet,
1353     void *__sized_by(header_len) header, size_t header_len);
1354 
1355 /*!
1356  *       @function bpf_tap_out
1357  *       @discussion Call this function when your interface transmits a
1358  *               packet. This function will check if any bpf devices need a
1359  *               a copy of the packet.
1360  *       @param interface The interface the packet was or will be transmitted on.
1361  *       @param dlt The data link type of the packet.
1362  *       @param packet The packet received.
1363  *       @param header An optional pointer to a header that will be prepended.
1364  *       @param header_len If the header was specified, the length of the header.
1365  */
1366 extern void bpf_tap_out(ifnet_t interface, u_int32_t dlt, mbuf_t packet,
1367     void *__sized_by(header_len) header, size_t header_len);
1368 
1369 #endif /* KERNEL */
1370 
1371 #if defined(PRIVATE) && !defined(MODULES_SUPPORTED)
1372 #include <net/bpf_private.h>
1373 #endif /* PRIVATE && !MODULES_SUPPORTED */
1374 
1375 #endif /* _NET_BPF_H_ */
1376