Wireshark 4.5.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
19typedef struct {
20 const header_field_info *hfinfo;
21 fvalue_t *value;
22 int proto_layer_num;
24
25typedef struct {
26 GPtrArray *array;
27} df_cell_t;
28
29typedef struct {
30 GPtrArray *ptr;
31 unsigned idx;
33
34/* Passed back to user */
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
53typedef struct {
54 df_error_t *error;
55 /* more fields. */
56} dfstate_t;
57
58/*
59 * State for first stage of compilation (parsing).
60 */
61typedef 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;
72
73/*
74 * State for second stage of compilation (semantic check and code generation).
75 */
76typedef 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 *interesting_fields;
85 int next_insn_id;
86 int next_register;
87 GPtrArray *deprecated;
88 GHashTable *references; /* hfinfo -> pointer to array of references */
89 GHashTable *raw_references; /* hfinfo -> pointer to array of references */
90 char *expanded_text;
91 wmem_allocator_t *dfw_scope; /* Because we use exceptions for error handling sometimes
92 cleaning up memory allocations is inconvenient. Memory
93 allocated from this pool will be freed when the dfwork_t
94 context is destroyed. */
95 GSList *warnings;
96 ftenum_t ret_type;
97} dfwork_t;
98
99/* Constructor/Destructor prototypes for Lemon Parser */
100void *DfilterAlloc(void *(*)(size_t));
101
102void DfilterFree(void *, void (*)(void *));
103
104void Dfilter(void *, int, stnode_t *, dfsyntax_t *);
105
106/* Return value for error in scanner. */
107#define SCAN_FAILED -1 /* not 0, as that means end-of-input */
108
109WS_DLL_PUBLIC
110void
111dfilter_vfail(void *state, int code, df_loc_t err_loc,
112 const char *format, va_list args);
113
114WS_DLL_PUBLIC
115void
116dfilter_fail(void *state, int code, df_loc_t err_loc,
117 const char *format, ...) G_GNUC_PRINTF(4, 5);
118
119WS_DLL_PUBLIC WS_NORETURN
120void
121dfilter_fail_throw(void *state, int code, df_loc_t err_loc,
122 const char *format, ...) G_GNUC_PRINTF(4, 5);
123
124void
125dfw_set_error_location(dfwork_t *dfw, df_loc_t err_loc);
126
127void
128add_deprecated_token(GPtrArray *deprecated, const char *token);
129
130void
131add_compile_warning(dfwork_t *dfw, const char *format, ...);
132
133void
134free_deprecated(GPtrArray *deprecated);
135
136void
137DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
138
140dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated);
141
142/* Returns true if the create syntax node has a (value) string type. */
143bool
144dfilter_fvalue_from_literal(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
145 bool allow_partial_value, header_field_info *hfinfo_value_string);
146
147/* Returns true if the create syntax node has a (value) string type. */
148bool
149dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
150 header_field_info *hfinfo_value_string);
151
152void
153dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
154
155void
156dfilter_fvalue_from_number(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
157
158const char *tokenstr(int token);
159
161reference_new(const field_info *finfo, bool raw);
162
163void
164reference_free(df_reference_t *ref);
165
166WS_DLL_PUBLIC
167void
168df_cell_append(df_cell_t *rp, fvalue_t *fv);
169
170WS_DLL_PUBLIC
171GPtrArray *
172df_cell_ref(df_cell_t *rp);
173
174#define df_cell_ptr(rp) ((rp)->array)
175
176WS_DLL_PUBLIC
177size_t
178df_cell_size(const df_cell_t *rp);
179
180WS_DLL_PUBLIC
181fvalue_t **
182df_cell_array(const df_cell_t *rp);
183
184WS_DLL_PUBLIC
185bool
186df_cell_is_empty(const df_cell_t *rp);
187
188WS_DLL_PUBLIC
189bool
190df_cell_is_null(const df_cell_t *rp);
191
192/* Pass true to free the array contents when the cell is cleared. */
193WS_DLL_PUBLIC
194void
195df_cell_init(df_cell_t *rp, bool free_seg);
196
197WS_DLL_PUBLIC
198void
199df_cell_clear(df_cell_t *rp);
200
201/* Cell must not be cleared while iter is alive. */
202WS_DLL_PUBLIC
203void
204df_cell_iter_init(df_cell_t *rp, df_cell_iter_t *iter);
205
206WS_DLL_PUBLIC
207fvalue_t *
208df_cell_iter_next(df_cell_iter_t *iter);
209
210
211#endif
Definition dfilter-loc.h:16
Definition ftypes-int.h:17
Definition proto.h:764
Definition wmem_allocator.h:27
Definition dfilter-int.h:29
Definition dfilter-int.h:25
Definition dfilter.h:30
Definition dfilter-int.h:19
Definition dfilter-int.h:53
Definition dfilter-int.h:61
Definition dfilter-int.h:76
Definition dfilter-int.h:35
Definition proto.h:813
Definition syntax-tree.h:78