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
118const char *
119dfvm_opcode_tostr(dfvm_opcode_t code);
120
121typedef struct {
122 int id;
123 dfvm_opcode_t op;
124 dfvm_value_t *arg1;
125 dfvm_value_t *arg2;
126 dfvm_value_t *arg3;
128
136dfvm_insn_new(dfvm_opcode_t op);
137
146void
148
156void
158
166dfvm_value_new(dfvm_value_type_t type);
167
176
182void
184
193
203dfvm_value_new_hfinfo(header_field_info *hfinfo, bool raw, bool val_str);
204
213
222
231
240
248dfvm_value_new_uint(unsigned num);
249
257void
258dfvm_dump(FILE *f, dfilter_t *df, uint16_t flags);
259
268char *
269dfvm_dump_str(wmem_allocator_t *alloc, dfilter_t *df, uint16_t flags);
270
278bool
280
291bool
292dfvm_apply_full(dfilter_t *df, proto_tree *tree, GPtrArray **fvals);
293
300fvalue_t *
302
303#endif
dfvm_value_t * dfvm_value_new(dfvm_value_type_t type)
Create a new DFVM value.
Definition dfvm.c:172
dfvm_value_t * dfvm_value_new_pcre(ws_regex_t *re)
Creates a new PCRE value.
Definition dfvm.c:231
void dfvm_value_unref(dfvm_value_t *v)
Decrements the reference count of a dfvm_value_t object and frees it if the reference count reaches z...
Definition dfvm.c:115
bool dfvm_apply(dfilter_t *df, proto_tree *tree)
Applies a display filter to a protocol tree.
Definition dfvm.c:1825
dfvm_value_t * dfvm_value_new_drange(drange_t *dr)
Creates a new dfvm_value_t with type DRANGE.
Definition dfvm.c:215
dfvm_value_t * dfvm_value_new_uint(unsigned num)
Create a new DFVM value with an unsigned integer.
Definition dfvm.c:239
void dfvm_dump(FILE *f, dfilter_t *df, uint16_t flags)
Dumps the bytecode of a dfilter_t to a file.
Definition dfvm.c:736
dfvm_value_t * dfvm_value_new_funcdef(df_func_def_t *funcdef)
Create a new DFVM value of type FUNCTION_DEF.
Definition dfvm.c:223
char * dfvm_dump_str(wmem_allocator_t *alloc, dfilter_t *df, uint16_t flags)
Dumps a string representation of a dfilter.
Definition dfvm.c:675
dfvm_value_t * dfvm_value_new_hfinfo(header_field_info *hfinfo, bool raw, bool val_str)
Create a new dfvm_value_t with header field information.
Definition dfvm.c:192
void dfvm_insn_free(dfvm_insn_t *insn)
Free a DFVM instruction.
Definition dfvm.c:156
dfvm_value_t * dfvm_value_new_fvalue(fvalue_t *fv)
Creates a new DFVM value of type FVALUE.
Definition dfvm.c:183
dfvm_value_t * dfvm_value_ref(dfvm_value_t *v)
Increment the reference count of a dfvm_value_t.
Definition dfvm.c:106
void dfvm_insn_replace_no_op(dfvm_insn_t *insn)
Replaces an instruction with a no-op.
Definition dfvm.c:138
dfvm_value_t * dfvm_value_new_register(int reg)
Creates a new dfvm_value_t representing a register.
Definition dfvm.c:207
dfvm_insn_t * dfvm_insn_new(dfvm_opcode_t op)
Creates a new DFVM instruction with the specified opcode.
Definition dfvm.c:125
const char * dfvm_opcode_tostr(dfvm_opcode_t code)
Converts a DFVM opcode to its string representation.
Definition dfvm.c:23
bool dfvm_apply_full(dfilter_t *df, proto_tree *tree, GPtrArray **fvals)
Apply a full Dissector Filter VM (DFVM) to a protocol tree.
Definition dfvm.c:1591
fvalue_t * dfvm_get_raw_fvalue(const field_info *fi)
Retrieves the raw value of a field as a GByteArray.
Definition dfvm.c:788
Definition drange.h:40
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:24
Definition proto.h:765
Definition proto.h:905
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:121
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:814