Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
prefs-int.h
Go to the documentation of this file.
1/* prefs-int.h
2 * Definitions for implementation of preference handling routines;
3 * used by "friends" of the preferences type.
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12#ifndef __PREFS_INT_H__
13#define __PREFS_INT_H__
14
15#include <stdio.h>
16#include "ws_symbol_export.h"
17#include <epan/wmem_scopes.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
28 const char *name;
29 const char *title;
30 const char *description;
31 const char *help;
32 void (*apply_cb)(void);
33 GList *prefs;
37 unsigned int prefs_changed_flags;
38 bool obsolete;
41 bool use_gui;
48 unsigned int effect_flags;
51};
52
53typedef struct {
54 module_t *module;
55 FILE *pf;
57
63
64typedef void (*pref_custom_free_cb) (pref_t* pref);
65typedef void (*pref_custom_reset_cb) (pref_t* pref);
66typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const char* value, unsigned int* changed_flags);
67/* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
68/* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
69typedef const char * (*pref_custom_type_name_cb) (void);
70typedef char * (*pref_custom_type_description_cb) (void);
71typedef bool (*pref_custom_is_default_cb) (pref_t* pref);
72typedef char * (*pref_custom_to_str_cb) (pref_t* pref, bool default_val);
73
76 pref_custom_free_cb free_cb;
77 pref_custom_reset_cb reset_cb;
78 pref_custom_set_cb set_cb;
79 /* pref_custom_write_cb write_cb; Deprecated. */
80 pref_custom_type_name_cb type_name_cb;
81 pref_custom_type_description_cb type_description_cb;
82 pref_custom_is_default_cb is_default_cb;
83 pref_custom_to_str_cb to_str_cb;
84};
85
86typedef enum {
87 PREF_UINT,
88 PREF_BOOL,
89 PREF_ENUM,
90 PREF_STRING,
91 PREF_RANGE,
92 PREF_STATIC_TEXT,
93 PREF_UAT,
94 PREF_SAVE_FILENAME,
95 PREF_COLOR, // (1)
96 PREF_CUSTOM, // (1)
97 PREF_DIRNAME,
98 PREF_DECODE_AS_RANGE, // (2)
99 PREF_OPEN_FILENAME,
100 PREF_PASSWORD, // (3)
101 PREF_PROTO_TCP_SNDAMB_ENUM, // (4)
102 PREF_DISSECTOR // (5)
103} pref_type_e;
104
105/*
106 * (1) These are only supported for "internal" (non-protocol) use
107 * and not as a generic protocol preference.
108 * (2) Internal use only, not a generic protocol preference.
109 * (3) Like string, but never saved to prefs file.
110 * (4) Dedicated to TCP PROTOCOL for handling manual SEQ interpretation,
111 * and allow users manage the sender traffic ambiguities
112 * (5) Like string, but with dissector name syntax check.
113 */
114
115/* read_prefs_file: read in a generic config file and do a callback to */
116/* pref_set_pair_fct() for every key/value pair found */
124typedef prefs_set_pref_e (*pref_set_pair_cb) (char *key, const char *value, void *private_data, bool return_range_errors);
125
126WS_DLL_PUBLIC
127const char* prefs_get_description(pref_t *pref);
128
129WS_DLL_PUBLIC
130const char* prefs_get_title(pref_t *pref);
131
132WS_DLL_PUBLIC
133const char* prefs_get_name(pref_t *pref);
134
135WS_DLL_PUBLIC
136int prefs_get_type(pref_t *pref);
137
138WS_DLL_PUBLIC uint32_t prefs_get_max_value(pref_t *pref);
139
140/* Bitmask of flags for the effect of a preference in Wireshark */
141#define PREF_EFFECT_DISSECTION (1u << 0)
142#define PREF_EFFECT_CAPTURE (1u << 1)
143#define PREF_EFFECT_GUI_LAYOUT (1u << 2)
144#define PREF_EFFECT_FIELDS (1u << 3)
145#define PREF_EFFECT_GUI (1u << 4)
146#define PREF_EFFECT_GUI_COLOR (1u << 5)
147
155WS_DLL_PUBLIC
156unsigned int prefs_get_effect_flags(pref_t *pref);
157
169WS_DLL_PUBLIC
170void prefs_set_effect_flags(pref_t *pref, unsigned int flags);
171
174WS_DLL_PUBLIC
175void prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags);
176
186WS_DLL_PUBLIC
187unsigned int prefs_get_module_effect_flags(module_t * module);
188
202WS_DLL_PUBLIC
203void prefs_set_module_effect_flags(module_t * module, unsigned int flags);
204
205WS_DLL_PUBLIC
206bool prefs_set_range_value_work(pref_t *pref, const char *value,
207 bool return_range_errors, unsigned int *changed_flags);
208
209WS_DLL_PUBLIC
210unsigned int
211prefs_set_stashed_range_value(pref_t *pref, const char *value);
212
214WS_DLL_PUBLIC
215void
216prefs_range_add_value(pref_t *pref, uint32_t val);
217
219WS_DLL_PUBLIC
220void
221prefs_range_remove_value(pref_t *pref, uint32_t val);
222
223
224WS_DLL_PUBLIC unsigned int prefs_set_bool_value(pref_t *pref, bool value, pref_source_t source);
225WS_DLL_PUBLIC bool prefs_get_bool_value(pref_t *pref, pref_source_t source);
226WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
227
228WS_DLL_PUBLIC unsigned int prefs_set_uint_value(pref_t *pref, unsigned value, pref_source_t source);
229WS_DLL_PUBLIC unsigned prefs_get_uint_base(pref_t *pref);
230WS_DLL_PUBLIC unsigned prefs_get_uint_value(pref_t *pref, pref_source_t source);
231
232
233WS_DLL_PUBLIC unsigned int prefs_set_enum_value(pref_t *pref, int value, pref_source_t source);
234WS_DLL_PUBLIC unsigned int prefs_set_enum_string_value(pref_t *pref, const char *value, pref_source_t source);
235WS_DLL_PUBLIC int prefs_get_enum_value(pref_t *pref, pref_source_t source);
236WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
237WS_DLL_PUBLIC bool prefs_get_enum_radiobuttons(pref_t *pref);
238
239WS_DLL_PUBLIC bool prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
240WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
241
242WS_DLL_PUBLIC unsigned int prefs_set_custom_value(pref_t *pref, const char *value, pref_source_t source);
243
244WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
245WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);
246
247WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);
248
249WS_DLL_PUBLIC bool prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source);
250WS_DLL_PUBLIC range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source);
251
252WS_DLL_PUBLIC bool prefs_add_decode_as_value(pref_t *pref, unsigned value, bool replace);
253WS_DLL_PUBLIC bool prefs_remove_decode_as_value(pref_t *pref, unsigned value, bool set_default);
254
255WS_DLL_PUBLIC unsigned int prefs_set_password_value(pref_t *pref, const char* value, pref_source_t source);
256WS_DLL_PUBLIC char* prefs_get_password_value(pref_t *pref, pref_source_t source);
257
258WS_DLL_PUBLIC bool prefs_add_list_value(pref_t *pref, void *value, pref_source_t source);
259WS_DLL_PUBLIC GList* prefs_get_list_value(pref_t *pref, pref_source_t source);
260
261WS_DLL_PUBLIC void reset_pref(pref_t *pref);
262
266WS_DLL_PUBLIC
267int
268read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
269
276WS_DLL_PUBLIC
277void
278prefs_read_module(const char *name);
279
280WS_DLL_PUBLIC
281bool
282prefs_pref_is_default(pref_t *pref);
283
290WS_DLL_PUBLIC
291unsigned pref_stash(pref_t *pref, void *unused);
292
293typedef struct pref_unstash_data
294{
295 /* Used to set prefs_changed member to true if the preference
296 differs from its stashed values. */
297 module_t *module;
298 /* Qt uses stashed values to then "applies" them
299 during unstash. Use this flag for that behavior */
300 bool handle_decode_as;
302
311WS_DLL_PUBLIC
312unsigned pref_unstash(pref_t *pref, void *unstash_data_p);
313
322WS_DLL_PUBLIC
323unsigned pref_clean_stash(pref_t *pref, void *unused);
324
329WS_DLL_PUBLIC
330void reset_stashed_pref(pref_t *pref);
331
341WS_DLL_PUBLIC
342char *
343join_string_list(GList *sl);
344
345#ifdef __cplusplus
346}
347#endif /* __cplusplus */
348
349#endif /* prefs-int.h */
WS_DLL_PUBLIC void prefs_set_effect_flags(pref_t *pref, unsigned int flags)
Definition prefs.c:6611
WS_DLL_PUBLIC void prefs_set_effect_flags_by_name(module_t *module, const char *pref, unsigned int flags)
Definition prefs.c:6622
WS_DLL_PUBLIC unsigned pref_unstash(pref_t *pref, void *unstash_data_p)
Definition prefs.c:2127
WS_DLL_PUBLIC char * join_string_list(GList *sl)
Definition prefs.c:4153
WS_DLL_PUBLIC module_t * protocols_module
Definition prefs-int.h:62
prefs_set_pref_e(* pref_set_pair_cb)(char *key, const char *value, void *private_data, bool return_range_errors)
Definition prefs-int.h:124
WS_DLL_PUBLIC void prefs_set_module_effect_flags(module_t *module, unsigned int flags)
Definition prefs.c:6637
WS_DLL_PUBLIC unsigned int prefs_get_module_effect_flags(module_t *module)
Definition prefs.c:6628
WS_DLL_PUBLIC void prefs_range_remove_value(pref_t *pref, uint32_t val)
Definition prefs.c:1793
WS_DLL_PUBLIC void prefs_read_module(const char *name)
Definition prefs.c:4680
WS_DLL_PUBLIC unsigned pref_stash(pref_t *pref, void *unused)
WS_DLL_PUBLIC int read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data)
Definition prefs.c:4846
WS_DLL_PUBLIC void reset_stashed_pref(pref_t *pref)
Definition prefs.c:2277
WS_DLL_PUBLIC void prefs_range_add_value(pref_t *pref, uint32_t val)
Definition prefs.c:1787
WS_DLL_PUBLIC unsigned int prefs_get_effect_flags(pref_t *pref)
Definition prefs.c:6602
WS_DLL_PUBLIC unsigned pref_clean_stash(pref_t *pref, void *unused)
prefs_set_pref_e
Definition prefs.h:976
Definition wmem_tree-int.h:48
Definition color.h:23
Definition params.h:23
Definition range.h:41
Definition uat-int.h:40
Definition prefs-int.h:75
Definition prefs-int.h:27
unsigned int effect_flags
Definition prefs-int.h:48
GList * prefs
Definition prefs-int.h:33
bool use_gui
Definition prefs-int.h:41
wmem_tree_t * submodules
Definition prefs-int.h:35
const char * description
Definition prefs-int.h:30
const char * name
Definition prefs-int.h:28
bool obsolete
Definition prefs-int.h:38
struct pref_module * parent
Definition prefs-int.h:34
unsigned int prefs_changed_flags
Definition prefs-int.h:37
void(* apply_cb)(void)
Definition prefs-int.h:32
int numprefs
Definition prefs-int.h:36
const char * title
Definition prefs-int.h:29
const char * help
Definition prefs-int.h:31
Definition prefs-int.h:294
Definition prefs.c:217
Definition prefs-int.h:53