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