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
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 *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
121WS_DLL_PUBLIC
122void
123dfilter_vfail(void *state, int code, df_loc_t err_loc,
124 const char *format, va_list args);
125
136WS_DLL_PUBLIC
137void
138dfilter_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
150void
151dfilter_fail_throw(void *state, int code, df_loc_t err_loc,
152 const char *format, ...) G_GNUC_PRINTF(4, 5);
153
160void
162
169void
170add_deprecated_token(GPtrArray *deprecated, const char *token);
171
178void
179add_compile_warning(dfwork_t *dfw, const char *format, ...);
180
186void
187free_deprecated(GPtrArray *deprecated);
188
195void
196DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
197
206dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated);
207
218bool
219dfilter_fvalue_from_literal(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
220 bool allow_partial_value, header_field_info *hfinfo_value_string);
221
230bool
231dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
232 header_field_info *hfinfo_value_string);
233
241void
242dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
243
253void
254dfilter_fvalue_from_number(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
255
262const char *tokenstr(int token);
263
272reference_new(const field_info *finfo, bool raw);
273
279void
281
288WS_DLL_PUBLIC
289void
291
298WS_DLL_PUBLIC
299GPtrArray *
301
302#define df_cell_ptr(rp) ((rp)->array)
303
310WS_DLL_PUBLIC
311size_t
312df_cell_size(const df_cell_t *rp);
313
314
321WS_DLL_PUBLIC
322fvalue_t **
323df_cell_array(const df_cell_t *rp);
324
331WS_DLL_PUBLIC
332bool
333df_cell_is_empty(const df_cell_t *rp);
334
341WS_DLL_PUBLIC
342bool
343df_cell_is_null(const df_cell_t *rp);
344
351WS_DLL_PUBLIC
352void
353df_cell_init(df_cell_t *rp, bool free_seg);
354
362WS_DLL_PUBLIC
363void
365
374WS_DLL_PUBLIC
375void
377
384WS_DLL_PUBLIC
385fvalue_t *
387
388
389#endif
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
df_reference_t * reference_new(const field_info *finfo, bool raw)
Creates a new reference for a field.
Definition dfilter.c:907
WS_DLL_PUBLIC bool df_cell_is_null(const df_cell_t *rp)
Check if the given cell is null.
Definition dfilter.c:1023
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
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
void add_compile_warning(dfwork_t *dfw, const char *format,...)
Adds a compile warning to the given dfwork_t structure.
Definition dfilter.c:382
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
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
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
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
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
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
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
WS_DLL_PUBLIC void df_cell_clear(df_cell_t *rp)
Clear a df_cell_t structure.
Definition dfilter.c:1039
const char * tokenstr(int token)
Retrieves a string representation of a token.
Definition dfilter.c:320
void DfilterTrace(FILE *TraceFILE, char *zTracePrompt)
Writes a trace prompt to the specified file.
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
void add_deprecated_token(GPtrArray *deprecated, const char *token)
Adds a deprecated token to an array.
Definition dfilter.c:369
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
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
WS_DLL_PUBLIC void df_cell_init(df_cell_t *rp, bool free_seg)
Initialize a df_cell_t structure.
Definition dfilter.c:1029
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
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
void reference_free(df_reference_t *ref)
Frees a reference.
Definition dfilter.c:922
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
void free_deprecated(GPtrArray *deprecated)
Frees memory allocated for deprecated items.
Definition dfilter-loc.h:16
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:24
Definition proto.h:765
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
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:814
Definition syntax-tree.h:78