Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 "dfilter-int.h"
15#include "syntax-tree.h"
16#include "drange.h"
17#include "dfunctions.h"
18
19#define ASSERT_DFVM_OP_NOT_REACHED(op) \
20 ws_error("Invalid dfvm opcode '%s'.", dfvm_opcode_tostr(op))
21
22typedef enum {
23 EMPTY,
24 FVALUE,
25 HFINFO,
26 RAW_HFINFO,
27 HFINFO_VS,
28 INSN_NUMBER,
29 REGISTER,
30 INTEGER,
31 DRANGE,
32 FUNCTION_DEF,
33 PCRE,
34} dfvm_value_type_t;
35
36typedef struct {
37 dfvm_value_type_t type;
38
39 union {
40 GPtrArray *fvalue_p; /* Always has length == 1 */
41 uint32_t numeric;
42 drange_t *drange;
43 header_field_info *hfinfo;
44 df_func_def_t *funcdef;
45 ws_regex_t *pcre;
46 } value;
47
48 int ref_count;
50
51#define dfvm_value_get_fvalue(val) ((val)->value.fvalue_p->pdata[0])
52
53typedef enum {
54 DFVM_NULL, /* Null/invalid opcode */
55 DFVM_IF_TRUE_GOTO,
56 DFVM_IF_FALSE_GOTO,
57 DFVM_CHECK_EXISTS,
58 DFVM_CHECK_EXISTS_R,
59 DFVM_NOT,
60 DFVM_RETURN,
61 DFVM_READ_TREE,
62 DFVM_READ_TREE_R,
63 DFVM_READ_REFERENCE,
64 DFVM_READ_REFERENCE_R,
65 DFVM_PUT_FVALUE,
66 DFVM_ALL_EQ,
67 DFVM_ANY_EQ,
68 DFVM_ALL_NE,
69 DFVM_ANY_NE,
70 DFVM_ALL_GT,
71 DFVM_ANY_GT,
72 DFVM_ALL_GE,
73 DFVM_ANY_GE,
74 DFVM_ALL_LT,
75 DFVM_ANY_LT,
76 DFVM_ALL_LE,
77 DFVM_ANY_LE,
78 DFVM_ALL_CONTAINS,
79 DFVM_ANY_CONTAINS,
80 DFVM_ALL_MATCHES,
81 DFVM_ANY_MATCHES,
82 DFVM_SET_ALL_IN,
83 DFVM_SET_ANY_IN,
84 DFVM_SET_ALL_NOT_IN,
85 DFVM_SET_ANY_NOT_IN,
86 DFVM_SET_ADD,
87 DFVM_SET_ADD_RANGE,
88 DFVM_SET_CLEAR,
89 DFVM_SLICE,
90 DFVM_LENGTH,
91 DFVM_BITWISE_AND,
92 DFVM_UNARY_MINUS,
93 DFVM_ADD,
94 DFVM_SUBTRACT,
95 DFVM_MULTIPLY,
96 DFVM_DIVIDE,
97 DFVM_MODULO,
98 DFVM_CALL_FUNCTION,
99 DFVM_STACK_PUSH,
100 DFVM_STACK_POP,
101 DFVM_NOT_ALL_ZERO,
102 DFVM_NO_OP,
103} dfvm_opcode_t;
104
105const char *
106dfvm_opcode_tostr(dfvm_opcode_t code);
107
108typedef struct {
109 int id;
110 dfvm_opcode_t op;
111 dfvm_value_t *arg1;
112 dfvm_value_t *arg2;
113 dfvm_value_t *arg3;
115
117dfvm_insn_new(dfvm_opcode_t op);
118
119void
120dfvm_insn_replace_no_op(dfvm_insn_t *insn);
121
122void
123dfvm_insn_free(dfvm_insn_t *insn);
124
126dfvm_value_new(dfvm_value_type_t type);
127
129dfvm_value_ref(dfvm_value_t *v);
130
131void
132dfvm_value_unref(dfvm_value_t *v);
133
135dfvm_value_new_fvalue(fvalue_t *fv);
136
138dfvm_value_new_hfinfo(header_field_info *hfinfo, bool raw, bool val_str);
139
141dfvm_value_new_register(int reg);
142
144dfvm_value_new_drange(drange_t *dr);
145
147dfvm_value_new_funcdef(df_func_def_t *funcdef);
148
150dfvm_value_new_pcre(ws_regex_t *re);
151
153dfvm_value_new_uint(unsigned num);
154
155void
156dfvm_dump(FILE *f, dfilter_t *df, uint16_t flags);
157
158char *
159dfvm_dump_str(wmem_allocator_t *alloc, dfilter_t *df, uint16_t flags);
160
161bool
162dfvm_apply(dfilter_t *df, proto_tree *tree);
163
164bool
165dfvm_apply_full(dfilter_t *df, proto_tree *tree, GPtrArray **fvals);
166
167fvalue_t *
168dfvm_get_raw_fvalue(const field_info *fi);
169
170#endif
Definition drange.h:40
Definition ftypes-int.h:17
Definition proto.h:767
Definition proto.h:906
Definition wmem_allocator.h:27
Definition regex.c:17
Definition dfunctions.h:39
Definition dfvm.h:108
Definition dfvm.h:36
Definition dfilter-int.h:35
Definition proto.h:816