Wireshark 4.7.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 HFINFO_VS,
28 INSN_NUMBER,
29 REGISTER,
30 INTEGER,
31 DRANGE,
32 FUNCTION_DEF,
33 PCRE,
34} dfvm_value_type_t;
35
43typedef struct {
44 dfvm_value_type_t type;
46 union {
47 GPtrArray *fvalue_p;
48 uint32_t numeric;
53 } value;
54
57
58#define dfvm_value_get_fvalue(val) ((val)->value.fvalue_p->pdata[0])
59
60typedef enum {
61 DFVM_NULL, /* Null/invalid opcode */
62 DFVM_IF_TRUE_GOTO,
63 DFVM_IF_FALSE_GOTO,
64 DFVM_CHECK_EXISTS,
65 DFVM_CHECK_EXISTS_R,
66 DFVM_NOT,
67 DFVM_RETURN,
68 DFVM_READ_TREE,
69 DFVM_READ_TREE_R,
70 DFVM_READ_REFERENCE,
71 DFVM_READ_REFERENCE_R,
72 DFVM_PUT_FVALUE,
73 DFVM_ALL_EQ,
74 DFVM_ANY_EQ,
75 DFVM_ALL_NE,
76 DFVM_ANY_NE,
77 DFVM_ALL_GT,
78 DFVM_ANY_GT,
79 DFVM_ALL_GE,
80 DFVM_ANY_GE,
81 DFVM_ALL_LT,
82 DFVM_ANY_LT,
83 DFVM_ALL_LE,
84 DFVM_ANY_LE,
85 DFVM_ALL_CONTAINS,
86 DFVM_ANY_CONTAINS,
87 DFVM_ALL_MATCHES,
88 DFVM_ANY_MATCHES,
89 DFVM_SET_ALL_IN,
90 DFVM_SET_ANY_IN,
91 DFVM_SET_ALL_NOT_IN,
92 DFVM_SET_ANY_NOT_IN,
93 DFVM_SET_ADD,
94 DFVM_SET_ADD_RANGE,
95 DFVM_SET_CLEAR,
96 DFVM_SLICE,
97 DFVM_LENGTH,
98 DFVM_BITWISE_AND,
99 DFVM_UNARY_MINUS,
100 DFVM_ADD,
101 DFVM_SUBTRACT,
102 DFVM_MULTIPLY,
103 DFVM_DIVIDE,
104 DFVM_MODULO,
105 DFVM_CALL_FUNCTION,
106 DFVM_STACK_PUSH,
107 DFVM_STACK_POP,
108 DFVM_NOT_ALL_ZERO,
109 DFVM_NO_OP,
110} dfvm_opcode_t;
111
112const char *
113dfvm_opcode_tostr(dfvm_opcode_t code);
114
115typedef struct {
116 int id;
117 dfvm_opcode_t op;
118 dfvm_value_t *arg1;
119 dfvm_value_t *arg2;
120 dfvm_value_t *arg3;
122
124dfvm_insn_new(dfvm_opcode_t op);
125
126void
127dfvm_insn_replace_no_op(dfvm_insn_t *insn);
128
129void
130dfvm_insn_free(dfvm_insn_t *insn);
131
133dfvm_value_new(dfvm_value_type_t type);
134
136dfvm_value_ref(dfvm_value_t *v);
137
138void
139dfvm_value_unref(dfvm_value_t *v);
140
142dfvm_value_new_fvalue(fvalue_t *fv);
143
145dfvm_value_new_hfinfo(header_field_info *hfinfo, bool raw, bool val_str);
146
148dfvm_value_new_register(int reg);
149
151dfvm_value_new_drange(drange_t *dr);
152
154dfvm_value_new_funcdef(df_func_def_t *funcdef);
155
157dfvm_value_new_pcre(ws_regex_t *re);
158
160dfvm_value_new_uint(unsigned num);
161
162void
163dfvm_dump(FILE *f, dfilter_t *df, uint16_t flags);
164
165char *
166dfvm_dump_str(wmem_allocator_t *alloc, dfilter_t *df, uint16_t flags);
167
168bool
169dfvm_apply(dfilter_t *df, proto_tree *tree);
170
171bool
172dfvm_apply_full(dfilter_t *df, proto_tree *tree, GPtrArray **fvals);
173
174fvalue_t *
175dfvm_get_raw_fvalue(const field_info *fi);
176
177#endif
Definition drange.h:40
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:24
Definition proto.h:767
Definition proto.h:907
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition regex.c:17
Definition dfunctions.h:39
Definition dfvm.h:115
Represents a typed value used in display filter virtual machine (DFVM) operations.
Definition dfvm.h:43
drange_t * drange
Definition dfvm.h:49
ws_regex_t * pcre
Definition dfvm.h:52
uint32_t numeric
Definition dfvm.h:48
header_field_info * hfinfo
Definition dfvm.h:50
GPtrArray * fvalue_p
Definition dfvm.h:47
dfvm_value_type_t type
Definition dfvm.h:44
df_func_def_t * funcdef
Definition dfvm.h:51
int ref_count
Definition dfvm.h:55
Definition dfilter-int.h:35
Definition proto.h:816