Skip to content
Newer
Older
100644 290 lines (247 sloc) 8.4 KB
b11ddf8 Initial revision
mcr authored Oct 7, 1999
1 /*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
243b20e @yuguy Add SunATM support, based on code from Yen Yen Lim at North Dakota State
yuguy authored Jul 11, 2002
21 * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.55 2002-07-11 09:06:34 guy Exp $ (LBL)
22 */
23
24 /*
25 * ATM support:
26 *
27 * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
28 * All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by Yen Yen Lim and
41 * North Dakota State University
42 * 4. The name of the author may not be used to endorse or promote products
43 * derived from this software without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
49 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
54 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
55 * POSSIBILITY OF SUCH DAMAGE.
b11ddf8 Initial revision
mcr authored Oct 7, 1999
56 */
57
58 /* Address qualifiers. */
59
60 #define Q_HOST 1
61 #define Q_NET 2
62 #define Q_PORT 3
63 #define Q_GATEWAY 4
64 #define Q_PROTO 5
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
65 #define Q_PROTOCHAIN 6
b11ddf8 Initial revision
mcr authored Oct 7, 1999
66
67 /* Protocol qualifiers. */
68
69 #define Q_LINK 1
70 #define Q_IP 2
71 #define Q_ARP 3
72 #define Q_RARP 4
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
73 #define Q_SCTP 5
74 #define Q_TCP 6
75 #define Q_UDP 7
76 #define Q_ICMP 8
77 #define Q_IGMP 9
78 #define Q_IGRP 10
b11ddf8 Initial revision
mcr authored Oct 7, 1999
79
80
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
81 #define Q_ATALK 11
82 #define Q_DECNET 12
83 #define Q_LAT 13
84 #define Q_SCA 14
85 #define Q_MOPRC 15
86 #define Q_MOPDL 16
b11ddf8 Initial revision
mcr authored Oct 7, 1999
87
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
88
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
89 #define Q_IPV6 17
90 #define Q_ICMPV6 18
91 #define Q_AH 19
92 #define Q_ESP 20
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
93
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
94 #define Q_PIM 21
95 #define Q_VRRP 22
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
96
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
97 #define Q_AARP 23
54b2ab1 @yuguy Patch from Monroe Williams <monroe@pobox.com>, submitted with NetBSD PR
yuguy authored Oct 28, 2000
98
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
99 #define Q_ISO 24
100 #define Q_ESIS 25
101 #define Q_ISIS 26
102 #define Q_CLNP 27
af30d75 @yuguy Tony Li's changes, from FreeBSD, to support filtering for OSI packets
yuguy authored Oct 28, 2000
103
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
104 #define Q_STP 28
2b3dac2 @yuguy Support checking for protocols specified by an LLC SAP on FDDI, Token
yuguy authored Jan 14, 2001
105
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
106 #define Q_IPX 29
d17596d @yuguy Add "ipx", which checks for the LLC SAP for IPX as well as, on Ethernet,
yuguy authored Jan 14, 2001
107
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored May 10, 2001
108 #define Q_NETBEUI 30
b0dcde2 @yuguy Add a "netbeui" keyword, which selects NetBEUI packets (LLC packets with
yuguy authored Jan 28, 2001
109
b11ddf8 Initial revision
mcr authored Oct 7, 1999
110 /* Directional qualifiers. */
111
112 #define Q_SRC 1
113 #define Q_DST 2
114 #define Q_OR 3
115 #define Q_AND 4
116
117 #define Q_DEFAULT 0
118 #define Q_UNDEF 255
119
243b20e @yuguy Add SunATM support, based on code from Yen Yen Lim at North Dakota State
yuguy authored Jul 11, 2002
120 /* ATM types */
121 #define A_METAC 22 /* Meta signalling Circuit */
122 #define A_BCC 23 /* Broadcast Circuit */
123 #define A_OAMF4SC 24 /* Segment OAM F4 Circuit */
124 #define A_OAMF4EC 25 /* End-to-End OAM F4 Circuit */
125 #define A_SC 26 /* Signalling Circuit*/
126 #define A_ILMIC 27 /* ILMI Circuit */
127 #define A_OAM 28 /* OAM cells : F4 only */
128 #define A_OAMF4 29 /* OAM F4 cells: Segment + End-to-end */
129 #define A_LANE 30 /* LANE traffic */
130 #define A_LLC 31 /* LLC-encapsulated traffic */
131
132 /* Based on Q.2931 signalling protocol */
133 #define A_SETUP 41 /* Setup message */
134 #define A_CALLPROCEED 42 /* Call proceeding message */
135 #define A_CONNECT 43 /* Connect message */
136 #define A_CONNECTACK 44 /* Connect Ack message */
137 #define A_RELEASE 45 /* Release message */
138 #define A_RELEASE_DONE 46 /* Release message */
139
140 /* ATM field types */
141 #define A_VPI 51
142 #define A_VCI 52
143 #define A_PROTOTYPE 53
144 #define A_MSGTYPE 54
145 #define A_CALLREFTYPE 55
146
147 #define A_CONNECTMSG 70 /* returns Q.2931 signalling messages for
148 establishing and destroying switched
149 virtual connection */
150 #define A_METACONNECT 71 /* returns Q.2931 signalling messages for
151 establishing and destroying predefined
152 virtual circuits, such as broadcast
153 circuit, oamf4 segment circuit, oamf4
154 end-to-end circuits, ILMI circuits or
155 connection signalling circuit. */
156
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
157 struct slist;
158
b11ddf8 Initial revision
mcr authored Oct 7, 1999
159 struct stmt {
160 int code;
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
161 struct slist *jt; /*only for relative jump in block*/
162 struct slist *jf; /*only for relative jump in block*/
b11ddf8 Initial revision
mcr authored Oct 7, 1999
163 bpf_int32 k;
164 };
165
166 struct slist {
167 struct stmt s;
168 struct slist *next;
169 };
170
5918c49 whitespace cleanup
itojun authored Jun 11, 2002
171 /*
b11ddf8 Initial revision
mcr authored Oct 7, 1999
172 * A bit vector to represent definition sets. We assume TOT_REGISTERS
173 * is smaller than 8*sizeof(atomset).
174 */
175 typedef bpf_u_int32 atomset;
176 #define ATOMMASK(n) (1 << (n))
177 #define ATOMELEM(d, n) (d & ATOMMASK(n))
178
179 /*
180 * An unbounded set.
181 */
182 typedef bpf_u_int32 *uset;
183
184 /*
185 * Total number of atomic entities, including accumulator (A) and index (X).
186 * We treat all these guys similarly during flow analysis.
187 */
188 #define N_ATOMS (BPF_MEMWORDS+2)
189
190 struct edge {
191 int id;
192 int code;
193 uset edom;
194 struct block *succ;
195 struct block *pred;
196 struct edge *next; /* link list of incoming edges for a node */
197 };
198
199 struct block {
200 int id;
201 struct slist *stmts; /* side effect stmts */
202 struct stmt s; /* branch stmt */
203 int mark;
204 int longjt; /* jt branch requires long jump */
205 int longjf; /* jf branch requires long jump */
206 int level;
207 int offset;
208 int sense;
209 struct edge et;
210 struct edge ef;
211 struct block *head;
212 struct block *link; /* link field used by optimizer */
213 uset dom;
214 uset closure;
215 struct edge *in_edges;
216 atomset def, kill;
217 atomset in_use;
218 atomset out_use;
219 int oval;
220 int val[N_ATOMS];
221 };
222
223 struct arth {
224 struct block *b; /* protocol checks */
225 struct slist *s; /* stmt list */
226 int regno; /* virtual register number of result */
227 };
228
229 struct qual {
230 unsigned char addr;
231 unsigned char proto;
232 unsigned char dir;
233 unsigned char pad;
234 };
235
236 struct arth *gen_loadi(int);
237 struct arth *gen_load(int, struct arth *, int);
238 struct arth *gen_loadlen(void);
239 struct arth *gen_neg(struct arth *);
240 struct arth *gen_arth(int, struct arth *, struct arth *);
241
242 void gen_and(struct block *, struct block *);
243 void gen_or(struct block *, struct block *);
244 void gen_not(struct block *);
245
246 struct block *gen_scode(const char *, struct qual);
247 struct block *gen_ecode(const u_char *, struct qual);
38b97b7 @yuguy ARCNet support, from NetBSD.
yuguy authored Apr 17, 2001
248 struct block *gen_acode(const u_char *, struct qual);
b11ddf8 Initial revision
mcr authored Oct 7, 1999
249 struct block *gen_mcode(const char *, const char *, int, struct qual);
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
250 #ifdef INET6
251 struct block *gen_mcode6(const char *, const char *, int, struct qual);
252 #endif
b11ddf8 Initial revision
mcr authored Oct 7, 1999
253 struct block *gen_ncode(const char *, bpf_u_int32, struct qual);
254 struct block *gen_proto_abbrev(int);
255 struct block *gen_relation(int, struct arth *, struct arth *, int);
256 struct block *gen_less(int);
257 struct block *gen_greater(int);
258 struct block *gen_byteop(int, int, int);
259 struct block *gen_broadcast(int);
260 struct block *gen_multicast(int);
261 struct block *gen_inbound(int);
262
98a503e @yuguy Improved VLAN support, from Peter Jeremy - "vlan" filtering keyword,
yuguy authored Oct 22, 2000
263 struct block *gen_vlan(int);
264
243b20e @yuguy Add SunATM support, based on code from Yen Yen Lim at North Dakota State
yuguy authored Jul 11, 2002
265 struct block *gen_atmfield_code(int atmfield, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
266 struct block *gen_atmtype_abbrev(int type);
267 struct block *gen_atmmulti_abbrev(int type);
268
b11ddf8 Initial revision
mcr authored Oct 7, 1999
269 void bpf_optimize(struct block **);
0e2f8c8 add config.h, remove gnuc.h. remove __dead
assar authored Jul 11, 2000
270 void bpf_error(const char *, ...)
417d093 (bpf_error): conditionalize __attribute__
assar authored Apr 1, 2000
271 #if HAVE___ATTRIBUTE__
0e2f8c8 add config.h, remove gnuc.h. remove __dead
assar authored Jul 11, 2000
272 __attribute__((noreturn, format (printf, 1, 2)))
417d093 (bpf_error): conditionalize __attribute__
assar authored Apr 1, 2000
273 #endif
274 ;
b11ddf8 Initial revision
mcr authored Oct 7, 1999
275
276 void finish_parse(struct block *);
277 char *sdup(const char *);
278
279 struct bpf_insn *icode_to_fcode(struct block *, int *);
280 int pcap_parse(void);
281 void lex_init(char *);
0d0297b @yuguy Older versions of Flex (e.g., 2.5.2, which at least one user had) dump
yuguy authored Jul 13, 2000
282 void lex_cleanup(void);
b11ddf8 Initial revision
mcr authored Oct 7, 1999
283 void sappend(struct slist *, struct slist *);
284
285 /* XXX */
286 #define JT(b) ((b)->et.succ)
287 #define JF(b) ((b)->ef.succ)
7fe3c11 IPv6 packet filtering code.
itojun authored Oct 19, 1999
288
289 extern int no_optimize;
Something went wrong with that request. Please try again.