3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 2001 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "syntax-tree.h"
16 #include <epan/proto.h>
20 const header_field_info
*hfinfo
;
34 /* Passed back to user */
37 unsigned num_registers
;
39 int *interesting_fields
;
40 int num_interesting_fields
;
41 GPtrArray
*deprecated
;
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
;
59 * State for first stage of compilation (parsing).
62 df_error_t
*error
; /* Must be first struct field. */
65 GPtrArray
*deprecated
;
67 GString
*quoted_string
;
74 * State for second stage of compilation (semantic check and code generation).
77 df_error_t
*error
; /* Must be first struct field. */
82 GHashTable
*loaded_fields
;
83 GHashTable
*loaded_raw_fields
;
84 GHashTable
*interesting_fields
;
87 GPtrArray
*deprecated
;
88 GHashTable
*references
; /* hfinfo -> pointer to array of references */
89 GHashTable
*raw_references
; /* hfinfo -> pointer to array of references */
91 wmem_allocator_t
*dfw_scope
; /* Because we use exceptions for error handling sometimes
92 cleaning up memory allocations is inconvenient. Memory
93 allocated from this pool will be freed when the dfwork_t
94 context is destroyed. */
99 /* Constructor/Destructor prototypes for Lemon Parser */
100 void *DfilterAlloc(void *(*)(size_t));
102 void DfilterFree(void *, void (*)(void *));
104 void Dfilter(void *, int, stnode_t
*, dfsyntax_t
*);
106 /* Return value for error in scanner. */
107 #define SCAN_FAILED -1 /* not 0, as that means end-of-input */
111 dfilter_vfail(void *state
, int code
, df_loc_t err_loc
,
112 const char *format
, va_list args
);
116 dfilter_fail(void *state
, int code
, df_loc_t err_loc
,
117 const char *format
, ...) G_GNUC_PRINTF(4, 5);
119 WS_DLL_PUBLIC WS_NORETURN
121 dfilter_fail_throw(void *state
, int code
, df_loc_t err_loc
,
122 const char *format
, ...) G_GNUC_PRINTF(4, 5);
125 dfw_set_error_location(dfwork_t
*dfw
, df_loc_t err_loc
);
128 add_deprecated_token(GPtrArray
*deprecated
, const char *token
);
131 add_compile_warning(dfwork_t
*dfw
, const char *format
, ...);
134 free_deprecated(GPtrArray
*deprecated
);
137 DfilterTrace(FILE *TraceFILE
, char *zTracePrompt
);
140 dfilter_resolve_unparsed(const char *name
, GPtrArray
*deprecated
);
142 /* Returns true if the create syntax node has a (value) string type. */
144 dfilter_fvalue_from_literal(dfwork_t
*dfw
, ftenum_t ftype
, stnode_t
*st
,
145 bool allow_partial_value
, header_field_info
*hfinfo_value_string
);
147 /* Returns true if the create syntax node has a (value) string type. */
149 dfilter_fvalue_from_string(dfwork_t
*dfw
, ftenum_t ftype
, stnode_t
*st
,
150 header_field_info
*hfinfo_value_string
);
153 dfilter_fvalue_from_charconst(dfwork_t
*dfw
, ftenum_t ftype
, stnode_t
*st
);
156 dfilter_fvalue_from_number(dfwork_t
*dfw
, ftenum_t ftype
, stnode_t
*st
);
158 const char *tokenstr(int token
);
161 reference_new(const field_info
*finfo
, bool raw
);
164 reference_free(df_reference_t
*ref
);
168 df_cell_append(df_cell_t
*rp
, fvalue_t
*fv
);
172 df_cell_ref(df_cell_t
*rp
);
174 #define df_cell_ptr(rp) ((rp)->array)
178 df_cell_size(const df_cell_t
*rp
);
182 df_cell_array(const df_cell_t
*rp
);
186 df_cell_is_empty(const df_cell_t
*rp
);
190 df_cell_is_null(const df_cell_t
*rp
);
192 /* Pass true to free the array contents when the cell is cleared. */
195 df_cell_init(df_cell_t
*rp
, bool free_seg
);
199 df_cell_clear(df_cell_t
*rp
);
201 /* Cell must not be cleared while iter is alive. */
204 df_cell_iter_init(df_cell_t
*rp
, df_cell_iter_t
*iter
);
208 df_cell_iter_next(df_cell_iter_t
*iter
);