]>
The Tcpdump Group git mirrors - libpcap/blob - gencode.h
8feffb06b119d7b228105319eb0fd6898336a82a
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.42 2000-10-22 04:15:56 guy Exp $ (LBL)
24 /* Address qualifiers. */
31 #define Q_PROTOCHAIN 6
33 /* Protocol qualifiers. */
61 /* Directional qualifiers. */
75 struct slist
*jt
; /*only for relative jump in block*/
76 struct slist
*jf
; /*only for relative jump in block*/
86 * A bit vector to represent definition sets. We assume TOT_REGISTERS
87 * is smaller than 8*sizeof(atomset).
89 typedef bpf_u_int32 atomset
;
90 #define ATOMMASK(n) (1 << (n))
91 #define ATOMELEM(d, n) (d & ATOMMASK(n))
96 typedef bpf_u_int32
*uset
;
99 * Total number of atomic entities, including accumulator (A) and index (X).
100 * We treat all these guys similarly during flow analysis.
102 #define N_ATOMS (BPF_MEMWORDS+2)
110 struct edge
*next
; /* link list of incoming edges for a node */
115 struct slist
*stmts
; /* side effect stmts */
116 struct stmt s
; /* branch stmt */
118 int longjt
; /* jt branch requires long jump */
119 int longjf
; /* jf branch requires long jump */
126 struct block
*link
; /* link field used by optimizer */
129 struct edge
*in_edges
;
138 struct block
*b
; /* protocol checks */
139 struct slist
*s
; /* stmt list */
140 int regno
; /* virtual register number of result */
150 struct arth
*gen_loadi(int);
151 struct arth
*gen_load(int, struct arth
*, int);
152 struct arth
*gen_loadlen(void);
153 struct arth
*gen_neg(struct arth
*);
154 struct arth
*gen_arth(int, struct arth
*, struct arth
*);
156 void gen_and(struct block
*, struct block
*);
157 void gen_or(struct block
*, struct block
*);
158 void gen_not(struct block
*);
160 struct block
*gen_scode(const char *, struct qual
);
161 struct block
*gen_ecode(const u_char
*, struct qual
);
162 struct block
*gen_mcode(const char *, const char *, int, struct qual
);
164 struct block
*gen_mcode6(const char *, const char *, int, struct qual
);
166 struct block
*gen_ncode(const char *, bpf_u_int32
, struct qual
);
167 struct block
*gen_proto_abbrev(int);
168 struct block
*gen_relation(int, struct arth
*, struct arth
*, int);
169 struct block
*gen_less(int);
170 struct block
*gen_greater(int);
171 struct block
*gen_byteop(int, int, int);
172 struct block
*gen_broadcast(int);
173 struct block
*gen_multicast(int);
174 struct block
*gen_inbound(int);
176 struct block
*gen_vlan(int);
178 void bpf_optimize(struct block
**);
179 void bpf_error(const char *, ...)
180 #if HAVE___ATTRIBUTE__
181 __attribute__((noreturn
, format (printf
, 1, 2)))
185 void finish_parse(struct block
*);
186 char *sdup(const char *);
188 struct bpf_insn
*icode_to_fcode(struct block
*, int *);
189 int pcap_parse(void);
190 void lex_init(char *);
191 void lex_cleanup(void);
192 void sappend(struct slist
*, struct slist
*);
195 #define JT(b) ((b)->et.succ)
196 #define JF(b) ((b)->ef.succ)
198 extern int no_optimize
;