| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
dfilter-int.h
Go to the documentation of this file.
1
10#ifndef DFILTER_INT_H
11#define DFILTER_INT_H
12
13#include "dfilter.h"
14#include "syntax-tree.h"
15
16#include <epan/proto.h>
17#include <stdio.h>
18
19 typedef struct {
20 const header_field_info *hfinfo;
21 fvalue_t *value;
22 int proto_layer_num;
23} df_reference_t;
24
25 typedef struct {
26 GPtrArray *array;
27} df_cell_t;
28
29 typedef struct {
30 GPtrArray *ptr;
31 unsigned idx;
32} df_cell_iter_t;
33
34/* Passed back to user */
35 struct epan_dfilter {
36 GPtrArray *insns;
37 unsigned num_registers;
38 df_cell_t *registers;
39 int *interesting_fields;
40 int num_interesting_fields;
41 GPtrArray *deprecated;
42 GSList *warnings;
43 char *expanded_text;
44 GHashTable *references;
45 GHashTable *raw_references;
46 char *syntax_tree_str;
47 /* Used to pass arguments to functions. List of Lists (list of registers). */
48 GSList *function_stack;
49 GSList *set_stack;
50 ftenum_t ret_type;
51};
52
53 typedef struct {
54 df_error_t *error;
55 /* more fields. */
56} dfstate_t;
57
58/*
59 * State for first stage of compilation (parsing).
60 */
61 typedef struct {
62 df_error_t *error; /* Must be first struct field. */
63 unsigned flags;
64 stnode_t *st_root;
65 GPtrArray *deprecated;
66 stnode_t *lval;
67 GString *quoted_string;
68 bool raw_string;
69 df_loc_t string_loc;
70 df_loc_t location;
71} dfsyntax_t;
72
73/*
74 * State for second stage of compilation (semantic check and code generation).
75 */
76 typedef struct {
77 df_error_t *error; /* Must be first struct field. */
78 unsigned flags;
79 stnode_t *st_root;
80 unsigned field_count;
81 GPtrArray *insns;
82 GHashTable *loaded_fields;
83 GHashTable *loaded_raw_fields;
84 GHashTable *loaded_vs_fields;
85 GHashTable *interesting_fields;
86 int next_insn_id;
87 int next_register;
88 GPtrArray *deprecated;
89 GHashTable *references; /* hfinfo -> pointer to array of references */
90 GHashTable *raw_references; /* hfinfo -> pointer to array of references */
91 char *expanded_text;
92 wmem_allocator_t *dfw_scope; /* Because we use exceptions for error handling sometimes
93 cleaning up memory allocations is inconvenient. Memory
94 allocated from this pool will be freed when the dfwork_t
95 context is destroyed. */
96 GSList *warnings;
97 ftenum_t ret_type;
98} dfwork_t;
99
100/* Constructor/Destructor prototypes for Lemon Parser */
101void *DfilterAlloc(void *(*)(size_t));
102
103void DfilterFree(void *, void (*)(void *));
104
105void Dfilter(void *, int, stnode_t *, dfsyntax_t *);
106
107/* Return value for error in scanner. */
108#define SCAN_FAILED -1 /* not 0, as that means end-of-input */
109
110WS_DLL_PUBLIC
111void
112dfilter_vfail(void *state, int code, df_loc_t err_loc,
113 const char *format, va_list args);
114
115WS_DLL_PUBLIC
116void
117dfilter_fail(void *state, int code, df_loc_t err_loc,
118 const char *format, ...) G_GNUC_PRINTF(4, 5);
119
120WS_DLL_PUBLIC WS_NORETURN
121void
122dfilter_fail_throw(void *state, int code, df_loc_t err_loc,
123 const char *format, ...) G_GNUC_PRINTF(4, 5);
124
125void
126dfw_set_error_location(dfwork_t *dfw, df_loc_t err_loc);
127
128void
129add_deprecated_token(GPtrArray *deprecated, const char *token);
130
131void
132add_compile_warning(dfwork_t *dfw, const char *format, ...);
133
134void
135free_deprecated(GPtrArray *deprecated);
136
137void
138DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
139
140 header_field_info *
141dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated);
142
143/* Returns true if the create syntax node has a (value) string type. */
144bool
145dfilter_fvalue_from_literal(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
146 bool allow_partial_value, header_field_info *hfinfo_value_string);
147
148/* Returns true if the create syntax node has a (value) string type. */
149bool
150dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
151 header_field_info *hfinfo_value_string);
152
153void
154dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
155
156void
157dfilter_fvalue_from_number(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
158
159const char *tokenstr(int token);
160
161 df_reference_t *
162reference_new(const field_info *finfo, bool raw);
163
164void
165reference_free(df_reference_t *ref);
166
167WS_DLL_PUBLIC
168void
169df_cell_append(df_cell_t *rp, fvalue_t *fv);
170
171WS_DLL_PUBLIC
172GPtrArray *
173df_cell_ref(df_cell_t *rp);
174
175#define df_cell_ptr(rp) ((rp)->array)
176
177WS_DLL_PUBLIC
178size_t
179df_cell_size(const df_cell_t *rp);
180
181WS_DLL_PUBLIC
182 fvalue_t **
183df_cell_array(const df_cell_t *rp);
184
185WS_DLL_PUBLIC
186bool
187df_cell_is_empty(const df_cell_t *rp);
188
189WS_DLL_PUBLIC
190bool
191df_cell_is_null(const df_cell_t *rp);
192
193/* Pass true to free the array contents when the cell is cleared. */
194WS_DLL_PUBLIC
195void
196df_cell_init(df_cell_t *rp, bool free_seg);
197
198WS_DLL_PUBLIC
199void
200df_cell_clear(df_cell_t *rp);
201
202/* Cell must not be cleared while iter is alive. */
203WS_DLL_PUBLIC
204void
205df_cell_iter_init(df_cell_t *rp, df_cell_iter_t *iter);
206
207WS_DLL_PUBLIC
208 fvalue_t *
209df_cell_iter_next(df_cell_iter_t *iter);
210
211
212#endif
dfilter.h
proto.h
_dfilter_loc
Definition dfilter-loc.h:16
_fvalue_t
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:24
_header_field_info
Definition proto.h:767
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
df_cell_iter_t
Definition dfilter-int.h:29
df_cell_t
Definition dfilter-int.h:25
df_error_t
Definition dfilter.h:30
df_reference_t
Definition dfilter-int.h:19
dfstate_t
Definition dfilter-int.h:53
dfsyntax_t
Definition dfilter-int.h:61
dfwork_t
Definition dfilter-int.h:76
epan_dfilter
Definition dfilter-int.h:35
field_info
Definition proto.h:816
stnode
Definition syntax-tree.h:78
syntax-tree.h