| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
dfunctions.h
Go to the documentation of this file.
1
9
10#ifndef DFUNCTIONS_H
11#define DFUNCTIONS_H
12
13#include <glib.h>
14#include <epan/ftypes/ftypes.h>
15#include <epan/dfilter/syntax-tree.h>
16#include <epan/dfilter/dfilter-int.h>
17
18#ifdef __cplusplus
19 extern "C" {
20#endif /* __cplusplus */
21
22/* Functions take any number of arguments and return 1. */
23
24#define dfunc_fail(dfw, node, ...) \
25 do { \
26 ws_noisy("Semantic check failed here."); \
27 dfilter_fail_throw(dfw, DF_ERROR_GENERIC, stnode_location(node), __VA_ARGS__); \
28 } while (0)
29
30/* The run-time logic of the dfilter function */
31 typedef bool (*DFFuncType)(GSList *stack, uint32_t arg_count, df_cell_t *retval);
32
33/* The semantic check for the dfilter function */
34 typedef ftenum_t (*DFSemCheckType)(dfwork_t *dfw, const char *func_name, ftenum_t lhs_ftype,
35 GSList *param_list, df_loc_t func_loc);
36
40 typedef struct {
41 const char* name;
42 DFFuncType function;
43 unsigned min_nargs;
44 unsigned max_nargs;
45 ftenum_t return_ftype;
46 DFSemCheckType semcheck_param_function;
47} df_func_def_t;
48
58WS_DLL_PUBLIC
59 ftenum_t
60 df_semcheck_param(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype,
61 stnode_t *param, df_loc_t func_loc);
62
69 void df_func_init(void);
70
79WS_DLL_PUBLIC
80 bool df_func_register(df_func_def_t *func);
81
88WS_DLL_PUBLIC
89 bool df_func_deregister(df_func_def_t *func);
90
97WS_DLL_PUBLIC
98 df_func_def_t* df_func_lookup(const char *name);
99
107WS_DLL_PUBLIC
108GPtrArray *df_func_name_list(void);
109
116 void df_func_cleanup(void);
117
118#ifdef __cplusplus
119}
120#endif /* __cplusplus */
121
122#endif
dfilter-int.h
df_loc_t
struct _dfilter_loc df_loc_t
Represents a location (column start and length) within a display filter string.
df_func_deregister
WS_DLL_PUBLIC bool df_func_deregister(df_func_def_t *func)
Deregisters a display filter function.
Definition dfunctions.c:742
df_func_name_list
WS_DLL_PUBLIC GPtrArray * df_func_name_list(void)
Returns a pointer to an array of registered display filter function names.
Definition dfunctions.c:766
df_semcheck_param
WS_DLL_PUBLIC ftenum_t df_semcheck_param(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype, stnode_t *param, df_loc_t func_loc)
Check semantic correctness of a parameter in a display filter function.
df_func_register
WS_DLL_PUBLIC bool df_func_register(df_func_def_t *func)
Register a display filter function.
Definition dfunctions.c:721
df_func_cleanup
void df_func_cleanup(void)
Cleans up resources used by display filter functions.
Definition dfunctions.c:772
df_func_init
void df_func_init(void)
Initialize the display filter functions.
Definition dfunctions.c:707
df_func_lookup
WS_DLL_PUBLIC df_func_def_t * df_func_lookup(const char *name)
Lookup a display filter function definition record by name.
Definition dfunctions.c:760
ftypes.h
ftenum_t
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
df_cell_t
A container for a pointer array, typically holding field references.
Definition dfilter-int.h:31
df_func_def_t
Defines a display filter function, holding its name, implementation, arity, and type information.
Definition dfunctions.h:40
df_func_def_t::max_nargs
unsigned max_nargs
Definition dfunctions.h:44
df_func_def_t::return_ftype
ftenum_t return_ftype
Definition dfunctions.h:45
df_func_def_t::semcheck_param_function
DFSemCheckType semcheck_param_function
Definition dfunctions.h:46
df_func_def_t::name
const char * name
Definition dfunctions.h:41
df_func_def_t::function
DFFuncType function
Definition dfunctions.h:42
df_func_def_t::min_nargs
unsigned min_nargs
Definition dfunctions.h:43
dfwork_t
State for the second stage of display filter compilation (semantic check and code generation).
Definition dfilter-int.h:90
syntax-tree.h
stnode_t
struct stnode stnode_t
A single node instance in the display filter syntax tree.