| 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 */
101 void *DfilterAlloc(void *(*)(size_t));
102
103 void DfilterFree(void *, void (*)(void *));
104
105 void 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
121WS_DLL_PUBLIC
122 void
123 dfilter_vfail(void *state, int code, df_loc_t err_loc,
124 const char *format, va_list args);
125
136WS_DLL_PUBLIC
137 void
138 dfilter_fail(void *state, int code, df_loc_t err_loc,
139 const char *format, ...) G_GNUC_PRINTF(4, 5);
140
149WS_DLL_PUBLIC WS_NORETURN
150 void
151 dfilter_fail_throw(void *state, int code, df_loc_t err_loc,
152 const char *format, ...) G_GNUC_PRINTF(4, 5);
153
160 void
161 dfw_set_error_location(dfwork_t *dfw, df_loc_t err_loc);
162
169 void
170 add_deprecated_token(GPtrArray *deprecated, const char *token);
171
178 void
179 add_compile_warning(dfwork_t *dfw, const char *format, ...);
180
186 void
187 free_deprecated(GPtrArray *deprecated);
188
195 void
196 DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
197
205 header_field_info *
206 dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated);
207
218 bool
219 dfilter_fvalue_from_literal(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
220 bool allow_partial_value, header_field_info *hfinfo_value_string);
221
230 bool
231 dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
232 header_field_info *hfinfo_value_string);
233
241 void
242 dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
243
253 void
254 dfilter_fvalue_from_number(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
255
262const char *tokenstr(int token);
263
271 df_reference_t *
272 reference_new(const field_info *finfo, bool raw);
273
279 void
280 reference_free(df_reference_t *ref);
281
288WS_DLL_PUBLIC
289 void
290 df_cell_append(df_cell_t *rp, fvalue_t *fv);
291
298WS_DLL_PUBLIC
299GPtrArray *
300 df_cell_ref(df_cell_t *rp);
301
302#define df_cell_ptr(rp) ((rp)->array)
303
310WS_DLL_PUBLIC
311 size_t
312 df_cell_size(const df_cell_t *rp);
313
314
321WS_DLL_PUBLIC
322 fvalue_t **
323 df_cell_array(const df_cell_t *rp);
324
331WS_DLL_PUBLIC
332 bool
333 df_cell_is_empty(const df_cell_t *rp);
334
341WS_DLL_PUBLIC
342 bool
343 df_cell_is_null(const df_cell_t *rp);
344
351WS_DLL_PUBLIC
352 void
353 df_cell_init(df_cell_t *rp, bool free_seg);
354
362WS_DLL_PUBLIC
363 void
364 df_cell_clear(df_cell_t *rp);
365
374WS_DLL_PUBLIC
375 void
376 df_cell_iter_init(df_cell_t *rp, df_cell_iter_t *iter);
377
384WS_DLL_PUBLIC
385 fvalue_t *
386 df_cell_iter_next(df_cell_iter_t *iter);
387
388
389#endif
df_cell_iter_next
WS_DLL_PUBLIC fvalue_t * df_cell_iter_next(df_cell_iter_t *iter)
Advances the iterator to the next cell and returns its value.
Definition dfilter.c:1054
reference_new
df_reference_t * reference_new(const field_info *finfo, bool raw)
Creates a new reference for a field.
Definition dfilter.c:907
df_cell_is_null
WS_DLL_PUBLIC bool df_cell_is_null(const df_cell_t *rp)
Check if the given cell is null.
Definition dfilter.c:1023
dfilter_fvalue_from_charconst
void dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st)
Create a new filter value from a character constant.
Definition semcheck.c:308
dfilter_fail
WS_DLL_PUBLIC void dfilter_fail(void *state, int code, df_loc_t err_loc, const char *format,...)
Handle a filter failure and log an error message.
Definition dfilter.c:52
add_compile_warning
void add_compile_warning(dfwork_t *dfw, const char *format,...)
Adds a compile warning to the given dfwork_t structure.
Definition dfilter.c:382
dfilter_fail_throw
WS_DLL_PUBLIC WS_NORETURN void dfilter_fail_throw(void *state, int code, df_loc_t err_loc, const char *format,...)
Throw a filter failure with an error message.
Definition dfilter.c:63
df_cell_is_empty
WS_DLL_PUBLIC bool df_cell_is_empty(const df_cell_t *rp)
Checks if a df_cell_t is empty.
Definition dfilter.c:1015
dfilter_resolve_unparsed
header_field_info * dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated)
Resolve an unparsed filter name to a header field info.
Definition dfilter.c:81
df_cell_array
WS_DLL_PUBLIC fvalue_t ** df_cell_array(const df_cell_t *rp)
Retrieves an array of fvalue_t pointers from a df_cell_t.
Definition dfilter.c:1007
dfilter_fvalue_from_number
void dfilter_fvalue_from_number(dfwork_t *dfw, ftenum_t ftype, stnode_t *st)
Create an filter value from a number token.
Definition semcheck.c:333
df_cell_iter_init
WS_DLL_PUBLIC void df_cell_iter_init(df_cell_t *rp, df_cell_iter_t *iter)
Initialize an iterator for a cell.
Definition dfilter.c:1047
df_cell_size
WS_DLL_PUBLIC size_t df_cell_size(const df_cell_t *rp)
Get the size of a df_cell_t.
Definition dfilter.c:999
df_cell_clear
WS_DLL_PUBLIC void df_cell_clear(df_cell_t *rp)
Clear a df_cell_t structure.
Definition dfilter.c:1039
tokenstr
const char * tokenstr(int token)
Retrieves a string representation of a token.
Definition dfilter.c:320
DfilterTrace
void DfilterTrace(FILE *TraceFILE, char *zTracePrompt)
Writes a trace prompt to the specified file.
df_cell_append
WS_DLL_PUBLIC void df_cell_append(df_cell_t *rp, fvalue_t *fv)
Append a fvalue to a df_cell.
Definition dfilter.c:983
add_deprecated_token
void add_deprecated_token(GPtrArray *deprecated, const char *token)
Adds a deprecated token to an array.
Definition dfilter.c:369
df_cell_ref
WS_DLL_PUBLIC GPtrArray * df_cell_ref(df_cell_t *rp)
Get a reference to the array in a df_cell_t structure.
Definition dfilter.c:991
dfw_set_error_location
void dfw_set_error_location(dfwork_t *dfw, df_loc_t err_loc)
Set the error location for a given dfwork_t object.
Definition dfilter.c:74
df_cell_init
WS_DLL_PUBLIC void df_cell_init(df_cell_t *rp, bool free_seg)
Initialize a df_cell_t structure.
Definition dfilter.c:1029
dfilter_fvalue_from_literal
bool dfilter_fvalue_from_literal(dfwork_t *dfw, ftenum_t ftype, stnode_t *st, bool allow_partial_value, header_field_info *hfinfo_value_string)
Creates a fvalue from a literal string.
Definition semcheck.c:224
dfilter_vfail
WS_DLL_PUBLIC void dfilter_vfail(void *state, int code, df_loc_t err_loc, const char *format, va_list args)
Report a failure in a display filter.
Definition dfilter.c:40
reference_free
void reference_free(df_reference_t *ref)
Frees a reference.
Definition dfilter.c:922
dfilter_fvalue_from_string
bool dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st, header_field_info *hfinfo_value_string)
Converts a string to a filter value.
Definition semcheck.c:269
free_deprecated
void free_deprecated(GPtrArray *deprecated)
Frees memory allocated for deprecated items.
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:765
_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:814
stnode
Definition syntax-tree.h:78
syntax-tree.h