diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-09-08 20:45:50 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-09-08 20:45:50 +0000 |
commit | c324caf6aa695508b0c830a414fa8a4e6793d5bc (patch) | |
tree | 4e39738956c50a0c87cecea158dc60c5ce88158b /packet-snmp.c | |
parent | 62e7edc9717d101a0dfa281b4c35b1a8f6fb4bbf (diff) |
There is no such thing as a preference that's not set - string
preferences are set to a null string if their value is null - so just
initialize "mib_modules" to DEF_MIB_MODULES and then, in the register
routine, override that with the setting of MIBS if it's set.
svn path=/trunk/; revision=8417
Diffstat (limited to 'packet-snmp.c')
-rw-r--r-- | packet-snmp.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/packet-snmp.c b/packet-snmp.c index 8407cc1c7c..97003f1da8 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -10,7 +10,7 @@ * * See RFCs 2570-2576 for SNMPv3 * - * $Id: packet-snmp.c,v 1.115 2003/09/08 20:21:04 guy Exp $ + * $Id: packet-snmp.c,v 1.116 2003/09/08 20:45:50 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -57,8 +57,6 @@ #include "packet-frame.h" #ifdef HAVE_SOME_SNMP -/*Default MIB Modules to load"*/ -#define DEF_MIB_MODULES "IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:SNMPv2-MIB:RFC1213-MIB:UCD-SNMP-MIB" #ifdef HAVE_NET_SNMP # include <net-snmp/net-snmp-config.h> @@ -118,7 +116,10 @@ static int proto_snmp = -1; -static gchar *mib_modules = NULL; +/* Default MIB modules to load */ +#define DEF_MIB_MODULES "IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:SNMPv2-MIB:RFC1213-MIB:UCD-SNMP-MIB" + +static gchar *mib_modules = DEF_MIB_MODULES; static gboolean display_oid = TRUE; static gint ett_snmp = -1; @@ -2351,6 +2352,7 @@ proto_register_snmp(void) char *mib_path; #define MIB_PATH_APPEND "snmp\\mibs" #endif + gchar *tmp_mib_modules; static hf_register_info hf[] = { { &hf_snmp_version, @@ -2450,6 +2452,16 @@ proto_register_snmp(void) "Whether the SNMP OID should be shown in the info column", &display_oid); + /* + * Set the default value of "mib_modules". + * + * If the MIBS environment variable is set, make its value + * the value of "mib_modules", otherwise, set "mib_modules" + * to DEF_MIB_MODULES. + */ + tmp_mib_modules = getenv("MIBS"); + if (tmp_mib_modules != NULL) + mib_modules = tmp_mib_modules; prefs_register_string_preference(snmp_module, "mib_modules", "MIB modules to load", "List of MIB modules to load (the list is set to environment variable MIBS if the variable is not already set)", @@ -2465,9 +2477,6 @@ void proto_reg_handoff_snmp(void) { dissector_handle_t snmp_tcp_handle; -#ifdef HAVE_SOME_SNMP - gchar *tmp_mib_modules; -#endif dissector_add("udp.port", UDP_PORT_SNMP, snmp_handle); dissector_add("udp.port", UDP_PORT_SNMP_TRAP, snmp_handle); @@ -2482,31 +2491,14 @@ proto_reg_handoff_snmp(void) data_handle = find_dissector("data"); -#ifdef HAVE_SOME_SNMP /* - * Load MIBs. We can't do this in the register routine, as we - * need the value of the "mib_modules" preference, and - * preferences aren't read until all dissector register routines - * have been called (so that all dissector preferences have - * been registered. - * - * If the mib_modules preference isn't set: + * Process preference settings. * - * if the MIBS environment variable is set to a value other - * than an empty string, make its value the value of - * "mib_modules"; - * - * otherwise, set it to DEF_MIB_MODULES. + * We can't do this in the register routine, as preferences aren't + * read until all dissector register routines have been called (so + * that all dissector preferences have been registered). */ - if (mib_modules == NULL) { - tmp_mib_modules = getenv("MIBS"); - if (tmp_mib_modules != NULL) - mib_modules = g_strdup(tmp_mib_modules); - else - mib_modules = g_strdup(DEF_MIB_MODULES); - } process_prefs(); -#endif /* HAVE_SOME_SNMP */ } void |