Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dfilter / dfvm.h
bloba4a2b0a3e13fc5d4a31603744acfedacd2555303
1 /** @file
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 2001 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef DFVM_H
11 #define DFVM_H
13 #include <wsutil/regex.h>
14 #include "dfilter-int.h"
15 #include "syntax-tree.h"
16 #include "drange.h"
17 #include "dfunctions.h"
19 #define ASSERT_DFVM_OP_NOT_REACHED(op) \
20 ws_error("Invalid dfvm opcode '%s'.", dfvm_opcode_tostr(op))
22 typedef 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;
35 typedef struct {
36 dfvm_value_type_t type;
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;
47 int ref_count;
48 } dfvm_value_t;
50 #define dfvm_value_get_fvalue(val) ((val)->value.fvalue_p->pdata[0])
52 typedef 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;
105 const char *
106 dfvm_opcode_tostr(dfvm_opcode_t code);
108 typedef struct {
109 int id;
110 dfvm_opcode_t op;
111 dfvm_value_t *arg1;
112 dfvm_value_t *arg2;
113 dfvm_value_t *arg3;
114 } dfvm_insn_t;
116 dfvm_insn_t*
117 dfvm_insn_new(dfvm_opcode_t op);
119 void
120 dfvm_insn_replace_no_op(dfvm_insn_t *insn);
122 void
123 dfvm_insn_free(dfvm_insn_t *insn);
125 dfvm_value_t*
126 dfvm_value_new(dfvm_value_type_t type);
128 dfvm_value_t*
129 dfvm_value_ref(dfvm_value_t *v);
131 void
132 dfvm_value_unref(dfvm_value_t *v);
134 dfvm_value_t*
135 dfvm_value_new_fvalue(fvalue_t *fv);
137 dfvm_value_t*
138 dfvm_value_new_hfinfo(header_field_info *hfinfo, bool raw);
140 dfvm_value_t*
141 dfvm_value_new_register(int reg);
143 dfvm_value_t*
144 dfvm_value_new_drange(drange_t *dr);
146 dfvm_value_t*
147 dfvm_value_new_funcdef(df_func_def_t *funcdef);
149 dfvm_value_t*
150 dfvm_value_new_pcre(ws_regex_t *re);
152 dfvm_value_t*
153 dfvm_value_new_uint(unsigned num);
155 void
156 dfvm_dump(FILE *f, dfilter_t *df, uint16_t flags);
158 char *
159 dfvm_dump_str(wmem_allocator_t *alloc, dfilter_t *df, uint16_t flags);
161 bool
162 dfvm_apply(dfilter_t *df, proto_tree *tree);
164 bool
165 dfvm_apply_full(dfilter_t *df, proto_tree *tree, GPtrArray **fvals);
167 fvalue_t *
168 dfvm_get_raw_fvalue(const field_info *fi);
170 #endif