Wireshark  4.3.0
The Wireshark network protocol analyzer
prefs.h
Go to the documentation of this file.
1 
11 #ifndef __PREFS_H__
12 #define __PREFS_H__
13 
14 #include <glib.h>
15 
16 #include <epan/params.h>
17 #include <epan/range.h>
18 
19 #include <wsutil/color.h>
20 
21 #include "ws_symbol_export.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 #define DEF_WIDTH 750
28 #define DEF_HEIGHT 550
29 
30 #define MAX_VAL_LEN 1024
31 
32 #define TAP_UPDATE_DEFAULT_INTERVAL 3000
33 #define ST_DEF_BURSTRES 5
34 #define ST_DEF_BURSTLEN 100
35 #define ST_MAX_BURSTRES 600000 /* somewhat arbirary limit of 10 minutes */
36 #define ST_MAX_BURSTBUCKETS 100 /* somewhat arbirary limit - more buckets degrade performance */
37 #define DEF_GUI_DECIMAL_PLACES1 2
38 #define DEF_GUI_DECIMAL_PLACES2 4
39 #define DEF_GUI_DECIMAL_PLACES3 6
40 
41 struct epan_uat;
42 struct _e_addr_resolve;
43 
55 WS_DLL_PUBLIC
56 char string_to_name_resolve(const char *string, struct _e_addr_resolve *name_resolve);
57 
58 /*
59  * Modes for the starting directory in File Open dialogs.
60  */
61 #define FO_STYLE_LAST_OPENED 0 /* start in last directory we looked at */
62 #define FO_STYLE_SPECIFIED 1 /* start in specified directory */
63 
64 /*
65  * Toolbar styles.
66  */
67 #define TB_STYLE_ICONS 0
68 #define TB_STYLE_TEXT 1
69 #define TB_STYLE_BOTH 2
70 
71 /*
72  * Color styles.
73  */
74 #define COLOR_STYLE_DEFAULT 0
75 #define COLOR_STYLE_FLAT 1
76 #define COLOR_STYLE_GRADIENT 2
77 
78 #define COLOR_STYLE_ALPHA 0.25
79 
80 /*
81  * Types of layout of summary/details/hex panes.
82  */
83 typedef enum {
84  layout_unused, /* entry currently unused */
85  layout_type_5,
86  layout_type_2,
87  layout_type_1,
88  layout_type_4,
89  layout_type_3,
90  layout_type_6,
91  layout_type_max
92 } layout_type_e;
93 
94 /*
95  * Types of pane.
96  */
97 typedef enum {
98  layout_pane_content_none,
99  layout_pane_content_plist,
100  layout_pane_content_pdetails,
101  layout_pane_content_pbytes,
102  layout_pane_content_pdiagram,
103 } layout_pane_content_e;
104 
105 /*
106  * Places version information will show up
107  */
108 typedef enum {
109  version_welcome_only,
110  version_title_only,
111  version_both,
112  version_neither
113 } version_info_e;
114 
115 typedef enum {
116  pref_default,
117  pref_stashed,
118  pref_current
119 } pref_source_t;
120 
121 typedef enum {
122  ELIDE_LEFT,
123  ELIDE_RIGHT,
124  ELIDE_MIDDLE,
125  ELIDE_NONE
126 } elide_mode_e;
127 
128 
129 /*
130  * Update channel.
131  */
132 typedef enum {
133  UPDATE_CHANNEL_DEVELOPMENT,
134  UPDATE_CHANNEL_STABLE
135 } software_update_channel_e;
136 
137 typedef struct _e_prefs {
138  GList *col_list;
139  gint num_cols;
140  color_t st_client_fg, st_client_bg, st_server_fg, st_server_bg;
141  color_t gui_text_valid, gui_text_invalid, gui_text_deprecated;
142  gboolean restore_filter_after_following_stream;
143  gint gui_toolbar_main_style;
144  gchar *gui_font_name;
145  color_t gui_active_fg;
146  color_t gui_active_bg;
147  gint gui_active_style;
148  gchar *gui_browser_sslkeylog_path;
149  color_t gui_inactive_fg;
150  color_t gui_inactive_bg;
151  gint gui_inactive_style;
152  color_t gui_marked_fg;
153  color_t gui_marked_bg;
154  color_t gui_ignored_fg;
155  color_t gui_ignored_bg;
156  gchar *gui_colorized_fg;
157  gchar *gui_colorized_bg;
158  gboolean gui_geometry_save_position;
159  gboolean gui_geometry_save_size;
160  gboolean gui_geometry_save_maximized;
161  guint gui_recent_df_entries_max;
162  guint gui_recent_files_count_max;
163  guint gui_fileopen_style;
164  gchar *gui_fileopen_dir;
165  guint gui_fileopen_preview;
166  gboolean gui_ask_unsaved;
167  gboolean gui_autocomplete_filter;
168  gboolean gui_find_wrap;
169  gchar *gui_window_title;
170  gchar *gui_prepend_window_title;
171  gchar *gui_start_title;
172  version_info_e gui_version_placement;
173  guint gui_max_export_objects;
174  guint gui_max_tree_items;
175  guint gui_max_tree_depth;
176  layout_type_e gui_layout_type;
177  layout_pane_content_e gui_layout_content_1;
178  layout_pane_content_e gui_layout_content_2;
179  layout_pane_content_e gui_layout_content_3;
180  gchar *gui_interfaces_hide_types;
181  gboolean gui_interfaces_show_hidden;
182  gboolean gui_interfaces_remote_display;
183  gboolean gui_io_graph_automatic_update;
184  gboolean gui_io_graph_enable_legend;
185  gboolean gui_packet_details_show_byteview;
186  gchar *capture_device;
187  gchar *capture_devices_linktypes;
188  gchar *capture_devices_descr;
189  gchar *capture_devices_hide;
190  gchar *capture_devices_monitor_mode;
191  gchar *capture_devices_buffersize;
192  gchar *capture_devices_snaplen;
193  gchar *capture_devices_pmode;
194  gchar *capture_devices_filter; /* XXX - Mostly unused. Deprecate? */
195  gboolean capture_prom_mode;
196  gboolean capture_pcap_ng;
197  gboolean capture_real_time;
198  guint capture_update_interval;
199  gboolean capture_no_interface_load;
200  gboolean capture_no_extcap;
201  gboolean capture_show_info;
202  GList *capture_columns;
203  guint tap_update_interval;
204  gboolean display_hidden_proto_items;
205  gboolean display_byte_fields_with_spaces;
206  gboolean enable_incomplete_dissectors_check;
207  gboolean incomplete_dissectors_check_debug;
208  gboolean strict_conversation_tracking_heuristics;
209  gboolean ignore_dup_frames;
210  guint ignore_dup_frames_cache_entries;
211  gboolean filter_expressions_old; /* TRUE if old filter expressions preferences were loaded. */
212  gboolean gui_update_enabled;
213  software_update_channel_e gui_update_channel;
214  gint gui_update_interval;
215  gint gui_debounce_timer;
216  gchar *saved_at_version;
217  gboolean unknown_prefs; /* unknown or obsolete pref(s) */
218  gboolean gui_packet_list_separator;
219  gboolean gui_packet_header_column_definition;
220  gboolean gui_packet_list_hover_style; /* Enable/Disable mouse-over colorization */
221  gboolean gui_show_selected_packet;
222  gboolean gui_show_file_load_time;
223  elide_mode_e gui_packet_list_elide_mode;
224  gboolean gui_packet_list_show_related;
225  gboolean gui_packet_list_show_minimap;
226  gboolean gui_packet_list_sortable;
227  guint gui_packet_list_cached_rows_max;
228  gint gui_decimal_places1; /* Used for type 1 calculations */
229  gint gui_decimal_places2; /* Used for type 2 calculations */
230  gint gui_decimal_places3; /* Used for type 3 calculations */
231  gboolean gui_rtp_player_use_disk1;
232  gboolean gui_rtp_player_use_disk2;
233  gboolean st_enable_burstinfo;
234  gboolean st_burst_showcount;
235  gint st_burst_resolution;
236  gint st_burst_windowlen;
237  gboolean st_sort_casesensitve;
238  gboolean st_sort_rng_fixorder;
239  gboolean st_sort_rng_nameonly;
240  gint st_sort_defcolflag;
241  gboolean st_sort_defdescending;
242  gboolean st_sort_showfullname;
243  gboolean extcap_save_on_start;
244 } e_prefs;
245 
246 WS_DLL_PUBLIC e_prefs prefs;
247 
248 /*
249  * Routines to let modules that have preference settings register
250  * themselves by name, and to let them register preference settings
251  * by name.
252  */
253 struct pref_module;
254 
255 struct pref_custom_cbs;
256 
257 typedef struct pref_module module_t;
258 
260 void prefs_init(void);
261 
263 WS_DLL_PUBLIC void prefs_reset(void);
264 
266 void prefs_cleanup(void);
267 
271 WS_DLL_PUBLIC void prefs_set_gui_theme_is_dark(gboolean is_dark);
272 
281 WS_DLL_PUBLIC module_t *prefs_register_protocol(int id, void (*apply_cb)(void));
282 
289 WS_DLL_PUBLIC void prefs_register_module_alias(const char *name, module_t *module);
290 
296 void prefs_deregister_protocol(int id);
297 
308 WS_DLL_PUBLIC module_t *prefs_register_stat(const char *name, const char *title,
309  const char *description, void (*apply_cb)(void));
310 
321 WS_DLL_PUBLIC module_t *prefs_register_codec(const char *name, const char *title,
322  const char *description, void (*apply_cb)(void));
323 
335 WS_DLL_PUBLIC module_t *prefs_register_protocol_subtree(const char *subtree, int id,
336  void (*apply_cb)(void));
337 
345 WS_DLL_PUBLIC module_t *prefs_register_protocol_obsolete(int id);
346 
350 typedef guint (*module_cb)(module_t *module, gpointer user_data);
351 
357 WS_DLL_PUBLIC gboolean prefs_module_has_submodules(module_t *module);
358 
370 WS_DLL_PUBLIC guint prefs_modules_foreach(module_cb callback, gpointer user_data);
371 
387 WS_DLL_PUBLIC guint prefs_modules_foreach_submodules(module_t *module, module_cb callback, gpointer user_data);
388 
395 WS_DLL_PUBLIC void prefs_apply_all(void);
396 
404 WS_DLL_PUBLIC void prefs_apply(module_t *module);
405 
406 
407 struct preference;
408 
409 typedef struct preference pref_t;
410 
416 WS_DLL_PUBLIC gboolean prefs_is_registered_protocol(const char *name);
417 
423 WS_DLL_PUBLIC const char *prefs_get_title_by_name(const char *name);
424 
433 WS_DLL_PUBLIC module_t *prefs_find_module(const char *name);
434 
444 WS_DLL_PUBLIC pref_t *prefs_find_preference(module_t * module, const char *pref);
445 
463 WS_DLL_PUBLIC void prefs_register_uint_preference(module_t *module, const char *name,
464  const char *title, const char *description, guint base, guint *var);
465 
466 /*
467  * prefs_register_ callers must conform to the following:
468  *
469  * Names must be in lowercase letters only (underscore allowed).
470  * Titles and descriptions must be valid UTF-8 or NULL.
471  * Titles must be short (less than 80 characters)
472  * Titles must not contain newlines.
473  */
474 
491 WS_DLL_PUBLIC void prefs_register_bool_preference(module_t *module, const char *name,
492  const char *title, const char *description, gboolean *var);
493 
514 WS_DLL_PUBLIC void prefs_register_enum_preference(module_t *module, const char *name,
515  const char *title, const char *description, gint *var,
516  const enum_val_t *enumvals, gboolean radio_buttons);
517 
539 WS_DLL_PUBLIC void prefs_register_string_preference(module_t *module, const char *name,
540  const char *title, const char *description, const char **var);
541 
569 WS_DLL_PUBLIC void prefs_register_filename_preference(module_t *module, const char *name,
570  const char *title, const char *description, const char **var, gboolean for_writing);
571 
596 WS_DLL_PUBLIC void prefs_register_directory_preference(module_t *module, const char *name,
597  const char *title, const char *description, const char **var);
598 
616 WS_DLL_PUBLIC void prefs_register_range_preference(module_t *module, const char *name,
617  const char *title, const char *description, range_t **var,
618  guint32 max_value);
619 
634 WS_DLL_PUBLIC void prefs_register_static_text_preference(module_t *module, const char *name,
635  const char *title, const char *description);
636 
654 WS_DLL_PUBLIC void prefs_register_uat_preference(module_t *module,
655  const char *name, const char* title, const char *description, struct epan_uat* uat);
656 
674 WS_DLL_PUBLIC void prefs_register_uat_preference_qt(module_t *module,
675  const char *name, const char* title, const char *description, struct epan_uat* uat);
676 
677 
698 void prefs_register_color_preference(module_t *module, const char *name,
699  const char *title, const char *description, color_t *color);
700 
722  const char *title, const char *description, struct pref_custom_cbs* custom_cbs,
723  void** custom_data);
724 
743  const char *title, const char *description, range_t **var,
744  guint32 max_value);
745 
762 WS_DLL_PUBLIC void prefs_register_password_preference(module_t *module, const char *name,
763  const char *title, const char *description, const char **var);
764 
781 WS_DLL_PUBLIC void prefs_register_obsolete_preference(module_t *module,
782  const char *name);
783 
804 WS_DLL_PUBLIC void prefs_register_custom_preference_TCP_Analysis(module_t *module, const char *name,
805  const char *title, const char *description, gint *var,
806  const enum_val_t *enumvals, gboolean radio_buttons);
807 
822 WS_DLL_PUBLIC void prefs_set_preference_effect_fields(module_t *module,
823  const char *name);
824 
825 
826 typedef guint (*pref_cb)(pref_t *pref, gpointer user_data);
827 
842 WS_DLL_PUBLIC guint prefs_pref_foreach(module_t *module, pref_cb callback,
843  gpointer user_data);
844 
855 WS_DLL_PUBLIC GList *prefs_get_string_list(const gchar *str);
856 
861 WS_DLL_PUBLIC void prefs_clear_string_list(GList *sl);
862 
869 WS_DLL_PUBLIC
870 const char *prefs_pref_type_name(pref_t *pref);
871 
880 WS_DLL_PUBLIC
882 
890 WS_DLL_PUBLIC
891 char *prefs_pref_to_str(pref_t *pref, pref_source_t source);
892 
903 extern e_prefs *read_prefs(void);
904 
914 WS_DLL_PUBLIC int write_prefs(char **pf_path_return);
915 
919 typedef enum {
920  PREFS_SET_OK, /* succeeded */
921  PREFS_SET_SYNTAX_ERR, /* syntax error in string */
922  PREFS_SET_NO_SUCH_PREF, /* no such preference */
923  PREFS_SET_OBSOLETE /* preference used to exist but no longer does */
925 
939 WS_DLL_PUBLIC prefs_set_pref_e prefs_set_pref(char *prefarg, char **errmsg);
940 
949 gboolean prefs_get_preference_obsolete(pref_t *pref);
950 
958 
968 WS_DLL_PUBLIC guint prefs_get_uint_value(const char *module_name, const char* pref_name);
969 
979 WS_DLL_PUBLIC range_t* prefs_get_range_value(const char *module_name, const char* pref_name);
980 
986 WS_DLL_PUBLIC gboolean prefs_is_capture_device_hidden(const char *name);
987 
993 WS_DLL_PUBLIC gboolean prefs_capture_device_monitor_mode(const char *name);
994 
1001 WS_DLL_PUBLIC gboolean prefs_capture_options_dialog_column_is_visible(const gchar *column);
1002 
1009 WS_DLL_PUBLIC gboolean prefs_has_layout_pane_content (layout_pane_content_e layout_pane_content);
1010 
1011 #ifdef __cplusplus
1012 }
1013 #endif /* __cplusplus */
1014 
1015 #endif /* prefs.h */
1016 
1017 /*
1018  * Editor modelines - https://www.wireshark.org/tools/modelines.html
1019  *
1020  * Local variables:
1021  * c-basic-offset: 4
1022  * tab-width: 8
1023  * indent-tabs-mode: nil
1024  * End:
1025  *
1026  * vi: set shiftwidth=4 tabstop=8 expandtab:
1027  * :indentSize=4:tabSize=8:noTabs=true:
1028  */
void prefs_init(void)
Definition: prefs.c:293
WS_DLL_PUBLIC prefs_set_pref_e prefs_set_pref(char *prefarg, char **errmsg)
Definition: prefs.c:4758
WS_DLL_PUBLIC void prefs_register_uat_preference(module_t *module, const char *name, const char *title, const char *description, struct epan_uat *uat)
Definition: prefs.c:1741
WS_DLL_PUBLIC gboolean prefs_has_layout_pane_content(layout_pane_content_e layout_pane_content)
Definition: prefs.c:5033
WS_DLL_PUBLIC void prefs_clear_string_list(GList *sl)
Definition: prefs.c:3933
void prefs_register_color_preference(module_t *module, const char *name, const char *title, const char *description, color_t *color)
Definition: prefs.c:1775
WS_DLL_PUBLIC void prefs_register_directory_preference(module_t *module, const char *name, const char *title, const char *description, const char **var)
Definition: prefs.c:1559
prefs_set_pref_e prefs_set_preference_obsolete(pref_t *pref)
Definition: prefs.c:2014
WS_DLL_PUBLIC void prefs_register_obsolete_preference(module_t *module, const char *name)
Definition: prefs.c:1984
WS_DLL_PUBLIC void prefs_register_enum_preference(module_t *module, const char *name, const char *title, const char *description, gint *var, const enum_val_t *enumvals, gboolean radio_buttons)
Definition: prefs.c:1301
WS_DLL_PUBLIC guint prefs_modules_foreach_submodules(module_t *module, module_cb callback, gpointer user_data)
Definition: prefs.c:901
WS_DLL_PUBLIC GList * prefs_get_string_list(const gchar *str)
Definition: prefs.c:3804
WS_DLL_PUBLIC void prefs_apply_all(void)
Definition: prefs.c:931
WS_DLL_PUBLIC void prefs_register_string_preference(module_t *module, const char *name, const char *title, const char *description, const char **var)
Definition: prefs.c:1531
WS_DLL_PUBLIC guint prefs_modules_foreach(module_cb callback, gpointer user_data)
Definition: prefs.c:885
WS_DLL_PUBLIC gboolean prefs_is_registered_protocol(const char *name)
Definition: prefs.c:1144
WS_DLL_PUBLIC void prefs_set_gui_theme_is_dark(gboolean is_dark)
Definition: prefs.c:397
WS_DLL_PUBLIC char * prefs_pref_to_str(pref_t *pref, pref_source_t source)
Definition: prefs.c:6490
WS_DLL_PUBLIC void prefs_register_static_text_preference(module_t *module, const char *name, const char *title, const char *description)
Definition: prefs.c:1729
WS_DLL_PUBLIC char * prefs_pref_type_description(pref_t *pref)
Definition: prefs.c:6303
WS_DLL_PUBLIC void prefs_set_preference_effect_fields(module_t *module, const char *name)
Definition: prefs.c:1990
guint(* module_cb)(module_t *module, gpointer user_data)
Definition: prefs.h:350
WS_DLL_PUBLIC module_t * prefs_register_protocol(int id, void(*apply_cb)(void))
Definition: prefs.c:605
gboolean prefs_get_preference_obsolete(pref_t *pref)
Definition: prefs.c:2002
WS_DLL_PUBLIC void prefs_register_uat_preference_qt(module_t *module, const char *name, const char *title, const char *description, struct epan_uat *uat)
Definition: prefs.c:1756
void prefs_deregister_protocol(int id)
Definition: prefs.c:630
WS_DLL_PUBLIC void prefs_register_custom_preference_TCP_Analysis(module_t *module, const char *name, const char *title, const char *description, gint *var, const enum_val_t *enumvals, gboolean radio_buttons)
Definition: prefs.c:1887
WS_DLL_PUBLIC void prefs_register_module_alias(const char *name, module_t *module)
Definition: prefs.c:555
WS_DLL_PUBLIC void prefs_register_range_preference(module_t *module, const char *name, const char *title, const char *description, range_t **var, guint32 max_value)
Definition: prefs.c:1599
prefs_set_pref_e
Definition: prefs.h:919
e_prefs * read_prefs(void)
Definition: prefs.c:4402
WS_DLL_PUBLIC guint prefs_pref_foreach(module_t *module, pref_cb callback, gpointer user_data)
Definition: prefs.c:2345
void prefs_register_decode_as_range_preference(module_t *module, const char *name, const char *title, const char *description, range_t **var, guint32 max_value)
Definition: prefs.c:1905
WS_DLL_PUBLIC pref_t * prefs_find_preference(module_t *module, const char *pref)
Definition: prefs.c:1135
WS_DLL_PUBLIC gboolean prefs_is_capture_device_hidden(const char *name)
Definition: prefs.c:4889
void prefs_cleanup(void)
Definition: prefs.c:379
WS_DLL_PUBLIC void prefs_register_uint_preference(module_t *module, const char *name, const char *title, const char *description, guint base, guint *var)
Definition: prefs.c:1166
WS_DLL_PUBLIC void prefs_register_filename_preference(module_t *module, const char *name, const char *title, const char *description, const char **var, gboolean for_writing)
Definition: prefs.c:1545
WS_DLL_PUBLIC int write_prefs(char **pf_path_return)
Definition: prefs.c:6818
WS_DLL_PUBLIC void prefs_reset(void)
Definition: prefs.c:4341
WS_DLL_PUBLIC gboolean prefs_module_has_submodules(module_t *module)
Definition: prefs.c:863
WS_DLL_PUBLIC module_t * prefs_register_protocol_obsolete(int id)
Definition: prefs.c:707
WS_DLL_PUBLIC module_t * prefs_register_codec(const char *name, const char *title, const char *description, void(*apply_cb)(void))
Definition: prefs.c:779
WS_DLL_PUBLIC module_t * prefs_register_protocol_subtree(const char *subtree, int id, void(*apply_cb)(void))
Definition: prefs.c:641
WS_DLL_PUBLIC void prefs_apply(module_t *module)
Definition: prefs.c:943
WS_DLL_PUBLIC range_t * prefs_get_range_value(const char *module_name, const char *pref_name)
Definition: prefs.c:1706
WS_DLL_PUBLIC gboolean prefs_capture_device_monitor_mode(const char *name)
Definition: prefs.c:4994
void prefs_register_custom_preference(module_t *module, const char *name, const char *title, const char *description, struct pref_custom_cbs *custom_cbs, void **custom_data)
WS_DLL_PUBLIC module_t * prefs_register_stat(const char *name, const char *title, const char *description, void(*apply_cb)(void))
Definition: prefs.c:747
WS_DLL_PUBLIC void prefs_register_bool_preference(module_t *module, const char *name, const char *title, const char *description, gboolean *var)
Definition: prefs.c:1209
WS_DLL_PUBLIC gboolean prefs_capture_options_dialog_column_is_visible(const gchar *column)
Definition: prefs.c:5018
WS_DLL_PUBLIC const char * prefs_pref_type_name(pref_t *pref)
Definition: prefs.c:6167
WS_DLL_PUBLIC guint prefs_get_uint_value(const char *module_name, const char *pref_name)
Definition: prefs.c:4828
WS_DLL_PUBLIC module_t * prefs_find_module(const char *name)
Definition: prefs.c:799
WS_DLL_PUBLIC char string_to_name_resolve(const char *string, struct _e_addr_resolve *name_resolve)
Definition: prefs.c:5053
WS_DLL_PUBLIC void prefs_register_password_preference(module_t *module, const char *name, const char *title, const char *description, const char **var)
Definition: prefs.c:1917
WS_DLL_PUBLIC const char * prefs_get_title_by_name(const char *name)
Definition: prefs.c:1155
Flags to control name resolution.
Definition: addr_resolv.h:48
Definition: prefs.h:137
Definition: color.h:23
Definition: params.h:23
Definition: range.h:42
Definition: uat-int.h:38
Definition: prefs-int.h:74
Definition: prefs-int.h:27
const char * description
Definition: prefs-int.h:30
const char * name
Definition: prefs-int.h:28
void(* apply_cb)(void)
Definition: prefs-int.h:31
const char * title
Definition: prefs-int.h:29
Definition: prefs.c:200
const char * description
Definition: prefs.c:203
const char * title
Definition: prefs.c:202
const char * name
Definition: prefs.c:201
struct pref_custom_cbs custom_cbs
Definition: prefs.c:247
const enum_val_t * enumvals
Definition: prefs.c:240
gboolean radio_buttons
Definition: prefs.c:241
guint base
Definition: prefs.c:237
guint32 max_value
Definition: prefs.c:238