Include files from the "epan" directory and subdirectories thereof with
[obnox/wireshark/wip.git] / epan / dfilter / dfvm.h
1 /*
2  * $Id: dfvm.h,v 1.4 2002/01/21 07:37:37 guy Exp $
3  *
4  * Ethereal - Network traffic analyzer
5  * By Gerald Combs <gerald@ethereal.com>
6  * Copyright 2001 Gerald Combs
7  * 
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  */
22
23 #ifndef DFVM_H
24 #define DFVM_H
25
26 #include <stdio.h>
27 #include <epan/proto.h>
28 #include "dfilter-int.h"
29 #include "syntax-tree.h"
30 #include "drange.h"
31
32 typedef enum {
33         EMPTY,
34         FVALUE,
35         FIELD_ID,
36         INSN_NUMBER,
37         REGISTER,
38         INTEGER,
39         DRANGE
40 } dfvm_value_type_t;
41
42 typedef struct {
43         dfvm_value_type_t       type;
44
45         union {
46                 fvalue_t        *fvalue;
47                 guint32         numeric;
48                 drange          *drange;
49         } value;
50
51 } dfvm_value_t;
52
53
54 typedef enum {
55
56         IF_TRUE_GOTO,
57         IF_FALSE_GOTO,
58         CHECK_EXISTS,
59         NOT,
60         RETURN,
61         READ_TREE,
62         PUT_FVALUE,
63         ANY_EQ,
64         ANY_NE,
65         ANY_GT,
66         ANY_GE,
67         ANY_LT,
68         ANY_LE,
69         MK_RANGE
70         
71 } dfvm_opcode_t;
72
73 typedef struct {
74         int             id;
75         int             LHS;
76         dfvm_opcode_t   op;
77         dfvm_value_t    *arg1;
78         dfvm_value_t    *arg2;
79         dfvm_value_t    *arg3;
80         dfvm_value_t    *arg4;
81 } dfvm_insn_t;
82
83 dfvm_insn_t*
84 dfvm_insn_new(dfvm_opcode_t op);
85
86 void
87 dfvm_insn_free(dfvm_insn_t *insn);
88
89 dfvm_value_t*
90 dfvm_value_new(dfvm_value_type_t type);
91
92 void
93 dfvm_value_free(dfvm_value_t *v);
94
95 void
96 dfvm_dump(FILE *f, GPtrArray *insns);
97
98 gboolean
99 dfvm_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree);
100
101
102 #endif