]>
The Tcpdump Group git mirrors - libpcap/blob - gencode.h
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
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
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.
21 * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.53 2001-05-10 14:48:02 fenner Exp $ (LBL)
24 /* Address qualifiers. */
31 #define Q_PROTOCHAIN 6
33 /* Protocol qualifiers. */
76 /* Directional qualifiers. */
90 struct slist
*jt
; /*only for relative jump in block*/
91 struct slist
*jf
; /*only for relative jump in block*/
101 * A bit vector to represent definition sets. We assume TOT_REGISTERS
102 * is smaller than 8*sizeof(atomset).
104 typedef bpf_u_int32 atomset
;
105 #define ATOMMASK(n) (1 << (n))
106 #define ATOMELEM(d, n) (d & ATOMMASK(n))
111 typedef bpf_u_int32
*uset
;
114 * Total number of atomic entities, including accumulator (A) and index (X).
115 * We treat all these guys similarly during flow analysis.
117 #define N_ATOMS (BPF_MEMWORDS+2)
125 struct edge
*next
; /* link list of incoming edges for a node */
130 struct slist
*stmts
; /* side effect stmts */
131 struct stmt s
; /* branch stmt */
133 int longjt
; /* jt branch requires long jump */
134 int longjf
; /* jf branch requires long jump */
141 struct block
*link
; /* link field used by optimizer */
144 struct edge
*in_edges
;
153 struct block
*b
; /* protocol checks */
154 struct slist
*s
; /* stmt list */
155 int regno
; /* virtual register number of result */
165 struct arth
*gen_loadi(int);
166 struct arth
*gen_load(int, struct arth
*, int);
167 struct arth
*gen_loadlen(void);
168 struct arth
*gen_neg(struct arth
*);
169 struct arth
*gen_arth(int, struct arth
*, struct arth
*);
171 void gen_and(struct block
*, struct block
*);
172 void gen_or(struct block
*, struct block
*);
173 void gen_not(struct block
*);
175 struct block
*gen_scode(const char *, struct qual
);
176 struct block
*gen_ecode(const u_char
*, struct qual
);
177 struct block
*gen_acode(const u_char
*, struct qual
);
178 struct block
*gen_mcode(const char *, const char *, int, struct qual
);
180 struct block
*gen_mcode6(const char *, const char *, int, struct qual
);
182 struct block
*gen_ncode(const char *, bpf_u_int32
, struct qual
);
183 struct block
*gen_proto_abbrev(int);
184 struct block
*gen_relation(int, struct arth
*, struct arth
*, int);
185 struct block
*gen_less(int);
186 struct block
*gen_greater(int);
187 struct block
*gen_byteop(int, int, int);
188 struct block
*gen_broadcast(int);
189 struct block
*gen_multicast(int);
190 struct block
*gen_inbound(int);
192 struct block
*gen_vlan(int);
194 void bpf_optimize(struct block
**);
195 void bpf_error(const char *, ...)
196 #if HAVE___ATTRIBUTE__
197 __attribute__((noreturn
, format (printf
, 1, 2)))
201 void finish_parse(struct block
*);
202 char *sdup(const char *);
204 struct bpf_insn
*icode_to_fcode(struct block
*, int *);
205 int pcap_parse(void);
206 void lex_init(char *);
207 void lex_cleanup(void);
208 void sappend(struct slist
*, struct slist
*);
211 #define JT(b) ((b)->et.succ)
212 #define JF(b) ((b)->ef.succ)
214 extern int no_optimize
;