aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/epan.c1
-rw-r--r--epan/oids.c53
-rw-r--r--epan/oids.h5
-rw-r--r--epan/prefs.c30
-rw-r--r--epan/prefs.h2
-rw-r--r--gtk/prefs_nameres.c46
6 files changed, 127 insertions, 10 deletions
diff --git a/epan/epan.c b/epan/epan.c
index ec1211a077..176e83ecc5 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -99,7 +99,6 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
final_registration_all_protocols();
host_name_lookup_init();
expert_init();
- oids_init();
#ifdef HAVE_LUA_5_1
wslua_init(NULL);
#endif
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;
diff --git a/epan/oids.h b/epan/oids.h
index 2143cdb261..328cd813f8 100644
--- a/epan/oids.h
+++ b/epan/oids.h
@@ -27,6 +27,8 @@
#ifndef __OIDS_H__
#define __OIDS_H__
+#include <epan/ftypes/ftypes.h>
+
#define BER_TAG_ANY -1
struct _oid_bit_t {
@@ -103,6 +105,9 @@ typedef struct _oid_info_t {
/* init funcion called from epan.h */
extern void oids_init(void);
+/* init funcion called from epan.h */
+extern void oids_cleanup(void);
+
/*
* The objects returned by all these functions are all allocated with a
* packet lifetime and does not have have to be freed.
diff --git a/epan/prefs.c b/epan/prefs.c
index 81cf8a5f57..b99f1e268a 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -41,6 +41,7 @@
#include <epan/filesystem.h>
#include <epan/address.h>
#include <epan/addr_resolv.h>
+#include <epan/oids.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto.h>
@@ -1206,6 +1207,8 @@ init_prefs(void) {
/* set the default values for the name resolution dialog box */
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
prefs.name_resolve_concurrency = 500;
+ prefs.load_smi_modules = FALSE;
+ prefs.suppress_smi_errors = FALSE;
/* set the default values for the tap/statistics dialog box */
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
@@ -1238,6 +1241,7 @@ prefs_reset(void)
g_free(prefs.capture_devices_hide);
uat_unload_all();
+ oids_cleanup();
init_prefs();
}
@@ -1261,6 +1265,11 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
char *pf_path;
FILE *pf;
+ /* clean up libsmi structures before reading prefs */
+ if (prefs.load_smi_modules) {
+ oids_cleanup();
+ }
+
init_prefs();
/*
@@ -1359,6 +1368,11 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
g_free(pf_path);
}
+ /* load SMI modules if needed */
+ if (prefs.load_smi_modules) {
+ oids_init();
+ }
+
return &prefs;
}
@@ -1673,6 +1687,8 @@ prefs_is_capture_device_hidden(const char *name)
*/
#define PRS_NAME_RESOLVE "name_resolve"
#define PRS_NAME_RESOLVE_CONCURRENCY "name_resolve_concurrency"
+#define PRS_NAME_RESOLVE_LOAD_SMI_MODULES "name_resolve_load_smi_modules"
+#define PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS "name_resolve_suppress_smi_errors"
#define PRS_CAP_NAME_RESOLVE "capture.name_resolve"
/* values for the capture dialog box */
@@ -2177,6 +2193,10 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
}
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_CONCURRENCY) == 0) {
prefs.name_resolve_concurrency = strtol(value, NULL, 10);
+ } else if (strcmp(pref_name, PRS_NAME_RESOLVE_LOAD_SMI_MODULES) == 0) {
+ prefs.load_smi_modules = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
+ } else if (strcmp(pref_name, PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS) == 0) {
+ prefs.suppress_smi_errors = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else if ((strcmp(pref_name, PRS_RTP_PLAYER_MAX_VISIBLE) == 0) ||
(strcmp(pref_name, "rtp_player.max_visible") == 0)) {
/* ... also accepting old name for this preference */
@@ -3054,6 +3074,16 @@ write_prefs(char **pf_path_return)
fprintf(pf, PRS_NAME_RESOLVE_CONCURRENCY ": %d\n",
prefs.name_resolve_concurrency);
+ fprintf(pf, "\n# Load SMI modules?\n");
+ fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(pf, PRS_NAME_RESOLVE_LOAD_SMI_MODULES ": %s\n",
+ prefs.load_smi_modules == TRUE ? "TRUE" : "FALSE");
+
+ fprintf(pf, "\n# Suppress SMI errors?\n");
+ fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(pf, PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS ": %s\n",
+ prefs.suppress_smi_errors == TRUE ? "TRUE" : "FALSE");
+
fprintf(pf, "\n####### Taps/Statistics ########\n");
fprintf(pf, "\n# Tap update interval in ms.\n");
diff --git a/epan/prefs.h b/epan/prefs.h
index 058e879912..68c97cbc14 100644
--- a/epan/prefs.h
+++ b/epan/prefs.h
@@ -147,6 +147,8 @@ typedef struct _e_prefs {
gint console_log_level;
guint32 name_resolve;
gint name_resolve_concurrency;
+ gboolean load_smi_modules;
+ gboolean suppress_smi_errors;
gchar *capture_device;
gchar *capture_devices_linktypes;
gchar *capture_devices_descr;
diff --git a/gtk/prefs_nameres.c b/gtk/prefs_nameres.c
index ed00bc8588..3a42e958a8 100644
--- a/gtk/prefs_nameres.c
+++ b/gtk/prefs_nameres.c
@@ -31,6 +31,7 @@
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
#include <epan/uat.h>
+#include <epan/oids.h>
#include "../globals.h"
@@ -60,6 +61,8 @@
#endif
#ifdef HAVE_LIBSMI
+# define SUPPRESS_SMI_ERRORS_KEY "suppress_smi_errors"
+# define LOAD_SMI_MODULES_KEY "load_smi_modules"
# define SMI_TABLE_ROWS 2
#else
# define SMI_TABLE_ROWS 0
@@ -91,6 +94,7 @@ nameres_prefs_show(void)
char concur_str[10+1];
#endif /* HAVE_C_ARES || HAVE_GNU_ADNS */
#ifdef HAVE_LIBSMI
+ GtkWidget *load_smi_modules_cb, *suppress_smi_errors_cb;
uat_t *smi_paths_uat;
uat_t *smi_modules_uat;
#endif
@@ -162,6 +166,20 @@ nameres_prefs_show(void)
"Support for this feature was not compiled into this version of Wireshark");
#endif /* HAVE_C_ARES || HAVE_GNU_ADNS */
#ifdef HAVE_LIBSMI
+ /* Suppress smi errors */
+ table_row++;
+ load_smi_modules_cb = create_preference_check_button(main_tb, table_row,
+ "Enable OID resolution:", "You must restart Wireshark for this change to"
+ " take effect.", prefs.load_smi_modules);
+ g_object_set_data(G_OBJECT(main_vb), LOAD_SMI_MODULES_KEY, load_smi_modules_cb);
+
+ /* Suppress smi errors */
+ table_row++;
+ suppress_smi_errors_cb = create_preference_check_button(main_tb, table_row,
+ "Suppress SMI errors:", "Some errors can be ignored. If unsure, set to false.",
+ prefs.suppress_smi_errors);
+ g_object_set_data(G_OBJECT(main_vb), SUPPRESS_SMI_ERRORS_KEY, suppress_smi_errors_cb);
+
/* SMI paths UAT */
smi_paths_uat = uat_get_table_by_name("SMI Paths");
if (smi_paths_uat) {
@@ -188,6 +206,14 @@ nameres_prefs_show(void)
create_preference_static_text(main_tb, table_row,
"SMI (MIB and PIB) modules and paths: N/A",
"Support for this feature was not compiled into this version of Wireshark");
+ table_row++;
+ create_preference_static_text(main_tb, table_row,
+ "Enable OID resolution: N/A",
+ "Support for this feature was not compiled into this version of Wireshark");
+ table_row++;
+ create_preference_static_text(main_tb, table_row,
+ "Suppress SMI errors: N/A",
+ "Support for this feature was not compiled into this version of Wireshark");
#endif /* HAVE_LIBSMI */
#ifdef HAVE_GEOIP
@@ -225,6 +251,10 @@ nameres_prefs_fetch(GtkWidget *w)
#if defined(HAVE_C_ARES) || defined(HAVE_GNU_ADNS)
GtkWidget *c_resolv_cb, *resolv_concurrency_te;
#endif /* HAVE_C_ARES || HAVE_GNU_ADNS */
+#ifdef HAVE_LIBSMI
+ GtkWidget *load_smi_modules_cb, *suppress_smi_errors_cb;
+ gboolean load_smi_modules_orig;
+#endif
m_resolv_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), M_RESOLVE_KEY);
n_resolv_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), N_RESOLVE_KEY);
@@ -245,6 +275,22 @@ nameres_prefs_fetch(GtkWidget *w)
prefs.name_resolve_concurrency = strtol (gtk_entry_get_text(
GTK_ENTRY(resolv_concurrency_te)), NULL, 10);
#endif /* HAVE_C_ARES || HAVE_GNU_ADNS */
+#ifdef HAVE_LIBSMI
+ load_smi_modules_orig = prefs.load_smi_modules;
+ load_smi_modules_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), LOAD_SMI_MODULES_KEY);
+ prefs.load_smi_modules = GTK_TOGGLE_BUTTON (load_smi_modules_cb)->active;
+ suppress_smi_errors_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), SUPPRESS_SMI_ERRORS_KEY);
+ prefs.suppress_smi_errors = GTK_TOGGLE_BUTTON (suppress_smi_errors_cb)->active;
+
+ /* Perform actions needed when enabling/disabling OID resolution */
+ if (load_smi_modules_orig && !prefs.load_smi_modules) {
+ prefs.load_smi_modules = TRUE; /* hack to make oids_cleanup() actually do something */
+ oids_cleanup();
+ prefs.load_smi_modules = FALSE; /* end hack */
+ } else if (!load_smi_modules_orig && prefs.load_smi_modules) {
+ oids_init();
+ }
+#endif
}
void