Wireshark  4.3.0
The Wireshark network protocol analyzer
dfvm.h
Go to the documentation of this file.
1 
10 #ifndef DFVM_H
11 #define DFVM_H
12 
13 #include <wsutil/regex.h>
14 #include <epan/proto.h>
15 #include "dfilter-int.h"
16 #include "syntax-tree.h"
17 #include "drange.h"
18 #include "dfunctions.h"
19 
20 typedef enum {
21  EMPTY,
22  FVALUE,
23  HFINFO,
24  RAW_HFINFO,
25  INSN_NUMBER,
26  REGISTER,
27  INTEGER,
28  DRANGE,
29  FUNCTION_DEF,
30  PCRE,
31 } dfvm_value_type_t;
32 
33 typedef struct {
34  dfvm_value_type_t type;
35 
36  union {
37  GPtrArray *fvalue_p; /* Always has length == 1 */
38  uint32_t numeric;
39  drange_t *drange;
40  header_field_info *hfinfo;
41  df_func_def_t *funcdef;
42  ws_regex_t *pcre;
43  } value;
44 
45  int ref_count;
46 } dfvm_value_t;
47 
48 #define dfvm_value_get_fvalue(val) ((val)->value.fvalue_p->pdata[0])
49 
50 typedef enum {
51 
52  DFVM_IF_TRUE_GOTO,
53  DFVM_IF_FALSE_GOTO,
54  DFVM_CHECK_EXISTS,
55  DFVM_CHECK_EXISTS_R,
56  DFVM_NOT,
57  DFVM_RETURN,
58  DFVM_READ_TREE,
59  DFVM_READ_TREE_R,
60  DFVM_READ_REFERENCE,
61  DFVM_READ_REFERENCE_R,
62  DFVM_PUT_FVALUE,
63  DFVM_ALL_EQ,
64  DFVM_ANY_EQ,
65  DFVM_ALL_NE,
66  DFVM_ANY_NE,
67  DFVM_ALL_GT,
68  DFVM_ANY_GT,
69  DFVM_ALL_GE,
70  DFVM_ANY_GE,
71  DFVM_ALL_LT,
72  DFVM_ANY_LT,
73  DFVM_ALL_LE,
74  DFVM_ANY_LE,
75  DFVM_ALL_CONTAINS,
76  DFVM_ANY_CONTAINS,
77  DFVM_ALL_MATCHES,
78  DFVM_ANY_MATCHES,
79  DFVM_SET_ALL_IN,
80  DFVM_SET_ANY_IN,
81  DFVM_SET_ALL_NOT_IN,
82  DFVM_SET_ANY_NOT_IN,
83  DFVM_SET_ADD,
84  DFVM_SET_ADD_RANGE,
85  DFVM_SET_CLEAR,
86  DFVM_SLICE,
87  DFVM_LENGTH,
88  DFVM_VALUE_STRING,
89  DFVM_BITWISE_AND,
90  DFVM_UNARY_MINUS,
91  DFVM_ADD,
92  DFVM_SUBTRACT,
93  DFVM_MULTIPLY,
94  DFVM_DIVIDE,
95  DFVM_MODULO,
96  DFVM_CALL_FUNCTION,
97  DFVM_STACK_PUSH,
98  DFVM_STACK_POP,
99  DFVM_NOT_ALL_ZERO,
100 } dfvm_opcode_t;
101 
102 const char *
103 dfvm_opcode_tostr(dfvm_opcode_t code);
104 
105 typedef struct {
106  int id;
107  dfvm_opcode_t op;
108  dfvm_value_t *arg1;
109  dfvm_value_t *arg2;
110  dfvm_value_t *arg3;
111 } dfvm_insn_t;
112 
114 dfvm_insn_new(dfvm_opcode_t op);
115 
116 void
117 dfvm_insn_free(dfvm_insn_t *insn);
118 
120 dfvm_value_new(dfvm_value_type_t type);
121 
123 dfvm_value_ref(dfvm_value_t *v);
124 
125 void
126 dfvm_value_unref(dfvm_value_t *v);
127 
129 dfvm_value_new_fvalue(fvalue_t *fv);
130 
132 dfvm_value_new_hfinfo(header_field_info *hfinfo, bool raw);
133 
135 dfvm_value_new_register(int reg);
136 
138 dfvm_value_new_drange(drange_t *dr);
139 
141 dfvm_value_new_funcdef(df_func_def_t *funcdef);
142 
144 dfvm_value_new_pcre(ws_regex_t *re);
145 
147 dfvm_value_new_guint(unsigned num);
148 
149 void
150 dfvm_dump(FILE *f, dfilter_t *df, uint16_t flags);
151 
152 char *
153 dfvm_dump_str(wmem_allocator_t *alloc, dfilter_t *df, uint16_t flags);
154 
155 bool
156 dfvm_apply(dfilter_t *df, proto_tree *tree);
157 
158 fvalue_t *
159 dfvm_get_raw_fvalue(const field_info *fi);
160 
161 #endif
Definition: drange.h:40
Definition: ftypes-int.h:17
Definition: proto.h:762
Definition: proto.h:897
Definition: wmem_allocator.h:27
Definition: regex.c:17
Definition: dfunctions.h:32
Definition: dfvm.h:105
Definition: dfvm.h:33
Definition: dfilter-int.h:35
Definition: proto.h:809