diff options
author | Balint Reczey <balint.reczey@ericsson.com> | 2010-03-03 17:19:30 +0000 |
---|---|---|
committer | Balint Reczey <balint.reczey@ericsson.com> | 2010-03-03 17:19:30 +0000 |
commit | e24d953fe19351b1925b184805d424cc758d58ad (patch) | |
tree | f14716c4cb399258dd58ff596e4913e43a7f6b9a /epan/oids.c | |
parent | 5baac1de18320f6a1055f69a62f0be6088134aab (diff) |
Disable OID resolution and loading SMI modules by default.
Add an option to enable OID resolution.
Add an option to suppress errors reported by libsmi.
svn path=/trunk/; revision=32096
Diffstat (limited to 'epan/oids.c')
-rw-r--r-- | epan/oids.c | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/epan/oids.c b/epan/oids.c index 153a585ab1..31948d2df3 100644 --- a/epan/oids.c +++ b/epan/oids.c @@ -44,6 +44,8 @@ #ifdef HAVE_LIBSMI #include <smi.h> + +static gboolean oids_init_done = FALSE; #endif #define D(level,args) do if (debuglevel >= level) { printf args; printf("\n"); fflush(stdout); } while(0) @@ -486,7 +488,14 @@ static inline oid_kind_t smikind(SmiNode* sN, oid_key_t** key_p) { || (ft == FT_INT8) || (ft == FT_INT16) || (ft == FT_INT24) || (ft == FT_INT32) \ || (ft == FT_UINT64) || (ft == FT_INT64) ) -static void register_mibs(void) { +static void unregister_mibs(void) { + /* TODO: Unregister "MIBs" proto and clean up field array and subtree array. + * Wireshark does not support that yet. :-( */ + + /* smiExit(); */ +} + +static void register_mibs() { SmiModule *smiModule; SmiNode *smiNode; guint i; @@ -531,8 +540,6 @@ static void register_mibs(void) { smi_paths_fields); - smiInit(NULL); - uat_load(smi_modules_uat, &smi_load_error); if (smi_load_error) { @@ -547,6 +554,22 @@ static void register_mibs(void) { return; } + if (!prefs.load_smi_modules) { + D(1,("OID resolution not enabled")); + return; + } + + /* TODO: Remove this workaround when unregistration of "MIBs" proto is solved. + * Wireshark does not support that yet. :-( */ + if (oids_init_done) { + D(1,("Exiting register_mibs() to avoid double registration of MIBs proto.")); + return; + } else { + oids_init_done = TRUE; + } + + smiInit(NULL); + smi_errors = g_string_new(""); smiSetErrorHandler(smi_error_handler); @@ -570,11 +593,13 @@ static void register_mibs(void) { } if (smi_errors->len) { - report_failure("The following errors were found while loading the MIBS:\n%s\n\n" + if (!prefs.suppress_smi_errors) { + report_failure("The following errors were found while loading the MIBS:\n%s\n\n" "The Current Path is: %s\n\nYou can avoid this error message " "by removing the missing MIB modules at Edit -> Preferences" " -> Name Resolution -> SMI (MIB and PIB) modules or by " "installing them.\n" , smi_errors->str , path_str); + } D(1,("Errors while loading:\n%s\n",smi_errors->str)); } @@ -592,11 +617,13 @@ static void register_mibs(void) { * Currently there is no such version. :-( */ if (smiModule->conformance == 1) - report_failure("Stopped processing module %s due to " - "error(s) to prevent potential crash in libsmi.\n" - "Module's conformance level: %d.\n" - "See details at: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560325\n", - smiModule->name, smiModule->conformance); + if (!prefs.suppress_smi_errors) { + report_failure("Stopped processing module %s due to " + "error(s) to prevent potential crash in libsmi.\n" + "Module's conformance level: %d.\n" + "See details at: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560325\n", + smiModule->name, smiModule->conformance); + } continue; for (smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_ANY); @@ -736,6 +763,14 @@ void oids_init(void) { #endif } +void oids_cleanup(void) { +#ifdef HAVE_LIBSMI + unregister_mibs(); +#else + D(1,("libsmi disabled oid resolution not enabled")); +#endif +} + const char* oid_subid2string(guint32* subids, guint len) { char* s = ep_alloc0(((len)*11)+1); char* w = s; |