Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dfilter / dfilter-int.h
blob1430fbfe2526ff6f17383adb0863b0551257a9b6
1 /** @file
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
8 */
10 #ifndef DFILTER_INT_H
11 #define DFILTER_INT_H
13 #include "dfilter.h"
14 #include "syntax-tree.h"
16 #include <epan/proto.h>
17 #include <stdio.h>
19 typedef struct {
20 const header_field_info *hfinfo;
21 fvalue_t *value;
22 int proto_layer_num;
23 } df_reference_t;
25 typedef struct {
26 GPtrArray *array;
27 } df_cell_t;
29 typedef struct {
30 GPtrArray *ptr;
31 unsigned idx;
32 } df_cell_iter_t;
34 /* Passed back to user */
35 struct epan_dfilter {
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;
53 typedef struct {
54 df_error_t *error;
55 /* more fields. */
56 } dfstate_t;
59 * State for first stage of compilation (parsing).
61 typedef 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;
71 } dfsyntax_t;
74 * State for second stage of compilation (semantic check and code generation).
76 typedef 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 *interesting_fields;
85 int next_insn_id;
86 int next_register;
87 GPtrArray *deprecated;
88 GHashTable *references; /* hfinfo -> pointer to array of references */
89 GHashTable *raw_references; /* hfinfo -> pointer to array of references */
90 char *expanded_text;
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. */
95 GSList *warnings;
96 ftenum_t ret_type;
97 } dfwork_t;
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 */
109 WS_DLL_PUBLIC
110 void
111 dfilter_vfail(void *state, int code, df_loc_t err_loc,
112 const char *format, va_list args);
114 WS_DLL_PUBLIC
115 void
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
120 void
121 dfilter_fail_throw(void *state, int code, df_loc_t err_loc,
122 const char *format, ...) G_GNUC_PRINTF(4, 5);
124 void
125 dfw_set_error_location(dfwork_t *dfw, df_loc_t err_loc);
127 void
128 add_deprecated_token(GPtrArray *deprecated, const char *token);
130 void
131 add_compile_warning(dfwork_t *dfw, const char *format, ...);
133 void
134 free_deprecated(GPtrArray *deprecated);
136 void
137 DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
139 header_field_info *
140 dfilter_resolve_unparsed(const char *name, GPtrArray *deprecated);
142 /* Returns true if the create syntax node has a (value) string type. */
143 bool
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. */
148 bool
149 dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
150 header_field_info *hfinfo_value_string);
152 void
153 dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
155 void
156 dfilter_fvalue_from_number(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
158 const char *tokenstr(int token);
160 df_reference_t *
161 reference_new(const field_info *finfo, bool raw);
163 void
164 reference_free(df_reference_t *ref);
166 WS_DLL_PUBLIC
167 void
168 df_cell_append(df_cell_t *rp, fvalue_t *fv);
170 WS_DLL_PUBLIC
171 GPtrArray *
172 df_cell_ref(df_cell_t *rp);
174 #define df_cell_ptr(rp) ((rp)->array)
176 WS_DLL_PUBLIC
177 size_t
178 df_cell_size(const df_cell_t *rp);
180 WS_DLL_PUBLIC
181 fvalue_t **
182 df_cell_array(const df_cell_t *rp);
184 WS_DLL_PUBLIC
185 bool
186 df_cell_is_empty(const df_cell_t *rp);
188 WS_DLL_PUBLIC
189 bool
190 df_cell_is_null(const df_cell_t *rp);
192 /* Pass true to free the array contents when the cell is cleared. */
193 WS_DLL_PUBLIC
194 void
195 df_cell_init(df_cell_t *rp, bool free_seg);
197 WS_DLL_PUBLIC
198 void
199 df_cell_clear(df_cell_t *rp);
201 /* Cell must not be cleared while iter is alive. */
202 WS_DLL_PUBLIC
203 void
204 df_cell_iter_init(df_cell_t *rp, df_cell_iter_t *iter);
206 WS_DLL_PUBLIC
207 fvalue_t *
208 df_cell_iter_next(df_cell_iter_t *iter);
211 #endif