/* prefs.c
* Routines for handling preferences
*
- * $Id$
- *
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
#include <glib.h>
#include <stdio.h>
-#include <epan/filesystem.h>
+#include <wsutil/filesystem.h>
#include <epan/address.h>
#include <epan/addr_resolv.h>
#include <epan/oids.h>
#include "epan/filter_expressions.h"
#include "epan/wmem/wmem.h"
+#include <epan/stats_tree.h>
/* Internal functions */
static module_t *find_subtree(module_t *parent, const char *tilte);
const char *name, const char *title, const char *description, gboolean is_subtree,
void (*apply_cb)(void), gboolean use_gui);
static prefs_set_pref_e set_pref(gchar*, const gchar*, void *, gboolean);
-static char * join_string_list(GList *);
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);
};
#if defined(HAVE_PCAP_CREATE)
- static gint num_capture_cols = 7;
- static const gchar *capture_cols[7] = {
- "INTERFACE",
- "LINK",
- "PMODE",
- "SNAPLEN",
- "MONITOR",
- "BUFFER",
- "FILTER"};
+/* Can set monitor mode and buffer size. */
+static gint num_capture_cols = 7;
+static const gchar *capture_cols[7] = {
+ "INTERFACE",
+ "LINK",
+ "PMODE",
+ "SNAPLEN",
+ "MONITOR",
+ "BUFFER",
+ "FILTER"
+};
+#define CAPTURE_COL_TYPE_DESCRIPTION \
+ "Possible values: INTERFACE, LINK, PMODE, SNAPLEN, MONITOR, BUFFER, FILTER\n"
#elif defined(_WIN32) && !defined (HAVE_PCAP_CREATE)
- static gint num_capture_cols = 6;
- static const gchar *capture_cols[6] = {
- "INTERFACE",
- "LINK",
- "PMODE",
- "SNAPLEN",
- "BUFFER",
- "FILTER"};
+/* Can set buffer size but not monitor mode. */
+static gint num_capture_cols = 6;
+static const gchar *capture_cols[6] = {
+ "INTERFACE",
+ "LINK",
+ "PMODE",
+ "SNAPLEN",
+ "BUFFER",
+ "FILTER"
+};
+#define CAPTURE_COL_TYPE_DESCRIPTION \
+ "Possible values: INTERFACE, LINK, PMODE, SNAPLEN, BUFFER, FILTER\n"
#else
- static gint num_capture_cols = 5;
- static const gchar *capture_cols[5] = {
- "INTERFACE",
- "LINK",
- "PMODE",
- "SNAPLEN",
- "FILTER"};
+/* Can neither set buffer size nor monitor mode. */
+static gint num_capture_cols = 5;
+static const gchar *capture_cols[5] = {
+ "INTERFACE",
+ "LINK",
+ "PMODE",
+ "SNAPLEN",
+ "FILTER"
+};
+#define CAPTURE_COL_TYPE_DESCRIPTION \
+ "Possible values: INTERFACE, LINK, PMODE, SNAPLEN, FILTER\n"
#endif
/*
* List of all modules with preference settings.
*/
-static emem_tree_t *prefs_modules = NULL;
+static wmem_tree_t *prefs_modules = NULL;
/*
* List of all modules that should show up at the top level of the
* tree in the preference dialog box.
*/
-static emem_tree_t *prefs_top_level_modules = NULL;
+static wmem_tree_t *prefs_top_level_modules = NULL;
/** Sets up memory used by proto routines. Called at program startup */
void
prefs_init(void)
{
- prefs_modules = pe_tree_create(EMEM_TREE_TYPE_RED_BLACK, "prefs_modules");
- prefs_top_level_modules = pe_tree_create(EMEM_TREE_TYPE_RED_BLACK, "prefs_top_level_modules");
+ prefs_modules = wmem_tree_new(wmem_epan_scope());
+ prefs_top_level_modules = wmem_tree_new(wmem_epan_scope());
}
static void
static guint
free_module_prefs(module_t *module, gpointer data _U_)
{
- g_list_foreach(module->prefs, free_pref, NULL);
- g_list_free(module->prefs);
+ if (module->prefs) {
+ g_list_foreach(module->prefs, free_pref, NULL);
+ g_list_free(module->prefs);
+ }
module->prefs = NULL;
module->numprefs = 0;
+ if (module->submodules) {
+ prefs_modules_foreach_submodules(module, free_module_prefs, NULL);
+ }
/* We don't free the actual module: its submodules pointer points to
- a pe_tree and the module itself is stored in a pe_tree
+ a wmem_tree and the module itself is stored in a wmem_tree
*/
return 0;
guchar c;
/* this module may have been created as a subtree item previously */
- if((module = find_subtree(parent, title))) {
+ if ((module = find_subtree(parent, title))) {
/* the module is currently a subtree */
module->name = name;
module->apply_cb = apply_cb;
module->description = description;
if (prefs_find_module(name) == NULL) {
- pe_tree_insert_string(prefs_modules, name, module,
- EMEM_TREE_STRING_NOCASE);
+ wmem_tree_insert_string(prefs_modules, name, module,
+ WMEM_TREE_STRING_NOCASE);
}
return module;
}
- module = g_new(module_t,1);
+ module = wmem_new(wmem_epan_scope(), module_t);
module->name = name;
module->title = title;
module->description = description;
/*
* Insert this module in the list of all modules.
*/
- pe_tree_insert_string(prefs_modules, name, module, EMEM_TREE_STRING_NOCASE);
+ wmem_tree_insert_string(prefs_modules, name, module, WMEM_TREE_STRING_NOCASE);
} else {
/*
* This has no name, just a title; check to make sure it's a
/*
* It goes at the top.
*/
- pe_tree_insert_string(prefs_top_level_modules, title, module, EMEM_TREE_STRING_NOCASE);
+ wmem_tree_insert_string(prefs_top_level_modules, title, module, WMEM_TREE_STRING_NOCASE);
} else {
/*
* It goes into the list for this module.
*/
if (parent->submodules == NULL)
- parent->submodules = pe_tree_create(EMEM_TREE_TYPE_RED_BLACK, "prefs_submodules");
+ parent->submodules = wmem_tree_new(wmem_epan_scope());
- pe_tree_insert_string(parent->submodules, title, module, EMEM_TREE_STRING_NOCASE);
+ wmem_tree_insert_string(parent->submodules, title, module, WMEM_TREE_STRING_NOCASE);
}
return module;
subtree_module = protocols_module;
- if(subtree) {
+ if (subtree) {
/* take a copy of the buffer, orig keeps a base pointer while ptr
* walks through the string */
orig = ptr = g_strdup(subtree);
- while(ptr && *ptr) {
+ while (ptr && *ptr) {
- if((sep = strchr(ptr, '/')))
+ if ((sep = strchr(ptr, '/')))
*sep++ = '\0';
- if(!(new_module = find_subtree(subtree_module, ptr))) {
+ if (!(new_module = find_subtree(subtree_module, ptr))) {
/*
* There's no such module; create it, with the description
* being the name (if it's later registered explicitly
module_t *
prefs_find_module(const char *name)
{
- return (module_t *)pe_tree_lookup_string(prefs_modules, name, EMEM_TREE_STRING_NOCASE);
+ return (module_t *)wmem_tree_lookup_string(prefs_modules, name, WMEM_TREE_STRING_NOCASE);
}
static module_t *
find_subtree(module_t *parent, const char *name)
{
- return (module_t *)pe_tree_lookup_string(parent ? parent->submodules : prefs_top_level_modules, name, EMEM_TREE_STRING_NOCASE);
+ return (module_t *)wmem_tree_lookup_string(parent ? parent->submodules : prefs_top_level_modules, name, WMEM_TREE_STRING_NOCASE);
}
/*
module_t *module = (module_t*)value;
call_foreach_t *call_data = (call_foreach_t*)data;
- if (!module->obsolete) {
+ if (!module->obsolete)
call_data->ret = (*call_data->callback)(module, call_data->user_data);
- }
+
return (call_data->ret != 0);
}
static guint
-prefs_module_list_foreach(emem_tree_t *module_list, module_cb callback,
+prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
gpointer user_data)
{
call_foreach_t call_data;
call_data.callback = callback;
call_data.user_data = user_data;
call_data.ret = 0;
- pe_tree_foreach(module_list, call_foreach_cb, &call_data);
+ wmem_tree_foreach(module_list, call_foreach_cb, &call_data);
return call_data.ret;
}
return FALSE;
}
- if (module->submodules->tree == NULL) {
+ if (wmem_tree_is_empty(module->submodules)) {
return FALSE;
}
void
prefs_apply_all(void)
{
- pe_tree_foreach(prefs_modules, call_apply_cb, NULL);
+ wmem_tree_foreach(prefs_modules, call_apply_cb, NULL);
}
/*
preference->title = title;
preference->description = description;
preference->type = type;
+ preference->gui = GUI_ALL; /* default */
if (title != NULL)
preference->ordinal = module->numprefs;
else
* Make sure the preference name doesn't begin with the
* module name, as that's redundant and Just Silly.
*/
- if(!((strncmp(name, module->name, strlen(module->name)) != 0) ||
+ if (!((strncmp(name, module->name, strlen(module->name)) != 0) ||
(((name[strlen(module->name)]) != '.') && ((name[strlen(module->name)]) != '_'))))
g_error("Preference %s begins with the module name", name);
}
return strcmp(name, pref->name);
}
-static gboolean module_find_pref_cb(void *value, void *data)
+static gboolean
+module_find_pref_cb(void *value, void *data)
{
find_pref_arg_t* arg = (find_pref_arg_t*)data;
GList *list_entry;
if (module->submodules != NULL)
{
arg.name = name;
- pe_tree_foreach(module->submodules, module_find_pref_cb, &arg);
+ wmem_tree_foreach(module->submodules, module_find_pref_cb, &arg);
}
list_entry = arg.list_entry;
}
if (list_entry == NULL)
- {
return NULL; /* no such preference */
- }
return (struct preference *) list_entry->data;
}
*/
static void
prefs_register_uint_custom_preference(module_t *module, const char *name,
- const char *title, const char *description,
- struct pref_custom_cbs* custom_cbs, guint *var)
+ const char *title, const char *description,
+ struct pref_custom_cbs* custom_cbs, guint *var)
{
pref_t *preference;
* XXX - This should be temporary until we can find a better way
* to do "custom" preferences
*/
-static
-void prefs_register_string_custom_preference(module_t *module, const char *name,
+static void
+prefs_register_string_custom_preference(module_t *module, const char *name,
const char *title, const char *description,
struct pref_custom_cbs* custom_cbs, const char **var)
{
preference->varp.uat = uat;
}
+/*
+ * Register a uat 'preference' for QT only. It adds a button that opens the uat's window in the
+ * preferences tab of the module.
+ */
+extern void
+prefs_register_uat_preference_qt(module_t *module, const char *name,
+ const char *title, const char *description,
+ uat_t* uat)
+{
+
+ pref_t* preference = register_preference(module, name, title, description, PREF_UAT);
+
+ preference->varp.uat = uat;
+
+ preference->gui = GUI_QT;
+}
+
/*
* Register a color preference.
*/
-void prefs_register_color_preference(module_t *module, const char *name,
- const char *title, const char *description, color_t *color)
+void
+prefs_register_color_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ color_t *color)
{
pref_t* preference = register_preference(module, name, title, description, PREF_COLOR);
*/
typedef void (*pref_custom_list_init_cb) (pref_t* pref, GList** value);
-static
-void prefs_register_list_custom_preference(module_t *module, const char *name,
- const char *title, const char *description, struct pref_custom_cbs* custom_cbs,
- pref_custom_list_init_cb init_cb, GList** list)
+static void
+prefs_register_list_custom_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ struct pref_custom_cbs* custom_cbs,
+ pref_custom_list_init_cb init_cb,
+ GList** list)
{
pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
/*
* Register a custom preference.
*/
-void prefs_register_custom_preference(module_t *module, const char *name,
- const char *title, const char *description, struct pref_custom_cbs* custom_cbs,
- void** custom_data _U_)
+void
+prefs_register_custom_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ struct pref_custom_cbs* custom_cbs,
+ void **custom_data _U_)
{
pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
extern gboolean
prefs_get_preference_obsolete(pref_t *pref)
{
- if (pref) {
+ if (pref)
return pref->type == PREF_OBSOLETE ? TRUE : FALSE;
- }
+
return TRUE;
}
}
/* Return the value assigned to the given uint preference. */
-guint prefs_get_uint_preference(pref_t *pref)
+guint
+prefs_get_uint_preference(pref_t *pref)
{
if (pref && pref->type == PREF_UINT)
return *pref->varp.uint;
{ NULL, NULL, 0 }
};
-static void stats_callback(void)
+static const enum_val_t gui_qt_language[] = {
+ {"Auto-Detect", "auto", 0},
+ {"English", "en", 1},
+ {"French", "fr", 2},
+ {"German", "de", 3},
+ {"Chinese", "zh_CN", 4},
+ {"Polish", "pl", 5},
+ {"Japanese", "ja_JP", 6},
+ {NULL, NULL, -1}
+};
+
+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 },
+ { "average", "Average value of the node", ST_SORT_COL_AVG },
+ { "min", "Minimum value of the node", ST_SORT_COL_MIN },
+ { "max", "Maximum value of the node", ST_SORT_COL_MAX },
+ { "burst", "Burst rate of the node", ST_SORT_COL_BURSTRATE },
+ { NULL, NULL, 0 }
+};
+
+static void
+stats_callback(void)
{
/* Test for a sane tap update interval */
- if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000) {
- prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
- }
+ 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;
+ 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;
+ }
+ else if (prefs.st_burst_resolution > ST_MAX_BURSTRES) {
+ prefs.st_burst_resolution = ST_MAX_BURSTRES;
+ }
+ /* make sure burst window value makes sense */
+ if (prefs.st_burst_windowlen < prefs.st_burst_resolution) {
+ prefs.st_burst_windowlen = prefs.st_burst_resolution;
+ }
+ /* round burst window down to multiple of resolution */
+ prefs.st_burst_windowlen -= prefs.st_burst_windowlen%prefs.st_burst_resolution;
+ if ((prefs.st_burst_windowlen/prefs.st_burst_resolution) > ST_MAX_BURSTBUCKETS) {
+ prefs.st_burst_windowlen = prefs.st_burst_resolution*ST_MAX_BURSTBUCKETS;
+ }
}
-static void gui_callback(void)
+static void
+gui_callback(void)
{
/* Ensure there is at least one file count */
if (prefs.gui_recent_files_count_max == 0)
prefs.gui_recent_df_entries_max = 10;
}
-static void gui_layout_callback(void)
+static void
+gui_layout_callback(void)
{
if (prefs.gui_layout_type == layout_unused ||
prefs.gui_layout_type >= layout_type_max) {
/*
* Console log level custom preference functions
*/
-static void console_log_level_reset_cb(pref_t* pref)
+static void
+console_log_level_reset_cb(pref_t* pref)
{
*pref->varp.uint = pref->default_val.uint;
}
-static prefs_set_pref_e console_log_level_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+static prefs_set_pref_e
+console_log_level_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
{
guint uval;
#define PRS_COL_NUM "column.number"
static module_t *gui_column_module = NULL;
-static void column_hidden_free_cb(pref_t* pref)
+static void
+column_hidden_free_cb(pref_t* pref)
{
g_free((char *)*pref->varp.string);
*pref->varp.string = NULL;
pref->default_val.string = NULL;
}
-static void column_hidden_reset_cb(pref_t* pref)
+static void
+column_hidden_reset_cb(pref_t* pref)
{
g_free((void *)*pref->varp.string);
*pref->varp.string = g_strdup(pref->default_val.string);
}
-static prefs_set_pref_e column_hidden_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+static prefs_set_pref_e
+column_hidden_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
{
GList *clp;
fmt_data *cfmt;
return PREFS_SET_OK;
}
-static const char * column_hidden_type_name_cb(void) {
+static const char *
+column_hidden_type_name_cb(void)
+{
return "Packet list hidden columns";
}
-static char * column_hidden_type_description_cb(void) {
+static char *
+column_hidden_type_description_cb(void)
+{
return g_strdup("List all columns to hide in the packet list.");
}
-static char * column_hidden_to_str_cb(pref_t* pref, gboolean default_val) {
+static char *
+column_hidden_to_str_cb(pref_t* pref, gboolean default_val)
+{
GString *cols_hidden = g_string_new ("");
GList *clp;
fmt_data *cfmt;
prefs_fmt = g_strdup(col_format_to_string(cfmt->fmt));
}
if (!cfmt->visible) {
- if (cols_hidden->len) {
+ if (cols_hidden->len)
g_string_append (cols_hidden, ",");
- }
g_string_append (cols_hidden, prefs_fmt);
}
clp = clp->next;
return g_string_free (cols_hidden, FALSE);
}
-static gboolean column_hidden_is_default_cb(pref_t* pref) {
+static gboolean
+column_hidden_is_default_cb(pref_t* pref)
+{
char *cur_hidden_str = column_hidden_to_str_cb(pref, FALSE);
gboolean is_default = g_strcmp0(cur_hidden_str, pref->default_val.string) == 0;
/* Number of columns "preference". This is only used internally and is not written to the
* preference file
*/
-static void column_num_reset_cb(pref_t* pref)
+static void
+column_num_reset_cb(pref_t* pref)
{
*pref->varp.uint = pref->default_val.uint;
}
-static prefs_set_pref_e column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, gboolean* changed _U_)
+static prefs_set_pref_e
+column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, gboolean* changed _U_)
{
/* Don't write this to the preferences file */
return PREFS_SET_OK;
}
-static const char * column_num_type_name_cb(void) {
+static const char *
+column_num_type_name_cb(void)
+{
return NULL;
}
-static char * column_num_type_description_cb(void) {
+static char *
+column_num_type_description_cb(void)
+{
return g_strdup("");
}
-static gboolean column_num_is_default_cb(pref_t* pref _U_) {
+static gboolean
+column_num_is_default_cb(pref_t* pref _U_)
+{
return TRUE;
}
-static char * column_num_to_str_cb(pref_t* pref _U_, gboolean default_val _U_) {
+static char *
+column_num_to_str_cb(pref_t* pref _U_, gboolean default_val _U_)
+{
return g_strdup("");
}
/*
* Column format custom preference functions
*/
-static void column_format_init_cb(pref_t* pref, GList** value)
+static void
+column_format_init_cb(pref_t* pref, GList** value)
{
fmt_data *src_cfmt, *dest_cfmt;
GList *entry;
}
}
-static void column_format_free_cb(pref_t* pref)
+static void
+column_format_free_cb(pref_t* pref)
{
free_col_info(*pref->varp.list);
free_col_info(pref->default_val.list);
}
-static void column_format_reset_cb(pref_t* pref)
+static void
+column_format_reset_cb(pref_t* pref)
{
fmt_data *src_cfmt, *dest_cfmt;
GList *entry;
}
col_num_pref = prefs_find_preference(gui_column_module, PRS_COL_NUM);
+ g_assert(col_num_pref != NULL); /* Should never happen */
column_num_reset_cb(col_num_pref);
}
-static prefs_set_pref_e column_format_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+static prefs_set_pref_e
+column_format_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
{
GList *col_l, *col_l_elt;
fmt_data *cfmt;
}
/* Check to make sure all column formats are valid. */
col_l_elt = g_list_first(col_l);
- while(col_l_elt) {
+ while (col_l_elt) {
fmt_data cfmt_check;
/* Go past the title. */
free_col_info(*pref->varp.list);
*pref->varp.list = NULL;
hidden_pref = prefs_find_preference(gui_column_module, PRS_COL_HIDDEN);
+ g_assert(hidden_pref != NULL); /* Should never happen */
col_num_pref = prefs_find_preference(gui_column_module, PRS_COL_NUM);
+ g_assert(col_num_pref != NULL); /* Should never happen */
llen = g_list_length(col_l);
*col_num_pref->varp.uint = llen / 2;
col_l_elt = g_list_first(col_l);
- while(col_l_elt) {
+ while (col_l_elt) {
cfmt = g_new(fmt_data,1);
cfmt->title = g_strdup((gchar *)col_l_elt->data);
col_l_elt = col_l_elt->next;
parse_column_format(cfmt, (char *)col_l_elt->data);
- cfmt->visible = prefs_is_column_visible((gchar*)(*hidden_pref->varp.string), cfmt);
+ cfmt->visible = prefs_is_column_visible(*hidden_pref->varp.string, cfmt);
col_l_elt = col_l_elt->next;
*pref->varp.list = g_list_append(*pref->varp.list, cfmt);
}
}
-static const char * column_format_type_name_cb(void) {
+static const char *
+column_format_type_name_cb(void)
+{
return "Packet list column format";
}
-static char * column_format_type_description_cb(void) {
+static char *
+column_format_type_description_cb(void)
+{
return g_strdup("Each pair of strings consists of a column title and its format");
}
-static gboolean column_format_is_default_cb(pref_t* pref) {
+static gboolean
+column_format_is_default_cb(pref_t* pref)
+{
GList *clp = *pref->varp.list,
*pref_col = g_list_first(clp),
*def_col = g_list_first(pref->default_val.list);
return is_default;
}
-static char * column_format_to_str_cb(pref_t* pref, gboolean default_val) {
+static char *
+column_format_to_str_cb(pref_t* pref, gboolean default_val)
+{
GList *pref_l = default_val ? pref->default_val.list : *pref->varp.list;
GList *clp = g_list_first(pref_l);
GList *col_l;
}
column_format_str = join_string_list(col_l);
-
- /* This frees the list of strings, but not the strings to which it
- refers; they are free'ed in join_string_list(). */
- g_list_free(col_l);
+ prefs_clear_string_list(col_l);
return column_format_str;
}
Copy the pref->capture_columns list (just loaded with the capture_cols[] struct values)
to prefs->default_val.list.
*/
-static void capture_column_init_cb(pref_t* pref, GList** capture_cols_values)
+static void
+capture_column_init_cb(pref_t* pref, GList** capture_cols_values)
{
GList *ccv_list = *capture_cols_values,
*dlist = NULL;
Note that since pref->varp.list points to &prefs.capture_columns, it is
also freed.
*/
-static void capture_column_free_cb(pref_t* pref)
+static void
+capture_column_free_cb(pref_t* pref)
{
GList *clist = prefs.capture_columns;
gchar *col_name;
/* Copy pref->default_val.list to *pref->varp.list.
*/
-static void capture_column_reset_cb(pref_t* pref)
+static void
+capture_column_reset_cb(pref_t* pref)
{
GList *vlist, *dlist;
gchar *vcol;
*pref->varp.list = vlist;
}
-static prefs_set_pref_e capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+static prefs_set_pref_e
+capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
{
GList *col_l = prefs_get_string_list(value);
GList *col_l_elt;
/* Verify that all the column names are valid. If not, use the entire list of valid columns.
*/
- while(col_l_elt) {
+ while (col_l_elt) {
gboolean found_match = FALSE;
col_name = (gchar *)col_l_elt->data;
}
col_l_elt = g_list_first(col_l);
- while(col_l_elt) {
+ while (col_l_elt) {
col_name = (gchar *)col_l_elt->data;
prefs.capture_columns = g_list_append(prefs.capture_columns, col_name);
col_l_elt = col_l_elt->next;
}
-static const char * capture_column_type_name_cb(void) {
+static const char *
+capture_column_type_name_cb(void)
+{
return "Column list";
}
-static char * capture_column_type_description_cb(void) {
- return g_strdup_printf(
+static char *
+capture_column_type_description_cb(void)
+{
+ return g_strdup(
"List of columns to be displayed in the capture options dialog.\n"
- "Possible values: INTERFACE, LINK, PMODE, SNAPLEN, MONITOR, BUFFER, FILTER\n");
+ CAPTURE_COL_TYPE_DESCRIPTION);
}
-static gboolean capture_column_is_default_cb(pref_t* pref) {
+static gboolean
+capture_column_is_default_cb(pref_t* pref)
+{
GList *pref_col = g_list_first(prefs.capture_columns),
*def_col = g_list_first(pref->default_val.list);
gboolean is_default = TRUE;
/* Ensure the same column count */
if (((pref_col == NULL) && (def_col != NULL)) ||
- ((pref_col != NULL) && (def_col == NULL)))
+ ((pref_col != NULL) && (def_col == NULL)))
is_default = FALSE;
return is_default;
}
-static char * capture_column_to_str_cb(pref_t* pref, gboolean default_val) {
+static char *
+capture_column_to_str_cb(pref_t* pref, gboolean default_val)
+{
GList *pref_l = default_val ? pref->default_val.list : prefs.capture_columns;
GList *clp = g_list_first(pref_l);
GList *col_l = NULL;
- gchar *col, *capture_column_str;
-
+ gchar *col;
+ char *capture_column_str;
while (clp) {
col = (gchar *) clp->data;
}
capture_column_str = join_string_list(col_l);
- /* This frees the list of strings, but not the strings to which it
- refers; they are free'ed in write_string_list(). */
- g_list_free(col_l);
+ prefs_clear_string_list(col_l);
return capture_column_str;
}
-static void colorized_frame_free_cb(pref_t* pref)
+static void
+colorized_frame_free_cb(pref_t* pref)
{
g_free((char *)*pref->varp.string);
*pref->varp.string = NULL;
}
-static void colorized_frame_reset_cb(pref_t* pref)
+static void
+colorized_frame_reset_cb(pref_t* pref)
{
g_free((void *)*pref->varp.string);
*pref->varp.string = g_strdup(pref->default_val.string);
}
-static prefs_set_pref_e colorized_frame_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+static prefs_set_pref_e
+colorized_frame_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
{
if (strcmp(*pref->varp.string, value) != 0) {
*changed = TRUE;
return PREFS_SET_OK;
}
-static const char * colorized_frame_type_name_cb(void) {
+static const char *
+colorized_frame_type_name_cb(void)
+{
/* Don't write the colors of the 10 easy-access-colorfilters to the preferences
* file until the colors can be changed in the GUI. Currently this is not really
* possible since the STOCK-icons for these colors are hardcoded.
return NULL;
}
-static char * colorized_frame_type_description_cb(void) {
+static char *
+colorized_frame_type_description_cb(void)
+{
return g_strdup("");
}
-static gboolean colorized_frame_is_default_cb(pref_t* pref _U_) {
+static gboolean
+colorized_frame_is_default_cb(pref_t* pref _U_)
+{
return TRUE;
}
-static char * colorized_frame_to_str_cb(pref_t* pref _U_, gboolean default_val _U_) {
+static char *
+colorized_frame_to_str_cb(pref_t* pref _U_, gboolean default_val _U_)
+{
return g_strdup("");
}
10,
&prefs.gui_auto_scroll_percentage);
+ prefs_register_enum_preference(gui_module, "qt_language",
+ "Qt Language",
+ "Qt Language",
+ &prefs.gui_qt_language, gui_qt_language, FALSE);
+
/* User Interface : Layout */
gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
"Layout content of the pane 3",
(gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
+ prefs_register_bool_preference(gui_module, "packet_editor.enabled",
+ "Enable Packet Editor",
+ "Enable Packet Editor (Experimental)",
+ &prefs.gui_packet_editor);
/* Console
* These are preferences that can be read/written using the
* preference module API. These preferences still use their own
prefs_register_bool_preference(capture_module, "prom_mode", "Capture in promiscuous mode",
"Capture in promiscuous mode?", &prefs.capture_prom_mode);
+ prefs_register_string_preference(capture_module, "devices_filter", "Interface capture filter",
+ "Interface capture filter (Ex: en0(tcp),en1(udp),...)",
+ (const char **)&prefs.capture_devices_filter);
+
prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in Pcap-NG format",
"Capture in Pcap-NG format?", &prefs.capture_pcap_ng);
&prefs.rtp_player_max_visible);
#endif
+ prefs_register_bool_preference(stats_module, "st_enable_burstinfo",
+ "Enable the calculation of burst information",
+ "If enabled burst rates will be calcuted for statistics that use the stats_tree system. "
+ "Burst rates are calculated over a much shorter time interval than the rate column.",
+ &prefs.st_enable_burstinfo);
+
+ prefs_register_bool_preference(stats_module, "st_burst_showcount",
+ "Show burst count for item rather than rate",
+ "If selected the stats_tree statistics nodes will show the count of events "
+ "within the burst window instead of a burst rate. Burst rate is calculated "
+ "as number of events within burst window divided by the burst windown length.",
+ &prefs.st_burst_showcount);
+
+ prefs_register_uint_preference(stats_module, "st_burst_resolution",
+ "Burst rate resolution (ms)",
+ "Sets the duration of the time interval into which events are grouped when calculating "
+ "the burst rate. Higher resolution (smaller number) increases processing overhead.",
+ 10,&prefs.st_burst_resolution);
+
+ prefs_register_uint_preference(stats_module, "st_burst_windowlen",
+ "Burst rate window size (ms)",
+ "Sets the duration of the sliding window during which the burst rate is "
+ "measured. Longer window relative to burst rate resolution increases "
+ "processing overhead. Will be truncated to a multiple of burst resolution.",
+ 10,&prefs.st_burst_windowlen);
+
+ prefs_register_enum_preference(stats_module, "st_sort_defcolflag",
+ "Default sort column for stats_tree stats",
+ "Sets the default column by which stats based on the stats_tree "
+ "system is sorted.",
+ &prefs.st_sort_defcolflag, st_sort_col_vals, FALSE);
+
+ prefs_register_bool_preference(stats_module, "st_sort_defdescending",
+ "Default stats_tree sort order is descending",
+ "When selected, statistics based on the stats_tree system will by default "
+ "be sorted in descending order.",
+ &prefs.st_sort_defdescending);
+
+ prefs_register_bool_preference(stats_module, "st_sort_casesensitve",
+ "Case sensitive sort of stats_tree item names",
+ "When selected, the item/node names of statistics based on the stats_tree "
+ "system will be sorted taking case into account. Else the case of the name "
+ "will be ignored.",
+ &prefs.st_sort_casesensitve);
+
+ prefs_register_bool_preference(stats_module, "st_sort_rng_nameonly",
+ "Always sort 'range' nodes by name",
+ "When selected, the stats_tree nodes representing a range of values "
+ "(0-49, 50-100, etc.) will always be sorted by name (the range of the "
+ "node). Else range nodes are sorted by the same column as the rest of "
+ " the tree.",
+ &prefs.st_sort_rng_nameonly);
+
+ prefs_register_bool_preference(stats_module, "st_sort_rng_fixorder",
+ "Always sort 'range' nodes in ascending order",
+ "When selected, the stats_tree nodes representing a range of values "
+ "(0-49, 50-100, etc.) will always be sorted ascending; else it follows "
+ "the sort direction of the tree. Only effective if \"Always sort "
+ "'range' nodes by name\" is also selected.",
+ &prefs.st_sort_rng_fixorder);
+
+ prefs_register_bool_preference(stats_module, "st_sort_showfullname",
+ "Display the full stats_tree plug-in name",
+ "When selected, the full name (including menu path) of the stats_tree "
+ "plug-in is show in windows. If cleared the plug-in name is shown "
+ "without menu path (only the part of the name after last '/' character.)",
+ &prefs.st_sort_showfullname);
/* Protocols */
protocols_module = prefs_register_module(NULL, "protocols", "Protocols",
GList *
prefs_get_string_list(const gchar *str)
{
- enum { PRE_STRING, IN_QUOT, NOT_IN_QUOT };
-
- gint state = PRE_STRING, i = 0, j = 0;
- gboolean backslash = FALSE;
- guchar cur_c;
- gchar *slstr = NULL;
- GList *sl = NULL;
-
- /* Allocate a buffer for the first string. */
- slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
- j = 0;
-
- for (;;) {
- cur_c = str[i];
- if (cur_c == '\0') {
- /* It's the end of the input, so it's the end of the string we
- were working on, and there's no more input. */
- if (state == IN_QUOT || backslash) {
- /* We were in the middle of a quoted string or backslash escape,
- and ran out of characters; that's an error. */
- g_free(slstr);
- prefs_clear_string_list(sl);
- return NULL;
- }
- slstr[j] = '\0';
- sl = g_list_append(sl, slstr);
- break;
- }
- if (cur_c == '"' && ! backslash) {
- switch (state) {
- case PRE_STRING:
- /* We hadn't yet started processing a string; this starts the
- string, and we're now quoting. */
- state = IN_QUOT;
- break;
- case IN_QUOT:
- /* We're in the middle of a quoted string, and we saw a quotation
- mark; we're no longer quoting. */
- state = NOT_IN_QUOT;
- break;
- case NOT_IN_QUOT:
- /* We're working on a string, but haven't seen a quote; we're
- now quoting. */
- state = IN_QUOT;
- break;
- default:
- break;
- }
- } else if (cur_c == '\\' && ! backslash) {
- /* We saw a backslash, and the previous character wasn't a
- backslash; escape the next character.
-
- This also means we've started a new string. */
- backslash = TRUE;
- if (state == PRE_STRING)
- state = NOT_IN_QUOT;
- } else if (cur_c == ',' && state != IN_QUOT && ! backslash) {
- /* We saw a comma, and we're not in the middle of a quoted string
- 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);
-
- /* ...and the beginning of a new string. */
- state = PRE_STRING;
- slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
- j = 0;
- } else if (!isspace(cur_c) || state != PRE_STRING) {
- /* Either this isn't a white-space character, or we've started a
- string (i.e., already seen a non-white-space character for that
- string and put it into the string).
-
- The character is to be put into the string; do so if there's
- room. */
- if (j < COL_MAX_LEN) {
- slstr[j] = cur_c;
- j++;
- }
+ enum { PRE_STRING, IN_QUOT, NOT_IN_QUOT };
+
+ gint state = PRE_STRING, i = 0, j = 0;
+ gboolean backslash = FALSE;
+ guchar cur_c;
+ gchar *slstr = NULL;
+ GList *sl = NULL;
+
+ /* Allocate a buffer for the first string. */
+ slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ j = 0;
+
+ for (;;) {
+ cur_c = str[i];
+ if (cur_c == '\0') {
+ /* It's the end of the input, so it's the end of the string we
+ were working on, and there's no more input. */
+ if (state == IN_QUOT || backslash) {
+ /* We were in the middle of a quoted string or backslash escape,
+ and ran out of characters; that's an error. */
+ g_free(slstr);
+ prefs_clear_string_list(sl);
+ return NULL;
+ }
+ slstr[j] = '\0';
+ sl = g_list_append(sl, slstr);
+ break;
+ }
+ if (cur_c == '"' && ! backslash) {
+ switch (state) {
+ case PRE_STRING:
+ /* We hadn't yet started processing a string; this starts the
+ string, and we're now quoting. */
+ state = IN_QUOT;
+ break;
+ case IN_QUOT:
+ /* We're in the middle of a quoted string, and we saw a quotation
+ mark; we're no longer quoting. */
+ state = NOT_IN_QUOT;
+ break;
+ case NOT_IN_QUOT:
+ /* We're working on a string, but haven't seen a quote; we're
+ now quoting. */
+ state = IN_QUOT;
+ break;
+ default:
+ break;
+ }
+ } else if (cur_c == '\\' && ! backslash) {
+ /* We saw a backslash, and the previous character wasn't a
+ backslash; escape the next character.
+
+ This also means we've started a new string. */
+ backslash = TRUE;
+ if (state == PRE_STRING)
+ state = NOT_IN_QUOT;
+ } else if (cur_c == ',' && state != IN_QUOT && ! backslash) {
+ /* We saw a comma, and we're not in the middle of a quoted string
+ 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);
+
+ /* ...and the beginning of a new string. */
+ state = PRE_STRING;
+ slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ j = 0;
+ } else if (!isspace(cur_c) || state != PRE_STRING) {
+ /* Either this isn't a white-space character, or we've started a
+ string (i.e., already seen a non-white-space character for that
+ string and put it into the string).
+
+ The character is to be put into the string; do so if there's
+ room. */
+ if (j < COL_MAX_LEN) {
+ slstr[j] = cur_c;
+ j++;
+ }
- /* If it was backslash-escaped, we're done with the backslash escape. */
- backslash = FALSE;
+ /* If it was backslash-escaped, we're done with the backslash escape. */
+ backslash = FALSE;
+ }
+ i++;
}
- i++;
- }
- return(sl);
+ return(sl);
}
-static char *
-join_string_list(GList *sl)
+char *join_string_list(GList *sl)
{
GString *joined_str = g_string_new("");
GList *cur, *first;
item_count++;
str = (gchar *)cur->data;
- if (cur != first) {
+ if (cur != first)
g_string_append_c(joined_str, ',');
- }
if (item_count % 2) {
/* Wrap the line. */
g_string_append(joined_str, "\n\t");
- } else {
+ } else
g_string_append_c(joined_str, ' ');
- }
quoted_str = g_strescape(str, "");
g_string_append_printf(joined_str, "\"%s\"", quoted_str);
void
prefs_clear_string_list(GList *sl)
{
- GList *l = sl;
+ GList *l = sl;
- while (l) {
- g_free(l->data);
- l = g_list_remove_link(l, l);
- }
+ while (l) {
+ g_free(l->data);
+ l = g_list_remove_link(l, l);
+ }
}
/*
static gboolean
parse_column_format(fmt_data *cfmt, const char *fmt)
{
- const gchar *cust_format = col_format_to_string(COL_CUSTOM);
- size_t cust_format_len = strlen(cust_format);
- gchar **cust_format_info;
- char *p;
- int col_fmt;
- gchar *col_custom_field;
- long col_custom_occurrence;
- gboolean col_resolved;
-
- /*
- * Is this a custom column?
- */
- if ((strlen(fmt) > cust_format_len) && (fmt[cust_format_len] == ':') &&
- strncmp(fmt, cust_format, cust_format_len) == 0) {
- /* Yes. */
- col_fmt = COL_CUSTOM;
- cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */
- col_custom_field = g_strdup(cust_format_info[0]);
- if (col_custom_field && cust_format_info[1]) {
- col_custom_occurrence = strtol(cust_format_info[1], &p, 10);
- if (p == cust_format_info[1] || *p != '\0') {
- /* Not a valid number. */
- g_free(col_custom_field);
+ const gchar *cust_format = col_format_to_string(COL_CUSTOM);
+ size_t cust_format_len = strlen(cust_format);
+ gchar **cust_format_info;
+ char *p;
+ int col_fmt;
+ gchar *col_custom_field = NULL;
+ long col_custom_occurrence = 0;
+ gboolean col_resolved = TRUE;
+
+ /*
+ * Is this a custom column?
+ */
+ if ((strlen(fmt) > cust_format_len) && (fmt[cust_format_len] == ':') &&
+ strncmp(fmt, cust_format, cust_format_len) == 0) {
+ /* Yes. */
+ col_fmt = COL_CUSTOM;
+ cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */
+ col_custom_field = g_strdup(cust_format_info[0]);
+ if (col_custom_field && cust_format_info[1]) {
+ col_custom_occurrence = strtol(cust_format_info[1], &p, 10);
+ if (p == cust_format_info[1] || *p != '\0') {
+ /* Not a valid number. */
+ g_free(col_custom_field);
+ g_strfreev(cust_format_info);
+ return FALSE;
+ }
+ }
+ if (col_custom_field && cust_format_info[1] && cust_format_info[2]) {
+ col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE;
+ }
g_strfreev(cust_format_info);
- return FALSE;
- }
- } else {
- col_custom_occurrence = 0;
- }
- if (col_custom_field && cust_format_info[1] && cust_format_info[2]) {
- col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE;
} else {
- col_resolved = TRUE;
+ col_fmt = get_column_format_from_str(fmt);
+ if (col_fmt == -1)
+ return FALSE;
}
- g_strfreev(cust_format_info);
- } else {
- col_fmt = get_column_format_from_str(fmt);
- if (col_fmt == -1)
- return FALSE;
- col_custom_field = NULL;
- col_custom_occurrence = 0;
- col_resolved = TRUE;
- }
-
- cfmt->fmt = col_fmt;
- cfmt->custom_field = col_custom_field;
- cfmt->custom_occurrence = (int)col_custom_occurrence;
- cfmt->resolved = col_resolved;
- return TRUE;
+
+ cfmt->fmt = col_fmt;
+ cfmt->custom_field = col_custom_field;
+ cfmt->custom_occurrence = (int)col_custom_occurrence;
+ cfmt->resolved = col_resolved;
+ return TRUE;
}
/* Initialize non-dissector preferences to wired-in default values.
static void
init_prefs(void)
{
- if (prefs_initialized)
- return;
+ if (prefs_initialized)
+ return;
- uat_load_all();
+ uat_load_all();
- prefs_register_modules();
+ prefs_register_modules();
- filter_expression_init(TRUE);
+ filter_expression_init(TRUE);
- prefs_initialized = TRUE;
+ prefs_initialized = TRUE;
}
/* Initialize non-dissector preferences used by the "register preference" API
static void
pre_init_prefs(void)
{
- int i;
- gchar *col_name;
- fmt_data *cfmt;
- static const gchar *col_fmt[DEF_NUM_COLS*2] = {
- "No.", "%m", "Time", "%t",
- "Source", "%s", "Destination", "%d",
- "Protocol", "%p", "Length", "%L",
- "Info", "%i"};
-
- if (prefs_pre_initialized)
- return;
-
- prefs.pr_format = PR_FMT_TEXT;
- prefs.pr_dest = PR_DEST_CMD;
- prefs.pr_file = "wireshark.out";
- prefs.pr_cmd = "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.gui_toolbar_main_style = TB_STYLE_ICONS;
- prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
- /* These string prefs will be strduped shortly, so we can safely cast away
- * their constness in these assignments */
+ int i;
+ gchar *col_name;
+ fmt_data *cfmt;
+ static const gchar *col_fmt[DEF_NUM_COLS*2] = {
+ "No.", "%m", "Time", "%t",
+ "Source", "%s", "Destination", "%d",
+ "Protocol", "%p", "Length", "%L",
+ "Info", "%i"};
+
+ if (prefs_pre_initialized)
+ return;
+
+ prefs.pr_format = PR_FMT_TEXT;
+ prefs.pr_dest = PR_DEST_CMD;
+ prefs.pr_file = "wireshark.out";
+ prefs.pr_cmd = "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.gui_toolbar_main_style = TB_STYLE_ICONS;
+ prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
+ /* These string prefs will be strduped shortly, so we can safely cast away
+ * their constness in these assignments */
#ifdef _WIN32
- prefs.gui_gtk2_font_name = (char *) "Lucida Console 10";
+ prefs.gui_gtk2_font_name = (char *) "Lucida Console 10";
#else
- prefs.gui_gtk2_font_name = (char *) "Monospace 10";
+ prefs.gui_gtk2_font_name = (char *) "Monospace 10";
#endif
- /* We try to find the best font in the Qt code */
- prefs.gui_qt_font_name = (char *) "";
- prefs.gui_marked_fg.pixel = 65535;
- prefs.gui_marked_fg.red = 65535;
- prefs.gui_marked_fg.green = 65535;
- prefs.gui_marked_fg.blue = 65535;
- prefs.gui_marked_bg.pixel = 0;
- prefs.gui_marked_bg.red = 0;
- prefs.gui_marked_bg.green = 8224;
- prefs.gui_marked_bg.blue = 10794;
- prefs.gui_ignored_fg.pixel = 32767;
- prefs.gui_ignored_fg.red = 32767;
- prefs.gui_ignored_fg.green = 32767;
- prefs.gui_ignored_fg.blue = 32767;
- prefs.gui_ignored_bg.pixel = 65535;
- prefs.gui_ignored_bg.red = 65535;
- prefs.gui_ignored_bg.green = 65535;
- prefs.gui_ignored_bg.blue = 65535;
- prefs.gui_colorized_fg = "000000,000000,000000,000000,000000,000000,000000,000000,000000,000000";
- prefs.gui_colorized_bg = "ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0";
- prefs.st_client_fg.pixel = 0;
- prefs.st_client_fg.red = 32767;
- prefs.st_client_fg.green = 0;
- prefs.st_client_fg.blue = 0;
- prefs.st_client_bg.pixel = 0;
- prefs.st_client_bg.red = 64507;
- prefs.st_client_bg.green = 60909;
- prefs.st_client_bg.blue = 60909;
- prefs.st_server_fg.pixel = 0;
- prefs.st_server_fg.red = 0;
- prefs.st_server_fg.green = 0;
- prefs.st_server_fg.blue = 32767;
- prefs.st_server_bg.pixel = 0;
- prefs.st_server_bg.red = 60909;
- prefs.st_server_bg.green = 60909;
- prefs.st_server_bg.blue = 64507;
- prefs.gui_text_valid.pixel = 0; /* light green */
- prefs.gui_text_valid.red = 0xAFFF;
- prefs.gui_text_valid.green = 0xFFFF;
- prefs.gui_text_valid.blue = 0xAFFF;
- prefs.gui_text_invalid.pixel = 0; /* light red */
- prefs.gui_text_invalid.red = 0xFFFF;
- prefs.gui_text_invalid.green = 0xAFFF;
- prefs.gui_text_invalid.blue = 0xAFFF;
- prefs.gui_text_deprecated.pixel = 0; /* light yellow */
- prefs.gui_text_deprecated.red = 0xFFFF;
- 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;
- prefs.gui_fileopen_dir = (char *) 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 */
- prefs.gui_webbrowser = (char *) HTML_VIEWER " %s";
- prefs.gui_window_title = (char *) "";
- prefs.gui_start_title = "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_layout_content_3 = layout_pane_content_pbytes;
-
- prefs.col_list = NULL;
- for (i = 0; i < DEF_NUM_COLS; i++) {
- cfmt = g_new(fmt_data,1);
- cfmt->title = g_strdup(col_fmt[i * 2]);
- parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
- cfmt->visible = TRUE;
- cfmt->resolved = TRUE;
- cfmt->custom_field = NULL;
- cfmt->custom_occurrence = 0;
- prefs.col_list = g_list_append(prefs.col_list, cfmt);
- }
- prefs.num_cols = DEF_NUM_COLS;
+ /* We try to find the best font in the Qt code */
+ prefs.gui_qt_font_name = (char *) "";
+ prefs.gui_marked_fg.pixel = 65535;
+ prefs.gui_marked_fg.red = 65535;
+ prefs.gui_marked_fg.green = 65535;
+ prefs.gui_marked_fg.blue = 65535;
+ prefs.gui_marked_bg.pixel = 0;
+ prefs.gui_marked_bg.red = 0;
+ prefs.gui_marked_bg.green = 8224;
+ prefs.gui_marked_bg.blue = 10794;
+ prefs.gui_ignored_fg.pixel = 32767;
+ prefs.gui_ignored_fg.red = 32767;
+ prefs.gui_ignored_fg.green = 32767;
+ prefs.gui_ignored_fg.blue = 32767;
+ prefs.gui_ignored_bg.pixel = 65535;
+ prefs.gui_ignored_bg.red = 65535;
+ prefs.gui_ignored_bg.green = 65535;
+ prefs.gui_ignored_bg.blue = 65535;
+ prefs.gui_colorized_fg = "000000,000000,000000,000000,000000,000000,000000,000000,000000,000000";
+ prefs.gui_colorized_bg = "ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0";
+ prefs.st_client_fg.pixel = 0;
+ prefs.st_client_fg.red = 32767;
+ prefs.st_client_fg.green = 0;
+ prefs.st_client_fg.blue = 0;
+ prefs.st_client_bg.pixel = 0;
+ prefs.st_client_bg.red = 64507;
+ prefs.st_client_bg.green = 60909;
+ prefs.st_client_bg.blue = 60909;
+ prefs.st_server_fg.pixel = 0;
+ prefs.st_server_fg.red = 0;
+ prefs.st_server_fg.green = 0;
+ prefs.st_server_fg.blue = 32767;
+ prefs.st_server_bg.pixel = 0;
+ prefs.st_server_bg.red = 60909;
+ prefs.st_server_bg.green = 60909;
+ prefs.st_server_bg.blue = 64507;
+ prefs.gui_text_valid.pixel = 0; /* light green */
+ prefs.gui_text_valid.red = 0xAFFF;
+ prefs.gui_text_valid.green = 0xFFFF;
+ prefs.gui_text_valid.blue = 0xAFFF;
+ prefs.gui_text_invalid.pixel = 0; /* light red */
+ prefs.gui_text_invalid.red = 0xFFFF;
+ prefs.gui_text_invalid.green = 0xAFFF;
+ prefs.gui_text_invalid.blue = 0xAFFF;
+ prefs.gui_text_deprecated.pixel = 0; /* light yellow */
+ prefs.gui_text_deprecated.red = 0xFFFF;
+ 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;
+ prefs.gui_fileopen_dir = (char *) 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 */
+#ifdef HTML_VIEWER
+ prefs.gui_webbrowser = (char *) HTML_VIEWER " %s";
+#else
+ prefs.gui_webbrowser = (char *) "";
+#endif
+ prefs.gui_window_title = (char *) "";
+ prefs.gui_start_title = "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_layout_content_3 = layout_pane_content_pbytes;
+ prefs.gui_qt_language = 0; /* (Auto-Detect) */
+ prefs.gui_packet_editor = FALSE;
+
+ prefs.col_list = NULL;
+ for (i = 0; i < DEF_NUM_COLS; i++) {
+ cfmt = g_new(fmt_data,1);
+ cfmt->title = g_strdup(col_fmt[i * 2]);
+ parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
+ cfmt->visible = TRUE;
+ cfmt->resolved = TRUE;
+ cfmt->custom_field = NULL;
+ cfmt->custom_occurrence = 0;
+ prefs.col_list = g_list_append(prefs.col_list, cfmt);
+ }
+ prefs.num_cols = DEF_NUM_COLS;
/* set the default values for the capture dialog box */
- prefs.capture_prom_mode = TRUE;
+ prefs.capture_prom_mode = TRUE;
#ifdef PCAP_NG_DEFAULT
- prefs.capture_pcap_ng = TRUE;
+ prefs.capture_pcap_ng = TRUE;
#else
- prefs.capture_pcap_ng = FALSE;
+ prefs.capture_pcap_ng = FALSE;
#endif
- prefs.capture_real_time = TRUE;
- prefs.capture_auto_scroll = TRUE;
- prefs.capture_show_info = FALSE;
-
- prefs.capture_columns = NULL;
- for (i = 0; i < num_capture_cols; i++) {
- col_name = g_strdup(capture_cols[i]);
- prefs.capture_columns = g_list_append(prefs.capture_columns, col_name);
- }
+ prefs.capture_real_time = TRUE;
+ prefs.capture_auto_scroll = TRUE;
+ prefs.capture_show_info = FALSE;
+
+ prefs.capture_columns = NULL;
+ for (i = 0; i < num_capture_cols; i++) {
+ col_name = g_strdup(capture_cols[i]);
+ prefs.capture_columns = g_list_append(prefs.capture_columns, col_name);
+ }
- prefs.console_log_level =
- G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR;
+ prefs.console_log_level =
+ G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR;
/* 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.display_hidden_proto_items = FALSE;
-
- prefs_pre_initialized = TRUE;
+ 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;
+ prefs.st_burst_windowlen = ST_DEF_BURSTLEN;
+ prefs.st_sort_casesensitve = TRUE;
+ prefs.st_sort_rng_fixorder = TRUE;
+ prefs.st_sort_rng_nameonly = TRUE;
+ prefs.st_sort_defcolflag = ST_SORT_COL_COUNT;
+ prefs.st_sort_defdescending = TRUE;
+ prefs.st_sort_showfullname = FALSE;
+ prefs.display_hidden_proto_items = FALSE;
+
+ prefs_pre_initialized = TRUE;
}
/*
void
prefs_reset(void)
{
- prefs_initialized = FALSE;
- g_free(prefs.saved_at_version);
- /*
- * Unload all UAT preferences.
- */
- uat_unload_all();
-
- /*
- * Unload any loaded MIBs.
- */
- oids_cleanup();
-
- /*
- * Reset the non-dissector preferences.
- */
- init_prefs();
-
- /*
- * Reset the non-UAT dissector preferences.
- */
- pe_tree_foreach(prefs_modules, reset_module_prefs, NULL);
+ prefs_initialized = FALSE;
+ g_free(prefs.saved_at_version);
+ prefs.saved_at_version = NULL;
+
+ /*
+ * Unload all UAT preferences.
+ */
+ uat_unload_all();
+
+ /*
+ * Unload any loaded MIBs.
+ */
+ oids_cleanup();
+
+ /*
+ * Reset the non-dissector preferences.
+ */
+ init_prefs();
+
+ /*
+ * Reset the non-UAT dissector preferences.
+ */
+ wmem_tree_foreach(prefs_modules, reset_module_prefs, NULL);
}
/* Read the preferences file, fill in "prefs", and return a pointer to it.
and a pointer to the path of the file into "*pf_path_return", and
return NULL. */
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)
{
- int err;
- char *pf_path;
- FILE *pf;
+ int err;
+ char *pf_path;
+ FILE *pf;
- /* clean up libsmi structures before reading prefs */
- oids_cleanup();
+ /* clean up libsmi structures before reading prefs */
+ oids_cleanup();
- init_prefs();
+ init_prefs();
- /*
- * If we don't already have the pathname of the global preferences
- * file, construct it. Then, in either case, try to open the file.
- */
- if (gpf_path == NULL) {
/*
- * We don't have the path; try the new path first, and, if that
- * file doesn't exist, try the old path.
+ * If we don't already have the pathname of the global preferences
+ * file, construct it. Then, in either case, try to open the file.
*/
- gpf_path = get_datafile_path(PF_NAME);
- if ((pf = ws_fopen(gpf_path, "r")) == NULL && errno == ENOENT) {
- /*
- * It doesn't exist by the new name; try the old name.
- */
- g_free(gpf_path);
- gpf_path = get_datafile_path(OLD_GPF_NAME);
- pf = ws_fopen(gpf_path, "r");
+ if (gpf_path == NULL) {
+ /*
+ * We don't have the path; try the new path first, and, if that
+ * file doesn't exist, try the old path.
+ */
+ gpf_path = get_datafile_path(PF_NAME);
+ if ((pf = ws_fopen(gpf_path, "r")) == NULL && errno == ENOENT) {
+ /*
+ * It doesn't exist by the new name; try the old name.
+ */
+ g_free(gpf_path);
+ gpf_path = get_datafile_path(OLD_GPF_NAME);
+ pf = ws_fopen(gpf_path, "r");
+ }
+ } else {
+ /*
+ * We have the path; try it.
+ */
+ pf = ws_fopen(gpf_path, "r");
}
- } else {
- /*
- * We have the path; try it.
- */
- pf = ws_fopen(gpf_path, "r");
- }
-
- /*
- * If we were able to open the file, read it.
- * 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
- * seen.
+ * If we were able to open the file, read it.
+ * XXX - if it failed for a reason other than "it doesn't exist",
+ * report the error.
*/
- mgcp_tcp_port_count = 0;
- mgcp_udp_port_count = 0;
-
- /* 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;
+ *gpf_path_return = NULL;
+ if (pf != NULL) {
+ /*
+ * Start out the counters of "mgcp.{tcp,udp}.port" entries we've
+ * seen.
+ */
+ mgcp_tcp_port_count = 0;
+ mgcp_udp_port_count = 0;
+
+ /* 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;
+ }
+ 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. */
+ if (errno != ENOENT) {
+ *gpf_errno_return = errno;
+ *gpf_read_errno_return = 0;
+ *gpf_path_return = gpf_path;
+ }
}
- 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. */
- if (errno != ENOENT) {
- *gpf_errno_return = errno;
- *gpf_read_errno_return = 0;
- *gpf_path_return = gpf_path;
+
+ /* Construct the pathname of the user's preferences file. */
+ 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
+ * seen.
+ */
+ mgcp_tcp_port_count = 0;
+ mgcp_udp_port_count = 0;
+
+ /* 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;
+ } else
+ g_free(pf_path);
+ 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. */
+ if (errno != ENOENT) {
+ *pf_errno_return = errno;
+ *pf_read_errno_return = 0;
+ *pf_path_return = pf_path;
+ } else
+ g_free(pf_path);
}
- }
- /* Construct the pathname of the user's preferences file. */
- pf_path = get_persconffile_path(PF_NAME, TRUE);
+ /* load SMI modules if needed */
+ oids_init();
- /* 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
- * seen.
- */
- mgcp_tcp_port_count = 0;
- mgcp_udp_port_count = 0;
-
- /* 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;
- } else
- g_free(pf_path);
- 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. */
- if (errno != ENOENT) {
- *pf_errno_return = errno;
- *pf_read_errno_return = 0;
- *pf_path_return = pf_path;
- } else
- g_free(pf_path);
- }
-
- /* load SMI modules if needed */
- oids_init();
-
- return &prefs;
+ return &prefs;
}
/* read the preferences file (or similiar) and call the callback
read_prefs_file(const char *pf_path, FILE *pf,
pref_set_pair_cb pref_set_pair_fct, void *private_data)
{
- enum { START, IN_VAR, PRE_VAL, IN_VAL, IN_SKIP };
- int got_c, state = START;
- GString *cur_val;
- GString *cur_var;
- gboolean got_val = FALSE;
- gint fline = 1, pline = 1;
- gchar hint[] = "(save preferences to remove this warning)";
-
- cur_val = g_string_new("");
- cur_var = g_string_new("");
-
- /* Try to read in the profile name in the first line of the preferences file. */
- got_c = getc(pf);
- if(got_c) {
- char firstl[100];
-
- if (fgets(firstl, 100, pf) != NULL) {
- if (strncmp((const char *)firstl, " Configuration file for ", 24) == 0) {
- const gchar *ver = (gchar *)&firstl[24];
- /* Eliminate the period and LF the end of the string */
- prefs.saved_at_version = g_strndup(ver, strlen(ver) - 2);
- }
- }
- }
- rewind(pf);
-
- while ((got_c = getc(pf)) != EOF) {
- if (got_c == '\n') {
- state = START;
- fline++;
- continue;
+ enum {
+ START, /* beginning of a line */
+ IN_VAR, /* processing key name */
+ PRE_VAL, /* finished processing key name, skipping white space befor evalue */
+ IN_VAL, /* processing value */
+ IN_SKIP /* skipping to the end of the line */
+ } state = START;
+ int got_c;
+ GString *cur_val;
+ GString *cur_var;
+ gboolean got_val = FALSE;
+ gint fline = 1, pline = 1;
+ gchar hint[] = "(save preferences to remove this warning)";
+ gchar ver[128];
+
+ cur_val = g_string_new("");
+ cur_var = g_string_new("");
+
+ /* Try to read in the profile name in the first line of the preferences file. */
+ if (fscanf(pf, "# Configuration file for %127[^\r\n]", ver) == 1) {
+ /* Assume trailing period and remove it */
+ prefs.saved_at_version = g_strndup(ver, strlen(ver) - 1);
}
+ rewind(pf);
+
+ while ((got_c = getc(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);
+ if (got_c == EOF)
+ break;
+ if (got_c != '\n') {
+ /* Put back the character after the CR, and process the CR normally. */
+ ungetc(got_c, pf);
+ got_c = '\r';
+ }
+ }
+ if (got_c == '\n') {
+ state = START;
+ fline++;
+ continue;
+ }
- switch (state) {
- case START:
- if (isalnum(got_c)) {
- if (cur_var->len > 0) {
- if (got_val) {
- if (cur_val->len > 0) {
- if (cur_val->str[cur_val->len-1] == ',') {
- /*
- * If the pref has a trailing comma, eliminate it.
- */
- cur_val->str[cur_val->len-1] = '\0';
- g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
+ switch (state) {
+ case START:
+ if (isalnum(got_c)) {
+ if (cur_var->len > 0) {
+ if (got_val) {
+ if (cur_val->len > 0) {
+ if (cur_val->str[cur_val->len-1] == ',') {
+ /*
+ * If the pref has a trailing comma, eliminate it.
+ */
+ cur_val->str[cur_val->len-1] = '\0';
+ g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
+ }
+ }
+ /* Call the routine to set the preference; it will parse
+ the value as appropriate.
+
+ Since we're reading a file, rather than processing
+ explicit user input, for range preferences, silently
+ lower values in excess of the range's maximum, rather
+ than reporting errors and failing. */
+ switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) {
+
+ case PREFS_SET_OK:
+ break;
+
+ case PREFS_SET_SYNTAX_ERR:
+ g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
+ 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);
+ 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);
+ prefs.unknown_prefs = TRUE;
+ break;
+ }
+ } else {
+ g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
+ }
}
- }
- /* Call the routine to set the preference; it will parse
- the value as appropriate. */
- switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) {
-
- case PREFS_SET_OK:
+ state = IN_VAR;
+ got_val = FALSE;
+ g_string_truncate(cur_var, 0);
+ g_string_append_c(cur_var, (gchar) got_c);
+ pline = fline;
+ } else if (isspace(got_c) && cur_var->len > 0 && got_val) {
+ state = PRE_VAL;
+ } else if (got_c == '#') {
+ state = IN_SKIP;
+ } else {
+ g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
+ }
+ break;
+ case IN_VAR:
+ if (got_c != ':') {
+ g_string_append_c(cur_var, (gchar) got_c);
+ } else {
+ /* This is a colon (':') */
+ state = PRE_VAL;
+ g_string_truncate(cur_val, 0);
+ /*
+ * Set got_val to TRUE to accommodate prefs such as
+ * "gui.fileopen.dir" that do not require a value.
+ */
+ got_val = TRUE;
+ }
+ break;
+ case PRE_VAL:
+ if (!isspace(got_c)) {
+ state = IN_VAL;
+ g_string_append_c(cur_val, (gchar) got_c);
+ }
+ break;
+ case IN_VAL:
+ g_string_append_c(cur_val, (gchar) got_c);
+ break;
+ case IN_SKIP:
+ break;
+ }
+ }
+ if (cur_var->len > 0) {
+ if (got_val) {
+ /* Call the routine to set the preference; it will parse
+ the value as appropriate.
+
+ Since we're reading a file, rather than processing
+ explicit user input, for range preferences, silently
+ lower values in excess of the range's maximum, rather
+ than reporting errors and failing. */
+ switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) {
+
+ case PREFS_SET_OK:
break;
- case PREFS_SET_SYNTAX_ERR:
- g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
- cur_var->str, pline, pf_path, hint);
+ case PREFS_SET_SYNTAX_ERR:
+ g_warning ("Syntax error in preference %s at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
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);
+ case PREFS_SET_NO_SUCH_PREF:
+ 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);
+ case PREFS_SET_OBSOLETE:
prefs.unknown_prefs = TRUE;
break;
- }
- } else {
- g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
}
- }
- state = IN_VAR;
- got_val = FALSE;
- g_string_truncate(cur_var, 0);
- g_string_append_c(cur_var, (gchar) got_c);
- pline = fline;
- } else if (isspace(got_c) && cur_var->len > 0 && got_val) {
- state = PRE_VAL;
- } else if (got_c == '#') {
- state = IN_SKIP;
} else {
- g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
+ g_warning ("Incomplete preference at line %d of\n%s %s",
+ pline, pf_path, hint);
}
- break;
- case IN_VAR:
- if (got_c != ':') {
- g_string_append_c(cur_var, (gchar) got_c);
- } else {
- /* This is a colon (':') */
- state = PRE_VAL;
- g_string_truncate(cur_val, 0);
- /*
- * Set got_val to TRUE to accommodate prefs such as
- * "gui.fileopen.dir" that do not require a value.
- */
- got_val = TRUE;
- }
- break;
- case PRE_VAL:
- if (!isspace(got_c)) {
- state = IN_VAL;
- g_string_append_c(cur_val, (gchar) got_c);
- }
- break;
- case IN_VAL:
- g_string_append_c(cur_val, (gchar) got_c);
- break;
}
- }
- if (cur_var->len > 0) {
- if (got_val) {
- /* Convert the string to a range. Since we're reading the
- * preferences file, silently lower values in excess of the
- * range's maximum.
- */
- switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) {
-
- case PREFS_SET_OK:
- break;
- case PREFS_SET_SYNTAX_ERR:
- g_warning ("Syntax error in preference %s at line %d of\n%s %s",
- cur_var->str, pline, pf_path, hint);
- break;
-
- case PREFS_SET_NO_SUCH_PREF:
- 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;
+ g_string_free(cur_val, TRUE);
+ g_string_free(cur_var, TRUE);
- case PREFS_SET_OBSOLETE:
- prefs.unknown_prefs = TRUE;
- break;
- }
- } else {
- g_warning ("Incomplete preference at line %d of\n%s %s",
- pline, pf_path, hint);
- }
- }
-
- g_string_free(cur_val, TRUE);
- g_string_free(cur_var, TRUE);
-
- if (ferror(pf))
- return errno;
- else
- return 0;
+ if (ferror(pf))
+ return errno;
+ else
+ return 0;
}
/*
/*
* Set the counters of "mgcp.{tcp,udp}.port" entries we've
- * seen to values that keep us from trying to interpret tham
+ * seen to values that keep us from trying to interpret them
* as "mgcp.{tcp,udp}.gateway_port" or "mgcp.{tcp,udp}.callagent_port",
* as, from the command line, we have no way of guessing which
* the user had in mind.
if (cfmt->fmt != cfmt_hidden.fmt) {
/* No. */
g_free(cfmt_hidden.custom_field);
+ cfmt_hidden.custom_field = NULL;
continue;
}
if (cfmt->fmt == COL_CUSTOM) {
* A custom column has to have the
* same custom field and occurrence.
*/
- if (strcmp(cfmt->custom_field,
- cfmt_hidden.custom_field) != 0) {
- /* Different fields. */
- g_free(cfmt_hidden.custom_field);
- continue;
- }
- if (cfmt->custom_occurrence != cfmt_hidden.custom_occurrence) {
- /* Different occurrences. */
- g_free(cfmt_hidden.custom_field);
- continue;
+ if (cfmt_hidden.custom_field && cfmt->custom_field) {
+ if (strcmp(cfmt->custom_field,
+ cfmt_hidden.custom_field) != 0) {
+ /* Different fields. */
+ g_free(cfmt_hidden.custom_field);
+ cfmt_hidden.custom_field = NULL;
+ continue;
+ }
+ if (cfmt->custom_occurrence != cfmt_hidden.custom_occurrence) {
+ /* Different occurrences. */
+ g_free(cfmt_hidden.custom_field);
+ cfmt_hidden.custom_field = NULL;
+ continue;
+ }
}
}
char
string_to_name_resolve(const char *string, e_addr_resolve *name_resolve)
{
- char c;
+ char c;
- memset(name_resolve, 0, sizeof(e_addr_resolve));
- while ((c = *string++) != '\0') {
- switch (c) {
- case 'm':
- name_resolve->mac_name = TRUE;
- break;
- case 'n':
- name_resolve->network_name = TRUE;
- break;
- case 'N':
- name_resolve->use_external_net_name_resolver = TRUE;
- break;
- case 't':
- name_resolve->transport_name = TRUE;
- break;
- case 'C':
- name_resolve->concurrent_dns = TRUE;
- break;
- default:
- /*
- * Unrecognized letter.
- */
- return c;
- }
- }
- return '\0';
+ memset(name_resolve, 0, sizeof(e_addr_resolve));
+ while ((c = *string++) != '\0') {
+ switch (c) {
+ case 'm':
+ name_resolve->mac_name = TRUE;
+ break;
+ case 'n':
+ name_resolve->network_name = TRUE;
+ break;
+ case 'N':
+ name_resolve->use_external_net_name_resolver = TRUE;
+ break;
+ case 't':
+ name_resolve->transport_name = TRUE;
+ break;
+ case 'C':
+ name_resolve->concurrent_dns = TRUE;
+ break;
+ default:
+ /*
+ * Unrecognized letter.
+ */
+ return c;
+ }
+ }
+ return '\0';
}
set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
gboolean return_range_errors)
{
- unsigned long int cval;
- guint uval;
- gboolean bval;
- gint enum_val;
- char *p;
- gchar *dotp, *last_dotp;
- static gchar *filter_label = NULL;
- static gboolean filter_enabled = FALSE;
- gchar *filter_expr = NULL;
- module_t *module;
- pref_t *pref;
-
- if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) {
- 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);
- g_free(filter_label);
- g_free(filter_expr);
- } 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) {
- prefs.gui_version_placement = version_both;
- } else {
- prefs.gui_version_placement = version_neither;
- }
- } else if (strcmp(pref_name, "name_resolve") == 0 ||
- strcmp(pref_name, "capture.name_resolve") == 0) {
- /*
- * Handle the deprecated name resolution options.
- *
- * "TRUE" and "FALSE", for backwards compatibility, are synonyms for
- * RESOLV_ALL and RESOLV_NONE.
- *
- * Otherwise, we treat it as a list of name types we want to resolve.
- */
- 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) {
- gbl_resolv_flags.mac_name = FALSE;
- gbl_resolv_flags.network_name = FALSE;
- gbl_resolv_flags.transport_name = FALSE;
- gbl_resolv_flags.concurrent_dns = FALSE;
- }
- else {
- /* start out with none set */
- gbl_resolv_flags.mac_name = FALSE;
- gbl_resolv_flags.network_name = FALSE;
- gbl_resolv_flags.transport_name = FALSE;
- gbl_resolv_flags.concurrent_dns = FALSE;
- if (string_to_name_resolve(value, &gbl_resolv_flags) != '\0')
- return PREFS_SET_SYNTAX_ERR;
- }
- } else {
- /* Handle deprecated "global" options that don't have a module
- * associated with them
- */
- if ((strcmp(pref_name, "name_resolve_concurrency") == 0) ||
- (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) ||
- (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0)) {
- module = nameres_module;
- dotp = pref_name;
- } else {
- /* To which module does this preference belong? */
- module = NULL;
- last_dotp = pref_name;
- while (!module) {
- dotp = strchr(last_dotp, '.');
- if (dotp == NULL) {
- /* Either there's no such module, or no module was specified.
- In either case, that means there's no such preference. */
- return PREFS_SET_NO_SUCH_PREF;
+ unsigned long int cval;
+ guint uval;
+ gboolean bval;
+ gint enum_val;
+ char *p;
+ gchar *dotp, *last_dotp;
+ static gchar *filter_label = NULL;
+ static gboolean filter_enabled = FALSE;
+ gchar *filter_expr = NULL;
+ module_t *module;
+ pref_t *pref;
+
+ if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) {
+ 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);
+ g_free(filter_label);
+ g_free(filter_expr);
+ } 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) {
+ prefs.gui_version_placement = version_both;
+ } else {
+ prefs.gui_version_placement = version_neither;
}
- *dotp = '\0'; /* separate module and preference name */
- module = prefs_find_module(pref_name);
-
+ } else if (strcmp(pref_name, "name_resolve") == 0 ||
+ strcmp(pref_name, "capture.name_resolve") == 0) {
/*
- * XXX - "Diameter" rather than "diameter" was used in earlier
- * versions of Wireshark; if we didn't find the module, and its name
- * was "Diameter", look for "diameter" instead.
- *
- * In addition, the BEEP protocol used to be the BXXP protocol,
- * so if we didn't find the module, and its name was "bxxp",
- * look for "beep" instead.
- *
- * Also, the preferences for GTP v0 and v1 were combined under
- * a single "gtp" heading, and the preferences for SMPP were
- * moved to "smpp-gsm-sms" and then moved to "gsm-sms-ud".
- * However, SMPP now has its own preferences, so we just map
- * "smpp-gsm-sms" to "gsm-sms-ud", and then handle SMPP below.
+ * Handle the deprecated name resolution options.
*
- * We also renamed "dcp" to "dccp", "x.25" to "x25", "x411" to "p1"
- * and "nsip" to "gprs_ns".
- *
- * The SynOptics Network Management Protocol (SONMP) is now known by
- * 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;
- }
- if (module) {
- g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
- "Save your preferences to make this change permanent.",
- pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
- prefs.unknown_prefs = TRUE;
- }
- }
- *dotp = '.'; /* put the preference string back */
- dotp++; /* skip past separator to preference name */
- last_dotp = dotp;
- }
- }
-
- pref = prefs_find_preference(module, dotp);
-
- if (pref == NULL) {
- 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)) {
- pref = prefs_find_preference(module, pref_name);
- }
- else if (strcmp(module->name, "mgcp") == 0) {
- /*
- * XXX - "mgcp.display raw text toggle" and "mgcp.display dissect tree"
- * rather than "mgcp.display_raw_text" and "mgcp.display_dissect_tree"
- * were used in earlier versions of Wireshark; if we didn't find the
- * preference, it was an MGCP preference, and its name was
- * "display raw text toggle" or "display dissect tree", look for
- * "display_raw_text" or "display_dissect_tree" instead.
+ * "TRUE" and "FALSE", for backwards compatibility, are synonyms for
+ * RESOLV_ALL and RESOLV_NONE.
*
- * "mgcp.tcp.port" and "mgcp.udp.port" are harder to handle, as both
- * the gateway and callagent ports were given those names; we interpret
- * the first as "mgcp.{tcp,udp}.gateway_port" and the second as
- * "mgcp.{tcp,udp}.callagent_port", as that's the order in which
- * they were registered by the MCCP dissector and thus that's the
- * order in which they were written to the preferences file. (If
- * we're not reading the preferences file, but are handling stuff
- * from a "-o" command-line option, we have no clue which the user
- * had in mind - they should have used "mgcp.{tcp,udp}.gateway_port"
- * or "mgcp.{tcp,udp}.callagent_port" instead.)
+ * Otherwise, we treat it as a list of name types we want to resolve.
*/
- if (strcmp(dotp, "display raw text toggle") == 0)
- pref = prefs_find_preference(module, "display_raw_text");
- else if (strcmp(dotp, "display dissect tree") == 0)
- pref = prefs_find_preference(module, "display_dissect_tree");
- else if (strcmp(dotp, "tcp.port") == 0) {
- mgcp_tcp_port_count++;
- if (mgcp_tcp_port_count == 1) {
- /* It's the first one */
- pref = prefs_find_preference(module, "tcp.gateway_port");
- } else if (mgcp_tcp_port_count == 2) {
- /* It's the second one */
- pref = prefs_find_preference(module, "tcp.callagent_port");
- }
- /* Otherwise it's from the command line, and we don't bother
- mapping it. */
- } else if (strcmp(dotp, "udp.port") == 0) {
- mgcp_udp_port_count++;
- if (mgcp_udp_port_count == 1) {
- /* It's the first one */
- pref = prefs_find_preference(module, "udp.gateway_port");
- } else if (mgcp_udp_port_count == 2) {
- /* It's the second one */
- pref = prefs_find_preference(module, "udp.callagent_port");
- }
- /* Otherwise it's from the command line, and we don't bother
- mapping it. */
+ 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 (strcmp(module->name, "smb") == 0) {
- /* Handle old names for SMB preferences. */
- if (strcmp(dotp, "smb.trans.reassembly") == 0)
- pref = prefs_find_preference(module, "trans_reassembly");
- else if (strcmp(dotp, "smb.dcerpc.reassembly") == 0)
- pref = prefs_find_preference(module, "dcerpc_reassembly");
- } else if (strcmp(module->name, "ndmp") == 0) {
- /* Handle old names for NDMP preferences. */
- if (strcmp(dotp, "ndmp.desegment") == 0)
- pref = prefs_find_preference(module, "desegment");
- } else if (strcmp(module->name, "diameter") == 0) {
- /* Handle old names for Diameter preferences. */
- if (strcmp(dotp, "diameter.desegment") == 0)
- pref = prefs_find_preference(module, "desegment");
- } else if (strcmp(module->name, "pcli") == 0) {
- /* Handle old names for PCLI preferences. */
- if (strcmp(dotp, "pcli.udp_port") == 0)
- pref = prefs_find_preference(module, "udp_port");
- } else if (strcmp(module->name, "artnet") == 0) {
- /* Handle old names for ARTNET preferences. */
- if (strcmp(dotp, "artnet.udp_port") == 0)
- pref = prefs_find_preference(module, "udp_port");
- } else if (strcmp(module->name, "mapi") == 0) {
- /* Handle old names for MAPI preferences. */
- if (strcmp(dotp, "mapi_decrypt") == 0)
- pref = prefs_find_preference(module, "decrypt");
- } else if (strcmp(module->name, "fc") == 0) {
- /* Handle old names for Fibre Channel preferences. */
- if (strcmp(dotp, "reassemble_fc") == 0)
- pref = prefs_find_preference(module, "reassemble");
- else if (strcmp(dotp, "fc_max_frame_size") == 0)
- pref = prefs_find_preference(module, "max_frame_size");
- } else if (strcmp(module->name, "fcip") == 0) {
- /* Handle old names for Fibre Channel-over-IP preferences. */
- if (strcmp(dotp, "desegment_fcip_messages") == 0)
- pref = prefs_find_preference(module, "desegment");
- else if (strcmp(dotp, "fcip_port") == 0)
- pref = prefs_find_preference(module, "target_port");
- } else if (strcmp(module->name, "gtp") == 0) {
- /* Handle old names for GTP preferences. */
- if (strcmp(dotp, "gtpv0_port") == 0)
- pref = prefs_find_preference(module, "v0_port");
- else if (strcmp(dotp, "gtpv1c_port") == 0)
- pref = prefs_find_preference(module, "v1c_port");
- else if (strcmp(dotp, "gtpv1u_port") == 0)
- pref = prefs_find_preference(module, "v1u_port");
- else if (strcmp(dotp, "gtp_dissect_tpdu") == 0)
- pref = prefs_find_preference(module, "dissect_tpdu");
- else if (strcmp(dotp, "gtpv0_dissect_cdr_as") == 0)
- pref = prefs_find_preference(module, "v0_dissect_cdr_as");
- else if (strcmp(dotp, "gtpv0_check_etsi") == 0)
- pref = prefs_find_preference(module, "v0_check_etsi");
- else if (strcmp(dotp, "gtpv1_check_etsi") == 0)
- pref = prefs_find_preference(module, "v1_check_etsi");
- } else if (strcmp(module->name, "ip") == 0) {
- /* Handle old names for IP preferences. */
- if (strcmp(dotp, "ip_summary_in_tree") == 0)
- pref = prefs_find_preference(module, "summary_in_tree");
- } else if (strcmp(module->name, "iscsi") == 0) {
- /* Handle old names for iSCSI preferences. */
- if (strcmp(dotp, "iscsi_port") == 0)
- pref = prefs_find_preference(module, "target_port");
- } else if (strcmp(module->name, "lmp") == 0) {
- /* Handle old names for LMP preferences. */
- if (strcmp(dotp, "lmp_version") == 0)
- pref = prefs_find_preference(module, "version");
- } else if (strcmp(module->name, "mtp3") == 0) {
- /* Handle old names for MTP3 preferences. */
- if (strcmp(dotp, "mtp3_standard") == 0)
- pref = prefs_find_preference(module, "standard");
- else if (strcmp(dotp, "net_addr_format") == 0)
- pref = prefs_find_preference(module, "addr_format");
- } else if (strcmp(module->name, "nlm") == 0) {
- /* Handle old names for NLM preferences. */
- if (strcmp(dotp, "nlm_msg_res_matching") == 0)
- pref = prefs_find_preference(module, "msg_res_matching");
- } else if (strcmp(module->name, "ppp") == 0) {
- /* Handle old names for PPP preferences. */
- if (strcmp(dotp, "ppp_fcs") == 0)
- pref = prefs_find_preference(module, "fcs_type");
- else if (strcmp(dotp, "ppp_vj") == 0)
- pref = prefs_find_preference(module, "decompress_vj");
- } else if (strcmp(module->name, "rsvp") == 0) {
- /* Handle old names for RSVP preferences. */
- if (strcmp(dotp, "rsvp_process_bundle") == 0)
- pref = prefs_find_preference(module, "process_bundle");
- } else if (strcmp(module->name, "tcp") == 0) {
- /* Handle old names for TCP preferences. */
- if (strcmp(dotp, "tcp_summary_in_tree") == 0)
- pref = prefs_find_preference(module, "summary_in_tree");
- else if (strcmp(dotp, "tcp_analyze_sequence_numbers") == 0)
- pref = prefs_find_preference(module, "analyze_sequence_numbers");
- else if (strcmp(dotp, "tcp_relative_sequence_numbers") == 0)
- pref = prefs_find_preference(module, "relative_sequence_numbers");
- } else if (strcmp(module->name, "udp") == 0) {
- /* Handle old names for UDP preferences. */
- if (strcmp(dotp, "udp_summary_in_tree") == 0)
- pref = prefs_find_preference(module, "summary_in_tree");
- } else if (strcmp(module->name, "ndps") == 0) {
- /* Handle old names for NDPS preferences. */
- if (strcmp(dotp, "desegment_ndps") == 0)
- pref = prefs_find_preference(module, "desegment_tcp");
- } else if (strcmp(module->name, "http") == 0) {
- /* Handle old names for HTTP preferences. */
- if (strcmp(dotp, "desegment_http_headers") == 0)
- pref = prefs_find_preference(module, "desegment_headers");
- else if (strcmp(dotp, "desegment_http_body") == 0)
- pref = prefs_find_preference(module, "desegment_body");
- } else if (strcmp(module->name, "smpp") == 0) {
- /* Handle preferences that moved from SMPP. */
- module_t *new_module = prefs_find_module("gsm-sms-ud");
- if(new_module){
- if (strcmp(dotp, "port_number_udh_means_wsp") == 0)
- pref = prefs_find_preference(new_module, "port_number_udh_means_wsp");
- else if (strcmp(dotp, "try_dissect_1st_fragment") == 0)
- pref = prefs_find_preference(new_module, "try_dissect_1st_fragment");
+ else if (g_ascii_strcasecmp(value, "false") == 0) {
+ gbl_resolv_flags.mac_name = FALSE;
+ gbl_resolv_flags.network_name = FALSE;
+ gbl_resolv_flags.transport_name = FALSE;
+ gbl_resolv_flags.concurrent_dns = FALSE;
}
- } else if (strcmp(module->name, "asn1") == 0) {
- /* Handle old generic ASN.1 preferences (it's not really a
- rename, as the new preferences support multiple ports,
- but we might as well copy them over). */
- if (strcmp(dotp, "tcp_port") == 0)
- pref = prefs_find_preference(module, "tcp_ports");
- else if (strcmp(dotp, "udp_port") == 0)
- pref = prefs_find_preference(module, "udp_ports");
- else if (strcmp(dotp, "sctp_port") == 0)
- pref = prefs_find_preference(module, "sctp_ports");
- } else if (strcmp(module->name, "llcgprs") == 0) {
- if (strcmp(dotp, "ignore_cipher_bit") == 0)
- pref = prefs_find_preference(module, "autodetect_cipher_bit");
- } else if (strcmp(module->name, "erf") == 0) {
- if (strcmp(dotp, "erfeth") == 0) {
- /* Handle the old "erfeth" preference; map it to the new
- "ethfcs" preference, and map the values to those for
- the new preference. */
- pref = prefs_find_preference(module, "ethfcs");
- if (strcmp(value, "ethfcs") == 0 || strcmp(value, "Ethernet with FCS") == 0)
- value = "TRUE";
- else if (strcmp(value, "eth") == 0 || strcmp(value, "Ethernet") == 0)
- value = "FALSE";
- else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0)
- value = "TRUE";
- } else if (strcmp(dotp, "erfatm") == 0) {
- /* Handle the old "erfatm" preference; map it to the new
- "aal5_type" preference, and map the values to those for
- the new preference. */
- pref = prefs_find_preference(module, "aal5_type");
- if (strcmp(value, "atm") == 0 || strcmp(value, "ATM") == 0)
- value = "guess";
- else if (strcmp(value, "llc") == 0 || strcmp(value, "LLC") == 0)
- value = "llc";
- else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0)
- value = "guess";
- } else if (strcmp(dotp, "erfhdlc") == 0) {
- /* Handle the old "erfhdlc" preference; map it to the new
- "hdlc_type" preference, and map the values to those for
- the new preference. */
- pref = prefs_find_preference(module, "hdlc_type");
- if (strcmp(value, "chdlc") == 0 || strcmp(value, "Cisco HDLC") == 0)
- value = "chdlc";
- else if (strcmp(value, "ppp") == 0 || strcmp(value, "PPP serial") == 0)
- value = "ppp";
- else if (strcmp(value, "fr") == 0 || strcmp(value, "Frame Relay") == 0)
- value = "frelay";
- else if (strcmp(value, "mtp2") == 0 || strcmp(value, "SS7 MTP2") == 0)
- value = "mtp2";
- else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0)
- value = "guess";
+ else {
+ /* start out with none set */
+ gbl_resolv_flags.mac_name = FALSE;
+ gbl_resolv_flags.network_name = FALSE;
+ gbl_resolv_flags.transport_name = FALSE;
+ gbl_resolv_flags.concurrent_dns = FALSE;
+ if (string_to_name_resolve(value, &gbl_resolv_flags) != '\0')
+ return PREFS_SET_SYNTAX_ERR;
}
- } else if (strcmp(module->name, "eth") == 0) {
- /* "eth.qinq_ethertype" has been changed(restored) to "vlan.qinq.ethertype" */
- if (strcmp(dotp, "qinq_ethertype") == 0) {
- module_t *new_module = prefs_find_module("vlan");
- if(new_module) {
- pref = prefs_find_preference(new_module, "qinq_ethertype");
- module = new_module;
- }
+ } else {
+ /* Handle deprecated "global" options that don't have a module
+ * associated with them
+ */
+ if ((strcmp(pref_name, "name_resolve_concurrency") == 0) ||
+ (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) ||
+ (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0)) {
+ module = nameres_module;
+ dotp = pref_name;
+ } else {
+ /* To which module does this preference belong? */
+ module = NULL;
+ last_dotp = pref_name;
+ while (!module) {
+ dotp = strchr(last_dotp, '.');
+ if (dotp == NULL) {
+ /* Either there's no such module, or no module was specified.
+ In either case, that means there's no such preference. */
+ return PREFS_SET_NO_SUCH_PREF;
+ }
+ *dotp = '\0'; /* separate module and preference name */
+ module = prefs_find_module(pref_name);
+
+ /*
+ * XXX - "Diameter" rather than "diameter" was used in earlier
+ * versions of Wireshark; if we didn't find the module, and its name
+ * was "Diameter", look for "diameter" instead.
+ *
+ * In addition, the BEEP protocol used to be the BXXP protocol,
+ * so if we didn't find the module, and its name was "bxxp",
+ * look for "beep" instead.
+ *
+ * Also, the preferences for GTP v0 and v1 were combined under
+ * a single "gtp" heading, and the preferences for SMPP were
+ * moved to "smpp-gsm-sms" and then moved to "gsm-sms-ud".
+ * However, SMPP now has its own preferences, so we just map
+ * "smpp-gsm-sms" to "gsm-sms-ud", and then handle SMPP below.
+ *
+ * We also renamed "dcp" to "dccp", "x.25" to "x25", "x411" to "p1"
+ * and "nsip" to "gprs_ns".
+ *
+ * The SynOptics Network Management Protocol (SONMP) is now known by
+ * 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;
+ }
+ if (module) {
+ g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
+ "Save your preferences to make this change permanent.",
+ pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
+ prefs.unknown_prefs = TRUE;
+ }
+ }
+ *dotp = '.'; /* put the preference string back */
+ dotp++; /* skip past separator to preference name */
+ last_dotp = dotp;
+ }
}
- } 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)
- pref = prefs_find_preference(stats_module, dotp);
- } else if (strcmp(module->name, "packet_list") == 0) {
- /* packet_list preferences moved to protocol module */
- if (strcmp(dotp, "display_hidden_proto_items") == 0)
- pref = prefs_find_preference(protocols_module, dotp);
- } else if (strcmp(module->name, "stream") == 0) {
- /* stream preferences moved to gui color module */
- if ((strcmp(dotp, "client.fg") == 0) ||
- (strcmp(dotp, "client.bg") == 0) ||
- (strcmp(dotp, "server.fg") == 0) ||
- (strcmp(dotp, "server.bg") == 0))
- pref = prefs_find_preference(gui_color_module, pref_name);
- } else if (strcmp(module->name, "nameres") == 0) {
- if (strcmp(pref_name, "name_resolve_concurrency") == 0) {
- pref = prefs_find_preference(nameres_module, pref_name);
- } else if (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) {
- pref = prefs_find_preference(nameres_module, "load_smi_modules");
- } else if (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0) {
- pref = prefs_find_preference(nameres_module, "suppress_smi_errors");
- }
- }
- }
- if (pref == NULL)
- return PREFS_SET_NO_SUCH_PREF; /* no such preference */
- switch (pref->type) {
+ pref = prefs_find_preference(module, dotp);
- case PREF_UINT:
- /* 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) {
- module->prefs_changed = TRUE;
- *pref->varp.uint = uval;
- }
- break;
+ if (pref == NULL) {
+ prefs.unknown_prefs = TRUE;
- case PREF_BOOL:
- /* XXX - give an error if it's neither "true" nor "false"? */
- if (g_ascii_strcasecmp(value, "true") == 0)
- bval = TRUE;
- else
- bval = FALSE;
- if (*pref->varp.boolp != bval) {
- module->prefs_changed = TRUE;
- *pref->varp.boolp = bval;
- }
- break;
+ /* "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)) {
+ pref = prefs_find_preference(module, pref_name);
+ }
+ else if (strcmp(module->name, "mgcp") == 0) {
+ /*
+ * XXX - "mgcp.display raw text toggle" and "mgcp.display dissect tree"
+ * rather than "mgcp.display_raw_text" and "mgcp.display_dissect_tree"
+ * were used in earlier versions of Wireshark; if we didn't find the
+ * preference, it was an MGCP preference, and its name was
+ * "display raw text toggle" or "display dissect tree", look for
+ * "display_raw_text" or "display_dissect_tree" instead.
+ *
+ * "mgcp.tcp.port" and "mgcp.udp.port" are harder to handle, as both
+ * the gateway and callagent ports were given those names; we interpret
+ * the first as "mgcp.{tcp,udp}.gateway_port" and the second as
+ * "mgcp.{tcp,udp}.callagent_port", as that's the order in which
+ * they were registered by the MCCP dissector and thus that's the
+ * order in which they were written to the preferences file. (If
+ * we're not reading the preferences file, but are handling stuff
+ * from a "-o" command-line option, we have no clue which the user
+ * had in mind - they should have used "mgcp.{tcp,udp}.gateway_port"
+ * or "mgcp.{tcp,udp}.callagent_port" instead.)
+ */
+ if (strcmp(dotp, "display raw text toggle") == 0)
+ pref = prefs_find_preference(module, "display_raw_text");
+ else if (strcmp(dotp, "display dissect tree") == 0)
+ pref = prefs_find_preference(module, "display_dissect_tree");
+ else if (strcmp(dotp, "tcp.port") == 0) {
+ mgcp_tcp_port_count++;
+ if (mgcp_tcp_port_count == 1) {
+ /* It's the first one */
+ pref = prefs_find_preference(module, "tcp.gateway_port");
+ } else if (mgcp_tcp_port_count == 2) {
+ /* It's the second one */
+ pref = prefs_find_preference(module, "tcp.callagent_port");
+ }
+ /* Otherwise it's from the command line, and we don't bother
+ mapping it. */
+ } else if (strcmp(dotp, "udp.port") == 0) {
+ mgcp_udp_port_count++;
+ if (mgcp_udp_port_count == 1) {
+ /* It's the first one */
+ pref = prefs_find_preference(module, "udp.gateway_port");
+ } else if (mgcp_udp_port_count == 2) {
+ /* It's the second one */
+ pref = prefs_find_preference(module, "udp.callagent_port");
+ }
+ /* Otherwise it's from the command line, and we don't bother
+ mapping it. */
+ }
+ } else if (strcmp(module->name, "smb") == 0) {
+ /* Handle old names for SMB preferences. */
+ if (strcmp(dotp, "smb.trans.reassembly") == 0)
+ pref = prefs_find_preference(module, "trans_reassembly");
+ else if (strcmp(dotp, "smb.dcerpc.reassembly") == 0)
+ pref = prefs_find_preference(module, "dcerpc_reassembly");
+ } else if (strcmp(module->name, "ndmp") == 0) {
+ /* Handle old names for NDMP preferences. */
+ if (strcmp(dotp, "ndmp.desegment") == 0)
+ pref = prefs_find_preference(module, "desegment");
+ } else if (strcmp(module->name, "diameter") == 0) {
+ /* Handle old names for Diameter preferences. */
+ if (strcmp(dotp, "diameter.desegment") == 0)
+ pref = prefs_find_preference(module, "desegment");
+ } else if (strcmp(module->name, "pcli") == 0) {
+ /* Handle old names for PCLI preferences. */
+ if (strcmp(dotp, "pcli.udp_port") == 0)
+ pref = prefs_find_preference(module, "udp_port");
+ } else if (strcmp(module->name, "artnet") == 0) {
+ /* Handle old names for ARTNET preferences. */
+ if (strcmp(dotp, "artnet.udp_port") == 0)
+ pref = prefs_find_preference(module, "udp_port");
+ } else if (strcmp(module->name, "mapi") == 0) {
+ /* Handle old names for MAPI preferences. */
+ if (strcmp(dotp, "mapi_decrypt") == 0)
+ pref = prefs_find_preference(module, "decrypt");
+ } else if (strcmp(module->name, "fc") == 0) {
+ /* Handle old names for Fibre Channel preferences. */
+ if (strcmp(dotp, "reassemble_fc") == 0)
+ pref = prefs_find_preference(module, "reassemble");
+ else if (strcmp(dotp, "fc_max_frame_size") == 0)
+ pref = prefs_find_preference(module, "max_frame_size");
+ } else if (strcmp(module->name, "fcip") == 0) {
+ /* Handle old names for Fibre Channel-over-IP preferences. */
+ if (strcmp(dotp, "desegment_fcip_messages") == 0)
+ pref = prefs_find_preference(module, "desegment");
+ else if (strcmp(dotp, "fcip_port") == 0)
+ pref = prefs_find_preference(module, "target_port");
+ } else if (strcmp(module->name, "gtp") == 0) {
+ /* Handle old names for GTP preferences. */
+ if (strcmp(dotp, "gtpv0_port") == 0)
+ pref = prefs_find_preference(module, "v0_port");
+ else if (strcmp(dotp, "gtpv1c_port") == 0)
+ pref = prefs_find_preference(module, "v1c_port");
+ else if (strcmp(dotp, "gtpv1u_port") == 0)
+ pref = prefs_find_preference(module, "v1u_port");
+ else if (strcmp(dotp, "gtp_dissect_tpdu") == 0)
+ pref = prefs_find_preference(module, "dissect_tpdu");
+ else if (strcmp(dotp, "gtpv0_dissect_cdr_as") == 0)
+ pref = prefs_find_preference(module, "v0_dissect_cdr_as");
+ else if (strcmp(dotp, "gtpv0_check_etsi") == 0)
+ pref = prefs_find_preference(module, "v0_check_etsi");
+ else if (strcmp(dotp, "gtpv1_check_etsi") == 0)
+ pref = prefs_find_preference(module, "v1_check_etsi");
+ } else if (strcmp(module->name, "ip") == 0) {
+ /* Handle old names for IP preferences. */
+ if (strcmp(dotp, "ip_summary_in_tree") == 0)
+ pref = prefs_find_preference(module, "summary_in_tree");
+ } else if (strcmp(module->name, "iscsi") == 0) {
+ /* Handle old names for iSCSI preferences. */
+ if (strcmp(dotp, "iscsi_port") == 0)
+ pref = prefs_find_preference(module, "target_port");
+ } else if (strcmp(module->name, "lmp") == 0) {
+ /* Handle old names for LMP preferences. */
+ if (strcmp(dotp, "lmp_version") == 0)
+ pref = prefs_find_preference(module, "version");
+ } else if (strcmp(module->name, "mtp3") == 0) {
+ /* Handle old names for MTP3 preferences. */
+ if (strcmp(dotp, "mtp3_standard") == 0)
+ pref = prefs_find_preference(module, "standard");
+ else if (strcmp(dotp, "net_addr_format") == 0)
+ pref = prefs_find_preference(module, "addr_format");
+ } else if (strcmp(module->name, "nlm") == 0) {
+ /* Handle old names for NLM preferences. */
+ if (strcmp(dotp, "nlm_msg_res_matching") == 0)
+ pref = prefs_find_preference(module, "msg_res_matching");
+ } else if (strcmp(module->name, "ppp") == 0) {
+ /* Handle old names for PPP preferences. */
+ if (strcmp(dotp, "ppp_fcs") == 0)
+ pref = prefs_find_preference(module, "fcs_type");
+ else if (strcmp(dotp, "ppp_vj") == 0)
+ pref = prefs_find_preference(module, "decompress_vj");
+ } else if (strcmp(module->name, "rsvp") == 0) {
+ /* Handle old names for RSVP preferences. */
+ if (strcmp(dotp, "rsvp_process_bundle") == 0)
+ pref = prefs_find_preference(module, "process_bundle");
+ } else if (strcmp(module->name, "tcp") == 0) {
+ /* Handle old names for TCP preferences. */
+ if (strcmp(dotp, "tcp_summary_in_tree") == 0)
+ pref = prefs_find_preference(module, "summary_in_tree");
+ else if (strcmp(dotp, "tcp_analyze_sequence_numbers") == 0)
+ pref = prefs_find_preference(module, "analyze_sequence_numbers");
+ else if (strcmp(dotp, "tcp_relative_sequence_numbers") == 0)
+ pref = prefs_find_preference(module, "relative_sequence_numbers");
+ } else if (strcmp(module->name, "udp") == 0) {
+ /* Handle old names for UDP preferences. */
+ if (strcmp(dotp, "udp_summary_in_tree") == 0)
+ pref = prefs_find_preference(module, "summary_in_tree");
+ } else if (strcmp(module->name, "ndps") == 0) {
+ /* Handle old names for NDPS preferences. */
+ if (strcmp(dotp, "desegment_ndps") == 0)
+ pref = prefs_find_preference(module, "desegment_tcp");
+ } else if (strcmp(module->name, "http") == 0) {
+ /* Handle old names for HTTP preferences. */
+ if (strcmp(dotp, "desegment_http_headers") == 0)
+ pref = prefs_find_preference(module, "desegment_headers");
+ else if (strcmp(dotp, "desegment_http_body") == 0)
+ pref = prefs_find_preference(module, "desegment_body");
+ } else if (strcmp(module->name, "smpp") == 0) {
+ /* Handle preferences that moved from SMPP. */
+ module_t *new_module = prefs_find_module("gsm-sms-ud");
+ if (new_module){
+ if (strcmp(dotp, "port_number_udh_means_wsp") == 0)
+ pref = prefs_find_preference(new_module, "port_number_udh_means_wsp");
+ else if (strcmp(dotp, "try_dissect_1st_fragment") == 0)
+ pref = prefs_find_preference(new_module, "try_dissect_1st_fragment");
+ }
+ } else if (strcmp(module->name, "asn1") == 0) {
+ /* Handle old generic ASN.1 preferences (it's not really a
+ rename, as the new preferences support multiple ports,
+ but we might as well copy them over). */
+ if (strcmp(dotp, "tcp_port") == 0)
+ pref = prefs_find_preference(module, "tcp_ports");
+ else if (strcmp(dotp, "udp_port") == 0)
+ pref = prefs_find_preference(module, "udp_ports");
+ else if (strcmp(dotp, "sctp_port") == 0)
+ pref = prefs_find_preference(module, "sctp_ports");
+ } else if (strcmp(module->name, "llcgprs") == 0) {
+ if (strcmp(dotp, "ignore_cipher_bit") == 0)
+ pref = prefs_find_preference(module, "autodetect_cipher_bit");
+ } else if (strcmp(module->name, "erf") == 0) {
+ if (strcmp(dotp, "erfeth") == 0) {
+ /* Handle the old "erfeth" preference; map it to the new
+ "ethfcs" preference, and map the values to those for
+ the new preference. */
+ pref = prefs_find_preference(module, "ethfcs");
+ if (strcmp(value, "ethfcs") == 0 || strcmp(value, "Ethernet with FCS") == 0)
+ value = "TRUE";
+ else if (strcmp(value, "eth") == 0 || strcmp(value, "Ethernet") == 0)
+ value = "FALSE";
+ else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0)
+ value = "TRUE";
+ } else if (strcmp(dotp, "erfatm") == 0) {
+ /* Handle the old "erfatm" preference; map it to the new
+ "aal5_type" preference, and map the values to those for
+ the new preference. */
+ pref = prefs_find_preference(module, "aal5_type");
+ if (strcmp(value, "atm") == 0 || strcmp(value, "ATM") == 0)
+ value = "guess";
+ else if (strcmp(value, "llc") == 0 || strcmp(value, "LLC") == 0)
+ value = "llc";
+ else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0)
+ value = "guess";
+ } else if (strcmp(dotp, "erfhdlc") == 0) {
+ /* Handle the old "erfhdlc" preference; map it to the new
+ "hdlc_type" preference, and map the values to those for
+ the new preference. */
+ pref = prefs_find_preference(module, "hdlc_type");
+ if (strcmp(value, "chdlc") == 0 || strcmp(value, "Cisco HDLC") == 0)
+ value = "chdlc";
+ else if (strcmp(value, "ppp") == 0 || strcmp(value, "PPP serial") == 0)
+ value = "ppp";
+ else if (strcmp(value, "fr") == 0 || strcmp(value, "Frame Relay") == 0)
+ value = "frelay";
+ else if (strcmp(value, "mtp2") == 0 || strcmp(value, "SS7 MTP2") == 0)
+ value = "mtp2";
+ else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0)
+ value = "guess";
+ }
+ } else if (strcmp(module->name, "eth") == 0) {
+ /* "eth.qinq_ethertype" has been changed(restored) to "vlan.qinq.ethertype" */
+ if (strcmp(dotp, "qinq_ethertype") == 0) {
+ module_t *new_module = prefs_find_module("vlan");
+ if (new_module) {
+ pref = prefs_find_preference(new_module, "qinq_ethertype");
+ module = new_module;
+ }
+ }
+ } 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)
+ pref = prefs_find_preference(stats_module, dotp);
+ } else if (strcmp(module->name, "packet_list") == 0) {
+ /* packet_list preferences moved to protocol module */
+ if (strcmp(dotp, "display_hidden_proto_items") == 0)
+ pref = prefs_find_preference(protocols_module, dotp);
+ } else if (strcmp(module->name, "stream") == 0) {
+ /* stream preferences moved to gui color module */
+ if ((strcmp(dotp, "client.fg") == 0) ||
+ (strcmp(dotp, "client.bg") == 0) ||
+ (strcmp(dotp, "server.fg") == 0) ||
+ (strcmp(dotp, "server.bg") == 0))
+ pref = prefs_find_preference(gui_color_module, pref_name);
+ } else if (strcmp(module->name, "nameres") == 0) {
+ if (strcmp(pref_name, "name_resolve_concurrency") == 0) {
+ pref = prefs_find_preference(nameres_module, pref_name);
+ } else if (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) {
+ pref = prefs_find_preference(nameres_module, "load_smi_modules");
+ } else if (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0) {
+ pref = prefs_find_preference(nameres_module, "suppress_smi_errors");
+ }
+ }
+ }
+ if (pref == NULL)
+ return PREFS_SET_NO_SUCH_PREF; /* no such preference */
+
+ switch (pref->type) {
+
+ case PREF_UINT:
+ /* 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) {
+ module->prefs_changed = TRUE;
+ *pref->varp.uint = uval;
+ }
+ break;
- case PREF_ENUM:
- /* XXX - give an error if it doesn't match? */
- enum_val = find_val_for_string(value, pref->info.enum_info.enumvals,
- *pref->varp.enump);
- if (*pref->varp.enump != enum_val) {
- module->prefs_changed = TRUE;
- *pref->varp.enump = enum_val;
- }
- break;
+ case PREF_BOOL:
+ /* XXX - give an error if it's neither "true" nor "false"? */
+ if (g_ascii_strcasecmp(value, "true") == 0)
+ bval = TRUE;
+ else
+ bval = FALSE;
+ if (*pref->varp.boolp != bval) {
+ module->prefs_changed = TRUE;
+ *pref->varp.boolp = bval;
+ }
+ break;
- case PREF_STRING:
- case PREF_FILENAME:
- case PREF_DIRNAME:
- if (strcmp(*pref->varp.string, value) != 0) {
- module->prefs_changed = TRUE;
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(value);
- }
- break;
+ case PREF_ENUM:
+ /* XXX - give an error if it doesn't match? */
+ enum_val = find_val_for_string(value, pref->info.enum_info.enumvals,
+ *pref->varp.enump);
+ if (*pref->varp.enump != enum_val) {
+ module->prefs_changed = TRUE;
+ *pref->varp.enump = enum_val;
+ }
+ break;
- case PREF_RANGE:
- {
- range_t *newrange;
+ case PREF_STRING:
+ case PREF_FILENAME:
+ case PREF_DIRNAME:
+ if (strcmp(*pref->varp.string, value) != 0) {
+ module->prefs_changed = TRUE;
+ g_free((void *)*pref->varp.string);
+ *pref->varp.string = g_strdup(value);
+ }
+ break;
- if (range_convert_str_work(&newrange, value, pref->info.max_value,
- return_range_errors) != CVT_NO_ERROR) {
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- }
+ case PREF_RANGE:
+ {
+ range_t *newrange;
- if (!ranges_are_equal(*pref->varp.range, newrange)) {
- module->prefs_changed = TRUE;
- g_free(*pref->varp.range);
- *pref->varp.range = newrange;
- } else {
- g_free (newrange);
- }
- break;
- }
+ if (range_convert_str_work(&newrange, value, pref->info.max_value,
+ return_range_errors) != CVT_NO_ERROR) {
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ }
- case PREF_COLOR:
- {
- cval = strtoul(value, NULL, 16);
- pref->varp.colorp->pixel = 0;
- if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
- (pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
- (pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
- module->prefs_changed = TRUE;
- pref->varp.colorp->red = RED_COMPONENT(cval);
- pref->varp.colorp->green = GREEN_COMPONENT(cval);
- pref->varp.colorp->blue = BLUE_COMPONENT(cval);
- }
- break;
- }
+ if (!ranges_are_equal(*pref->varp.range, newrange)) {
+ module->prefs_changed = TRUE;
+ g_free(*pref->varp.range);
+ *pref->varp.range = newrange;
+ } else {
+ g_free (newrange);
+ }
+ break;
+ }
- case PREF_CUSTOM:
- return pref->custom_cbs.set_cb(pref, value, &module->prefs_changed);
+ case PREF_COLOR:
+ {
+ cval = strtoul(value, NULL, 16);
+ pref->varp.colorp->pixel = 0;
+ if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
+ (pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
+ (pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
+ module->prefs_changed = TRUE;
+ pref->varp.colorp->red = RED_COMPONENT(cval);
+ pref->varp.colorp->green = GREEN_COMPONENT(cval);
+ pref->varp.colorp->blue = BLUE_COMPONENT(cval);
+ }
+ break;
+ }
- case PREF_STATIC_TEXT:
- case PREF_UAT:
- {
- break;
- }
+ case PREF_CUSTOM:
+ return pref->custom_cbs.set_cb(pref, value, &module->prefs_changed);
- case PREF_OBSOLETE:
- return PREFS_SET_OBSOLETE; /* no such preference any more */
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ {
+ break;
+ }
+
+ case PREF_OBSOLETE:
+ return PREFS_SET_OBSOLETE; /* no such preference any more */
+ }
}
- }
- return PREFS_SET_OK;
+ return PREFS_SET_OK;
}
typedef struct {
char *
prefs_pref_to_str(pref_t *pref, pref_source_t source) {
const char *pref_text = "[Unknown]";
- guint pref_uint;
- gboolean pref_boolval;
- gint pref_enumval;
- const char *pref_string;
- range_t *pref_range;
+ void *valp; /* pointer to preference value */
color_t *pref_color;
if (!pref) {
switch (source) {
case pref_default:
- pref_uint = pref->default_val.uint;
- pref_boolval = pref->default_val.boolval;
- pref_enumval = pref->default_val.enumval;
- pref_string = pref->default_val.string;
- pref_range = pref->default_val.range;
+ valp = &pref->default_val;
+ /* valp = &boolval, &enumval, etc. are implied by union property */
pref_color = &pref->default_val.color;
break;
case pref_stashed:
- pref_uint = pref->stashed_val.uint;
- pref_boolval = pref->stashed_val.boolval;
- pref_enumval = pref->stashed_val.enumval;
- pref_string = pref->stashed_val.string;
- pref_range = pref->stashed_val.range;
+ valp = &pref->stashed_val;
+ /* valp = &boolval, &enumval, etc. are implied by union property */
pref_color = &pref->stashed_val.color;
break;
case pref_current:
- pref_uint = *pref->varp.uint;
- pref_boolval = *pref->varp.boolp;
- pref_enumval = *pref->varp.enump;
- pref_string = *pref->varp.string;
- pref_range = *pref->varp.range;
+ valp = pref->varp.uint;
+ /* valp = boolval, enumval, etc. are implied by union property */
pref_color = pref->varp.colorp;
break;
default:
switch (pref->type) {
case PREF_UINT:
+ {
+ guint pref_uint = *(guint *) valp;
switch (pref->info.base) {
case 10:
return g_strdup_printf("%u", pref_uint);
- break;
case 8:
return g_strdup_printf("%#o", pref_uint);
- break;
case 16:
return g_strdup_printf("%#x", pref_uint);
- break;
}
break;
+ }
case PREF_BOOL:
- return g_strdup_printf("%s", pref_boolval ? "TRUE" : "FALSE");
- break;
+ return g_strdup_printf("%s", (*(gboolean *) valp) ? "TRUE" : "FALSE");
case PREF_ENUM:
{
+ gint pref_enumval = *(gint *) valp;
/*
* For now, we return the "description" value, so that if we
* save the preferences older versions of Wireshark can at
case PREF_STRING:
case PREF_FILENAME:
case PREF_DIRNAME:
- return g_strdup(pref_string);
- break;
+ return g_strdup(*(const char **) valp);
case PREF_RANGE:
- pref_text = range_convert_range(pref_range);
+ pref_text = range_convert_range(*(range_t **) valp);
break;
case PREF_COLOR:
(pref_color->red * 255 / 65535),
(pref_color->green * 255 / 65535),
(pref_color->blue * 255 / 65535));
- break;
case PREF_CUSTOM:
if (pref->custom_cbs.to_str_cb)
arg.pf = gui_pref_arg->pf;
g_list_foreach(arg.module->prefs, write_pref, &arg);
- if(prefs_module_has_submodules(module))
+ if (prefs_module_has_submodules(module))
return prefs_modules_foreach_submodules(module, write_module_prefs, user_data);
return 0;
int
write_prefs(char **pf_path_return)
{
- char *pf_path;
- FILE *pf;
- write_gui_pref_arg_t write_gui_pref_info;
+ char *pf_path;
+ FILE *pf;
+ write_gui_pref_arg_t write_gui_pref_info;
- /* Needed for "-G defaultprefs" */
- init_prefs();
+ /* Needed for "-G defaultprefs" */
+ init_prefs();
- /* To do:
- * - Split output lines longer than MAX_VAL_LEN
- * - Create a function for the preference directory check/creation
- * so that duplication can be avoided with filter.c
- */
+ /* To do:
+ * - Split output lines longer than MAX_VAL_LEN
+ * - Create a function for the preference directory check/creation
+ * so that duplication can be avoided with filter.c
+ */
- if (pf_path_return != NULL) {
- pf_path = get_persconffile_path(PF_NAME, TRUE);
- if ((pf = ws_fopen(pf_path, "w")) == NULL) {
- *pf_path_return = pf_path;
- return errno;
+ if (pf_path_return != NULL) {
+ pf_path = get_persconffile_path(PF_NAME, TRUE);
+ if ((pf = ws_fopen(pf_path, "w")) == NULL) {
+ *pf_path_return = pf_path;
+ return errno;
+ }
+ } else {
+ pf = stdout;
}
- } else {
- pf = stdout;
- }
-
- fputs("# Configuration file for Wireshark " VERSION ".\n"
- "#\n"
- "# This file is regenerated each time preferences are saved within\n"
- "# Wireshark. Making manual changes should be safe, however.\n"
- "# Preferences that have been commented out have not been\n"
- "# changed from their default value.\n", pf);
-
- /*
- * For "backwards compatibility" the GUI module is written first as it's
- * at the top of the file. This is followed by all modules that can't
- * fit into the preferences read/write API. Finally the remaining modules
- * are written in alphabetical order (including of course the protocol preferences)
- */
- write_gui_pref_info.pf = pf;
- write_gui_pref_info.is_gui_module = TRUE;
-
- 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");
-
- 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;
+
+ fputs("# Configuration file for Wireshark " VERSION ".\n"
+ "#\n"
+ "# This file is regenerated each time preferences are saved within\n"
+ "# Wireshark. Making manual changes should be safe, however.\n"
+ "# Preferences that have been commented out have not been\n"
+ "# changed from their default value.\n", pf);
+
+ /*
+ * For "backwards compatibility" the GUI module is written first as it's
+ * at the top of the file. This is followed by all modules that can't
+ * fit into the preferences read/write API. Finally the remaining modules
+ * are written in alphabetical order (including of course the protocol preferences)
+ */
+ write_gui_pref_info.pf = pf;
+ write_gui_pref_info.is_gui_module = TRUE;
+
+ 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");
+
+ 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);
+ write_gui_pref_info.is_gui_module = FALSE;
+ prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info);
- fclose(pf);
+ fclose(pf);
- /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
- an error indication, or maybe write to a new preferences file and
- rename that file on top of the old one only if there are not I/O
- errors. */
- return 0;
+ /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
+ an error indication, or maybe write to a new preferences file and
+ rename that file on top of the old one only if there are not I/O
+ errors. */
+ return 0;
}
/** The col_list is only partly managed by the custom preference API
static void
free_col_info(GList * list)
{
- fmt_data *cfmt;
-
- while (list != NULL) {
- cfmt = (fmt_data *)list->data;
-
- g_free(cfmt->title);
- g_free(cfmt->custom_field);
- g_free(cfmt);
- list = g_list_remove_link(list, list);
- }
- g_list_free(list);
- list = NULL;
+ fmt_data *cfmt;
+
+ while (list != NULL) {
+ cfmt = (fmt_data *)list->data;
+
+ g_free(cfmt->title);
+ g_free(cfmt->custom_field);
+ g_free(cfmt);
+ list = g_list_remove_link(list, list);
+ }
+ g_list_free(list);
+ list = NULL;
}
/*