xref: /titanic_51/usr/src/uts/common/inet/ipf/bpf-ipf.h (revision ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4)
1*ab25eeb5Syz155240 /*-
2*ab25eeb5Syz155240  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3*ab25eeb5Syz155240  *	The Regents of the University of California.  All rights reserved.
4*ab25eeb5Syz155240  *
5*ab25eeb5Syz155240  * This code is derived from the Stanford/CMU enet packet filter,
6*ab25eeb5Syz155240  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7*ab25eeb5Syz155240  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8*ab25eeb5Syz155240  * Berkeley Laboratory.
9*ab25eeb5Syz155240  *
10*ab25eeb5Syz155240  * Redistribution and use in source and binary forms, with or without
11*ab25eeb5Syz155240  * modification, are permitted provided that the following conditions
12*ab25eeb5Syz155240  * are met:
13*ab25eeb5Syz155240  * 1. Redistributions of source code must retain the above copyright
14*ab25eeb5Syz155240  *    notice, this list of conditions and the following disclaimer.
15*ab25eeb5Syz155240  * 2. Redistributions in binary form must reproduce the above copyright
16*ab25eeb5Syz155240  *    notice, this list of conditions and the following disclaimer in the
17*ab25eeb5Syz155240  *    documentation and/or other materials provided with the distribution.
18*ab25eeb5Syz155240  * 3. All advertising materials mentioning features or use of this software
19*ab25eeb5Syz155240  *    must display the following acknowledgement:
20*ab25eeb5Syz155240  *      This product includes software developed by the University of
21*ab25eeb5Syz155240  *      California, Berkeley and its contributors.
22*ab25eeb5Syz155240  * 4. Neither the name of the University nor the names of its contributors
23*ab25eeb5Syz155240  *    may be used to endorse or promote products derived from this software
24*ab25eeb5Syz155240  *    without specific prior written permission.
25*ab25eeb5Syz155240  *
26*ab25eeb5Syz155240  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27*ab25eeb5Syz155240  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28*ab25eeb5Syz155240  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29*ab25eeb5Syz155240  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30*ab25eeb5Syz155240  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31*ab25eeb5Syz155240  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32*ab25eeb5Syz155240  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33*ab25eeb5Syz155240  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34*ab25eeb5Syz155240  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35*ab25eeb5Syz155240  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36*ab25eeb5Syz155240  * SUCH DAMAGE.
37*ab25eeb5Syz155240  *
38*ab25eeb5Syz155240  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
39*ab25eeb5Syz155240  *
40*ab25eeb5Syz155240  * @(#) $Header: /devel/CVS/IP-Filter/bpf-ipf.h,v 2.1 2002/10/26 12:14:26 darrenr Exp $ (LBL)
41*ab25eeb5Syz155240  */
42*ab25eeb5Syz155240 
43*ab25eeb5Syz155240 #ifndef BPF_MAJOR_VERSION
44*ab25eeb5Syz155240 
45*ab25eeb5Syz155240 #ifdef __cplusplus
46*ab25eeb5Syz155240 extern "C" {
47*ab25eeb5Syz155240 #endif
48*ab25eeb5Syz155240 
49*ab25eeb5Syz155240 /* BSD style release date */
50*ab25eeb5Syz155240 #define BPF_RELEASE 199606
51*ab25eeb5Syz155240 
52*ab25eeb5Syz155240 typedef	int bpf_int32;
53*ab25eeb5Syz155240 typedef	u_int bpf_u_int32;
54*ab25eeb5Syz155240 
55*ab25eeb5Syz155240 /*
56*ab25eeb5Syz155240  * Alignment macros.  BPF_WORDALIGN rounds up to the next
57*ab25eeb5Syz155240  * even multiple of BPF_ALIGNMENT.
58*ab25eeb5Syz155240  */
59*ab25eeb5Syz155240 #ifndef __NetBSD__
60*ab25eeb5Syz155240 #define BPF_ALIGNMENT sizeof(bpf_int32)
61*ab25eeb5Syz155240 #else
62*ab25eeb5Syz155240 #define BPF_ALIGNMENT sizeof(long)
63*ab25eeb5Syz155240 #endif
64*ab25eeb5Syz155240 #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
65*ab25eeb5Syz155240 
66*ab25eeb5Syz155240 #define BPF_MAXINSNS 512
67*ab25eeb5Syz155240 #define BPF_MAXBUFSIZE 0x8000
68*ab25eeb5Syz155240 #define BPF_MINBUFSIZE 32
69*ab25eeb5Syz155240 
70*ab25eeb5Syz155240 /*
71*ab25eeb5Syz155240  *  Structure for BIOCSETF.
72*ab25eeb5Syz155240  */
73*ab25eeb5Syz155240 struct bpf_program {
74*ab25eeb5Syz155240 	u_int bf_len;
75*ab25eeb5Syz155240 	struct bpf_insn *bf_insns;
76*ab25eeb5Syz155240 };
77*ab25eeb5Syz155240 
78*ab25eeb5Syz155240 /*
79*ab25eeb5Syz155240  * Struct returned by BIOCGSTATS.
80*ab25eeb5Syz155240  */
81*ab25eeb5Syz155240 struct bpf_stat {
82*ab25eeb5Syz155240 	u_int bs_recv;		/* number of packets received */
83*ab25eeb5Syz155240 	u_int bs_drop;		/* number of packets dropped */
84*ab25eeb5Syz155240 };
85*ab25eeb5Syz155240 
86*ab25eeb5Syz155240 /*
87*ab25eeb5Syz155240  * Struct return by BIOCVERSION.  This represents the version number of
88*ab25eeb5Syz155240  * the filter language described by the instruction encodings below.
89*ab25eeb5Syz155240  * bpf understands a program iff kernel_major == filter_major &&
90*ab25eeb5Syz155240  * kernel_minor >= filter_minor, that is, if the value returned by the
91*ab25eeb5Syz155240  * running kernel has the same major number and a minor number equal
92*ab25eeb5Syz155240  * equal to or less than the filter being downloaded.  Otherwise, the
93*ab25eeb5Syz155240  * results are undefined, meaning an error may be returned or packets
94*ab25eeb5Syz155240  * may be accepted haphazardly.
95*ab25eeb5Syz155240  * It has nothing to do with the source code version.
96*ab25eeb5Syz155240  */
97*ab25eeb5Syz155240 struct bpf_version {
98*ab25eeb5Syz155240 	u_short bv_major;
99*ab25eeb5Syz155240 	u_short bv_minor;
100*ab25eeb5Syz155240 };
101*ab25eeb5Syz155240 /* Current version number of filter architecture. */
102*ab25eeb5Syz155240 #define BPF_MAJOR_VERSION 1
103*ab25eeb5Syz155240 #define BPF_MINOR_VERSION 1
104*ab25eeb5Syz155240 
105*ab25eeb5Syz155240 /*
106*ab25eeb5Syz155240  * BPF ioctls
107*ab25eeb5Syz155240  *
108*ab25eeb5Syz155240  * The first set is for compatibility with Sun's pcc style
109*ab25eeb5Syz155240  * header files.  If your using gcc, we assume that you
110*ab25eeb5Syz155240  * have run fixincludes so the latter set should work.
111*ab25eeb5Syz155240  */
112*ab25eeb5Syz155240 #if (defined(sun) || defined(ibm032)) && !defined(__GNUC__)
113*ab25eeb5Syz155240 #define	BIOCGBLEN	_IOR(B,102, u_int)
114*ab25eeb5Syz155240 #define	BIOCSBLEN	_IOWR(B,102, u_int)
115*ab25eeb5Syz155240 #define	BIOCSETF	_IOW(B,103, struct bpf_program)
116*ab25eeb5Syz155240 #define	BIOCFLUSH	_IO(B,104)
117*ab25eeb5Syz155240 #define BIOCPROMISC	_IO(B,105)
118*ab25eeb5Syz155240 #define	BIOCGDLT	_IOR(B,106, u_int)
119*ab25eeb5Syz155240 #define BIOCGETIF	_IOR(B,107, struct ifreq)
120*ab25eeb5Syz155240 #define BIOCSETIF	_IOW(B,108, struct ifreq)
121*ab25eeb5Syz155240 #define BIOCSRTIMEOUT	_IOW(B,109, struct timeval)
122*ab25eeb5Syz155240 #define BIOCGRTIMEOUT	_IOR(B,110, struct timeval)
123*ab25eeb5Syz155240 #define BIOCGSTATS	_IOR(B,111, struct bpf_stat)
124*ab25eeb5Syz155240 #define BIOCIMMEDIATE	_IOW(B,112, u_int)
125*ab25eeb5Syz155240 #define BIOCVERSION	_IOR(B,113, struct bpf_version)
126*ab25eeb5Syz155240 #define BIOCSTCPF	_IOW(B,114, struct bpf_program)
127*ab25eeb5Syz155240 #define BIOCSUDPF	_IOW(B,115, struct bpf_program)
128*ab25eeb5Syz155240 #else
129*ab25eeb5Syz155240 #define	BIOCGBLEN	_IOR('B',102, u_int)
130*ab25eeb5Syz155240 #define	BIOCSBLEN	_IOWR('B',102, u_int)
131*ab25eeb5Syz155240 #define	BIOCSETF	_IOW('B',103, struct bpf_program)
132*ab25eeb5Syz155240 #define	BIOCFLUSH	_IO('B',104)
133*ab25eeb5Syz155240 #define BIOCPROMISC	_IO('B',105)
134*ab25eeb5Syz155240 #define	BIOCGDLT	_IOR('B',106, u_int)
135*ab25eeb5Syz155240 #define BIOCGETIF	_IOR('B',107, struct ifreq)
136*ab25eeb5Syz155240 #define BIOCSETIF	_IOW('B',108, struct ifreq)
137*ab25eeb5Syz155240 #define BIOCSRTIMEOUT	_IOW('B',109, struct timeval)
138*ab25eeb5Syz155240 #define BIOCGRTIMEOUT	_IOR('B',110, struct timeval)
139*ab25eeb5Syz155240 #define BIOCGSTATS	_IOR('B',111, struct bpf_stat)
140*ab25eeb5Syz155240 #define BIOCIMMEDIATE	_IOW('B',112, u_int)
141*ab25eeb5Syz155240 #define BIOCVERSION	_IOR('B',113, struct bpf_version)
142*ab25eeb5Syz155240 #define BIOCSTCPF	_IOW('B',114, struct bpf_program)
143*ab25eeb5Syz155240 #define BIOCSUDPF	_IOW('B',115, struct bpf_program)
144*ab25eeb5Syz155240 #endif
145*ab25eeb5Syz155240 
146*ab25eeb5Syz155240 /*
147*ab25eeb5Syz155240  * Structure prepended to each packet.
148*ab25eeb5Syz155240  */
149*ab25eeb5Syz155240 struct bpf_hdr {
150*ab25eeb5Syz155240 	struct timeval	bh_tstamp;	/* time stamp */
151*ab25eeb5Syz155240 	bpf_u_int32	bh_caplen;	/* length of captured portion */
152*ab25eeb5Syz155240 	bpf_u_int32	bh_datalen;	/* original length of packet */
153*ab25eeb5Syz155240 	u_short		bh_hdrlen;	/* length of bpf header (this struct
154*ab25eeb5Syz155240 					   plus alignment padding) */
155*ab25eeb5Syz155240 };
156*ab25eeb5Syz155240 /*
157*ab25eeb5Syz155240  * Because the structure above is not a multiple of 4 bytes, some compilers
158*ab25eeb5Syz155240  * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work.
159*ab25eeb5Syz155240  * Only the kernel needs to know about it; applications use bh_hdrlen.
160*ab25eeb5Syz155240  */
161*ab25eeb5Syz155240 #if defined(KERNEL) || defined(_KERNEL)
162*ab25eeb5Syz155240 #define SIZEOF_BPF_HDR 18
163*ab25eeb5Syz155240 #endif
164*ab25eeb5Syz155240 
165*ab25eeb5Syz155240 /*
166*ab25eeb5Syz155240  * Data-link level type codes.
167*ab25eeb5Syz155240  */
168*ab25eeb5Syz155240 
169*ab25eeb5Syz155240 /*
170*ab25eeb5Syz155240  * These are the types that are the same on all platforms; on other
171*ab25eeb5Syz155240  * platforms, a <net/bpf.h> should be supplied that defines the additional
172*ab25eeb5Syz155240  * DLT_* codes appropriately for that platform (the BSDs, for example,
173*ab25eeb5Syz155240  * should not just pick up this version of "bpf.h"; they should also define
174*ab25eeb5Syz155240  * the additional DLT_* codes used by their kernels, as well as the values
175*ab25eeb5Syz155240  * defined here - and, if the values they use for particular DLT_ types
176*ab25eeb5Syz155240  * differ from those here, they should use their values, not the ones
177*ab25eeb5Syz155240  * here).
178*ab25eeb5Syz155240  */
179*ab25eeb5Syz155240 #define DLT_NULL	0	/* no link-layer encapsulation */
180*ab25eeb5Syz155240 #define DLT_EN10MB	1	/* Ethernet (10Mb) */
181*ab25eeb5Syz155240 #define DLT_EN3MB	2	/* Experimental Ethernet (3Mb) */
182*ab25eeb5Syz155240 #define DLT_AX25	3	/* Amateur Radio AX.25 */
183*ab25eeb5Syz155240 #define DLT_PRONET	4	/* Proteon ProNET Token Ring */
184*ab25eeb5Syz155240 #define DLT_CHAOS	5	/* Chaos */
185*ab25eeb5Syz155240 #define DLT_IEEE802	6	/* IEEE 802 Networks */
186*ab25eeb5Syz155240 #define DLT_ARCNET	7	/* ARCNET */
187*ab25eeb5Syz155240 #define DLT_SLIP	8	/* Serial Line IP */
188*ab25eeb5Syz155240 #define DLT_PPP		9	/* Point-to-point Protocol */
189*ab25eeb5Syz155240 #define DLT_FDDI	10	/* FDDI */
190*ab25eeb5Syz155240 
191*ab25eeb5Syz155240 /*
192*ab25eeb5Syz155240  * These are values from the traditional libpcap "bpf.h".
193*ab25eeb5Syz155240  * Ports of this to particular platforms should replace these definitions
194*ab25eeb5Syz155240  * with the ones appropriate to that platform, if the values are
195*ab25eeb5Syz155240  * different on that platform.
196*ab25eeb5Syz155240  */
197*ab25eeb5Syz155240 #define DLT_ATM_RFC1483	11	/* LLC/SNAP encapsulated atm */
198*ab25eeb5Syz155240 #define DLT_RAW		12	/* raw IP */
199*ab25eeb5Syz155240 
200*ab25eeb5Syz155240 /*
201*ab25eeb5Syz155240  * These are values from BSD/OS's "bpf.h".
202*ab25eeb5Syz155240  * These are not the same as the values from the traditional libpcap
203*ab25eeb5Syz155240  * "bpf.h"; however, these values shouldn't be generated by any
204*ab25eeb5Syz155240  * OS other than BSD/OS, so the correct values to use here are the
205*ab25eeb5Syz155240  * BSD/OS values.
206*ab25eeb5Syz155240  *
207*ab25eeb5Syz155240  * Platforms that have already assigned these values to other
208*ab25eeb5Syz155240  * DLT_ codes, however, should give these codes the values
209*ab25eeb5Syz155240  * from that platform, so that programs that use these codes will
210*ab25eeb5Syz155240  * continue to compile - even though they won't correctly read
211*ab25eeb5Syz155240  * files of these types.
212*ab25eeb5Syz155240  */
213*ab25eeb5Syz155240 #ifdef __NetBSD__
214*ab25eeb5Syz155240 #ifndef DLT_SLIP_BSDOS
215*ab25eeb5Syz155240 #define DLT_SLIP_BSDOS	13	/* BSD/OS Serial Line IP */
216*ab25eeb5Syz155240 #define DLT_PPP_BSDOS	14	/* BSD/OS Point-to-point Protocol */
217*ab25eeb5Syz155240 #endif
218*ab25eeb5Syz155240 #else
219*ab25eeb5Syz155240 #define DLT_SLIP_BSDOS	15	/* BSD/OS Serial Line IP */
220*ab25eeb5Syz155240 #define DLT_PPP_BSDOS	16	/* BSD/OS Point-to-point Protocol */
221*ab25eeb5Syz155240 #endif
222*ab25eeb5Syz155240 
223*ab25eeb5Syz155240 #define DLT_ATM_CLIP	19	/* Linux Classical-IP over ATM */
224*ab25eeb5Syz155240 
225*ab25eeb5Syz155240 /*
226*ab25eeb5Syz155240  * These values are defined by NetBSD; other platforms should refrain from
227*ab25eeb5Syz155240  * using them for other purposes, so that NetBSD savefiles with link
228*ab25eeb5Syz155240  * types of 50 or 51 can be read as this type on all platforms.
229*ab25eeb5Syz155240  */
230*ab25eeb5Syz155240 #define DLT_PPP_SERIAL	50	/* PPP over serial with HDLC encapsulation */
231*ab25eeb5Syz155240 #define DLT_PPP_ETHER	51	/* PPP over Ethernet */
232*ab25eeb5Syz155240 
233*ab25eeb5Syz155240 /*
234*ab25eeb5Syz155240  * Values between 100 and 103 are used in capture file headers as
235*ab25eeb5Syz155240  * link-layer types corresponding to DLT_ types that differ
236*ab25eeb5Syz155240  * between platforms; don't use those values for new DLT_ new types.
237*ab25eeb5Syz155240  */
238*ab25eeb5Syz155240 
239*ab25eeb5Syz155240 /*
240*ab25eeb5Syz155240  * This value was defined by libpcap 0.5; platforms that have defined
241*ab25eeb5Syz155240  * it with a different value should define it here with that value -
242*ab25eeb5Syz155240  * a link type of 104 in a save file will be mapped to DLT_C_HDLC,
243*ab25eeb5Syz155240  * whatever value that happens to be, so programs will correctly
244*ab25eeb5Syz155240  * handle files with that link type regardless of the value of
245*ab25eeb5Syz155240  * DLT_C_HDLC.
246*ab25eeb5Syz155240  *
247*ab25eeb5Syz155240  * The name DLT_C_HDLC was used by BSD/OS; we use that name for source
248*ab25eeb5Syz155240  * compatibility with programs written for BSD/OS.
249*ab25eeb5Syz155240  *
250*ab25eeb5Syz155240  * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
251*ab25eeb5Syz155240  * for source compatibility with programs written for libpcap 0.5.
252*ab25eeb5Syz155240  */
253*ab25eeb5Syz155240 #define DLT_C_HDLC	104	/* Cisco HDLC */
254*ab25eeb5Syz155240 #define DLT_CHDLC	DLT_C_HDLC
255*ab25eeb5Syz155240 
256*ab25eeb5Syz155240 #define DLT_IEEE802_11	105	/* IEEE 802.11 wireless */
257*ab25eeb5Syz155240 
258*ab25eeb5Syz155240 /*
259*ab25eeb5Syz155240  * Values between 106 and 107 are used in capture file headers as
260*ab25eeb5Syz155240  * link-layer types corresponding to DLT_ types that might differ
261*ab25eeb5Syz155240  * between platforms; don't use those values for new DLT_ new types.
262*ab25eeb5Syz155240  */
263*ab25eeb5Syz155240 
264*ab25eeb5Syz155240 /*
265*ab25eeb5Syz155240  * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
266*ab25eeb5Syz155240  * that the AF_ type in the link-layer header is in network byte order.
267*ab25eeb5Syz155240  *
268*ab25eeb5Syz155240  * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
269*ab25eeb5Syz155240  * define it as 108 here.  If OpenBSD picks up this file, it should
270*ab25eeb5Syz155240  * define DLT_LOOP as 12 in its version, as per the comment above -
271*ab25eeb5Syz155240  * and should not use 108 as a DLT_ value.
272*ab25eeb5Syz155240  */
273*ab25eeb5Syz155240 #define DLT_LOOP	108
274*ab25eeb5Syz155240 
275*ab25eeb5Syz155240 /*
276*ab25eeb5Syz155240  * Values between 109 and 112 are used in capture file headers as
277*ab25eeb5Syz155240  * link-layer types corresponding to DLT_ types that might differ
278*ab25eeb5Syz155240  * between platforms; don't use those values for new DLT_ types
279*ab25eeb5Syz155240  * other than the corresponding DLT_ types.
280*ab25eeb5Syz155240  */
281*ab25eeb5Syz155240 
282*ab25eeb5Syz155240 /*
283*ab25eeb5Syz155240  * This is for Linux cooked sockets.
284*ab25eeb5Syz155240  */
285*ab25eeb5Syz155240 #define DLT_LINUX_SLL	113
286*ab25eeb5Syz155240 
287*ab25eeb5Syz155240 /*
288*ab25eeb5Syz155240  * Apple LocalTalk hardware.
289*ab25eeb5Syz155240  */
290*ab25eeb5Syz155240 #define DLT_LTALK	114
291*ab25eeb5Syz155240 
292*ab25eeb5Syz155240 /*
293*ab25eeb5Syz155240  * Acorn Econet.
294*ab25eeb5Syz155240  */
295*ab25eeb5Syz155240 #define DLT_ECONET	115
296*ab25eeb5Syz155240 
297*ab25eeb5Syz155240 /*
298*ab25eeb5Syz155240  * Reserved for use with OpenBSD ipfilter.
299*ab25eeb5Syz155240  */
300*ab25eeb5Syz155240 #define DLT_IPFILTER	116
301*ab25eeb5Syz155240 
302*ab25eeb5Syz155240 /*
303*ab25eeb5Syz155240  * Reserved for use in capture-file headers as a link-layer type
304*ab25eeb5Syz155240  * corresponding to OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD,
305*ab25eeb5Syz155240  * but that's DLT_LANE8023 in SuSE 6.3, so we can't use 17 for it
306*ab25eeb5Syz155240  * in capture-file headers.
307*ab25eeb5Syz155240  */
308*ab25eeb5Syz155240 #define DLT_PFLOG	117
309*ab25eeb5Syz155240 
310*ab25eeb5Syz155240 /*
311*ab25eeb5Syz155240  * Registered for Cisco-internal use.
312*ab25eeb5Syz155240  */
313*ab25eeb5Syz155240 #define DLT_CISCO_IOS	118
314*ab25eeb5Syz155240 
315*ab25eeb5Syz155240 /*
316*ab25eeb5Syz155240  * Reserved for 802.11 cards using the Prism II chips, with a link-layer
317*ab25eeb5Syz155240  * header including Prism monitor mode information plus an 802.11
318*ab25eeb5Syz155240  * header.
319*ab25eeb5Syz155240  */
320*ab25eeb5Syz155240 #define DLT_PRISM_HEADER	119
321*ab25eeb5Syz155240 
322*ab25eeb5Syz155240 /*
323*ab25eeb5Syz155240  * Reserved for Aironet 802.11 cards, with an Aironet link-layer header
324*ab25eeb5Syz155240  * (see Doug Ambrisko's FreeBSD patches).
325*ab25eeb5Syz155240  */
326*ab25eeb5Syz155240 #define DLT_AIRONET_HEADER	120
327*ab25eeb5Syz155240 
328*ab25eeb5Syz155240 /*
329*ab25eeb5Syz155240  * Reserved for Siemens HiPath HDLC.
330*ab25eeb5Syz155240  */
331*ab25eeb5Syz155240 #define DLT_HHDLC		121
332*ab25eeb5Syz155240 
333*ab25eeb5Syz155240 /*
334*ab25eeb5Syz155240  * Reserved for RFC 2625 IP-over-Fibre Channel, as per a request from
335*ab25eeb5Syz155240  * Don Lee <donlee@cray.com>.
336*ab25eeb5Syz155240  *
337*ab25eeb5Syz155240  * This is not for use with raw Fibre Channel, where the link-layer
338*ab25eeb5Syz155240  * header starts with a Fibre Channel frame header; it's for IP-over-FC,
339*ab25eeb5Syz155240  * where the link-layer header starts with an RFC 2625 Network_Header
340*ab25eeb5Syz155240  * field.
341*ab25eeb5Syz155240  */
342*ab25eeb5Syz155240 #define DLT_IP_OVER_FC		122
343*ab25eeb5Syz155240 
344*ab25eeb5Syz155240 /*
345*ab25eeb5Syz155240  * The instruction encodings.
346*ab25eeb5Syz155240  */
347*ab25eeb5Syz155240 /* instruction classes */
348*ab25eeb5Syz155240 #define BPF_CLASS(code) ((code) & 0x07)
349*ab25eeb5Syz155240 #define		BPF_LD		0x00
350*ab25eeb5Syz155240 #define		BPF_LDX		0x01
351*ab25eeb5Syz155240 #define		BPF_ST		0x02
352*ab25eeb5Syz155240 #define		BPF_STX		0x03
353*ab25eeb5Syz155240 #define		BPF_ALU		0x04
354*ab25eeb5Syz155240 #define		BPF_JMP		0x05
355*ab25eeb5Syz155240 #define		BPF_RET		0x06
356*ab25eeb5Syz155240 #define		BPF_MISC	0x07
357*ab25eeb5Syz155240 
358*ab25eeb5Syz155240 /* ld/ldx fields */
359*ab25eeb5Syz155240 #define BPF_SIZE(code)	((code) & 0x18)
360*ab25eeb5Syz155240 #define		BPF_W		0x00
361*ab25eeb5Syz155240 #define		BPF_H		0x08
362*ab25eeb5Syz155240 #define		BPF_B		0x10
363*ab25eeb5Syz155240 #define BPF_MODE(code)	((code) & 0xe0)
364*ab25eeb5Syz155240 #define		BPF_IMM 	0x00
365*ab25eeb5Syz155240 #define		BPF_ABS		0x20
366*ab25eeb5Syz155240 #define		BPF_IND		0x40
367*ab25eeb5Syz155240 #define		BPF_MEM		0x60
368*ab25eeb5Syz155240 #define		BPF_LEN		0x80
369*ab25eeb5Syz155240 #define		BPF_MSH		0xa0
370*ab25eeb5Syz155240 
371*ab25eeb5Syz155240 /* alu/jmp fields */
372*ab25eeb5Syz155240 #define BPF_OP(code)	((code) & 0xf0)
373*ab25eeb5Syz155240 #define		BPF_ADD		0x00
374*ab25eeb5Syz155240 #define		BPF_SUB		0x10
375*ab25eeb5Syz155240 #define		BPF_MUL		0x20
376*ab25eeb5Syz155240 #define		BPF_DIV		0x30
377*ab25eeb5Syz155240 #define		BPF_OR		0x40
378*ab25eeb5Syz155240 #define		BPF_AND		0x50
379*ab25eeb5Syz155240 #define		BPF_LSH		0x60
380*ab25eeb5Syz155240 #define		BPF_RSH		0x70
381*ab25eeb5Syz155240 #define		BPF_NEG		0x80
382*ab25eeb5Syz155240 #define		BPF_JA		0x00
383*ab25eeb5Syz155240 #define		BPF_JEQ		0x10
384*ab25eeb5Syz155240 #define		BPF_JGT		0x20
385*ab25eeb5Syz155240 #define		BPF_JGE		0x30
386*ab25eeb5Syz155240 #define		BPF_JSET	0x40
387*ab25eeb5Syz155240 #define BPF_SRC(code)	((code) & 0x08)
388*ab25eeb5Syz155240 #define		BPF_K		0x00
389*ab25eeb5Syz155240 #define		BPF_X		0x08
390*ab25eeb5Syz155240 
391*ab25eeb5Syz155240 /* ret - BPF_K and BPF_X also apply */
392*ab25eeb5Syz155240 #define BPF_RVAL(code)	((code) & 0x18)
393*ab25eeb5Syz155240 #define		BPF_A		0x10
394*ab25eeb5Syz155240 
395*ab25eeb5Syz155240 /* misc */
396*ab25eeb5Syz155240 #define BPF_MISCOP(code) ((code) & 0xf8)
397*ab25eeb5Syz155240 #define		BPF_TAX		0x00
398*ab25eeb5Syz155240 #define		BPF_TXA		0x80
399*ab25eeb5Syz155240 
400*ab25eeb5Syz155240 /*
401*ab25eeb5Syz155240  * The instruction data structure.
402*ab25eeb5Syz155240  */
403*ab25eeb5Syz155240 struct bpf_insn {
404*ab25eeb5Syz155240 	u_short	code;
405*ab25eeb5Syz155240 	u_char 	jt;
406*ab25eeb5Syz155240 	u_char 	jf;
407*ab25eeb5Syz155240 	bpf_int32 k;
408*ab25eeb5Syz155240 };
409*ab25eeb5Syz155240 
410*ab25eeb5Syz155240 /*
411*ab25eeb5Syz155240  * Macros for insn array initializers.
412*ab25eeb5Syz155240  */
413*ab25eeb5Syz155240 #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
414*ab25eeb5Syz155240 #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
415*ab25eeb5Syz155240 
416*ab25eeb5Syz155240 #if defined(BSD) && (defined(KERNEL) || defined(_KERNEL))
417*ab25eeb5Syz155240 /*
418*ab25eeb5Syz155240  * Systems based on non-BSD kernels don't have ifnet's (or they don't mean
419*ab25eeb5Syz155240  * anything if it is in <net/if.h>) and won't work like this.
420*ab25eeb5Syz155240  */
421*ab25eeb5Syz155240 # if __STDC__
422*ab25eeb5Syz155240 extern void bpf_tap(struct ifnet *, u_char *, u_int);
423*ab25eeb5Syz155240 extern void bpf_mtap(struct ifnet *, struct mbuf *);
424*ab25eeb5Syz155240 extern void bpfattach(struct ifnet *, u_int, u_int);
425*ab25eeb5Syz155240 extern void bpfilterattach(int);
426*ab25eeb5Syz155240 # else
427*ab25eeb5Syz155240 extern void bpf_tap();
428*ab25eeb5Syz155240 extern void bpf_mtap();
429*ab25eeb5Syz155240 extern void bpfattach();
430*ab25eeb5Syz155240 extern void bpfilterattach();
431*ab25eeb5Syz155240 # endif /* __STDC__ */
432*ab25eeb5Syz155240 #endif /* BSD && (_KERNEL || KERNEL) */
433*ab25eeb5Syz155240 #if __STDC__ || defined(__cplusplus)
434*ab25eeb5Syz155240 extern int bpf_validate(struct bpf_insn *, int);
435*ab25eeb5Syz155240 extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
436*ab25eeb5Syz155240 #else
437*ab25eeb5Syz155240 extern int bpf_validate();
438*ab25eeb5Syz155240 extern u_int bpf_filter();
439*ab25eeb5Syz155240 #endif
440*ab25eeb5Syz155240 
441*ab25eeb5Syz155240 /*
442*ab25eeb5Syz155240  * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
443*ab25eeb5Syz155240  */
444*ab25eeb5Syz155240 #define BPF_MEMWORDS 16
445*ab25eeb5Syz155240 
446*ab25eeb5Syz155240 #ifdef __cplusplus
447*ab25eeb5Syz155240 }
448*ab25eeb5Syz155240 #endif
449*ab25eeb5Syz155240 
450*ab25eeb5Syz155240 #endif
451