Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 215 lines (178 sloc) 5.293 kb
b11ddf8 Initial revision
mcr authored
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 *
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
21 * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.53 2001-05-10 14:48:02 fenner Exp $ (LBL)
b11ddf8 Initial revision
mcr authored
22 */
23
24 /* Address qualifiers. */
25
26 #define Q_HOST 1
27 #define Q_NET 2
28 #define Q_PORT 3
29 #define Q_GATEWAY 4
30 #define Q_PROTO 5
7fe3c11 IPv6 packet filtering code.
itojun authored
31 #define Q_PROTOCHAIN 6
b11ddf8 Initial revision
mcr authored
32
33 /* Protocol qualifiers. */
34
35 #define Q_LINK 1
36 #define Q_IP 2
37 #define Q_ARP 3
38 #define Q_RARP 4
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
39 #define Q_SCTP 5
40 #define Q_TCP 6
41 #define Q_UDP 7
42 #define Q_ICMP 8
43 #define Q_IGMP 9
44 #define Q_IGRP 10
b11ddf8 Initial revision
mcr authored
45
46
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
47 #define Q_ATALK 11
48 #define Q_DECNET 12
49 #define Q_LAT 13
50 #define Q_SCA 14
51 #define Q_MOPRC 15
52 #define Q_MOPDL 16
b11ddf8 Initial revision
mcr authored
53
7fe3c11 IPv6 packet filtering code.
itojun authored
54
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
55 #define Q_IPV6 17
56 #define Q_ICMPV6 18
57 #define Q_AH 19
58 #define Q_ESP 20
7fe3c11 IPv6 packet filtering code.
itojun authored
59
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
60 #define Q_PIM 21
61 #define Q_VRRP 22
7fe3c11 IPv6 packet filtering code.
itojun authored
62
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
63 #define Q_AARP 23
54b2ab1 @yuguy Patch from Monroe Williams <monroe@pobox.com>, submitted with NetBSD PR
yuguy authored
64
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
65 #define Q_ISO 24
66 #define Q_ESIS 25
67 #define Q_ISIS 26
68 #define Q_CLNP 27
af30d75 @yuguy Tony Li's changes, from FreeBSD, to support filtering for OSI packets
yuguy authored
69
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
70 #define Q_STP 28
2b3dac2 @yuguy Support checking for protocols specified by an LLC SAP on FDDI, Token
yuguy authored
71
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
72 #define Q_IPX 29
d17596d @yuguy Add "ipx", which checks for the LLC SAP for IPX as well as, on Ethernet,
yuguy authored
73
283da6d SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
fenner authored
74 #define Q_NETBEUI 30
b0dcde2 @yuguy Add a "netbeui" keyword, which selects NetBEUI packets (LLC packets with
yuguy authored
75
b11ddf8 Initial revision
mcr authored
76 /* Directional qualifiers. */
77
78 #define Q_SRC 1
79 #define Q_DST 2
80 #define Q_OR 3
81 #define Q_AND 4
82
83 #define Q_DEFAULT 0
84 #define Q_UNDEF 255
85
7fe3c11 IPv6 packet filtering code.
itojun authored
86 struct slist;
87
b11ddf8 Initial revision
mcr authored
88 struct stmt {
89 int code;
7fe3c11 IPv6 packet filtering code.
itojun authored
90 struct slist *jt; /*only for relative jump in block*/
91 struct slist *jf; /*only for relative jump in block*/
b11ddf8 Initial revision
mcr authored
92 bpf_int32 k;
93 };
94
95 struct slist {
96 struct stmt s;
97 struct slist *next;
98 };
99
100 /*
101 * A bit vector to represent definition sets. We assume TOT_REGISTERS
102 * is smaller than 8*sizeof(atomset).
103 */
104 typedef bpf_u_int32 atomset;
105 #define ATOMMASK(n) (1 << (n))
106 #define ATOMELEM(d, n) (d & ATOMMASK(n))
107
108 /*
109 * An unbounded set.
110 */
111 typedef bpf_u_int32 *uset;
112
113 /*
114 * Total number of atomic entities, including accumulator (A) and index (X).
115 * We treat all these guys similarly during flow analysis.
116 */
117 #define N_ATOMS (BPF_MEMWORDS+2)
118
119 struct edge {
120 int id;
121 int code;
122 uset edom;
123 struct block *succ;
124 struct block *pred;
125 struct edge *next; /* link list of incoming edges for a node */
126 };
127
128 struct block {
129 int id;
130 struct slist *stmts; /* side effect stmts */
131 struct stmt s; /* branch stmt */
132 int mark;
133 int longjt; /* jt branch requires long jump */
134 int longjf; /* jf branch requires long jump */
135 int level;
136 int offset;
137 int sense;
138 struct edge et;
139 struct edge ef;
140 struct block *head;
141 struct block *link; /* link field used by optimizer */
142 uset dom;
143 uset closure;
144 struct edge *in_edges;
145 atomset def, kill;
146 atomset in_use;
147 atomset out_use;
148 int oval;
149 int val[N_ATOMS];
150 };
151
152 struct arth {
153 struct block *b; /* protocol checks */
154 struct slist *s; /* stmt list */
155 int regno; /* virtual register number of result */
156 };
157
158 struct qual {
159 unsigned char addr;
160 unsigned char proto;
161 unsigned char dir;
162 unsigned char pad;
163 };
164
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 *);
170
171 void gen_and(struct block *, struct block *);
172 void gen_or(struct block *, struct block *);
173 void gen_not(struct block *);
174
175 struct block *gen_scode(const char *, struct qual);
176 struct block *gen_ecode(const u_char *, struct qual);
38b97b7 @yuguy ARCNet support, from NetBSD.
yuguy authored
177 struct block *gen_acode(const u_char *, struct qual);
b11ddf8 Initial revision
mcr authored
178 struct block *gen_mcode(const char *, const char *, int, struct qual);
7fe3c11 IPv6 packet filtering code.
itojun authored
179 #ifdef INET6
180 struct block *gen_mcode6(const char *, const char *, int, struct qual);
181 #endif
b11ddf8 Initial revision
mcr authored
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);
191
98a503e @yuguy Improved VLAN support, from Peter Jeremy - "vlan" filtering keyword,
yuguy authored
192 struct block *gen_vlan(int);
193
b11ddf8 Initial revision
mcr authored
194 void bpf_optimize(struct block **);
0e2f8c8 add config.h, remove gnuc.h. remove __dead
assar authored
195 void bpf_error(const char *, ...)
417d093 (bpf_error): conditionalize __attribute__
assar authored
196 #if HAVE___ATTRIBUTE__
0e2f8c8 add config.h, remove gnuc.h. remove __dead
assar authored
197 __attribute__((noreturn, format (printf, 1, 2)))
417d093 (bpf_error): conditionalize __attribute__
assar authored
198 #endif
199 ;
b11ddf8 Initial revision
mcr authored
200
201 void finish_parse(struct block *);
202 char *sdup(const char *);
203
204 struct bpf_insn *icode_to_fcode(struct block *, int *);
205 int pcap_parse(void);
206 void lex_init(char *);
0d0297b @yuguy Older versions of Flex (e.g., 2.5.2, which at least one user had) dump
yuguy authored
207 void lex_cleanup(void);
b11ddf8 Initial revision
mcr authored
208 void sappend(struct slist *, struct slist *);
209
210 /* XXX */
211 #define JT(b) ((b)->et.succ)
212 #define JF(b) ((b)->ef.succ)
7fe3c11 IPv6 packet filtering code.
itojun authored
213
214 extern int no_optimize;
Something went wrong with that request. Please try again.