| Wireshark 4.7.3 The Wireshark network protocol analyzer

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