1 /* From: NetBSD: bpf.h,v 1.12 1995/09/27 18:30:40 thorpej Exp */
4 * Copyright (c) 1990, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from the Stanford/CMU enet packet filter,
8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
10 * Berkeley Laboratory.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * @(#)bpf.h 8.1 (Berkeley) 6/10/93
47 * Alignment macros. BPF_WORDALIGN rounds up to the next
48 * even multiple of BPF_ALIGNMENT.
50 #define BPF_ALIGNMENT sizeof(long)
51 #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
53 #define BPF_MAXINSNS 512
54 #define BPF_MAXBUFSIZE 0x8000
55 #define BPF_MINBUFSIZE 32
58 * Structure for BIOCSETF.
62 struct bpf_insn *bf_insns;
66 * The instruction encondings.
68 /* instruction classes */
69 #define BPF_CLASS(code) ((code) & 0x07)
80 #define BPF_SIZE(code) ((code) & 0x18)
84 #define BPF_MODE(code) ((code) & 0xe0)
93 #define BPF_OP(code) ((code) & 0xf0)
107 #define BPF_JSET 0x40
108 #define BPF_SRC(code) ((code) & 0x08)
112 /* ret - BPF_K and BPF_X also apply */
113 #define BPF_RVAL(code) ((code) & 0x18)
117 #define BPF_MISCOP(code) ((code) & 0xf8)
122 * The instruction data structure.
132 * Macros for insn array initializers.
134 #define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
135 #define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
138 int bpf_validate __P((struct bpf_insn *, int));
139 u_int bpf_filter __P((struct bpf_insn *, u_char *, u_int, u_int));
143 * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
145 #define BPF_MEMWORDS 16
147 #endif /* _NET_BPF_H_ */