aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/main.c3
-rw-r--r--gtk/prefs_dlg.c17
-rw-r--r--packet-diameter.c7
-rw-r--r--packet-iscsi.c9
-rw-r--r--prefs-int.h12
-rw-r--r--prefs.c98
-rw-r--r--prefs.h9
-rw-r--r--tethereal.c3
8 files changed, 144 insertions, 14 deletions
diff --git a/gtk/main.c b/gtk/main.c
index 1471ed321a..af37b3650b 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.208 2001/10/24 07:18:39 guy Exp $
+ * $Id: main.c,v 1.209 2001/11/04 02:50:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1133,6 +1133,7 @@ main(int argc, char *argv[])
break;
case PREFS_SET_NO_SUCH_PREF:
+ case PREFS_SET_OBSOLETE:
fprintf(stderr, "ethereal: -o flag \"%s\" specifies unknown preference\n",
optarg);
exit(1);
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index e1512ccfba..ddad06f934 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.32 2001/10/24 06:13:07 guy Exp $
+ * $Id: prefs_dlg.c,v 1.33 2001/11/04 02:50:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -136,6 +136,7 @@ pref_show(pref_t *pref, gpointer user_data)
/* Save the current value of the preference, so that we can revert it if
the user does "Apply" and then "Cancel", and create the control for
editing the preference. */
+ widget = NULL; /* squelch GCC complaints */
switch (pref->type) {
case PREF_UINT:
@@ -220,7 +221,7 @@ pref_show(pref_t *pref, gpointer user_data)
pref->control = widget;
break;
- default:
+ case PREF_OBSOLETE:
g_assert_not_reached();
widget = NULL;
break;
@@ -531,6 +532,10 @@ pref_fetch(pref_t *pref, gpointer user_data)
*pref->varp.string = g_strdup(str_val);
}
break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
}
}
@@ -571,6 +576,10 @@ pref_clean(pref_t *pref, gpointer user_data)
pref->saved_val.string = NULL;
}
break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
}
}
@@ -741,6 +750,10 @@ pref_revert(pref_t *pref, gpointer user_data)
*pref->varp.string = g_strdup(pref->saved_val.string);
}
break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
}
}
diff --git a/packet-diameter.c b/packet-diameter.c
index 36942f56c7..5bf3caeb72 100644
--- a/packet-diameter.c
+++ b/packet-diameter.c
@@ -1,7 +1,7 @@
/* packet-diameter.c
* Routines for Diameter packet disassembly
*
- * $Id: packet-diameter.c,v 1.32 2001/11/03 23:13:03 guy Exp $
+ * $Id: packet-diameter.c,v 1.33 2001/11/04 02:50:19 guy Exp $
*
* Copyright (c) 2001 by David Frascone <dave@frascone.com>
*
@@ -1801,4 +1801,9 @@ proto_register_diameter(void)
"Desegment all Diameter messages spanning multiple TCP segments",
"Whether the Diameter dissector should desegment all messages spanning multiple TCP segments",
&gbl_diameter_desegment);
+
+ /* Register some preferences we no longer support, so we can report
+ them as obsolete rather than just illegal. */
+ prefs_register_obsolete_preference(diameter_module, "udp.port");
+ prefs_register_obsolete_preference(diameter_module, "command_in_header");
} /* proto_register_diameter */
diff --git a/packet-iscsi.c b/packet-iscsi.c
index 812fb1c145..f6f86c419e 100644
--- a/packet-iscsi.c
+++ b/packet-iscsi.c
@@ -4,7 +4,7 @@
*
* Conforms to the protocol described in: draft-ietf-ips-iscsi-08.txt
*
- * $Id: packet-iscsi.c,v 1.16 2001/11/04 00:58:23 guy Exp $
+ * $Id: packet-iscsi.c,v 1.17 2001/11/04 02:50:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1767,6 +1767,13 @@ proto_register_iscsi(void)
"The size of a data digest (bytes)",
10,
&dataDigestSize);
+
+ /* Preference supported in older versions.
+ Register them as obsolete. */
+ prefs_register_obsolete_preference(iscsi_module,
+ "version_03_compatible");
+ prefs_register_obsolete_preference(iscsi_module,
+ "bogus_pdu_max_digest_padding");
}
}
diff --git a/prefs-int.h b/prefs-int.h
index 04eb084c38..352e19f663 100644
--- a/prefs-int.h
+++ b/prefs-int.h
@@ -2,12 +2,11 @@
* Definitions for implementation of preference handling routines;
* used by "friends" of the preferences type.
*
- * $Id: prefs-int.h,v 1.3 2000/11/18 21:41:36 guy Exp $
+ * $Id: prefs-int.h,v 1.4 2001/11/04 02:50:19 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -36,11 +35,16 @@ struct pref_module {
gboolean prefs_changed; /* if TRUE, a preference has changed since we last checked */
};
+/*
+ * PREF_OBSOLETE is used for preferences that a module used to support
+ * but no longer supports; we give different error messages for them.
+ */
typedef enum {
PREF_UINT,
PREF_BOOL,
PREF_ENUM,
- PREF_STRING
+ PREF_STRING,
+ PREF_OBSOLETE
} pref_type_t;
struct preference {
diff --git a/prefs.c b/prefs.c
index f58c1dce3c..257d91d336 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.69 2001/11/03 21:37:00 guy Exp $
+ * $Id: prefs.c,v 1.70 2001/11/04 02:50:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -53,6 +53,7 @@
#include "prefs-int.h"
/* Internal functions */
+static module_t *find_module(const char *name);
static struct preference *find_preference(module_t *, const char *);
static int set_pref(gchar*, gchar*);
static GList *get_string_list(gchar *);
@@ -111,6 +112,7 @@ prefs_register_module(const char *name, const char *title,
void (*apply_cb)(void))
{
module_t *module;
+ const guchar *p;
module = g_malloc(sizeof (module_t));
module->name = name;
@@ -120,6 +122,28 @@ prefs_register_module(const char *name, const char *title,
module->numprefs = 0;
module->prefs_changed = FALSE;
+ /*
+ * Make sure that only lower-case ASCII letters, numbers, and
+ * underscores appear in the module name.
+ *
+ * Crash if there is, as that's an error in the code;
+ * you can make the title a nice string with capitalization,
+ * white space, punctuation, etc., but the name can be used
+ * on the command line, and shouldn't require quoting,
+ * shifting, etc.
+ */
+ for (p = name; *p != '\0'; p++)
+ g_assert(isascii(*p) &&
+ (islower(*p) || isdigit(*p) || *p == '_'));
+
+ /*
+ * Make sure there's not already a module with that
+ * name. Crash if there is, as that's an error in the
+ * code, and the code has to be fixed not to register
+ * more than one module with the same name.
+ */
+ g_assert(find_module(name) == NULL);
+
modules = g_list_insert_sorted(modules, module, module_compare_name);
return module;
@@ -149,11 +173,11 @@ module_match(gconstpointer a, gconstpointer b)
}
static module_t *
-find_module(char *name)
+find_module(const char *name)
{
GList *list_entry;
- list_entry = g_list_find_custom(modules, name, module_match);
+ list_entry = g_list_find_custom(modules, (gpointer)name, module_match);
if (list_entry == NULL)
return NULL; /* no such module */
return (module_t *) list_entry->data;
@@ -218,6 +242,7 @@ register_preference(module_t *module, const char *name, const char *title,
const char *description)
{
pref_t *preference;
+ const guchar *p;
preference = g_malloc(sizeof (pref_t));
preference->name = name;
@@ -226,6 +251,20 @@ register_preference(module_t *module, const char *name, const char *title,
preference->ordinal = module->numprefs;
/*
+ * Make sure that only lower-case ASCII letters, numbers,
+ * underscores, and dots appear in the preference name.
+ *
+ * Crash if there is, as that's an error in the code;
+ * you can make the title and description nice strings
+ * with capitalization, white space, punctuation, etc.,
+ * but the name can be used on the command line,
+ * and shouldn't require quoting, Shifting, etc.
+ */
+ for (p = name; *p != '\0'; p++)
+ g_assert(isascii(*p) &&
+ (islower(*p) || isdigit(*p) || *p == '_' || *p == '.'));
+
+ /*
* Make sure there's not already a preference with that
* name. Crash if there is, as that's an error in the
* code, and the code has to be fixed not to register
@@ -348,6 +387,18 @@ prefs_register_string_preference(module_t *module, const char *name,
preference->saved_val.string = NULL;
}
+/*
+ * Register a preference that used to be supported but no longer is.
+ */
+void
+prefs_register_obsolete_preference(module_t *module, const char *name)
+{
+ pref_t *preference;
+
+ preference = register_preference(module, name, NULL, NULL);
+ preference->type = PREF_OBSOLETE;
+}
+
typedef struct {
pref_cb callback;
gpointer user_data;
@@ -359,6 +410,17 @@ do_pref_callback(gpointer data, gpointer user_data)
pref_t *pref = data;
pref_cb_arg_t *arg = user_data;
+ if (pref->type == PREF_OBSOLETE) {
+ /*
+ * This preference is no longer supported; it's not a
+ * real preference, so we don't call the callback for
+ * it (i.e., we treat it as if it weren't found in the
+ * list of preferences, and we weren't called in the
+ * first place).
+ */
+ return;
+ }
+
(*arg->callback)(pref, arg->user_data);
}
@@ -837,6 +899,13 @@ read_prefs_file(const char *pf_path, FILE *pf)
g_warning ("%s line %d: No such preference \"%s\"", pf_path,
pline, cur_var);
break;
+
+ case PREFS_SET_OBSOLETE:
+ /* We silently ignore attempts to set these; it's
+ probably not the user's fault that it's in there -
+ they may have saved preferences with a release that
+ supported them. */
+ break;
}
} else {
g_warning ("%s line %d: Incomplete preference", pf_path, pline);
@@ -898,6 +967,12 @@ read_prefs_file(const char *pf_path, FILE *pf)
g_warning ("%s line %d: No such preference \"%s\"", pf_path,
pline, cur_var);
break;
+
+ case PREFS_SET_OBSOLETE:
+ /* We silently ignore attempts to set these; it's probably not
+ the user's fault that it's in there - they may have saved
+ preferences with a release that supported it. */
+ break;
}
} else {
g_warning ("%s line %d: Incomplete preference", pf_path, pline);
@@ -1355,6 +1430,9 @@ set_pref(gchar *pref_name, gchar *value)
*pref->varp.string = g_strdup(value);
}
break;
+
+ case PREF_OBSOLETE:
+ return PREFS_SET_OBSOLETE; /* no such preference any more */
}
}
@@ -1377,6 +1455,16 @@ write_pref(gpointer data, gpointer user_data)
const enum_val_t *enum_valp;
const char *val_string;
+ if (pref->type == PREF_OBSOLETE) {
+ /*
+ * This preference is no longer supported; it's not a
+ * real preference, so we don't write it out (i.e., we
+ * treat it as if it weren't found in the list of
+ * preferences, and we weren't called in the first place).
+ */
+ return;
+ }
+
fprintf(arg->pf, "\n# %s\n", pref->description);
switch (pref->type) {
@@ -1434,6 +1522,10 @@ write_pref(gpointer data, gpointer user_data)
fprintf(arg->pf, "%s.%s: %s\n", arg->module->name, pref->name,
*pref->varp.string);
break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
}
}
diff --git a/prefs.h b/prefs.h
index b637f7f046..c8b88276dc 100644
--- a/prefs.h
+++ b/prefs.h
@@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
- * $Id: prefs.h,v 1.33 2001/10/31 07:47:25 guy Exp $
+ * $Id: prefs.h,v 1.34 2001/11/04 02:50:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -161,6 +161,12 @@ extern void prefs_register_enum_preference(module_t *module, const char *name,
extern void prefs_register_string_preference(module_t *module, const char *name,
const char *title, const char *description, char **var);
+/*
+ * Register a preference that used to be supported but no longer is.
+ */
+extern void prefs_register_obsolete_preference(module_t *module,
+ const char *name);
+
typedef void (*pref_cb)(pref_t *pref, gpointer user_data);
/*
@@ -212,6 +218,7 @@ extern void free_prefs(e_prefs *pr);
#define PREFS_SET_OK 0 /* succeeded */
#define PREFS_SET_SYNTAX_ERR 1 /* syntax error in string */
#define PREFS_SET_NO_SUCH_PREF 2 /* no such preference */
+#define PREFS_SET_OBSOLETE 3 /* preference used to exist but no longer does */
extern int prefs_set_pref(char *prefarg);
diff --git a/tethereal.c b/tethereal.c
index 9035db8e0c..75de86f80e 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.95 2001/10/26 18:28:16 gram Exp $
+ * $Id: tethereal.c,v 1.96 2001/11/04 02:50:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -446,6 +446,7 @@ main(int argc, char *argv[])
break;
case PREFS_SET_NO_SUCH_PREF:
+ case PREFS_SET_OBSOLETE:
fprintf(stderr, "tethereal: -o flag \"%s\" specifies unknown preference\n",
optarg);
exit(1);