]> git.ozlabs.org Git - ppp.git/blob - pppd/gencode.h
removed bpf filters; added option_error; improved error messages
[ppp.git] / pppd / gencode.h
1 /*      From NetBSD: gencode.h,v 1.2 1995/03/06 11:38:24 mycroft Exp */
2
3 /*
4  * Copyright (c) 1990, 1991, 1992, 1993, 1994
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that: (1) source code distributions
9  * retain the above copyright notice and this paragraph in its entirety, (2)
10  * distributions including binary code include the above copyright notice and
11  * this paragraph in its entirety in the documentation or other materials
12  * provided with the distribution, and (3) all advertising materials mentioning
13  * features or use of this software display the following acknowledgement:
14  * ``This product includes software developed by the University of California,
15  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16  * the University nor the names of its contributors may be used to endorse
17  * or promote products derived from this software without specific prior
18  * written permission.
19  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22  *
23  * @(#) Header: gencode.h,v 1.20 94/06/12 14:29:30 leres Exp (LBL)
24  */
25
26 /* $Id: gencode.h,v 1.1 1996/04/04 04:22:26 paulus Exp $ */
27
28 /* Address qualifers. */
29
30 #define Q_HOST          1
31 #define Q_NET           2
32 #define Q_PORT          3
33 #define Q_PROTO         4
34
35 /* Protocol qualifiers. */
36
37 #define Q_LINK          1
38 #define Q_IP            2
39 #define Q_TCP           3
40 #define Q_UDP           4
41 #define Q_ICMP          5
42
43 /* Directional qualifers. */
44
45 #define Q_SRC           1
46 #define Q_DST           2
47 #define Q_OR            3
48 #define Q_AND           4
49
50 #define Q_DEFAULT       0
51 #define Q_UNDEF         255
52
53 struct stmt {
54         int code;
55         long k;
56 };
57
58 struct slist {
59         struct stmt s;
60         struct slist *next;
61 };
62
63 /* 
64  * A bit vector to represent definition sets.  We assume TOT_REGISTERS
65  * is smaller than 8*sizeof(atomset).
66  */
67 typedef unsigned long atomset;
68 #define ATOMMASK(n) (1 << (n))
69 #define ATOMELEM(d, n) (d & ATOMMASK(n))
70
71 /*
72  * An unbounded set.
73  */
74 typedef unsigned long *uset;
75
76 /*
77  * Total number of atomic entities, including accumulator (A) and index (X).
78  * We treat all these guys similarly during flow analysis.
79  */
80 #define N_ATOMS (BPF_MEMWORDS+2)
81
82 struct edge {
83         int id;
84         int code;
85         uset edom;
86         struct block *succ;
87         struct block *pred;
88         struct edge *next;      /* link list of incoming edges for a node */
89 };
90
91 struct block {
92         int id;
93         struct slist *stmts;    /* side effect stmts */
94         struct stmt s;          /* branch stmt */
95         int mark;
96         int level;
97         int offset;
98         int sense;
99         struct edge et;
100         struct edge ef;
101         struct block *head;
102         struct block *link;     /* link field used by optimizer */
103         uset dom;
104         uset closure;
105         struct edge *in_edges;
106         atomset def, kill;
107         atomset in_use;
108         atomset out_use;
109         long oval;
110         long val[N_ATOMS];
111 };
112
113 struct arth {
114         struct block *b;        /* protocol checks */
115         struct slist *s;        /* stmt list */
116         int regno;              /* virtual register number of result */
117 };
118
119 struct qual {
120         unsigned char addr;
121         unsigned char proto;
122         unsigned char dir;
123         unsigned char pad;
124 };
125
126 #ifndef __GNUC__
127 #define volatile
128 #endif
129
130 struct arth *gen_loadi __P((int));
131 struct arth *gen_load __P((int, struct arth *, int));
132 struct arth *gen_loadlen __P((void));
133 struct arth *gen_neg __P((struct arth *));
134 struct arth *gen_arth __P((int, struct arth *, struct arth *));
135
136 void gen_and __P((struct block *, struct block *));
137 void gen_or __P((struct block *, struct block *));
138 void gen_not __P((struct block *));
139
140 struct block *gen_scode __P((char *, struct qual));
141 struct block *gen_ecode __P((unsigned char *, struct qual));
142 struct block *gen_ncode __P((unsigned long, struct qual));
143 struct block *gen_proto_abbrev __P((int));
144 struct block *gen_relation __P((int, struct arth *, struct arth *, int));
145 struct block *gen_less __P((int));
146 struct block *gen_greater __P((int));
147 struct block *gen_byteop __P((int, int, int));
148 struct block *gen_broadcast __P((int));
149 struct block *gen_multicast __P((int));
150 struct block *gen_inbound __P((int));
151
152 void bpf_optimize __P((struct block **));
153 volatile void bpf_error __P((char *, ...));
154
155 void finish_parse __P((struct block *));
156 char *sdup __P((char *));
157
158 struct bpf_insn *icode_to_fcode __P((struct block *, int *));
159 int pcap_parse __P((void));
160 void lex_init __P((char *));
161 void sappend __P((struct slist *, struct slist *));
162
163 /* XXX */
164 #define JT(b)  ((b)->et.succ)
165 #define JF(b)  ((b)->ef.succ)