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