Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
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 INSN_NUMBER,
28 REGISTER,
29 INTEGER,
30 DRANGE,
31 FUNCTION_DEF,
32 PCRE,
33} dfvm_value_type_t;
34
35typedef struct {
36 dfvm_value_type_t type;
37
38 union {
39 GPtrArray *fvalue_p; /* Always has length == 1 */
40 uint32_t numeric;
41 drange_t *drange;
42 header_field_info *hfinfo;
43 df_func_def_t *funcdef;
44 ws_regex_t *pcre;
45 } value;
46
47 int ref_count;
49
50#define dfvm_value_get_fvalue(val) ((val)->value.fvalue_p->pdata[0])
51
52typedef enum {
53 DFVM_NULL, /* Null/invalid opcode */
54 DFVM_IF_TRUE_GOTO,
55 DFVM_IF_FALSE_GOTO,
56 DFVM_CHECK_EXISTS,
57 DFVM_CHECK_EXISTS_R,
58 DFVM_NOT,
59 DFVM_RETURN,
60 DFVM_READ_TREE,
61 DFVM_READ_TREE_R,
62 DFVM_READ_REFERENCE,
63 DFVM_READ_REFERENCE_R,
64 DFVM_PUT_FVALUE,
65 DFVM_ALL_EQ,
66 DFVM_ANY_EQ,
67 DFVM_ALL_NE,
68 DFVM_ANY_NE,
69 DFVM_ALL_GT,
70 DFVM_ANY_GT,
71 DFVM_ALL_GE,
72 DFVM_ANY_GE,
73 DFVM_ALL_LT,
74 DFVM_ANY_LT,
75 DFVM_ALL_LE,
76 DFVM_ANY_LE,
77 DFVM_ALL_CONTAINS,
78 DFVM_ANY_CONTAINS,
79 DFVM_ALL_MATCHES,
80 DFVM_ANY_MATCHES,
81 DFVM_SET_ALL_IN,
82 DFVM_SET_ANY_IN,
83 DFVM_SET_ALL_NOT_IN,
84 DFVM_SET_ANY_NOT_IN,
85 DFVM_SET_ADD,
86 DFVM_SET_ADD_RANGE,
87 DFVM_SET_CLEAR,
88 DFVM_SLICE,
89 DFVM_LENGTH,
90 DFVM_VALUE_STRING,
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);
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:764
Definition proto.h:901
Definition wmem_allocator.h:27
Definition regex.c:17
Definition dfunctions.h:39
Definition dfvm.h:108
Definition dfvm.h:35
Definition dfilter-int.h:35
Definition proto.h:813