c97faae5fb62a67983460919d34f2a652a38b505
[obnox/wireshark/wip.git] / epan / dfilter / dfvm.h
1 /*
2  * $Id: dfvm.h,v 1.8 2002/10/16 16:32:59 gram 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         HFINFO,
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                 header_field_info       *hfinfo;
50         } value;
51
52 } dfvm_value_t;
53
54
55 typedef enum {
56
57         IF_TRUE_GOTO,
58         IF_FALSE_GOTO,
59         CHECK_EXISTS,
60         NOT,
61         RETURN,
62         READ_TREE,
63         PUT_FVALUE,
64         ANY_EQ,
65         ANY_NE,
66         ANY_GT,
67         ANY_GE,
68         ANY_LT,
69         ANY_LE,
70         MK_RANGE
71
72 } dfvm_opcode_t;
73
74 typedef struct {
75         int             id;
76         int             LHS;
77         dfvm_opcode_t   op;
78         dfvm_value_t    *arg1;
79         dfvm_value_t    *arg2;
80         dfvm_value_t    *arg3;
81         dfvm_value_t    *arg4;
82 } dfvm_insn_t;
83
84 dfvm_insn_t*
85 dfvm_insn_new(dfvm_opcode_t op);
86
87 void
88 dfvm_insn_free(dfvm_insn_t *insn);
89
90 dfvm_value_t*
91 dfvm_value_new(dfvm_value_type_t type);
92
93 void
94 dfvm_dump(FILE *f, GPtrArray *insns);
95
96 gboolean
97 dfvm_apply(dfilter_t *df, proto_tree *tree);
98
99
100 #endif