diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-04-08 12:45:19 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-04-08 20:40:08 +0000 |
commit | 2c44a7f930967335b442e899c17e1eb46831e3c1 (patch) | |
tree | 7ce2db4007feccf638308dc205f509ec385436a3 /ui/gtk | |
parent | f1751ef22fc9877e59fad3b1c60826bff8569d94 (diff) | |
download | wireshark-2c44a7f930967335b442e899c17e1eb46831e3c1.tar.gz |
Clean up handling of enabled/disabled protocols/heuristic dissectors.
Add a "report a warning message" routine to the "report_err" code in
libwsutil, and rename files and routines appropriately, as they don't
only handle errors any more.
Have a routine read_enabled_and_disabled_protos() that reads all the
files that enable or disable protocols or heuristic dissectors, enables
and disables them based on the contents of those files, and reports
errors itself (as warnings) using the new "report a warning message"
routine. Fix that error reporting to report separately on the disabled
protocols, enabled protocols, and heuristic dissectors files.
Have a routine to set up the enabled and disabled protocols and
heuristic dissectors from the command-line arguments, so it's done the
same way in all programs.
If we try to enable or disable an unknown heuristic dissector via a
command-line argument, report an error.
Update a bunch of comments.
Update the name of disabled_protos_cleanup(), as it cleans up
information for disabled *and* enabled protocols and for heuristic
dissectors.
Support the command-line flags to enable and disable protocols and
heuristic dissectors in tfshark.
Change-Id: I9b8bd29947cccdf6dc34a0540b5509ef941391df
Reviewed-on: https://code.wireshark.org/review/20966
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/gtk')
-rw-r--r-- | ui/gtk/compare_stat.c | 2 | ||||
-rw-r--r-- | ui/gtk/main.c | 119 | ||||
-rw-r--r-- | ui/gtk/rtp_player.c | 2 | ||||
-rw-r--r-- | ui/gtk/simple_dialog.c | 9 | ||||
-rw-r--r-- | ui/gtk/stats_tree_stat.c | 2 | ||||
-rw-r--r-- | ui/gtk/uat_gui.c | 2 |
6 files changed, 41 insertions, 95 deletions
diff --git a/ui/gtk/compare_stat.c b/ui/gtk/compare_stat.c index 9a5d7d04a8..224c24b58e 100644 --- a/ui/gtk/compare_stat.c +++ b/ui/gtk/compare_stat.c @@ -38,7 +38,7 @@ #include <gtk/gtk.h> -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include <epan/stat_tap_ui.h> #include <epan/to_str.h> diff --git a/ui/gtk/main.c b/ui/gtk/main.c index b7002f5660..50b3c4c42d 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -53,7 +53,7 @@ #include <wsutil/filesystem.h> #include <wsutil/file_util.h> #include <wsutil/privileges.h> -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include <ws_version_info.h> #include <wiretap/merge.h> @@ -208,6 +208,7 @@ #include <gtkmacintegration/gtkosxapplication.h> #endif +#define INVALID_OPTION 1 #define INIT_FAILED 2 #define INVALID_CAPABILITY 2 #define INVALID_LINK_TYPE 2 @@ -1902,12 +1903,10 @@ get_wireshark_runtime_info(GString *str) } static e_prefs * -read_configuration_files(char **gdp_path, char **dp_path) +read_configuration_files(void) { int gpf_open_errno, gpf_read_errno; int cf_open_errno, df_open_errno; - int gdp_open_errno, gdp_read_errno; - int dp_open_errno, dp_read_errno; char *gpf_path, *pf_path; char *cf_path, *df_path; int pf_open_errno, pf_read_errno; @@ -1972,41 +1971,11 @@ read_configuration_files(char **gdp_path, char **dp_path) g_free(df_path); } - /* Read the disabled protocols file. */ - read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno, - dp_path, &dp_open_errno, &dp_read_errno); - read_enabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno, - dp_path, &dp_open_errno, &dp_read_errno); - read_disabled_heur_dissector_list(gdp_path, &gdp_open_errno, &gdp_read_errno, - dp_path, &dp_open_errno, &dp_read_errno); - if (*gdp_path != NULL) { - if (gdp_open_errno != 0) { - simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, - "Could not open global disabled protocols file\n\"%s\": %s.", - *gdp_path, g_strerror(gdp_open_errno)); - } - if (gdp_read_errno != 0) { - simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, - "I/O error reading global disabled protocols file\n\"%s\": %s.", - *gdp_path, g_strerror(gdp_read_errno)); - } - g_free(*gdp_path); - *gdp_path = NULL; - } - if (*dp_path != NULL) { - if (dp_open_errno != 0) { - simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, - "Could not open your disabled protocols file\n\"%s\": %s.", - *dp_path, g_strerror(dp_open_errno)); - } - if (dp_read_errno != 0) { - simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, - "I/O error reading your disabled protocols file\n\"%s\": %s.", - *dp_path, g_strerror(dp_read_errno)); - } - g_free(*dp_path); - *dp_path = NULL; - } + /* + * Read the files that enable and disable protocols and heuristic + * dissectors. + */ + read_enabled_and_disabled_protos(); return prefs_p; } @@ -2071,7 +2040,6 @@ main(int argc, char *argv[]) char *rf_path; int rf_open_errno; - char *gdp_path, *dp_path; int err; #ifdef HAVE_LIBPCAP gchar *err_str; @@ -2280,8 +2248,9 @@ main(int argc, char *argv[]) capture_session_init(&global_capture_session, &cfile); #endif - init_report_err(vfailure_alert_box, open_failure_alert_box, - read_failure_alert_box, write_failure_alert_box); + init_report_message(vfailure_alert_box, vwarning_alert_box, + open_failure_alert_box, read_failure_alert_box, + write_failure_alert_box); /* Non-blank filter means we're remote. Throttle splash screen and resolution updates. */ filter = get_conn_cfilter(); @@ -2357,7 +2326,7 @@ main(int argc, char *argv[]) splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win); - global_commandline_info.prefs_p = read_configuration_files (&gdp_path, &dp_path); + global_commandline_info.prefs_p = read_configuration_files(); /* Removed thread code: * https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=9e277ae6154fd04bf6a0a34ec5655a73e5a736a3 */ @@ -2476,43 +2445,13 @@ main(int argc, char *argv[]) } #endif - /* disabled protocols as per configuration file */ - if (gdp_path == NULL && dp_path == NULL) { - set_disabled_protos_list(); - set_enabled_protos_list(); - set_disabled_heur_dissector_list(); - } - - if(global_dissect_options.disable_protocol_slist) { - GSList *proto_disable; - for (proto_disable = global_dissect_options.disable_protocol_slist; proto_disable != NULL; proto_disable = g_slist_next(proto_disable)) - { - proto_disable_proto_by_name((char*)proto_disable->data); - } - } - - if(global_dissect_options.enable_protocol_slist) { - GSList *proto_enable; - for (proto_enable = global_dissect_options.enable_protocol_slist; proto_enable != NULL; proto_enable = g_slist_next(proto_enable)) - { - proto_enable_proto_by_name((char*)proto_enable->data); - } - } - - if(global_dissect_options.disable_heur_slist) { - GSList *heur_enable; - for (heur_enable = global_dissect_options.disable_heur_slist; heur_enable != NULL; heur_enable = g_slist_next(heur_enable)) - { - proto_enable_heuristic_by_name((char*)heur_enable->data, TRUE); - } - } - - if(global_dissect_options.disable_heur_slist) { - GSList *heur_disable; - for (heur_disable = global_dissect_options.disable_heur_slist; heur_disable != NULL; heur_disable = g_slist_next(heur_disable)) - { - proto_enable_heuristic_by_name((char*)heur_disable->data, FALSE); - } + /* + * Enabled and disabled protocols and heuristic dissectors as per + * command-line options. + */ + if (!setup_enabled_and_disabled_protocols()) { + ret = INVALID_OPTION; + goto clean_exit; } build_column_format_array(&cfile.cinfo, global_commandline_info.prefs_p->num_cols, TRUE); @@ -3314,7 +3253,6 @@ static void copy_global_profile (const gchar *profile_name) /* Change configuration profile */ void change_configuration_profile (const gchar *profile_name) { - char *gdp_path, *dp_path; char *rf_path; int rf_open_errno; gchar* err_msg = NULL; @@ -3347,11 +3285,18 @@ void change_configuration_profile (const gchar *profile_name) set_profile_name (profile_name); profile_bar_update (); - /* Reset current preferences and apply the new */ + /* + * Reset current preferences and enabled/disabled protocols and + * heuristic dissectors. + */ prefs_reset(); menu_prefs_reset(); + proto_reenable_all(); - (void) read_configuration_files (&gdp_path, &dp_path); + /* + * Read the configuration files for the new profile. + */ + (void) read_configuration_files(); if (!recent_read_profile_static(&rf_path, &rf_open_errno)) { simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, @@ -3379,14 +3324,6 @@ void change_configuration_profile (const gchar *profile_name) filter_expression_reinit(FILTER_EXPRESSION_REINIT_CREATE); toolbar_redraw_all(); - /* Enable all protocols and disable from the disabled list */ - proto_enable_all(); - if (gdp_path == NULL && dp_path == NULL) { - set_disabled_protos_list(); - set_enabled_protos_list(); - set_disabled_heur_dissector_list(); - } - /* Reload color filters */ if (!color_filters_reload(&err_msg, color_filter_add_cb)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg); diff --git a/ui/gtk/rtp_player.c b/ui/gtk/rtp_player.c index 269db47179..7b89901b90 100644 --- a/ui/gtk/rtp_player.c +++ b/ui/gtk/rtp_player.c @@ -64,7 +64,7 @@ #include <epan/dissectors/packet-rtp.h> #include <epan/rtp_pt.h> #include <epan/prefs.h> -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include "globals.h" diff --git a/ui/gtk/simple_dialog.c b/ui/gtk/simple_dialog.c index a8359186df..00b4a32af6 100644 --- a/ui/gtk/simple_dialog.c +++ b/ui/gtk/simple_dialog.c @@ -545,6 +545,15 @@ simple_error_message_box(const char *msg_format, ...) } /* + * Warning alert box, taking a format and a va_list argument. + */ +void +vsimple_warning_message_box(const char *msg_format, va_list ap) +{ + do_simple_message_box(ESD_TYPE_WARN, NULL, NULL, msg_format, ap); +} + +/* * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local Variables: diff --git a/ui/gtk/stats_tree_stat.c b/ui/gtk/stats_tree_stat.c index cedab7e84c..b2420fd96b 100644 --- a/ui/gtk/stats_tree_stat.c +++ b/ui/gtk/stats_tree_stat.c @@ -34,7 +34,7 @@ #include <gtk/gtk.h> -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include <wsutil/file_util.h> #include <epan/stats_tree_priv.h> diff --git a/ui/gtk/uat_gui.c b/ui/gtk/uat_gui.c index 247e522835..aea06302cb 100644 --- a/ui/gtk/uat_gui.c +++ b/ui/gtk/uat_gui.c @@ -44,7 +44,7 @@ # include <gdk/gdkkeysyms-compat.h> #endif -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include <epan/dfilter/dfilter-macro.h> #include <epan/proto.h> |