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
27
31typedef struct {
32 GPtrArray *array;
33} df_cell_t;
34
38typedef struct {
39 GPtrArray *ptr;
40 unsigned idx;
42
47 GPtrArray *insns;
48 unsigned num_registers;
52 GPtrArray *deprecated;
53 GSList *warnings;
55 GHashTable *references;
56 GHashTable *raw_references;
58 /* Used to pass arguments to functions. List of Lists (list of registers). */
60 GSList *set_stack;
62};
63
67typedef struct {
69 /* more fields. */
70} dfstate_t;
71
86
114
115/* Constructor/Destructor prototypes for Lemon Parser */
116
120void *DfilterAlloc(void *(*)(size_t));
121
125void DfilterFree(void *, void (*)(void *));
126
133void Dfilter(void *yyp, int yymajor, stnode_t *yyminor, dfsyntax_t *);
134
135/* Return value for error in scanner. */
140#define SCAN_FAILED -1
141
153WS_DLL_PUBLIC
154void
155dfilter_vfail(void *state, int code, df_loc_t err_loc,
156 const char *format, va_list args);
157
168WS_DLL_PUBLIC
169void
170dfilter_fail(void *state, int code, df_loc_t err_loc,
171 const char *format, ...) G_GNUC_PRINTF(4, 5);
172
181WS_DLL_PUBLIC WS_NORETURN
182void
183dfilter_fail_throw(void *state, int code, df_loc_t err_loc,
184 const char *format, ...) G_GNUC_PRINTF(4, 5);
185
192void
194
201void
202add_deprecated_token(GPtrArray *deprecated, const char *token);
203
210void
211add_compile_warning(dfwork_t *dfw, const char *format, ...);
212
218void
219free_deprecated(GPtrArray *deprecated);
220
227void
228DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
229
238dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated);
239
250bool
252 bool allow_partial_value, header_field_info *hfinfo_value_string);
253
262bool
264 header_field_info *hfinfo_value_string);
265
273void
275
285void
287
294const char *tokenstr(int token);
295
304reference_new(const field_info *finfo, bool raw);
305
311void
313
320WS_DLL_PUBLIC
321void
323
330WS_DLL_PUBLIC
331GPtrArray *
333
334#define df_cell_ptr(rp) ((rp)->array)
335
342WS_DLL_PUBLIC
343size_t
344df_cell_size(const df_cell_t *rp);
345
346
353WS_DLL_PUBLIC
354fvalue_t **
355df_cell_array(const df_cell_t *rp);
356
363WS_DLL_PUBLIC
364bool
365df_cell_is_empty(const df_cell_t *rp);
366
373WS_DLL_PUBLIC
374bool
375df_cell_is_null(const df_cell_t *rp);
376
383WS_DLL_PUBLIC
384void
385df_cell_init(df_cell_t *rp, bool free_seg);
386
394WS_DLL_PUBLIC
395void
397
406WS_DLL_PUBLIC
407void
409
416WS_DLL_PUBLIC
417fvalue_t *
419
420
421#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
void DfilterFree(void *, void(*)(void *))
Deallocator for the display filter.
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 * DfilterAlloc(void *(*)(size_t))
Allocator for the display filter.
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 Dfilter(void *yyp, int yymajor, stnode_t *yyminor, dfsyntax_t *)
Evaluates a token in the Lemon Parser.
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.
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
Represents a location (column start and length) within a display filter string.
Definition dfilter-loc.h:19
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:22
Definition proto.h:768
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Iterator for navigating through a df_cell_t array.
Definition dfilter-int.h:38
unsigned idx
Definition dfilter-int.h:40
GPtrArray * ptr
Definition dfilter-int.h:39
A container for a pointer array, typically holding field references.
Definition dfilter-int.h:31
GPtrArray * array
Definition dfilter-int.h:32
Represents a display filter error, including an error code, message, and source location.
Definition dfilter.h:33
Reference to a display filter field.
Definition dfilter-int.h:22
int proto_layer_num
Definition dfilter-int.h:25
fvalue_t * value
Definition dfilter-int.h:24
const header_field_info * hfinfo
Definition dfilter-int.h:23
State structure for display filter evaluation or processing.
Definition dfilter-int.h:67
df_error_t * error
Definition dfilter-int.h:68
State for the first stage of display filter compilation (parsing).
Definition dfilter-int.h:75
unsigned flags
Definition dfilter-int.h:77
df_loc_t location
Definition dfilter-int.h:84
stnode_t * st_root
Definition dfilter-int.h:78
bool raw_string
Definition dfilter-int.h:82
df_error_t * error
Definition dfilter-int.h:76
GPtrArray * deprecated
Definition dfilter-int.h:79
GString * quoted_string
Definition dfilter-int.h:81
stnode_t * lval
Definition dfilter-int.h:80
df_loc_t string_loc
Definition dfilter-int.h:83
State for the second stage of display filter compilation (semantic check and code generation).
Definition dfilter-int.h:90
unsigned flags
Definition dfilter-int.h:92
df_error_t * error
Definition dfilter-int.h:91
int next_insn_id
Definition dfilter-int.h:100
GPtrArray * deprecated
Definition dfilter-int.h:102
GHashTable * references
Definition dfilter-int.h:103
GHashTable * loaded_raw_fields
Definition dfilter-int.h:97
int next_register
Definition dfilter-int.h:101
GHashTable * interesting_fields
Definition dfilter-int.h:99
char * expanded_text
Definition dfilter-int.h:105
GHashTable * loaded_vs_fields
Definition dfilter-int.h:98
unsigned field_count
Definition dfilter-int.h:94
GHashTable * raw_references
Definition dfilter-int.h:104
ftenum_t ret_type
Definition dfilter-int.h:112
stnode_t * st_root
Definition dfilter-int.h:93
GSList * warnings
Definition dfilter-int.h:111
GHashTable * loaded_fields
Definition dfilter-int.h:96
wmem_allocator_t * dfw_scope
Definition dfilter-int.h:106
GPtrArray * insns
Definition dfilter-int.h:95
The compiled display filter object passed back to the user.
Definition dfilter-int.h:46
char * expanded_text
Definition dfilter-int.h:54
unsigned num_registers
Definition dfilter-int.h:48
ftenum_t ret_type
Definition dfilter-int.h:61
GSList * function_stack
Definition dfilter-int.h:59
int num_interesting_fields
Definition dfilter-int.h:51
GHashTable * references
Definition dfilter-int.h:55
GPtrArray * insns
Definition dfilter-int.h:47
GSList * warnings
Definition dfilter-int.h:53
GHashTable * raw_references
Definition dfilter-int.h:56
GSList * set_stack
Definition dfilter-int.h:60
int * interesting_fields
Definition dfilter-int.h:50
df_cell_t * registers
Definition dfilter-int.h:49
GPtrArray * deprecated
Definition dfilter-int.h:52
char * syntax_tree_str
Definition dfilter-int.h:57
Definition proto.h:817
A single node instance in the display filter syntax tree.
Definition syntax-tree.h:115