* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
+#include "ws_diag_control.h"
+
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <epan/address.h>
#include <epan/addr_resolv.h>
#include <epan/oids.h>
-#ifdef HAVE_GEOIP
-#include <epan/geoip_db.h>
-#endif
+#include <epan/maxmind_db.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto.h>
#include <epan/strutil.h>
#include <epan/column.h>
+#include <epan/decode_as.h>
#include "print.h"
#include <wsutil/file_util.h>
+#include <wsutil/report_message.h>
#include <epan/prefs-int.h>
#include <epan/uat-int.h>
#include "epan/wmem/wmem.h"
#include <epan/stats_tree.h>
+/*
+ * Module alias.
+ */
+typedef struct pref_module_alias {
+ const char *name; /**< name of module alias */
+ module_t *module; /**< module for which it's an alias */
+} module_alias_t;
+
/* Internal functions */
static module_t *find_subtree(module_t *parent, const char *tilte);
static module_t *prefs_register_module_or_subtree(module_t *parent,
const char *name, const char *title, const char *description, gboolean is_subtree,
void (*apply_cb)(void), gboolean use_gui);
static void prefs_register_modules(void);
+static module_t *prefs_find_module_alias(const char *name);
static prefs_set_pref_e set_pref(gchar*, const gchar*, void *, gboolean);
static void free_col_info(GList *);
static void pre_init_prefs(void);
static gboolean prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt);
static gboolean parse_column_format(fmt_data *cfmt, const char *fmt);
static void try_convert_to_custom_column(gpointer *el_data);
+static guint prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
+ gpointer user_data, gboolean skip_obsolete);
#define IS_PREF_OBSOLETE(p) ((p) & PREF_OBSOLETE)
#define SET_PREF_OBSOLETE(p) ((p) |= PREF_OBSOLETE)
static gboolean prefs_initialized = FALSE;
static gchar *gpf_path = NULL;
static gchar *cols_hidden_list = NULL;
+static gboolean gui_theme_is_dark = FALSE;
/*
* XXX - variables to allow us to attempt to interpret the first
e_prefs prefs;
-static const enum_val_t gui_ptree_line_style[] = {
- {"NONE", "NONE", 0},
- {"SOLID", "SOLID", 1},
- {"DOTTED", "DOTTED", 2},
- {"TABBED", "TABBED", 3},
- {NULL, NULL, -1}
-};
-
-static const enum_val_t gui_ptree_expander_style[] = {
- {"NONE", "NONE", 0},
- {"SQUARE", "SQUARE", 1},
- {"TRIANGLE", "TRIANGLE", 2},
- {"CIRCULAR", "CIRCULAR", 3},
- {NULL, NULL, -1}
-};
-
-static const enum_val_t gui_hex_dump_highlight_style[] = {
- {"BOLD", "BOLD", 0},
- {"INVERSE", "INVERSE", 1},
- {NULL, NULL, -1}
-};
-
static const enum_val_t gui_console_open_type[] = {
{"NEVER", "NEVER", console_open_never},
{"AUTOMATIC", "AUTOMATIC", console_open_auto},
{NULL, NULL, -1}
};
-/* GTK knows of two ways representing "both", vertical and horizontal aligned.
- * as this may not work on other guis, we use only "both" in general here */
static const enum_val_t gui_toolbar_style[] = {
{"ICONS", "ICONS", 0},
{"TEXT", "TEXT", 1},
{NULL, NULL, -1}
};
+static const enum_val_t gui_selection_style[] = {
+ {"DEFAULT", "DEFAULT", COLOR_STYLE_DEFAULT},
+ {"FLAT", "FLAT", COLOR_STYLE_FLAT},
+ {"GRADIENT", "GRADIENT", COLOR_STYLE_GRADIENT},
+ {NULL, NULL, -1}
+};
+
#if defined(HAVE_PCAP_CREATE)
/* Can set monitor mode and buffer size. */
static gint num_capture_cols = 7;
{NULL, NULL, -1}
};
+/** Struct to hold preference data */
+struct preference {
+ const char *name; /**< name of preference */
+ const char *title; /**< title to use in GUI */
+ const char *description; /**< human-readable description of preference */
+ int ordinal; /**< ordinal number of this preference */
+ int type; /**< type of that preference */
+ unsigned int effect_flags; /**< Flags of types effected by preference (PREF_TYPE_DISSECTION, PREF_EFFECT_CAPTURE, etc).
+ Flags must be non-zero to ensure saving to disk */
+ gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
+ union { /* The Qt preference code assumes that these will all be pointers (and unique) */
+ guint *uint;
+ gboolean *boolp;
+ gint *enump;
+ char **string;
+ range_t **range;
+ struct epan_uat* uat;
+ color_t *colorp;
+ GList** list;
+ } varp; /**< pointer to variable storing the value */
+ union {
+ guint uint;
+ gboolean boolval;
+ gint enumval;
+ char *string;
+ range_t *range;
+ color_t color;
+ GList* list;
+ } stashed_val; /**< original value, when editing from the GUI */
+ union {
+ guint uint;
+ gboolean boolval;
+ gint enumval;
+ char *string;
+ range_t *range;
+ color_t color;
+ GList* list;
+ } default_val; /**< the default value of the preference */
+ union {
+ guint base; /**< input/output base, for PREF_UINT */
+ guint32 max_value; /**< maximum value of a range */
+ struct {
+ const enum_val_t *enumvals; /**< list of name & values */
+ gboolean radio_buttons; /**< TRUE if it should be shown as
+ radio buttons rather than as an
+ option menu or combo box in
+ the preferences tab */
+ } enum_info; /**< for PREF_ENUM */
+ } info; /**< display/text file information */
+ struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
+};
+
+const char* prefs_get_description(pref_t *pref)
+{
+ return pref->description;
+}
+
+const char* prefs_get_title(pref_t *pref)
+{
+ return pref->title;
+}
+
+int prefs_get_type(pref_t *pref)
+{
+ return pref->type;
+}
+
+gui_type_t prefs_get_gui_type(pref_t *pref)
+{
+ return pref->gui;
+}
+
+const char* prefs_get_name(pref_t *pref)
+{
+ return pref->name;
+}
+
+guint32 prefs_get_max_value(pref_t *pref)
+{
+ return pref->info.max_value;
+}
+
/*
* List of all modules with preference settings.
*/
*/
static wmem_tree_t *prefs_top_level_modules = NULL;
+/*
+ * List of aliases for modules.
+ */
+static wmem_tree_t *prefs_module_aliases = NULL;
+
/** Sets up memory used by proto routines. Called at program startup */
void
prefs_init(void)
memset(&prefs, 0, sizeof(prefs));
prefs_modules = wmem_tree_new(wmem_epan_scope());
prefs_top_level_modules = wmem_tree_new(wmem_epan_scope());
+ prefs_module_aliases = wmem_tree_new(wmem_epan_scope());
}
/*
static void
free_string_like_preference(pref_t *pref)
{
- g_free(*pref->varp.string);
+DIAG_OFF(cast-qual)
+ g_free((char *)*pref->varp.string);
+DIAG_ON(cast-qual)
*pref->varp.string = NULL;
g_free(pref->default_val.string);
pref->default_val.string = NULL;
case PREF_BOOL:
case PREF_ENUM:
case PREF_UINT:
+ case PREF_DECODE_AS_UINT:
case PREF_STATIC_TEXT:
case PREF_UAT:
case PREF_COLOR:
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
- g_free(*pref->varp.string);
- *pref->varp.string = NULL;
- g_free(pref->default_val.string);
- pref->default_val.string = NULL;
+ free_string_like_preference(pref);
break;
case PREF_RANGE:
- g_free(*pref->varp.range);
+ case PREF_DECODE_AS_RANGE:
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
*pref->varp.range = NULL;
- g_free(pref->default_val.range);
+ wmem_free(wmem_epan_scope(), pref->default_val.range);
pref->default_val.range = NULL;
break;
case PREF_CUSTOM:
module->prefs = NULL;
module->numprefs = 0;
if (module->submodules) {
- prefs_modules_foreach_submodules(module, free_module_prefs, NULL);
+ prefs_module_list_foreach(module->submodules, free_module_prefs, NULL, FALSE);
}
/* We don't free the actual module: its submodules pointer points to
a wmem_tree and the module itself is stored in a wmem_tree
/* This isn't strictly necessary since we're exiting anyway, but let's
* do what clean up we can.
*/
- prefs_modules_foreach(free_module_prefs, NULL);
+ prefs_module_list_foreach(prefs_modules, free_module_prefs, NULL, FALSE);
+
+ /* Clean the uats */
+ uat_cleanup();
+
+ /* Shut down mmdbresolve */
+ maxmind_db_pref_cleanup();
+
+ g_free(prefs.saved_at_version);
+ g_free(gpf_path);
+ gpf_path = NULL;
+}
+
+void prefs_set_gui_theme_is_dark(gboolean is_dark)
+{
+ gui_theme_is_dark = is_dark;
}
/*
* the title used in the tab for it in a preferences dialog box, and a
* routine to call back when we apply the preferences.
*/
-module_t *
+static module_t *
prefs_register_module(module_t *parent, const char *name, const char *title,
const char *description, void (*apply_cb)(void),
const gboolean use_gui)
* at the top level and the title used in the tab for it in a preferences
* dialog box.
*/
-module_t *
+static module_t *
prefs_register_subtree(module_t *parent, const char *title, const char *description,
void (*apply_cb)(void))
{
module->parent = parent;
module->submodules = NULL; /* no submodules, to start */
module->numprefs = 0;
- module->prefs_changed = FALSE;
+ module->prefs_changed_flags = 0;
module->obsolete = FALSE;
module->use_gui = use_gui;
+ /* A module's preferences affects dissection unless otherwise told */
+ module->effect_flags = PREF_EFFECT_DISSECTION;
/*
* Do we have a module name?
* on the command line, and shouldn't require quoting,
* shifting, etc.
*/
- for (p = name; (c = *p) != '\0'; p++)
- g_assert(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
- c == '-' || c == '.');
+ for (p = name; (c = *p) != '\0'; p++) {
+ if (!(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
+ c == '-' || c == '.'))
+ g_error("Preference module \"%s\" contains invalid characters", name);
+ }
/*
* Make sure there's not already a module with that
return module;
}
+void
+prefs_register_module_alias(const char *name, module_t *module)
+{
+ module_alias_t *alias;
+ const char *p;
+ guchar c;
+
+ /*
+ * Yes.
+ * Make sure that only ASCII letters, numbers, underscores, hyphens,
+ * and dots appear in the name. We allow upper-case letters, to
+ * handle the Diameter dissector having used "Diameter" rather
+ * than "diameter" as its preference module name in the past.
+ *
+ * Crash if there is, as that's an error in the code, but the name
+ * can be used on the command line, and shouldn't require quoting,
+ * etc.
+ */
+ for (p = name; (c = *p) != '\0'; p++) {
+ if (!(g_ascii_isalpha(c) || g_ascii_isdigit(c) || c == '_' ||
+ c == '-' || c == '.'))
+ g_error("Preference module alias \"%s\" contains invalid characters", name);
+ }
+
+ /*
+ * Make sure there's not already an alias with that
+ * name. Crash if there is, as that's an error in the
+ * code, and the code has to be fixed not to register
+ * more than one alias with the same name.
+ *
+ * We search the list of all aliases.
+ */
+ g_assert(prefs_find_module_alias(name) == NULL);
+
+ alias = wmem_new(wmem_epan_scope(), module_alias_t);
+ alias->name = name;
+ alias->module = module;
+
+ /*
+ * Insert this module in the list of all modules.
+ */
+ wmem_tree_insert_string(prefs_module_aliases, name, alias, WMEM_TREE_STRING_NOCASE);
+}
+
/*
* Register that a protocol has preferences.
*/
prefs_register_modules();
}
protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol preferences being registered with an invalid protocol ID");
return prefs_register_module(protocols_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol),
prefs_deregister_protocol (int id)
{
protocol_t *protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol preferences being de-registered with an invalid protocol ID");
prefs_deregister_module (protocols_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol));
* being the name (if it's later registered explicitly
* with a description, that will override it).
*/
- ptr = wmem_strdup(wmem_epan_scope(), ptr),
+ ptr = wmem_strdup(wmem_epan_scope(), ptr);
new_module = prefs_register_subtree(subtree_module, ptr, ptr, NULL);
}
}
protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol subtree being registered with an invalid protocol ID");
return prefs_register_module(subtree_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol),
prefs_register_modules();
}
protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol being registered with an invalid protocol ID");
module = prefs_register_module(protocols_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol),
apply_cb, TRUE);
}
+/*
+ * Register that a codec has preferences.
+ *
+ * "name" is a name for the codec to use on the command line with "-o"
+ * and in preference files.
+ *
+ * "title" is a short human-readable name for the codec.
+ *
+ * "description" is a longer human-readable description of the codec.
+ */
+module_t *codecs_module = NULL;
+
+module_t *
+prefs_register_codec(const char *name, const char *title,
+ const char *description, void (*apply_cb)(void))
+{
+ /*
+ * Have we yet created the "Codecs" subtree?
+ */
+ if (codecs_module == NULL) {
+ /*
+ * No. Register Codecs subtree as well as any preferences
+ * for non-dissector modules.
+ */
+ pre_init_prefs();
+ prefs_register_modules();
+ }
+
+ return prefs_register_module(codecs_module, name, title, description,
+ apply_cb, TRUE);
+}
+
module_t *
prefs_find_module(const char *name)
{
* non-zero value, we stop and return that value, otherwise we
* return 0.
*
- * Ignores "obsolete" modules; their sole purpose is to allow old
+ * Normally "obsolete" modules are ignored; their sole purpose is to allow old
* preferences for dissectors that no longer have preferences to be
* silently ignored in preference files. Does not ignore subtrees,
* as this can be used when walking the display tree of modules.
module_cb callback;
gpointer user_data;
guint ret;
+ gboolean skip_obsolete;
} call_foreach_t;
static gboolean
module_t *module = (module_t*)value;
call_foreach_t *call_data = (call_foreach_t*)data;
- if (!module->obsolete)
+ if (!call_data->skip_obsolete || !module->obsolete)
call_data->ret = (*call_data->callback)(module, call_data->user_data);
return (call_data->ret != 0);
static guint
prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
- gpointer user_data)
+ gpointer user_data, gboolean skip_obsolete)
{
call_foreach_t call_data;
call_data.callback = callback;
call_data.user_data = user_data;
call_data.ret = 0;
+ call_data.skip_obsolete = skip_obsolete;
wmem_tree_foreach(module_list, call_foreach_cb, &call_data);
return call_data.ret;
}
guint
prefs_modules_foreach(module_cb callback, gpointer user_data)
{
- return prefs_module_list_foreach(prefs_modules, callback, user_data);
+ return prefs_module_list_foreach(prefs_modules, callback, user_data, TRUE);
}
/*
prefs_modules_foreach_submodules(module_t *module, module_cb callback,
gpointer user_data)
{
- return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data);
+ return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data, TRUE);
}
static gboolean
if (module->obsolete)
return FALSE;
- if (module->prefs_changed) {
+ if (module->prefs_changed_flags) {
if (module->apply_cb != NULL)
(*module->apply_cb)();
- module->prefs_changed = FALSE;
+ module->prefs_changed_flags = 0;
}
if (module->submodules)
wmem_tree_foreach(module->submodules, call_apply_cb, NULL);
void
prefs_apply(module_t *module)
{
- if (module && module->prefs_changed)
+ if (module && module->prefs_changed_flags)
call_apply_cb(NULL, module, NULL);
}
+static module_t *
+prefs_find_module_alias(const char *name)
+{
+ module_alias_t *alias;
+
+ alias = (module_alias_t *)wmem_tree_lookup_string(prefs_module_aliases, name, WMEM_TREE_STRING_NOCASE);
+ if (alias == NULL)
+ return NULL;
+ return alias->module;
+}
+
/*
* Register a preference in a module's list of preferences.
* If it has a title, give it an ordinal number; otherwise, it's a
{
pref_t *preference;
const gchar *p;
+ const char *name_prefix = (module->name != NULL) ? module->name : module->parent->name;
preference = g_new(pref_t,1);
preference->name = name;
preference->title = title;
preference->description = description;
preference->type = type;
+ /* Default to module's preference effects */
+ preference->effect_flags = module->effect_flags;
+
preference->gui = GUI_ALL; /* default */
if (title != NULL)
preference->ordinal = module->numprefs;
*/
for (p = name; *p != '\0'; p++)
if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.'))
- g_error("Preference %s.%s contains invalid characters", module->name, name);
+ g_error("Preference \"%s.%s\" contains invalid characters", module->name, name);
/*
* Make sure there's not already a preference with that
g_error("Preference %s begins with the module name", name);
}
+ /* The title shows up in the preferences dialog. Make sure it's UI-friendly. */
+ if (preference->title) {
+ const char *cur_char;
+ if (preference->type != PREF_STATIC_TEXT && g_utf8_strlen(preference->title, -1) > 80) { // Arbitrary.
+ g_error("Title for preference %s.%s is too long: %s", name_prefix, preference->name, preference->title);
+ }
+
+ if (!g_utf8_validate(preference->title, -1, NULL)) {
+ g_error("Title for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+ }
+
+ for (cur_char = preference->title; *cur_char; cur_char = g_utf8_next_char(cur_char)) {
+ if (!g_unichar_isprint(g_utf8_get_char(cur_char))) {
+ g_error("Title for preference %s.%s isn't printable UTF-8.", name_prefix, preference->name);
+ }
+ }
+ }
+
+ if (preference->description) {
+ if (!g_utf8_validate(preference->description, -1, NULL)) {
+ g_error("Description for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+ }
+ }
+
/*
- * There isn't already one with that name, so add the
- * preference.
+ * We passed all of our checks. Add the preference.
*/
module->prefs = g_list_append(module->prefs, preference);
if (title != NULL)
preference->default_val.boolval = *var;
}
+unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source)
+{
+ unsigned int changed = 0;
+
+ switch (source)
+ {
+ case pref_default:
+ if (pref->default_val.boolval != value) {
+ pref->default_val.boolval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.boolval != value) {
+ pref->stashed_val.boolval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.boolp != value) {
+ *pref->varp.boolp = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+void prefs_invert_bool_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ pref->default_val.boolval = !pref->default_val.boolval;
+ break;
+ case pref_stashed:
+ pref->stashed_val.boolval = !pref->stashed_val.boolval;
+ break;
+ case pref_current:
+ *pref->varp.boolp = !(*pref->varp.boolp);
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+}
+
+gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.boolval;
+ break;
+ case pref_stashed:
+ return pref->stashed_val.boolval;
+ break;
+ case pref_current:
+ return *pref->varp.boolp;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return FALSE;
+}
+
/*
* Register a preference with an enumerated value.
*/
+/*
+ * XXX Should we get rid of the radio_buttons parameter and make that
+ * behavior automatic depending on the number of items?
+ */
void
prefs_register_enum_preference(module_t *module, const char *name,
const char *title, const char *description,
preference->info.enum_info.radio_buttons = radio_buttons;
}
+unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source)
+{
+ unsigned int changed = 0;
+
+ switch (source)
+ {
+ case pref_default:
+ if (pref->default_val.enumval != value) {
+ pref->default_val.enumval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.enumval != value) {
+ pref->stashed_val.enumval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.enump != value) {
+ *pref->varp.enump = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+gint prefs_get_enum_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.enumval;
+ break;
+ case pref_stashed:
+ return pref->stashed_val.enumval;
+ break;
+ case pref_current:
+ return *pref->varp.enump;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return 0;
+}
+
+const enum_val_t* prefs_get_enumvals(pref_t *pref)
+{
+ return pref->info.enum_info.enumvals;
+}
+
+gboolean prefs_get_enum_radiobuttons(pref_t *pref)
+{
+ return pref->info.enum_info.radio_buttons;
+}
+
static void
register_string_like_preference(module_t *module, const char *name,
const char *title, const char *description,
}
}
+/*
+ * Assign to a string preference.
+ */
+static void
+pref_set_string_like_pref_value(pref_t *pref, const gchar *value)
+{
+DIAG_OFF(cast-qual)
+ g_free((void *)*pref->varp.string);
+DIAG_ON(cast-qual)
+ *pref->varp.string = g_strdup(value);
+}
+
/*
* For use by UI code that sets preferences.
*/
-void
-prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed)
+unsigned int
+prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
{
- if (*pref->varp.string) {
- if (strcmp(*pref->varp.string, value) != 0) {
- *changed = TRUE;
- g_free(*pref->varp.string);
- *pref->varp.string = g_strdup(value);
+ unsigned int changed = 0;
+
+ switch (source)
+ {
+ case pref_default:
+ if (*pref->default_val.string) {
+ if (strcmp(pref->default_val.string, value) != 0) {
+ changed = prefs_get_effect_flags(pref);
+ g_free(pref->default_val.string);
+ pref->default_val.string = g_strdup(value);
+ }
+ } else if (value) {
+ pref->default_val.string = g_strdup(value);
}
- } else if (value) {
- *pref->varp.string = g_strdup(value);
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.string) {
+ if (strcmp(pref->stashed_val.string, value) != 0) {
+ changed = prefs_get_effect_flags(pref);
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = g_strdup(value);
+ }
+ } else if (value) {
+ pref->stashed_val.string = g_strdup(value);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.string) {
+ if (strcmp(*pref->varp.string, value) != 0) {
+ changed = prefs_get_effect_flags(pref);
+ pref_set_string_like_pref_value(pref, value);
+ }
+ } else if (value) {
+ pref_set_string_like_pref_value(pref, value);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+char* prefs_get_string_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.string;
+ case pref_stashed:
+ return pref->stashed_val.string;
+ case pref_current:
+ return *pref->varp.string;
+ default:
+ g_assert_not_reached();
+ break;
}
+
+ return NULL;
}
/*
void
prefs_register_filename_preference(module_t *module, const char *name,
const char *title, const char *description,
- const char **var)
+ const char **var, gboolean for_writing)
{
DIAG_OFF(cast-qual)
- register_string_like_preference(module, name, title, description,
- (char **)var, PREF_FILENAME, NULL, FALSE);
+ register_string_like_preference(module, name, title, description, (char **)var,
+ for_writing ? PREF_SAVE_FILENAME : PREF_OPEN_FILENAME, NULL, FALSE);
DIAG_ON(cast-qual)
}
DIAG_ON(cast-qual)
}
-/*
- * Register a preference with a ranged value.
- */
-void
-prefs_register_range_preference(module_t *module, const char *name,
+/* Refactoring to handle both PREF_RANGE and PREF_DECODE_AS_RANGE */
+static void
+prefs_register_range_preference_common(module_t *module, const char *name,
const char *title, const char *description,
- range_t **var, guint32 max_value)
+ range_t **var, guint32 max_value, int type)
{
pref_t *preference;
- preference = register_preference(module, name, title, description,
- PREF_RANGE);
+ preference = register_preference(module, name, title, description, type);
preference->info.max_value = max_value;
-
/*
* Range preference values should be non-null (as you can't
* keep them null after using the preferences GUI, you can at best
* If the value is a null pointer, make it an empty range.
*/
if (*var == NULL)
- *var = range_empty();
+ *var = range_empty(wmem_epan_scope());
preference->varp.range = var;
- preference->default_val.range = range_copy(*var);
+ preference->default_val.range = range_copy(wmem_epan_scope(), *var);
preference->stashed_val.range = NULL;
}
-static gboolean
+/*
+ * Register a preference with a ranged value.
+ */
+void
+prefs_register_range_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ range_t **var, guint32 max_value)
+{
+ prefs_register_range_preference_common(module, name, title,
+ description, var, max_value, PREF_RANGE);
+}
+
+gboolean
prefs_set_range_value_work(pref_t *pref, const gchar *value,
- gboolean return_range_errors, gboolean *changed)
+ gboolean return_range_errors, unsigned int *changed_flags)
{
range_t *newrange;
- if (range_convert_str_work(&newrange, value, pref->info.max_value,
+ if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
return_range_errors) != CVT_NO_ERROR) {
return FALSE; /* number was bad */
}
if (!ranges_are_equal(*pref->varp.range, newrange)) {
- *changed = TRUE;
- g_free(*pref->varp.range);
+ *changed_flags |= prefs_get_effect_flags(pref);
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
*pref->varp.range = newrange;
} else {
- g_free(newrange);
+ wmem_free(wmem_epan_scope(), newrange);
}
return TRUE;
}
/*
* For use by UI code that sets preferences.
*/
-gboolean
-prefs_set_range_value(pref_t *pref, const gchar *value, gboolean *changed)
+unsigned int
+prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
+{
+ range_t *newrange;
+
+ if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
+ TRUE) != CVT_NO_ERROR) {
+ return 0; /* number was bad */
+ }
+
+ if (!ranges_are_equal(pref->stashed_val.range, newrange)) {
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = newrange;
+ } else {
+ wmem_free(wmem_epan_scope(), newrange);
+ }
+ return prefs_get_effect_flags(pref);
+
+}
+
+gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source)
+{
+ gboolean changed = FALSE;
+
+ switch (source)
+ {
+ case pref_default:
+ if (!ranges_are_equal(pref->default_val.range, value)) {
+ wmem_free(wmem_epan_scope(), pref->default_val.range);
+ pref->default_val.range = range_copy(wmem_epan_scope(), value);
+ changed = TRUE;
+ }
+ break;
+ case pref_stashed:
+ if (!ranges_are_equal(pref->stashed_val.range, value)) {
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = range_copy(wmem_epan_scope(), value);
+ changed = TRUE;
+ }
+ break;
+ case pref_current:
+ if (!ranges_are_equal(*pref->varp.range, value)) {
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), value);
+ changed = TRUE;
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.range;
+ case pref_stashed:
+ return pref->stashed_val.range;
+ break;
+ case pref_current:
+ return *pref->varp.range;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return NULL;
+}
+
+range_t* prefs_get_range_value(const char *module_name, const char* pref_name)
{
- return prefs_set_range_value_work(pref, value, TRUE, changed);
+ return prefs_get_range_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
+}
+
+void
+prefs_range_add_value(pref_t *pref, guint32 val)
+{
+ range_add_value(wmem_epan_scope(), pref->varp.range, val);
+}
+
+void
+prefs_range_remove_value(pref_t *pref, guint32 val)
+{
+ range_remove_value(wmem_epan_scope(), pref->varp.range, val);
}
/*
preference->gui = GUI_QT;
}
+struct epan_uat* prefs_get_uat_value(pref_t *pref)
+{
+ return pref->varp.uat;
+}
+
/*
* Register a color preference.
*/
preference->default_val.color = *color;
}
+gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source)
+{
+ gboolean changed = FALSE;
+
+ switch (source)
+ {
+ case pref_default:
+ if ((pref->default_val.color.red != value.red) ||
+ (pref->default_val.color.green != value.green) ||
+ (pref->default_val.color.blue != value.blue)) {
+ changed = TRUE;
+ pref->default_val.color = value;
+ }
+ break;
+ case pref_stashed:
+ if ((pref->stashed_val.color.red != value.red) ||
+ (pref->stashed_val.color.green != value.green) ||
+ (pref->stashed_val.color.blue != value.blue)) {
+ changed = TRUE;
+ pref->stashed_val.color = value;
+ }
+ break;
+ case pref_current:
+ if ((pref->varp.colorp->red != value.red) ||
+ (pref->varp.colorp->green != value.green) ||
+ (pref->varp.colorp->blue != value.blue)) {
+ changed = TRUE;
+ *pref->varp.colorp = value;
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+color_t* prefs_get_color_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return &pref->default_val.color;
+ case pref_stashed:
+ return &pref->stashed_val.color;
+ break;
+ case pref_current:
+ return pref->varp.colorp;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return NULL;
+}
+
/*
* Register a "custom" preference with a list.
* XXX - This should be temporary until we can find a better way
*/
}
+/*
+ * Register a (internal) "Decode As" preference with a ranged value.
+ */
+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)
+{
+ prefs_register_range_preference_common(module, name, title,
+ description, var, max_value, PREF_DECODE_AS_RANGE);
+}
+
+/*
+ * Register a (internal) "Decode As" preference with an unsigned integral value
+ * for a dissector table.
+ */
+void prefs_register_decode_as_preference(module_t *module, const char *name,
+ const char *title, const char *description, guint *var)
+{
+ pref_t *preference;
+
+ preference = register_preference(module, name, title, description,
+ PREF_DECODE_AS_UINT);
+ preference->varp.uint = var;
+ preference->default_val.uint = *var;
+ /* XXX - Presume base 10 for now */
+ preference->info.base = 10;
+}
+
+gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace)
+{
+ switch(pref->type)
+ {
+ case PREF_DECODE_AS_UINT:
+ /* This doesn't support multiple values for a dissector in Decode As because the
+ preference only supports a single value. This leads to a "last port for
+ dissector in Decode As wins" */
+ *pref->varp.uint = value;
+ break;
+ case PREF_DECODE_AS_RANGE:
+ if (replace)
+ {
+ /* If range has single value, replace it */
+ if (((*pref->varp.range)->nranges == 1) &&
+ ((*pref->varp.range)->ranges[0].low == (*pref->varp.range)->ranges[0].high)) {
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_empty(wmem_epan_scope());
+ }
+ }
+
+ prefs_range_add_value(pref, value);
+ break;
+ default:
+ /* XXX - Worth asserting over? */
+ break;
+ }
+
+ return TRUE;
+}
+
+gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default)
+{
+ switch(pref->type)
+ {
+ case PREF_DECODE_AS_UINT:
+ if (set_default) {
+ *pref->varp.uint = pref->default_val.uint;
+ } else {
+ *pref->varp.uint = 0;
+ }
+ break;
+ case PREF_DECODE_AS_RANGE:
+ prefs_range_remove_value(pref, value);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
/*
* Register a preference that used to be supported but no longer is.
*/
return PREFS_SET_NO_SUCH_PREF;
}
+guint
+pref_stash(pref_t *pref, gpointer unused _U_)
+{
+ switch (pref->type) {
+
+ case PREF_DECODE_AS_UINT:
+ pref->stashed_val.uint = *pref->varp.uint;
+ break;
+
+ case PREF_UINT:
+ pref->stashed_val.uint = *pref->varp.uint;
+ break;
+
+ case PREF_BOOL:
+ pref->stashed_val.boolval = *pref->varp.boolp;
+ break;
+
+ case PREF_ENUM:
+ pref->stashed_val.enumval = *pref->varp.enump;
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = g_strdup(*pref->varp.string);
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ case PREF_RANGE:
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = range_copy(wmem_epan_scope(), *pref->varp.range);
+ break;
+
+ case PREF_COLOR:
+ pref->stashed_val.color = *pref->varp.colorp;
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
+ return 0;
+}
+
+guint
+pref_unstash(pref_t *pref, gpointer unstash_data_p)
+{
+ pref_unstash_data_t *unstash_data = (pref_unstash_data_t *)unstash_data_p;
+ dissector_table_t sub_dissectors = NULL;
+ dissector_handle_t handle = NULL;
+
+ /* Revert the preference to its saved value. */
+ switch (pref->type) {
+
+ case PREF_DECODE_AS_UINT:
+ if (*pref->varp.uint != pref->stashed_val.uint) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+ if (unstash_data->handle_decode_as) {
+ if (*pref->varp.uint != pref->default_val.uint) {
+ dissector_reset_uint(pref->name, *pref->varp.uint);
+ }
+ }
+
+ *pref->varp.uint = pref->stashed_val.uint;
+
+ if (unstash_data->handle_decode_as) {
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
+ if (handle != NULL) {
+ dissector_change_uint(pref->name, *pref->varp.uint, handle);
+ }
+ }
+ }
+ }
+ break;
+
+ case PREF_UINT:
+ if (*pref->varp.uint != pref->stashed_val.uint) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.uint = pref->stashed_val.uint;
+ }
+ break;
+
+ case PREF_BOOL:
+ if (*pref->varp.boolp != pref->stashed_val.boolval) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.boolp = pref->stashed_val.boolval;
+ }
+ break;
+
+ case PREF_ENUM:
+ if (*pref->varp.enump != pref->stashed_val.enumval) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.enump = pref->stashed_val.enumval;
+ }
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ g_free(*pref->varp.string);
+ *pref->varp.string = g_strdup(pref->stashed_val.string);
+ }
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
+ guint32 i, j;
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+ if (unstash_data->handle_decode_as) {
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
+ if (handle != NULL) {
+ /* Delete all of the old values from the dissector table */
+ for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+ for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+ dissector_delete_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), pref->stashed_val.range);
+
+ if (unstash_data->handle_decode_as) {
+ if ((sub_dissectors != NULL) && (handle != NULL)) {
+
+ /* Add new values to the dissector table */
+ for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+
+ for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+ dissector_change_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_change_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+ break;
+
+ case PREF_RANGE:
+ if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), pref->stashed_val.range);
+ }
+ break;
+
+ case PREF_COLOR:
+ if ((pref->varp.colorp->blue != pref->stashed_val.color.blue) ||
+ (pref->varp.colorp->red != pref->stashed_val.color.red) ||
+ (pref->varp.colorp->green != pref->stashed_val.color.green)) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.colorp = pref->stashed_val.color;
+ }
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
+ return 0;
+}
+
+void
+reset_stashed_pref(pref_t *pref) {
+ switch (pref->type) {
+
+ case PREF_DECODE_AS_UINT:
+ pref->stashed_val.uint = pref->default_val.uint;
+ break;
+
+ case PREF_UINT:
+ pref->stashed_val.uint = pref->default_val.uint;
+ break;
+
+ case PREF_BOOL:
+ pref->stashed_val.boolval = pref->default_val.boolval;
+ break;
+
+ case PREF_ENUM:
+ pref->stashed_val.enumval = pref->default_val.enumval;
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = g_strdup(pref->default_val.string);
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ case PREF_RANGE:
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = range_copy(wmem_epan_scope(), pref->default_val.range);
+ break;
+
+ case PREF_COLOR:
+ memcpy(&pref->stashed_val.color, &pref->default_val.color, sizeof(color_t));
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
+}
+
+guint
+pref_clean_stash(pref_t *pref, gpointer unused _U_)
+{
+ switch (pref->type) {
+
+ case PREF_UINT:
+ case PREF_DECODE_AS_UINT:
+ break;
+
+ case PREF_BOOL:
+ break;
+
+ case PREF_ENUM:
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ if (pref->stashed_val.string != NULL) {
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = NULL;
+ }
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ case PREF_RANGE:
+ if (pref->stashed_val.range != NULL) {
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = NULL;
+ }
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_COLOR:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
+ return 0;
+}
+
#if 0
/* Return the value assigned to the given uint preference. */
guint
return 0;
}
-static const enum_val_t print_format_vals[] = {
- { "text", "Plain Text", PR_FMT_TEXT },
- { "postscript", "Postscript", PR_FMT_PS },
- { NULL, NULL, 0 }
-};
-
-static const enum_val_t print_dest_vals[] = {
-#ifdef _WIN32
- /* "PR_DEST_CMD" means "to printer" on Windows */
- { "command", "Printer", PR_DEST_CMD },
-#else
- { "command", "Command", PR_DEST_CMD },
-#endif
- { "file", "File", PR_DEST_FILE },
- { NULL, NULL, 0 }
-};
-
static const enum_val_t st_sort_col_vals[] = {
{ "name", "Node name (topic/item)", ST_SORT_COL_NAME },
{ "count", "Item count", ST_SORT_COL_COUNT },
if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000)
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
-#ifdef HAVE_LIBPORTAUDIO
- /* Test for a sane max channels entry */
- if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
-#endif
-
/* burst resolution can't be less than 1 (ms) */
if (prefs.st_burst_resolution < 1) {
prefs.st_burst_resolution = 1;
}
static prefs_set_pref_e
-console_log_level_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+console_log_level_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
{
guint uval;
uval = (guint)strtoul(value, NULL, 10);
if (*pref->varp.uint != uval) {
- *changed = TRUE;
+ *changed_flags = prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
static module_t *gui_column_module = NULL;
static prefs_set_pref_e
-column_hidden_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+column_hidden_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
{
GList *clp;
fmt_data *cfmt;
pref_t *format_pref;
- prefs_set_string_like_value(pref, value, changed);
+ (*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
/*
* Set the "visible" flag for the existing columns; we need to
}
static prefs_set_pref_e
-column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, gboolean* changed _U_)
+column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, unsigned int* changed_flags _U_)
{
/* Don't write this to the preferences file */
return PREFS_SET_OK;
}
static prefs_set_pref_e
-column_format_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+column_format_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags _U_)
{
GList *col_l, *col_l_elt;
fmt_data *cfmt;
}
static prefs_set_pref_e
-capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+capture_column_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags _U_)
{
GList *col_l = prefs_get_string_list(value);
GList *col_l_elt;
}
static prefs_set_pref_e
-colorized_frame_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+colorized_frame_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
{
- prefs_set_string_like_value(pref, value, changed);
-
+ (*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
return PREFS_SET_OK;
}
{
module_t *printing, *capture_module, *console_module,
*gui_layout_module, *gui_font_module;
-#ifdef HAVE_EXTCAP
module_t *extcap_module;
-#endif
-
+ unsigned int layout_gui_flags;
struct pref_custom_cbs custom_cbs;
if (protocols_module != NULL) {
return;
}
-#ifdef HAVE_EXTCAP
/* GUI
* These are "simple" GUI preferences that can be read/written using the
* preference module API. These preferences still use their own
"Save arguments on start of capture",
"Save arguments on start of capture",
&prefs.extcap_save_on_start);
-#endif
/* GUI
* These are "simple" GUI preferences that can be read/written using the
prefs_register_obsolete_preference(gui_module, "scrollbar_on_right");
prefs_register_obsolete_preference(gui_module, "packet_list_sel_browse");
prefs_register_obsolete_preference(gui_module, "protocol_tree_sel_browse");
+ prefs_register_obsolete_preference(gui_module, "tree_view_altern_colors");
+ prefs_register_obsolete_preference(gui_module, "expert_composite_eyecandy");
+ prefs_register_obsolete_preference(gui_module, "filter_toolbar_show_in_statusbar");
- prefs_register_bool_preference(gui_module, "tree_view_altern_colors",
- "Alternating colors in TreeViews",
- "Alternating colors in TreeViews?",
- &prefs.gui_altern_colors);
+ prefs_register_bool_preference(gui_module, "restore_filter_after_following_stream",
+ "Restore current display filter after following a stream",
+ "Restore current display filter after following a stream?",
+ &prefs.restore_filter_after_following_stream);
- prefs_register_bool_preference(gui_module, "expert_composite_eyecandy",
- "Display Icons on Expert Composite Dialog Tabs",
- "Display Icons on Expert Composite Dialog Tabs?",
- &prefs.gui_expert_composite_eyecandy);
+ prefs_register_obsolete_preference(gui_module, "protocol_tree_line_style");
- prefs_register_bool_preference(gui_module, "filter_toolbar_show_in_statusbar",
- "Place filter toolbar inside the statusbar",
- "Place filter toolbar inside the statusbar?",
- &prefs.filter_toolbar_show_in_statusbar);
+ prefs_register_obsolete_preference(gui_module, "protocol_tree_expander_style");
- prefs_register_enum_preference(gui_module, "protocol_tree_line_style",
- "Protocol-tree line style",
- "Protocol-tree line style",
- &prefs.gui_ptree_line_style, gui_ptree_line_style, FALSE);
-
- prefs_register_enum_preference(gui_module, "protocol_tree_expander_style",
- "Protocol-tree expander style",
- "Protocol-tree expander style",
- &prefs.gui_ptree_expander_style, gui_ptree_expander_style, FALSE);
-
- prefs_register_enum_preference(gui_module, "hex_dump_highlight_style",
- "Hex dump highlight style",
- "Hex dump highlight style",
- &prefs.gui_hex_dump_highlight_style, gui_hex_dump_highlight_style, FALSE);
+ prefs_register_obsolete_preference(gui_module, "hex_dump_highlight_style");
gui_column_module = prefs_register_subtree(gui_module, "Columns", "Columns", NULL);
+ /* For reading older preference files with "column." preferences */
+ prefs_register_module_alias("column", gui_column_module);
custom_cbs.free_cb = free_string_like_preference;
custom_cbs.reset_cb = reset_string_like_preference;
prefs_register_obsolete_preference(gui_font_module, "font_name");
- register_string_like_preference(gui_font_module, "gtk2.font_name", "Font name",
- "Font name for packet list, protocol tree, and hex dump panes. (GTK+)",
- &prefs.gui_gtk2_font_name, PREF_STRING, NULL, TRUE);
+ prefs_register_obsolete_preference(gui_font_module, "gtk2.font_name");
register_string_like_preference(gui_font_module, "qt.font_name", "Font name",
"Font name for packet list, protocol tree, and hex dump panes. (Qt)",
/* User Interface : Colors */
gui_color_module = prefs_register_subtree(gui_module, "Colors", "Colors", NULL);
+ prefs_register_color_preference(gui_color_module, "active_frame.fg", "Foregound color for an active selected item",
+ "Foregound color for an active selected item", &prefs.gui_active_fg);
+
+ prefs_register_color_preference(gui_color_module, "active_frame.bg", "Backgound color for an active selected item",
+ "Backgound color for an active selected item", &prefs.gui_active_bg);
+
+ prefs_register_enum_preference(gui_color_module, "active_frame.style", "Color style for an active selected item",
+ "Color style for an active selected item", &prefs.gui_active_style, gui_selection_style, FALSE);
+
+ prefs_register_color_preference(gui_color_module, "inactive_frame.fg", "Foregound color for an inactive selected item",
+ "Foregound color for an inactive selected item", &prefs.gui_inactive_fg);
+
+ prefs_register_color_preference(gui_color_module, "inactive_frame.bg", "Backgound color for an inactive selected item",
+ "Backgound color for an inactive selected item", &prefs.gui_inactive_bg);
+
+ prefs_register_enum_preference(gui_color_module, "inactive_frame.style", "Color style for an inactive selected item",
+ "Color style for an inactive selected item", &prefs.gui_inactive_style, gui_selection_style, FALSE);
+
prefs_register_color_preference(gui_color_module, "marked_frame.fg", "Color preferences for a marked frame",
"Color preferences for a marked frame", &prefs.gui_marked_fg);
"Wrap to beginning/end of file during search?",
&prefs.gui_find_wrap);
- prefs_register_bool_preference(gui_module, "use_pref_save",
- "Settings dialogs use a save button",
- "Settings dialogs use a save button?",
- &prefs.gui_use_pref_save);
+ prefs_register_obsolete_preference(gui_module, "use_pref_save");
prefs_register_bool_preference(gui_module, "geometry.save.position",
"Save window position at exit",
"Save window maximized state at exit?",
&prefs.gui_geometry_save_maximized);
- /* GTK+ only */
- prefs_register_bool_preference(gui_module, "macosx_style",
- "Use OS X style",
- "Use OS X style (OS X with native GTK only)?",
- &prefs.gui_macosx_style);
+ prefs_register_obsolete_preference(gui_module, "macosx_style");
prefs_register_obsolete_preference(gui_module, "geometry.main.x");
prefs_register_obsolete_preference(gui_module, "geometry.main.y");
"Main Toolbar style",
&prefs.gui_toolbar_main_style, gui_toolbar_style, FALSE);
- prefs_register_enum_preference(gui_module, "toolbar_filter_style",
- "Filter Toolbar style",
- "Filter Toolbar style",
- &prefs.gui_toolbar_filter_style, gui_toolbar_style, FALSE);
-
- register_string_like_preference(gui_module, "webbrowser", "The path to the webbrowser",
- "The path to the webbrowser (Ex: mozilla)",
- &prefs.gui_webbrowser, PREF_STRING, NULL, TRUE);
+ prefs_register_obsolete_preference(gui_module, "toolbar_filter_style");
+ prefs_register_obsolete_preference(gui_module, "webbrowser");
prefs_register_bool_preference(gui_module, "update.enabled",
"Check for updates",
&prefs.gui_update_interval);
register_string_like_preference(gui_module, "window_title", "Custom window title",
- "Custom window title to be appended to the existing title\n%P = profile name\n%V = version info",
+ "Custom window title to be appended to the existing title\n"
+ "%F = file path of the capture file\n"
+ "%P = profile name\n"
+ "%S = a conditional separator (\" - \") that only shows when surrounded by variables with values or static text\n"
+ "%V = version info",
&prefs.gui_window_title, PREF_STRING, NULL, TRUE);
register_string_like_preference(gui_module, "prepend_window_title", "Custom window title prefix",
- "Custom window title to be prepended to the existing title\n%P = profile name\n%V = version info",
+ "Custom window title to be prepended to the existing title\n"
+ "%F = file path of the capture file\n"
+ "%P = profile name\n"
+ "%S = a conditional separator (\" - \") that only shows when surrounded by variables with values or static text\n"
+ "%V = version info",
&prefs.gui_prepend_window_title, PREF_STRING, NULL, TRUE);
register_string_like_preference(gui_module, "start_title", "Custom start page title",
"Show version in the start page and/or main screen's title bar",
(gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE);
- prefs_register_bool_preference(gui_module, "auto_scroll_on_expand",
- "Automatically scroll the recently expanded item",
- "Automatically scroll the recently expanded item",
- &prefs.gui_auto_scroll_on_expand);
-
- prefs_register_uint_preference(gui_module, "auto_scroll_percentage",
- "The percentage down the view the recently expanded item should be scrolled",
- "The percentage down the view the recently expanded item should be scrolled",
- 10,
- &prefs.gui_auto_scroll_percentage);
+ prefs_register_obsolete_preference(gui_module, "auto_scroll_on_expand");
+ prefs_register_obsolete_preference(gui_module, "auto_scroll_percentage");
/* User Interface : Layout */
gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
+ /* Adjust the preference effects of layout GUI for better handling of preferences at Wireshark (GUI) level */
+ layout_gui_flags = prefs_get_module_effect_flags(gui_layout_module);
+ layout_gui_flags |= PREF_EFFECT_GUI_LAYOUT;
+ layout_gui_flags &= (~PREF_EFFECT_DISSECTION);
prefs_register_uint_preference(gui_layout_module, "layout_type",
"Layout type",
"Layout type (1-6)",
10,
(guint*)(void*)(&prefs.gui_layout_type));
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_type", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_1",
"Layout content of the pane 1",
"Layout content of the pane 1",
(gint*)(void*)(&prefs.gui_layout_content_1), gui_layout_content, FALSE);
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_1", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_2",
"Layout content of the pane 2",
"Layout content of the pane 2",
(gint*)(void*)(&prefs.gui_layout_content_2), gui_layout_content, FALSE);
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_2", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_3",
"Layout content of the pane 3",
"Layout content of the pane 3",
(gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_3", layout_gui_flags);
prefs_register_bool_preference(gui_layout_module, "packet_list_separator.enabled",
"Enable Packet List Separator",
"Enable Packet List Separator",
&prefs.gui_qt_packet_list_separator);
+ prefs_register_bool_preference(gui_layout_module, "show_selected_packet.enabled",
+ "Show selected packet in the Status Bar",
+ "Show selected packet in the Status Bar",
+ &prefs.gui_qt_show_selected_packet);
+
+ prefs_register_bool_preference(gui_layout_module, "show_file_load_time.enabled",
+ "Show file load time in the Status Bar",
+ "Show file load time in the Status Bar",
+ &prefs.gui_qt_show_file_load_time);
+
prefs_register_bool_preference(gui_module, "packet_editor.enabled",
"Enable Packet Editor",
"Enable Packet Editor (Experimental)",
"Show the intelligent scroll bar (a minimap of packet list colors in the scrollbar)",
&prefs.gui_packet_list_show_minimap);
+
+ prefs_register_bool_preference(gui_module, "interfaces_show_hidden",
+ "Show hidden interfaces",
+ "Show all interfaces, including interfaces marked as hidden",
+ &prefs.gui_interfaces_show_hidden);
+
+ prefs_register_bool_preference(gui_module, "interfaces_remote_display",
+ "Show Remote interfaces",
+ "Show remote interfaces in the interface selection",
+ &prefs.gui_interfaces_remote_display);
+
+ register_string_like_preference(gui_module, "interfaces_hidden_types", "Hide interface types in list",
+ "Hide the given interface types in the startup list",
+ &prefs.gui_interfaces_hide_types, PREF_STRING, NULL, TRUE);
+
/* Console
* These are preferences that can be read/written using the
* preference module API. These preferences still use their own
* preference "string compare list" in set_pref()
*/
console_module = prefs_register_module(NULL, "console", "Console",
- "CONSOLE", NULL, FALSE);
+ "Console logging and debugging output", NULL, FALSE);
custom_cbs.free_cb = custom_pref_no_cb;
custom_cbs.reset_cb = console_log_level_reset_cb;
custom_cbs.is_default_cb = console_log_level_is_default_cb;
custom_cbs.to_str_cb = console_log_level_to_str_cb;
prefs_register_uint_custom_preference(console_module, "log.level", "logging level",
- "A bitmask of glib log levels", &custom_cbs, &prefs.console_log_level);
+ "A bitmask of GLib log levels", &custom_cbs, &prefs.console_log_level);
+
+ prefs_register_bool_preference(console_module, "incomplete_dissectors_check_debug",
+ "Print debug line for incomplete dissectors",
+ "Look for dissectors that left some bytes undecoded (debug)",
+ &prefs.incomplete_dissectors_check_debug);
+
+ /* Display filter Expressions
+ * This used to be an array of individual fields that has now been
+ * converted to a UAT. Just make it part of the GUI category even
+ * though the name of the preference will never be seen in preference
+ * file
+ */
+ filter_expression_register_uat(gui_module);
/* Capture
* These are preferences that can be read/written using the
* preference "string compare list" in set_pref()
*/
capture_module = prefs_register_module(NULL, "capture", "Capture",
- "CAPTURE", NULL, FALSE);
+ "Capture preferences", NULL, FALSE);
+ /* Capture preferences don't affect dissection */
+ prefs_set_module_effect_flags(capture_module, PREF_EFFECT_CAPTURE);
register_string_like_preference(capture_module, "device", "Default capture device",
"Default capture device",
"By default, capture in monitor mode on interface? (Ex: eth0,eth3,...)",
&prefs.capture_devices_monitor_mode, PREF_STRING, NULL, FALSE);
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
register_string_like_preference(capture_module, "devices_buffersize", "Interface buffer size",
"Interface buffer size (Ex: en0(1),en1(143),...)",
&prefs.capture_devices_buffersize, PREF_STRING, NULL, FALSE);
-#endif
register_string_like_preference(capture_module, "devices_snaplen", "Interface snap length",
"Interface snap length (Ex: en0(65535),en1(1430),...)",
"Interface capture filter (Ex: en0(tcp),en1(udp),...)",
&prefs.capture_devices_filter, PREF_STRING, NULL, FALSE);
- prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in Pcap-NG format",
- "Capture in Pcap-NG format?", &prefs.capture_pcap_ng);
+ prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in pcapng format",
+ "Capture in pcapng format?", &prefs.capture_pcap_ng);
prefs_register_bool_preference(capture_module, "real_time_update", "Update packet list in real time during capture",
"Update packet list in real time during capture?", &prefs.capture_real_time);
+ prefs_register_bool_preference(capture_module, "no_interface_load", "Don't load interfaces on startup",
+ "Don't automatically load capture interfaces on startup", &prefs.capture_no_interface_load);
+
+ prefs_register_bool_preference(capture_module, "no_extcap", "Disable external capture interfaces",
+ "Disable external capture modules (extcap)", &prefs.capture_no_extcap);
+
/* We might want to make this a "recent" setting. */
prefs_register_bool_preference(capture_module, "auto_scroll", "Scroll packet list during capture",
"Scroll packet list during capture?", &prefs.capture_auto_scroll);
- /* GTK+ only */
- prefs_register_bool_preference(capture_module, "show_info", "Show capture info dialog while capturing",
- "Show capture info dialog while capturing?", &prefs.capture_show_info);
+ prefs_register_bool_preference(capture_module, "show_info", "Show capture information dialog while capturing",
+ "Show capture information dialog while capturing?", &prefs.capture_show_info);
prefs_register_obsolete_preference(capture_module, "syntax_check_filter");
"Name Resolution", NULL, TRUE);
addr_resolve_pref_init(nameres_module);
oid_pref_init(nameres_module);
-#ifdef HAVE_GEOIP
- geoip_db_pref_init(nameres_module);
-#endif
+ maxmind_db_pref_init(nameres_module);
- /* Printing */
+ /* Printing
+ * None of these have any effect; we keep them as obsolete preferences
+ * in order to avoid errors when reading older preference files.
+ */
printing = prefs_register_module(NULL, "print", "Printing",
- "Printing", NULL, TRUE);
-
- prefs_register_enum_preference(printing, "format",
- "Format", "Can be one of \"text\" or \"postscript\"",
- &prefs.pr_format, print_format_vals, TRUE);
+ "Printing", NULL, FALSE);
+ prefs_register_obsolete_preference(printing, "format");
+ prefs_register_obsolete_preference(printing, "command");
+ prefs_register_obsolete_preference(printing, "file");
- prefs_register_enum_preference(printing, "destination",
- "Print to", "Can be one of \"command\" or \"file\"",
- &prefs.pr_dest, print_dest_vals, TRUE);
-
-#ifndef _WIN32
- register_string_like_preference(printing, "command", "Command",
- "Output gets piped to this command when the destination is set to \"command\"",
- &prefs.pr_cmd, PREF_STRING, NULL, TRUE);
-#endif
-
- register_string_like_preference(printing, "file", "File",
- "This is the file that gets written to when the destination is set to \"file\"",
- &prefs.pr_file, PREF_FILENAME, NULL, TRUE);
+ /* Codecs */
+ codecs_module = prefs_register_module(NULL, "codecs", "Codecs",
+ "Codecs", NULL, TRUE);
/* Statistics */
stats_module = prefs_register_module(NULL, "statistics", "Statistics",
10,
&prefs.tap_update_interval);
-#ifdef HAVE_LIBPORTAUDIO
- prefs_register_uint_preference(stats_module, "rtp_player_max_visible",
- "Max visible channels in RTP Player",
- "Determines maximum height of RTP Player window",
- 10,
- &prefs.rtp_player_max_visible);
-#endif
+ prefs_register_obsolete_preference(stats_module, "rtp_player_max_visible");
prefs_register_bool_preference(stats_module, "st_enable_burstinfo",
"Enable the calculation of burst information",
"Look for dissectors that left some bytes undecoded.",
&prefs.enable_incomplete_dissectors_check);
+ prefs_register_bool_preference(protocols_module, "strict_conversation_tracking_heuristics",
+ "Enable stricter conversation tracking heuristics",
+ "Protocols may use things like VLAN ID or interface ID to narrow the potential for duplicate conversations."
+ "Currently only ICMP and ICMPv6 use this preference to add VLAN ID to conversation tracking",
+ &prefs.strict_conversation_tracking_heuristics);
+
/* Obsolete preferences
* These "modules" were reorganized/renamed to correspond to their GUI
* configuration screen within the preferences dialog
return NULL;
}
slstr[j] = '\0';
- sl = g_list_append(sl, slstr);
+ if (j > 0)
+ sl = g_list_append(sl, slstr);
+ else
+ g_free(slstr);
break;
}
if (cur_c == '"' && ! backslash) {
and it wasn't preceded by a backslash; it's the end of
the string we were working on... */
slstr[j] = '\0';
- sl = g_list_append(sl, slstr);
+ if (j > 0) {
+ sl = g_list_append(sl, slstr);
+ slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ }
/* ...and the beginning of a new string. */
state = PRE_STRING;
- slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
j = 0;
} else if (!g_ascii_isspace(cur_c) || state != PRE_STRING) {
/* Either this isn't a white-space character, or we've started a
GString *joined_str = g_string_new("");
GList *cur, *first;
gchar *str;
- gchar *quoted_str;
guint item_count = 0;
cur = first = g_list_first(sl);
} else
g_string_append_c(joined_str, ' ');
- quoted_str = g_strescape(str, "");
- g_string_append_printf(joined_str, "\"%s\"", quoted_str);
- g_free(quoted_str);
+ g_string_append_c(joined_str, '"');
+ while (*str) {
+ gunichar uc = g_utf8_get_char (str);
+
+ if (uc == '"' || uc == '\\')
+ g_string_append_c(joined_str, '\\');
+
+ if (g_unichar_isprint(uc))
+ g_string_append_unichar (joined_str, uc);
+
+ str = g_utf8_next_char (str);
+ }
+
+ g_string_append_c(joined_str, '"');
cur = cur->next;
}
void
prefs_clear_string_list(GList *sl)
{
- /* g_list_free_full() only exists since 2.28. */
- g_list_foreach(sl, (GFunc)g_free, NULL);
- g_list_free(sl);
+ g_list_free_full(sl, g_free);
}
/*
prefs_register_modules();
- filter_expression_init();
-
prefs_initialized = TRUE;
}
"Protocol", "%p", "Length", "%L",
"Info", "%i"};
- prefs.pr_format = PR_FMT_TEXT;
- prefs.pr_dest = PR_DEST_CMD;
- if (prefs.pr_file) g_free(prefs.pr_file);
- prefs.pr_file = g_strdup("wireshark.out");
- if (prefs.pr_cmd) g_free(prefs.pr_cmd);
- prefs.pr_cmd = g_strdup("lpr");
-
- prefs.gui_altern_colors = FALSE;
- prefs.gui_expert_composite_eyecandy = FALSE;
- prefs.gui_ptree_line_style = 0;
- prefs.gui_ptree_expander_style = 1;
- prefs.gui_hex_dump_highlight_style = 1;
- prefs.filter_toolbar_show_in_statusbar = FALSE;
+ prefs.restore_filter_after_following_stream = FALSE;
prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
- prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
- /* These will be g_freed, so they must be g_mallocated. */
- if (prefs.gui_gtk2_font_name) g_free(prefs.gui_gtk2_font_name);
-#ifdef _WIN32
- prefs.gui_gtk2_font_name = g_strdup("Lucida Console 10");
-#else
- prefs.gui_gtk2_font_name = g_strdup("Monospace 10");
-#endif
/* We try to find the best font in the Qt code */
- if (prefs.gui_qt_font_name) g_free(prefs.gui_qt_font_name);
+ g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = g_strdup("");
+ prefs.gui_active_fg.red = 0;
+ prefs.gui_active_fg.green = 0;
+ prefs.gui_active_fg.blue = 0;
+ prefs.gui_active_bg.red = 52223;
+ prefs.gui_active_bg.green = 59647;
+ prefs.gui_active_bg.blue = 65535;
+ prefs.gui_active_style = COLOR_STYLE_DEFAULT;
+ prefs.gui_inactive_fg.red = 0;
+ prefs.gui_inactive_fg.green = 0;
+ prefs.gui_inactive_fg.blue = 0;
+ prefs.gui_inactive_bg.red = 61439;
+ prefs.gui_inactive_bg.green = 61439;
+ prefs.gui_inactive_bg.blue = 61439;
+ prefs.gui_inactive_style = COLOR_STYLE_DEFAULT;
prefs.gui_marked_fg.red = 65535;
prefs.gui_marked_fg.green = 65535;
prefs.gui_marked_fg.blue = 65535;
prefs.gui_ignored_bg.red = 65535;
prefs.gui_ignored_bg.green = 65535;
prefs.gui_ignored_bg.blue = 65535;
- if (prefs.gui_colorized_fg) g_free(prefs.gui_colorized_fg);
+ g_free(prefs.gui_colorized_fg);
prefs.gui_colorized_fg = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
- if (prefs.gui_colorized_bg) g_free(prefs.gui_colorized_bg);
+ g_free(prefs.gui_colorized_bg);
prefs.gui_colorized_bg = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
prefs.st_client_fg.red = 32767;
prefs.st_client_fg.green = 0;
prefs.st_server_bg.red = 60909;
prefs.st_server_bg.green = 60909;
prefs.st_server_bg.blue = 64507;
- prefs.gui_text_valid.red = 0xAFFF; /* light green */
- prefs.gui_text_valid.green = 0xFFFF;
- prefs.gui_text_valid.blue = 0xAFFF;
- prefs.gui_text_invalid.red = 0xFFFF; /* light red */
- prefs.gui_text_invalid.green = 0xAFFF;
- prefs.gui_text_invalid.blue = 0xAFFF;
- prefs.gui_text_deprecated.red = 0xFFFF; /* light yellow */
- prefs.gui_text_deprecated.green = 0xFFFF;
- prefs.gui_text_deprecated.blue = 0xAFFF;
+
+ if (gui_theme_is_dark) {
+ // Green, red and yellow with HSV V = 84
+ prefs.gui_text_valid.red = 0x0000; /* dark green */
+ prefs.gui_text_valid.green = 0x66ff;
+ prefs.gui_text_valid.blue = 0x0000;
+ prefs.gui_text_invalid.red = 0x66FF; /* dark red */
+ prefs.gui_text_invalid.green = 0x0000;
+ prefs.gui_text_invalid.blue = 0x0000;
+ prefs.gui_text_deprecated.red = 0x66FF; /* dark yellow / olive */
+ prefs.gui_text_deprecated.green = 0x66FF;
+ prefs.gui_text_deprecated.blue = 0x0000;
+ } else {
+ // Green, red and yellow with HSV V = 20
+ prefs.gui_text_valid.red = 0xAFFF; /* light green */
+ prefs.gui_text_valid.green = 0xFFFF;
+ prefs.gui_text_valid.blue = 0xAFFF;
+ prefs.gui_text_invalid.red = 0xFFFF; /* light red */
+ prefs.gui_text_invalid.green = 0xAFFF;
+ prefs.gui_text_invalid.blue = 0xAFFF;
+ prefs.gui_text_deprecated.red = 0xFFFF; /* light yellow */
+ prefs.gui_text_deprecated.green = 0xFFFF;
+ prefs.gui_text_deprecated.blue = 0xAFFF;
+ }
+
prefs.gui_geometry_save_position = TRUE;
prefs.gui_geometry_save_size = TRUE;
prefs.gui_geometry_save_maximized= TRUE;
- prefs.gui_macosx_style = TRUE;
prefs.gui_console_open = console_open_never;
prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED;
prefs.gui_recent_df_entries_max = 10;
prefs.gui_recent_files_count_max = 10;
- if (prefs.gui_fileopen_dir) g_free(prefs.gui_fileopen_dir);
+ g_free(prefs.gui_fileopen_dir);
prefs.gui_fileopen_dir = g_strdup(get_persdatafile_dir());
prefs.gui_fileopen_preview = 3;
prefs.gui_ask_unsaved = TRUE;
prefs.gui_find_wrap = TRUE;
- prefs.gui_use_pref_save = FALSE;
prefs.gui_update_enabled = TRUE;
prefs.gui_update_channel = UPDATE_CHANNEL_STABLE;
prefs.gui_update_interval = 60*60*24; /* Seconds */
- if (prefs.gui_webbrowser) g_free(prefs.gui_webbrowser);
-#ifdef HTML_VIEWER
- prefs.gui_webbrowser = g_strdup(HTML_VIEWER " %s");
-#else
- prefs.gui_webbrowser = g_strdup("");
-#endif
- if (prefs.gui_window_title) g_free(prefs.gui_window_title);
+ g_free(prefs.gui_window_title);
prefs.gui_window_title = g_strdup("");
- if (prefs.gui_prepend_window_title) g_free(prefs.gui_prepend_window_title);
+ g_free(prefs.gui_prepend_window_title);
prefs.gui_prepend_window_title = g_strdup("");
- if (prefs.gui_start_title) g_free(prefs.gui_start_title);
+ g_free(prefs.gui_start_title);
prefs.gui_start_title = g_strdup("The World's Most Popular Network Protocol Analyzer");
prefs.gui_version_placement = version_both;
- prefs.gui_auto_scroll_on_expand = FALSE;
- prefs.gui_auto_scroll_percentage = 0;
prefs.gui_layout_type = layout_type_5;
prefs.gui_layout_content_1 = layout_pane_content_plist;
prefs.gui_layout_content_2 = layout_pane_content_pdetails;
prefs.gui_packet_list_elide_mode = ELIDE_RIGHT;
prefs.gui_packet_list_show_related = TRUE;
prefs.gui_packet_list_show_minimap = TRUE;
-
+ g_free (prefs.gui_interfaces_hide_types);
+ prefs.gui_interfaces_hide_types = g_strdup("");
+ prefs.gui_interfaces_show_hidden = FALSE;
+ prefs.gui_interfaces_remote_display = TRUE;
prefs.gui_qt_packet_list_separator = FALSE;
+ prefs.gui_qt_show_selected_packet = FALSE;
+ prefs.gui_qt_show_file_load_time = FALSE;
if (prefs.col_list) {
free_col_info(prefs.col_list);
prefs.capture_pcap_ng = FALSE;
#endif
prefs.capture_real_time = TRUE;
+ prefs.capture_no_extcap = FALSE;
prefs.capture_auto_scroll = TRUE;
prefs.capture_show_info = FALSE;
/* set the default values for the tap/statistics dialog box */
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
prefs.st_enable_burstinfo = TRUE;
prefs.st_burst_showcount = FALSE;
prefs.st_burst_resolution = ST_DEF_BURSTRES;
/*
* Reset a single dissector preference.
*/
-static void
+void
reset_pref(pref_t *pref)
{
int type;
switch (type) {
case PREF_UINT:
+ case PREF_DECODE_AS_UINT:
*pref->varp.uint = pref->default_val.uint;
break;
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
reset_string_like_preference(pref);
break;
case PREF_RANGE:
- g_free(*pref->varp.range);
- *pref->varp.range = range_copy(pref->default_val.range);
+ case PREF_DECODE_AS_RANGE:
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), pref->default_val.range);
break;
case PREF_STATIC_TEXT:
}
static void
-reset_pref_cb(gpointer data, gpointer user_data _U_)
+reset_pref_cb(gpointer data, gpointer user_data)
{
pref_t *pref = (pref_t *) data;
+ module_t *module = (module_t *)user_data;
+
+ if (pref && (pref->type == PREF_RANGE || pref->type == PREF_DECODE_AS_RANGE)) {
+ /*
+ * Some dissectors expect the range (returned via prefs_get_range_value)
+ * to remain valid if it has not changed. If it did change, then we
+ * should set "prefs_changed_flags" to ensure that the preference apply
+ * callback is invoked. That callback will notify dissectors that it
+ * should no longer assume the range to be valid.
+ */
+ if (ranges_are_equal(*pref->varp.range, pref->default_val.range)) {
+ /* Optimization: do not invoke apply callback if nothing changed. */
+ return;
+ }
+ module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ }
reset_pref(pref);
}
-typedef struct {
- module_t *module;
-} reset_pref_arg_t;
-
/*
* Reset all preferences for a module.
*/
static gboolean
reset_module_prefs(const void *key _U_, void *value, void *data _U_)
{
- reset_pref_arg_t arg;
-
- arg.module = (module_t *)value;
- g_list_foreach(arg.module->prefs, reset_pref_cb, &arg);
+ module_t *module = (module_t *)value;
+ g_list_foreach(module->prefs, reset_pref_cb, module);
return FALSE;
}
*/
oids_cleanup();
- /*
- * Free the filter expression list.
- */
- filter_expression_free(*pfilter_expression_head);
- *pfilter_expression_head = NULL;
-
/*
* Reset the non-dissector preferences.
*/
/* Read the preferences file, fill in "prefs", and return a pointer to it.
- If we got an error (other than "it doesn't exist") trying to read
- the global preferences file, stuff the errno into "*gpf_errno_return"
- and a pointer to the path of the file into "*gpf_path_return", and
- return NULL.
-
- If we got an error (other than "it doesn't exist") trying to read
- the user's preferences file, stuff the errno into "*pf_errno_return"
- and a pointer to the path of the file into "*pf_path_return", and
- return NULL. */
+ If we got an error (other than "it doesn't exist") we report it through
+ the UI. */
e_prefs *
-read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
- char **gpf_path_return, int *pf_errno_return,
- int *pf_read_errno_return, char **pf_path_return)
+read_prefs(void)
{
int err;
char *pf_path;
* XXX - if it failed for a reason other than "it doesn't exist",
* report the error.
*/
- *gpf_path_return = NULL;
if (pf != NULL) {
/*
* Start out the counters of "mgcp.{tcp,udp}.port" entries we've
/* We succeeded in opening it; read it. */
err = read_prefs_file(gpf_path, pf, set_pref, NULL);
if (err != 0) {
- /* We had an error reading the file; return the errno and the
- pathname, so our caller can report the error. */
- *gpf_errno_return = 0;
- *gpf_read_errno_return = err;
- *gpf_path_return = gpf_path;
+ /* We had an error reading the file; report it. */
+ report_warning("Error reading global preferences file \"%s\": %s.",
+ gpf_path, g_strerror(err));
}
fclose(pf);
} else {
/* We failed to open it. If we failed for some reason other than
- "it doesn't exist", return the errno and the pathname, so our
- caller can report the error. */
+ "it doesn't exist", report the error. */
if (errno != ENOENT) {
- *gpf_errno_return = errno;
- *gpf_read_errno_return = 0;
- *gpf_path_return = gpf_path;
+ if (errno != 0) {
+ report_warning("Can't open global preferences file \"%s\": %s.",
+ gpf_path, g_strerror(errno));
+ }
}
}
pf_path = get_persconffile_path(PF_NAME, TRUE);
/* Read the user's preferences file, if it exists. */
- *pf_path_return = NULL;
if ((pf = ws_fopen(pf_path, "r")) != NULL) {
/*
* Start out the counters of "mgcp.{tcp,udp}.port" entries we've
/* We succeeded in opening it; read it. */
err = read_prefs_file(pf_path, pf, set_pref, NULL);
if (err != 0) {
- /* We had an error reading the file; return the errno and the
- pathname, so our caller can report the error. */
- *pf_errno_return = 0;
- *pf_read_errno_return = err;
- *pf_path_return = pf_path;
+ /* We had an error reading the file; report it. */
+ report_warning("Error reading your preferences file \"%s\": %s.",
+ pf_path, g_strerror(err));
} else
g_free(pf_path);
fclose(pf);
"it doesn't exist", return the errno and the pathname, so our
caller can report the error. */
if (errno != ENOENT) {
- *pf_errno_return = errno;
- *pf_read_errno_return = 0;
- *pf_path_return = pf_path;
+ report_warning("Can't open your preferences file \"%s\": %s.",
+ pf_path, g_strerror(errno));
} else
g_free(pf_path);
}
}
rewind(pf);
- while ((got_c = getc(pf)) != EOF) {
+ while ((got_c = ws_getc_unlocked(pf)) != EOF) {
if (got_c == '\r') {
/* Treat CR-LF at the end of a line like LF, so that if we're reading
* a Windows-format file on UN*X, we handle it the same way we'd handle
* a UN*X-format file. */
- got_c = getc(pf);
+ got_c = ws_getc_unlocked(pf);
if (got_c == EOF)
break;
if (got_c != '\n') {
break;
case PREFS_SET_NO_SUCH_PREF:
- /*
- * If "print.command" silently ignore it because it's valid
- * on non-Win32 platforms.
- */
- if (strcmp(cur_var->str, "print.command") != 0)
- g_warning ("No such preference \"%s\" at line %d of\n%s %s",
- cur_var->str, pline, pf_path, hint);
+ g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
case PREFS_SET_OBSOLETE:
- if (strcmp(cur_var->str, "print.command") != 0)
- /* If an attempt is made to save the preferences, a popup warning will be
- displayed stating that obsolete prefs have been detected and the user will
- be given the opportunity to save these prefs under a different profile name.
- The prefs in question need to be listed in the console window so that the
- user can make an informed choice.
- */
- g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
- cur_var->str, pline, pf_path, hint);
+ /*
+ * If an attempt is made to save the
+ * preferences, a popup warning will be
+ * displayed stating that obsolete prefs
+ * have been detected and the user will
+ * be given the opportunity to save these
+ * prefs under a different profile name.
+ * The prefs in question need to be listed
+ * in the console window so that the
+ * user can make an informed choice.
+ */
+ g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
}
break;
}
} else {
- g_warning ("Incomplete preference at line %d of\n%s %s",
+ g_warning("Incomplete preference at line %d of\n%s %s",
pline, pf_path, hint);
}
}
* a valid uat entry.
*/
static gboolean
-prefs_set_uat_pref(char *uat_entry) {
+prefs_set_uat_pref(char *uat_entry, char **errmsg) {
gchar *p, *colonp;
uat_t *uat;
- gchar *err = NULL;
gboolean ret;
colonp = strchr(uat_entry, ':');
uat = uat_find(uat_entry);
*colonp = ':';
if (uat == NULL) {
+ *errmsg = g_strdup("Unknown preference");
return FALSE;
}
- ret = uat_load_str(uat, p, &err);
- g_free(err);
+ ret = uat_load_str(uat, p, errmsg);
return ret;
}
* in some fashion.
*/
prefs_set_pref_e
-prefs_set_pref(char *prefarg)
+prefs_set_pref(char *prefarg, char **errmsg)
{
gchar *p, *colonp;
prefs_set_pref_e ret;
mgcp_tcp_port_count = -1;
mgcp_udp_port_count = -1;
+ *errmsg = NULL;
+
colonp = strchr(prefarg, ':');
if (colonp == NULL)
return PREFS_SET_SYNTAX_ERR;
if (strcmp(prefarg, "uat")) {
ret = set_pref(prefarg, p, NULL, TRUE);
} else {
- ret = prefs_set_uat_pref(p) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
+ ret = prefs_set_uat_pref(p, errmsg) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
}
*colonp = ':'; /* put the colon back */
return ret;
}
+guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.uint;
+ break;
+ case pref_stashed:
+ return pref->stashed_val.uint;
+ break;
+ case pref_current:
+ return *pref->varp.uint;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return 0;
+}
+
+guint prefs_get_uint_value(const char *module_name, const char* pref_name)
+{
+ return prefs_get_uint_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
+}
+
+unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source)
+{
+ unsigned int changed = 0;
+ switch (source)
+ {
+ case pref_default:
+ if (pref->default_val.uint != value) {
+ pref->default_val.uint = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.uint != value) {
+ pref->stashed_val.uint = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.uint != value) {
+ *pref->varp.uint = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+guint prefs_get_uint_base(pref_t *pref)
+{
+ return pref->info.base;
+}
+
/*
* Returns TRUE if the given device is hidden
*/
}
if (cfmt->fmt == COL_CUSTOM) {
/*
- * A custom column has to have the
- * same custom field and occurrence.
+ * A custom column has to have the same custom field,
+ * occurrence and resolved settings.
*/
if (cfmt_hidden.custom_fields && cfmt->custom_fields) {
if (strcmp(cfmt->custom_fields,
cfmt_hidden.custom_fields = NULL;
continue;
}
- if (cfmt->custom_occurrence != cfmt_hidden.custom_occurrence) {
- /* Different occurrences. */
+ if ((cfmt->custom_occurrence != cfmt_hidden.custom_occurrence) ||
+ (cfmt->resolved != cfmt_hidden.resolved)) {
+ /* Different occurrences or resolved settings. */
g_free(cfmt_hidden.custom_fields);
cfmt_hidden.custom_fields = NULL;
continue;
return FALSE;
}
+gboolean
+prefs_has_layout_pane_content (layout_pane_content_e layout_pane_content)
+{
+ return ((prefs.gui_layout_content_1 == layout_pane_content) ||
+ (prefs.gui_layout_content_2 == layout_pane_content) ||
+ (prefs.gui_layout_content_3 == layout_pane_content));
+}
+
#define PRS_GUI_FILTER_LABEL "gui.filter_expressions.label"
#define PRS_GUI_FILTER_EXPR "gui.filter_expressions.expr"
#define PRS_GUI_FILTER_ENABLED "gui.filter_expressions.enabled"
case 't':
name_resolve->transport_name = TRUE;
break;
- case 'C':
- name_resolve->concurrent_dns = TRUE;
- break;
case 'd':
name_resolve->dns_pkt_addr_resolution = TRUE;
break;
+ case 'v':
+ name_resolve->vlan_name = TRUE;
+ break;
default:
/*
* Unrecognized letter.
{"gvsp.enable_heuristic", "gvsp_udp", 0},
{"hdcp2.enable", "hdcp2_tcp", 0},
{"hislip.enable_heuristic", "hislip_tcp", 0},
+ {"infiniband.dissect_eoib", "mellanox_eoib", 1},
+ {"infiniband.identify_payload", "eth_over_ib", 0},
{"jxta.udp.heuristic", "jxta_udp", 0},
{"jxta.tcp.heuristic", "jxta_tcp", 0},
{"jxta.sctp.heuristic", "jxta_sctp", 0},
return FALSE;
}
+static gboolean
+deprecated_enable_dissector_pref(gchar *pref_name, const gchar *value)
+{
+ struct dissector_pref_name
+ {
+ const char* pref_name;
+ const char* short_name;
+ };
+
+ struct dissector_pref_name dissector_prefs[] = {
+ {"transum.tsumenabled", "TRANSUM"},
+ {"snort.enable_snort_dissector", "Snort"},
+ {"prp.enable", "PRP"},
+ };
+
+ unsigned int i;
+ int proto_id;
+
+ for (i = 0; i < sizeof(dissector_prefs)/sizeof(struct dissector_pref_name); i++)
+ {
+ if (strcmp(pref_name, dissector_prefs[i].pref_name) == 0)
+ {
+ proto_id = proto_get_id_by_short_name(dissector_prefs[i].short_name);
+ if (proto_id >= 0)
+ proto_set_decoding(proto_id, ((g_ascii_strcasecmp(value, "true") == 0) ? TRUE : FALSE));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+deprecated_port_pref(gchar *pref_name, const gchar *value)
+{
+ struct port_pref_name
+ {
+ const char* pref_name;
+ const char* module_name; /* the protocol filter name */
+ const char* table_name;
+ guint base;
+ };
+
+ struct obsolete_pref_name
+ {
+ const char* pref_name;
+ };
+
+ /* For now this is only supporting TCP/UDP port dissector preferences
+ which are assumed to be decimal */
+ struct port_pref_name port_prefs[] = {
+ /* TCP */
+ {"cmp.tcp_alternate_port", "CMP", "tcp.port", 10},
+ {"h248.tcp_port", "H248", "tcp.port", 10},
+ {"cops.tcp.cops_port", "COPS", "tcp.port", 10},
+ {"dhcpfo.tcp_port", "DHCPFO", "tcp.port", 10},
+ {"enttec.tcp_port", "ENTTEC", "tcp.port", 10},
+ {"forces.tcp_alternate_port", "ForCES", "tcp.port", 10},
+ {"ged125.tcp_port", "GED125", "tcp.port", 10},
+ {"hpfeeds.dissector_port", "HPFEEDS", "tcp.port", 10},
+ {"lsc.port", "LSC", "tcp.port", 10},
+ {"megaco.tcp.txt_port", "MEGACO", "tcp.port", 10},
+ {"netsync.tcp_port", "Netsync", "tcp.port", 10},
+ {"osi.tpkt_port", "OSI", "tcp.port", 10},
+ {"rsync.tcp_port", "RSYNC", "tcp.port", 10},
+ {"sametime.tcp_port", "SAMETIME", "tcp.port", 10},
+ {"sigcomp.tcp.port2", "SIGCOMP", "tcp.port", 10},
+ {"synphasor.tcp_port", "synphasor", "tcp.port", 10},
+ {"tipc.alternate_port", "TIPC", "tcp.port", 10},
+ {"vnc.alternate_port", "VNC", "tcp.port", 10},
+ {"scop.port", "SCoP", "tcp.port", 10},
+ {"scop.port_secure", "SCoP", "tcp.port", 10},
+ /* UDP */
+ {"h248.udp_port", "H248", "udp.port", 10},
+ {"actrace.udp_port", "ACtrace", "udp.port", 10},
+ {"brp.port", "BRP", "udp.port", 10},
+ {"bvlc.additional_udp_port", "BVLC", "udp.port", 10},
+ {"capwap.udp.port.control", "capwap", "udp.port", 10},
+ {"capwap.udp.port.data", "capwap", "udp.port", 10},
+ {"coap.udp_port", "CoAP", "udp.port", 10},
+ {"enttec.udp_port", "ENTTEC", "udp.port", 10},
+ {"forces.udp_alternate_port", "ForCES", "udp.port", 10},
+ {"ldss.udp_port", "LDSS", "udp.port", 10},
+ {"lmp.udp_port", "LMP", "udp.port", 10},
+ {"ltp.port", "LTP", "udp.port", 10},
+ {"lwres.udp.lwres_port", "LWRES", "udp.port", 10},
+ {"megaco.udp.txt_port", "MEGACO", "udp.port", 10},
+ {"pgm.udp.encap_ucast_port", "PGM", "udp.port", 10},
+ {"pgm.udp.encap_mcast_port", "PGM", "udp.port", 10},
+ {"quic.udp.quic.port", "QUIC", "udp.port", 10},
+ {"quic.udp.quics.port", "QUIC", "udp.port", 10},
+ {"radius.alternate_port", "RADIUS", "udp.port", 10},
+ {"rdt.default_udp_port", "RDT", "udp.port", 10},
+ {"alc.default.udp_port", "ALC", "udp.port", 10},
+ {"sigcomp.udp.port2", "SIGCOMP", "udp.port", 10},
+ {"synphasor.udp_port", "synphasor", "udp.port", 10},
+ {"tdmop.udpport", "TDMoP", "udp.port", 10},
+ {"uaudp.port1", "UAUDP", "udp.port", 10},
+ {"uaudp.port2", "UAUDP", "udp.port", 10},
+ {"uaudp.port3", "UAUDP", "udp.port", 10},
+ {"uaudp.port4", "UAUDP", "udp.port", 10},
+ {"uhd.dissector_port", "UHD", "udp.port", 10},
+ {"vrt.dissector_port", "vrt", "udp.port", 10},
+ };
+
+ struct port_pref_name port_range_prefs[] = {
+ /* TCP */
+ {"couchbase.tcp.ports", "Couchbase", "tcp.port", 10},
+ {"gsm_ipa.tcp_ports", "GSM over IP", "tcp.port", 10},
+ {"kafka.tcp.ports", "Kafka", "tcp.port", 10},
+ {"kt.tcp.ports", "Kyoto Tycoon", "tcp.port", 10},
+ {"memcache.tcp.ports", "MEMCACHE", "tcp.port", 10},
+ {"mrcpv2.tcp.port_range", "MRCPv2", "tcp.port", 10},
+ {"rtsp.tcp.port_range", "RTSP", "tcp.port", 10},
+ {"sip.tcp.ports", "SIP", "tcp.port", 10},
+ {"tds.tcp_ports", "TDS", "tcp.port", 10},
+ {"uma.tcp.ports", "UMA", "tcp.port", 10},
+ /* UDP */
+ {"aruba_erm.udp.ports", "ARUBA_ERM", "udp.port", 10},
+ {"diameter.udp.ports", "DIAMETER", "udp.port", 10},
+ {"dmp.udp_ports", "DMP", "udp.port", 10},
+ {"dns.udp.ports", "DNS", "udp.port", 10},
+ {"gsm_ipa.udp_ports", "GSM over IP", "udp.port", 10},
+ {"hcrt.dissector_udp_port", "HCrt", "udp.port", 10},
+ {"memcache.udp.ports", "MEMCACHE", "udp.port", 10},
+ {"nb_rtpmux.udp_ports", "NB_RTPMUX", "udp.port", 10},
+ {"gprs-ns.udp.ports", "GPRS-NS", "udp.port", 10},
+ {"p_mul.udp_ports", "P_MUL", "udp.port", 10},
+ {"radius.ports", "RADIUS", "udp.port", 10},
+ {"sflow.ports", "sFlow", "udp.port", 10},
+ {"sscop.udp.ports", "SSCOP", "udp.port", 10},
+ {"tftp.udp_ports", "TFTP", "udp.port", 10},
+ {"tipc.udp.ports", "TIPC", "udp.port", 10},
+ };
+
+ /* These are subdissectors of TPKT/OSITP that used to have a
+ TCP port preference even though they were never
+ directly on TCP. Convert them to use Decode As
+ with the TPKT dissector handle */
+ struct port_pref_name tpkt_subdissector_port_prefs[] = {
+ {"dap.tcp.port", "DAP", "tcp.port", 10},
+ {"disp.tcp.port", "DISP", "tcp.port", 10},
+ {"dop.tcp.port", "DOP", "tcp.port", 10},
+ {"dsp.tcp.port", "DSP", "tcp.port", 10},
+ {"p1.tcp.port", "P1", "tcp.port", 10},
+ {"p7.tcp.port", "P7", "tcp.port", 10},
+ {"rdp.tcp.port", "RDP", "tcp.port", 10},
+ };
+
+ /* These are obsolete preferences from the dissectors' view,
+ (typically because of a switch from a single value to a
+ range value) but the name of the preference conflicts
+ with the generated preference name from the dissector table.
+ Don't allow the obsolete preference through to be handled */
+ struct obsolete_pref_name obsolete_prefs[] = {
+ {"diameter.tcp.port"},
+ {"kafka.tcp.port"},
+ {"mrcpv2.tcp.port"},
+ {"rtsp.tcp.port"},
+ {"sip.tcp.port"},
+ {"t38.tcp.port"},
+ };
+
+ unsigned int i;
+ char *p;
+ guint uval;
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle, tpkt_handle;
+ module_t *module;
+ pref_t *pref;
+
+ static gboolean sanity_checked;
+ if (!sanity_checked) {
+ sanity_checked = TRUE;
+ for (i = 0; i < G_N_ELEMENTS(port_prefs); i++) {
+ module = prefs_find_module(port_prefs[i].module_name);
+ if (!module) {
+ g_warning("Deprecated ports pref check - module '%s' not found", port_prefs[i].module_name);
+ continue;
+ }
+ pref = prefs_find_preference(module, port_prefs[i].table_name);
+ if (!pref) {
+ g_warning("Deprecated ports pref '%s.%s' not found", module->name, port_prefs[i].table_name);
+ continue;
+ }
+ if (pref->type != PREF_DECODE_AS_UINT && pref->type != PREF_DECODE_AS_RANGE) {
+ g_warning("Deprecated ports pref '%s.%s' has wrong type: %#x (%s)", module->name, port_prefs[i].table_name, pref->type, prefs_pref_type_name(pref));
+ }
+ }
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(port_prefs); i++) {
+ if (strcmp(pref_name, port_prefs[i].pref_name) == 0) {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ module = prefs_find_module(port_prefs[i].module_name);
+ pref = prefs_find_preference(module, port_prefs[i].table_name);
+ if (pref != NULL) {
+ module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ if (pref->type == PREF_DECODE_AS_UINT) {
+ *pref->varp.uint = uval;
+ } else if (pref->type == PREF_DECODE_AS_RANGE) {
+ // The legacy preference was a port number, but the new
+ // preference is a port range. Add to existing range.
+ if (uval) {
+ prefs_range_add_value(pref, uval);
+ }
+ }
+ }
+
+ /* If the value is zero, it wouldn't add to the Decode As tables */
+ if (uval != 0)
+ {
+ sub_dissectors = find_dissector_table(port_prefs[i].table_name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_prefs[i].module_name);
+ if (handle != NULL) {
+ dissector_change_uint(port_prefs[i].table_name, uval, handle);
+ decode_build_reset_list(port_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(port_range_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, port_range_prefs[i].pref_name) == 0)
+ {
+ guint32 range_i, range_j;
+
+ sub_dissectors = find_dissector_table(port_range_prefs[i].table_name);
+ if (sub_dissectors != NULL) {
+ switch (dissector_table_get_type(sub_dissectors)) {
+ case FT_UINT8:
+ case FT_UINT16:
+ case FT_UINT24:
+ case FT_UINT32:
+ break;
+
+ default:
+ g_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", port_range_prefs[i].table_name, get_dissector_table_ui_name(port_range_prefs[i].table_name));
+ g_assert_not_reached();
+ }
+
+ module = prefs_find_module(port_range_prefs[i].module_name);
+ pref = prefs_find_preference(module, port_range_prefs[i].table_name);
+ if (pref != NULL)
+ {
+ if (!prefs_set_range_value_work(pref, value, TRUE, &module->prefs_changed_flags))
+ {
+ return FALSE; /* number was bad */
+ }
+
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_range_prefs[i].module_name);
+ if (handle != NULL) {
+
+ for (range_i = 0; range_i < (*pref->varp.range)->nranges; range_i++) {
+ for (range_j = (*pref->varp.range)->ranges[range_i].low; range_j < (*pref->varp.range)->ranges[range_i].high; range_j++) {
+ dissector_change_uint(port_range_prefs[i].table_name, range_j, handle);
+ decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(range_j), NULL, NULL);
+ }
+
+ dissector_change_uint(port_range_prefs[i].table_name, (*pref->varp.range)->ranges[range_i].high, handle);
+ decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[range_i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(tpkt_subdissector_port_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, tpkt_subdissector_port_prefs[i].pref_name) == 0)
+ {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, tpkt_subdissector_port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ /* If the value is 0 or 102 (default TPKT port), don't add to the Decode As tables */
+ if ((uval != 0) && (uval != 102))
+ {
+ tpkt_handle = find_dissector("tpkt");
+ if (tpkt_handle != NULL) {
+ dissector_change_uint(tpkt_subdissector_port_prefs[i].table_name, uval, tpkt_handle);
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(obsolete_prefs)/sizeof(struct obsolete_pref_name); i++)
+ {
+ if (strcmp(pref_name, obsolete_prefs[i].pref_name) == 0)
+ {
+ /* Just ignore the preference */
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static prefs_set_pref_e
set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
gboolean return_range_errors)
gchar *dotp, *last_dotp;
static gchar *filter_label = NULL;
static gboolean filter_enabled = FALSE;
- gchar *filter_expr = NULL;
module_t *module, *containing_module;
pref_t *pref;
int type;
+ //The PRS_GUI field names are here for backwards compatibility
+ //display filters have been converted to a UAT.
if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) {
+ /* Assume that PRS_GUI_FILTER_EXPR follows this preference. In case of
+ * malicious preference files, free the previous value to limit the size
+ * of leaked memory. */
+ g_free(filter_label);
filter_label = g_strdup(value);
} else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) {
filter_enabled = (strcmp(value, "TRUE") == 0) ? TRUE : FALSE;
} else if (strcmp(pref_name, PRS_GUI_FILTER_EXPR) == 0) {
- filter_expr = g_strdup(value);
- filter_expression_new(filter_label, filter_expr, filter_enabled);
+ /* Comments not supported for "old" preference style */
+ filter_expression_new(filter_label, value, "", filter_enabled);
g_free(filter_label);
- g_free(filter_expr);
+ filter_label = NULL;
+ /* Remember to save the new UAT to file. */
+ prefs.filter_expressions_old = TRUE;
} else if (strcmp(pref_name, "gui.version_in_start_page") == 0) {
/* Convert deprecated value to closest current equivalent */
if (g_ascii_strcasecmp(value, "true") == 0) {
gbl_resolv_flags.mac_name = TRUE;
gbl_resolv_flags.network_name = TRUE;
gbl_resolv_flags.transport_name = TRUE;
- gbl_resolv_flags.concurrent_dns = TRUE;
}
else if (g_ascii_strcasecmp(value, "false") == 0) {
disable_name_resolution();
}
} else if (deprecated_heur_dissector_pref(pref_name, value)) {
/* Handled within deprecated_heur_dissector_pref() if found */
+ } else if (deprecated_enable_dissector_pref(pref_name, value)) {
+ /* Handled within deprecated_enable_dissector_pref() if found */
+ } else if (deprecated_port_pref(pref_name, value)) {
+ /* Handled within deprecated_port_pref() if found */
} else {
/* Handle deprecated "global" options that don't have a module
* associated with them
* its modern name, the Nortel Discovery Protocol (NDP).
*/
if (module == NULL) {
- if (strcmp(pref_name, "column") == 0)
- module = gui_column_module;
- else if (strcmp(pref_name, "Diameter") == 0)
- module = prefs_find_module("diameter");
- else if (strcmp(pref_name, "bxxp") == 0)
- module = prefs_find_module("beep");
- else if (strcmp(pref_name, "gtpv0") == 0 ||
- strcmp(pref_name, "gtpv1") == 0)
- module = prefs_find_module("gtp");
- else if (strcmp(pref_name, "smpp-gsm-sms") == 0)
- module = prefs_find_module("gsm-sms-ud");
- else if (strcmp(pref_name, "dcp") == 0)
- module = prefs_find_module("dccp");
- else if (strcmp(pref_name, "x.25") == 0)
- module = prefs_find_module("x25");
- else if (strcmp(pref_name, "x411") == 0)
- module = prefs_find_module("p1");
- else if (strcmp(pref_name, "nsip") == 0)
- module = prefs_find_module("gprs-ns");
- else if (strcmp(pref_name, "sonmp") == 0)
- module = prefs_find_module("ndp");
- else if (strcmp(pref_name, "etheric") == 0 ||
- strcmp(pref_name, "isup_thin") == 0) {
- /* This protocol was removed 7. July 2009 */
- return PREFS_SET_OBSOLETE;
+ /*
+ * See if there's a backwards-compatibility name
+ * that maps to this module.
+ */
+ module = prefs_find_module_alias(pref_name);
+ if (module == NULL) {
+ /*
+ * There's no alias for the module; see if the
+ * module name matches any protocol aliases.
+ */
+ header_field_info *hfinfo = proto_registrar_get_byalias(pref_name);
+ if (hfinfo) {
+ module = (module_t *) wmem_tree_lookup_string(prefs_modules, hfinfo->abbrev, WMEM_TREE_STRING_NOCASE);
+ }
+ }
+ if (module == NULL) {
+ /*
+ * There aren't any aliases. Was the module
+ * removed rather than renamed?
+ */
+ if (strcmp(pref_name, "etheric") == 0 ||
+ strcmp(pref_name, "isup_thin") == 0) {
+ /*
+ * The dissectors for these protocols were
+ * removed as obsolete on 2009-07-70 in change
+ * 739bfc6ff035583abb9434e0e988048de38a8d9a.
+ */
+ return PREFS_SET_OBSOLETE;
+ }
}
if (module) {
- g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
+ g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s\"\n"
"Save your preferences to make this change permanent.",
- pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
+ pref_name, dotp+1, module->name, dotp+1);
prefs.unknown_prefs = TRUE;
}
}
/* "gui" prefix was added to column preferences for better organization
* within the preferences file
*/
- if ((strcmp(pref_name, PRS_COL_HIDDEN) == 0) ||
- (strcmp(pref_name, PRS_COL_FMT) == 0)) {
+ if (module == gui_column_module) {
/* While this has a subtree, there is no apply callback, so no
- * need to use prefs_find_preference_with_submodule. */
+ * need to use prefs_find_preference_with_submodule to update
+ * containing_module. It would not be useful. */
pref = prefs_find_preference(module, pref_name);
}
else if (strcmp(module->name, "mgcp") == 0) {
}
} else if (strcmp(module->name, "taps") == 0) {
/* taps preferences moved to "statistics" module */
- if (strcmp(dotp, "update_interval") == 0 ||
- strcmp(dotp, "rtp_player_max_visible") == 0)
+ if (strcmp(dotp, "update_interval") == 0)
pref = prefs_find_preference(stats_module, dotp);
} else if (strcmp(module->name, "packet_list") == 0) {
/* packet_list preferences moved to protocol module */
if (p == value || *p != '\0')
return PREFS_SET_SYNTAX_ERR; /* number was bad */
if (*pref->varp.uint != uval) {
- containing_module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
break;
+ case PREF_DECODE_AS_UINT:
+ {
+ /* This is for backwards compatibility in case any of the preferences
+ that shared the "Decode As" preference name and used to be PREF_UINT
+ are now applied directly to the Decode As funtionality */
+
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle;
+
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, pref->info.base);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+
+ if (*pref->varp.uint != uval) {
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.uint = uval;
+
+ /* Name of preference is the dissector table */
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
+ if (handle != NULL) {
+ if (uval != 0) {
+ dissector_change_uint(pref->name, uval, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+ } else {
+ dissector_delete_uint(pref->name, *pref->varp.uint, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), pref->varp.uint, NULL, NULL);
+ }
+ /* XXX - Do we save the decode_as_entries file here? */
+ }
+ }
+ }
+ break;
+ }
case PREF_BOOL:
/* XXX - give an error if it's neither "true" nor "false"? */
if (g_ascii_strcasecmp(value, "true") == 0)
else
bval = FALSE;
if (*pref->varp.boolp != bval) {
- containing_module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.boolp = bval;
}
break;
enum_val = find_val_for_string(value, pref->info.enum_info.enumvals,
*pref->varp.enump);
if (*pref->varp.enump != enum_val) {
- containing_module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.enump = enum_val;
}
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
- prefs_set_string_like_value(pref, value, &containing_module->prefs_changed);
+ containing_module->prefs_changed_flags |= prefs_set_string_value(pref, value, pref_current);
break;
case PREF_RANGE:
{
if (!prefs_set_range_value_work(pref, value, return_range_errors,
- &containing_module->prefs_changed))
+ &containing_module->prefs_changed_flags))
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ break;
+ }
+ case PREF_DECODE_AS_RANGE:
+ {
+ /* This is for backwards compatibility in case any of the preferences
+ that shared the "Decode As" preference name and used to be PREF_RANGE
+ are now applied directly to the Decode As funtionality */
+ range_t *newrange;
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle;
+ guint32 i, j;
+
+ if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
+ return_range_errors) != CVT_NO_ERROR) {
return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ }
+
+ if (!ranges_are_equal(*pref->varp.range, newrange)) {
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = newrange;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+ /* Name of preference is the dissector table */
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
+ if (handle != NULL) {
+ /* Delete all of the old values from the dissector table */
+ for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+ for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+ dissector_delete_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+ }
+
+ /* Add new values to the dissector table */
+ for (i = 0; i < newrange->nranges; i++) {
+ for (j = newrange->ranges[i].low; j < newrange->ranges[i].high; j++) {
+ dissector_change_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_change_uint(pref->name, newrange->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(newrange->ranges[i].high), NULL, NULL);
+ }
+
+ /* XXX - Do we save the decode_as_entries file here? */
+ }
+ }
+ } else {
+ wmem_free(wmem_epan_scope(), newrange);
+ }
break;
}
if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
(pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
(pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
- containing_module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
pref->varp.colorp->red = RED_COMPONENT(cval);
pref->varp.colorp->green = GREEN_COMPONENT(cval);
pref->varp.colorp->blue = BLUE_COMPONENT(cval);
}
case PREF_CUSTOM:
- return pref->custom_cbs.set_cb(pref, value, &containing_module->prefs_changed);
+ return pref->custom_cbs.set_cb(pref, value, &containing_module->prefs_changed_flags);
case PREF_STATIC_TEXT:
case PREF_UAT:
type_name = "String";
break;
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
type_name = "Filename";
break;
type_name = "Custom";
break;
+ case PREF_DECODE_AS_UINT:
+ type_name = "Decode As value";
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ type_name = "Range (for Decode As)";
+ break;
+
case PREF_STATIC_TEXT:
type_name = "Static text";
break;
return type_name;
}
+unsigned int
+prefs_get_effect_flags(pref_t *pref)
+{
+ if (pref == NULL)
+ return 0;
+
+ return pref->effect_flags;
+}
+
+void
+prefs_set_effect_flags(pref_t *pref, unsigned int flags)
+{
+ if (pref != NULL) {
+ pref->effect_flags = flags;
+ }
+}
+
+void
+prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags)
+{
+ prefs_set_effect_flags(prefs_find_preference(module, pref), flags);
+}
+
+unsigned int
+prefs_get_module_effect_flags(module_t * module)
+{
+ if (module == NULL)
+ return 0;
+
+ return module->effect_flags;
+}
+
+void
+prefs_set_module_effect_flags(module_t * module, unsigned int flags)
+{
+ if (module != NULL) {
+ module->effect_flags = flags;
+ }
+}
+
char *
prefs_pref_type_description(pref_t *pref)
{
}
g_string_append(enum_str, "\n(case-insensitive).");
return g_string_free(enum_str, FALSE);
- break;
}
case PREF_STRING:
type_desc = "A string";
break;
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
type_desc = "A path to a file";
break;
type_desc = "A custom value";
break;
+ case PREF_DECODE_AS_UINT:
+ type_desc = "An integer value used in Decode As";
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ type_desc = "A string denoting an positive integer range for Decode As";
+ break;
+
case PREF_STATIC_TEXT:
type_desc = "[Static text]";
break;
return g_strdup(type_desc);
}
-static gboolean
+gboolean
prefs_pref_is_default(pref_t *pref)
{
int type;
switch (type) {
+ case PREF_DECODE_AS_UINT:
+ if (pref->default_val.uint == *pref->varp.uint)
+ return TRUE;
+ break;
+
case PREF_UINT:
if (pref->default_val.uint == *pref->varp.uint)
return TRUE;
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
if (!(g_strcmp0(pref->default_val.string, *pref->varp.string)))
return TRUE;
break;
+ case PREF_DECODE_AS_RANGE:
case PREF_RANGE:
{
if ((ranges_are_equal(pref->default_val.range, *pref->varp.range)))
switch (type) {
+ case PREF_DECODE_AS_UINT:
case PREF_UINT:
{
guint pref_uint = *(guint *) valp;
}
case PREF_BOOL:
- return g_strdup_printf("%s", (*(gboolean *) valp) ? "TRUE" : "FALSE");
+ return g_strdup((*(gboolean *) valp) ? "TRUE" : "FALSE");
case PREF_ENUM:
{
}
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
return g_strdup(*(const char **) valp);
+ case PREF_DECODE_AS_RANGE:
case PREF_RANGE:
/* Convert wmem to g_alloc memory */
tmp_value = range_convert_range(NULL, *(range_t **) valp);
int type;
type = pref->type;
+
if (IS_PREF_OBSOLETE(type)) {
/*
* This preference is no longer supported; it's not a
case PREF_UAT:
/* Nothing to do; don't bother printing the description */
return;
+ case PREF_DECODE_AS_UINT:
+ case PREF_DECODE_AS_RANGE:
+ /* Data is saved through Decode As mechanism and not part of preferences file */
+ return;
default:
break;
}
}
+static void
+count_non_uat_pref(gpointer data, gpointer user_data)
+{
+ pref_t *pref = (pref_t *)data;
+ int *arg = (int *)user_data;
+
+ switch (pref->type)
+ {
+ case PREF_UAT:
+ case PREF_OBSOLETE:
+ case PREF_DECODE_AS_UINT:
+ case PREF_DECODE_AS_RANGE:
+ //These types are not written in preference file
+ break;
+ default:
+ (*arg)++;
+ break;
+ }
+}
+
+static int num_non_uat_prefs(module_t *module)
+{
+ int num = 0;
+
+ g_list_foreach(module->prefs, count_non_uat_pref, &num);
+
+ return num;
+}
+
/*
* Write out all preferences for a module.
*/
/* Write a header for the main modules and GUI sub-modules */
if (((module->parent == NULL) || (module->parent == gui_module)) &&
((prefs_module_has_submodules(module)) ||
- (module->numprefs > 0) ||
+ (num_non_uat_prefs(module) > 0) ||
(module->name == NULL))) {
if ((module->name == NULL) && (module->parent != NULL)) {
fprintf(gui_pref_arg->pf, "\n####### %s: %s ########\n", module->parent->title, module->title);
pf = stdout;
}
+ /*
+ * If the preferences file is being written, be sure to write UAT files
+ * first that were migrated from the preferences file.
+ */
+ if (pf_path_return != NULL) {
+ if (prefs.filter_expressions_old) {
+ char *err = NULL;
+ prefs.filter_expressions_old = FALSE;
+ if (!uat_save(uat_get_table_by_name("Display expressions"), &err)) {
+ g_warning("Unable to save Display expressions: %s", err);
+ g_free(err);
+ }
+ }
+ }
+
fputs("# Configuration file for Wireshark " VERSION ".\n"
"#\n"
"# This file is regenerated each time preferences are saved within\n"
write_module_prefs(gui_module, &write_gui_pref_info);
- {
- struct filter_expression *fe = *(struct filter_expression **)prefs.filter_expressions;
-
- if (fe != NULL)
- fprintf(pf, "\n####### Filter Expressions ########\n\n");
-
- while (fe != NULL) {
- if (fe->deleted == FALSE) {
- fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_LABEL, fe->label);
- fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_ENABLED,
- fe->enabled == TRUE ? "TRUE" : "FALSE");
- fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_EXPR, fe->expression);
- }
- fe = fe->next;
- }
- }
-
write_gui_pref_info.is_gui_module = FALSE;
prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info);