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>
This commit is contained in:
Guy Harris 2017-04-08 12:45:19 -07:00
parent f1751ef22f
commit 2c44a7f930
61 changed files with 670 additions and 783 deletions

View File

@ -91,7 +91,7 @@
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#ifdef HAVE_EXTCAP
#include "extcap.h"
#endif

View File

@ -81,7 +81,7 @@
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/str_util.h>
#include <wsutil/file_util.h>
@ -1378,10 +1378,11 @@ print_usage(FILE *output)
#ifdef HAVE_PLUGINS
/*
* General errors are reported with an console message in capinfos.
* General errors and warnings are reported with an console message
* in capinfos.
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "capinfos: ");
vfprintf(stderr, msg_format, ap);
@ -1468,7 +1469,8 @@ main(int argc, char *argv[])
wtap_init();
#ifdef HAVE_PLUGINS
init_report_err(failure_message, NULL, NULL, NULL);
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
/* Scan for plugins. This does *not* call their registration routines;
that's done later.

View File

@ -50,7 +50,7 @@
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/str_util.h>
#ifdef _WIN32
@ -70,10 +70,11 @@ print_usage(FILE *output)
#ifdef HAVE_PLUGINS
/*
* General errors are reported with an console message in captype.
* General errors and warnings are reported with an console message
* in captype.
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "captype: ");
vfprintf(stderr, msg_format, ap);
@ -143,7 +144,8 @@ main(int argc, char *argv[])
wtap_init();
#ifdef HAVE_PLUGINS
init_report_err(failure_message,NULL,NULL,NULL);
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
/* Scan for plugins. This does *not* call their registration routines;
that's done later.

View File

@ -40,14 +40,14 @@
#endif
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wiretap/wtap.h>
#include "ui/util.h"
#include "register.h"
static void failure_message(const char *msg_format, va_list ap);
static void failure_warning_message(const char *msg_format, va_list ap);
static void open_failure_message(const char *filename, int err,
gboolean for_writing);
static void read_failure_message(const char *filename, int err);
@ -80,8 +80,9 @@ main(int argc, char **argv)
g_free(init_progfile_dir_error);
}
init_report_err(failure_message, open_failure_message,
read_failure_message, write_failure_message);
init_report_message(failure_warning_message, failure_warning_message,
open_failure_message, read_failure_message,
write_failure_message);
timestamp_set_type(TS_RELATIVE);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
@ -172,10 +173,11 @@ main(int argc, char **argv)
}
/*
* General errors are reported with an console message in "dftest".
* General errors and warnings are reported with an console message
* in "dftest".
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "dftest: ");
vfprintf(stderr, msg_format, ap);

View File

@ -83,7 +83,7 @@
#include <wsutil/wsgcrypt.h>
#include <wsutil/plugins.h>
#include <wsutil/privileges.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/strnatcmp.h>
#include <wsutil/str_util.h>
#include <ws_version_info.h>
@ -910,10 +910,11 @@ framenum_compare(gconstpointer a, gconstpointer b, gpointer user_data _U_)
}
/*
* General errors are reported with an console message in editcap.
* General errors and warnings are reported with an console message
* in editcap.
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "editcap: ");
vfprintf(stderr, msg_format, ap);
@ -998,7 +999,7 @@ main(int argc, char *argv[])
char *shb_user_appl;
int ret = EXIT_SUCCESS;
cmdarg_err_init(failure_message, failure_message_cont);
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
@ -1042,7 +1043,8 @@ main(int argc, char *argv[])
#ifdef HAVE_PLUGINS
/* Register wiretap plugins */
init_report_err(failure_message,NULL,NULL,NULL);
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
/* Scan for plugins. This does *not* call their registration routines;
that's done later.

View File

@ -100,7 +100,7 @@
#include "addr_resolv.h"
#include "wsutil/filesystem.h"
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/file_util.h>
#include <wsutil/pint.h>
#include "wsutil/inet_aton.h"

View File

@ -36,6 +36,7 @@
#include "disabled_protos.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include <wsutil/report_message.h>
#define ENABLED_PROTOCOLS_FILE_NAME "enabled_protos"
#define DISABLED_PROTOCOLS_FILE_NAME "disabled_protos"
@ -268,8 +269,7 @@ save_protos_list(char **pref_path_return, int *errno_return, const char* filenam
}
static int
read_protos_list_file(const char *ff_path, FILE *ff,
GList **flp)
read_protos_list_file(const char *ff_path, FILE *ff, GList **flp)
{
protocol_def *prot;
int c;
@ -285,8 +285,8 @@ read_protos_list_file(const char *ff_path, FILE *ff,
prot_name = (char *)g_malloc(prot_name_len + 1);
for (line = 1; ; line++) {
/* Lines in a disabled protocol file contain the "filter name" of
a protocol to be disabled. */
/* Lines in a protocol file contain the "filter name" of a protocol
to be enabled or disabled. */
/* Skip over leading white space, if any. */
while ((c = ws_getc_unlocked(ff)) != EOF && g_ascii_isspace(c)) {
@ -381,20 +381,27 @@ error:
}
/*
* Read in a list of protocols.
* Read in global and personal versions of a list of protocols.
*
* On success, "*pref_path_return" is set to NULL.
* On error, "*pref_path_return" is set to point to the pathname of
* the file we tried to read - it should be freed by our caller -
* and "*open_errno_return" is set to the error if an open failed
* or "*read_errno_return" is set to the error if a read failed.
* If we can open and read the global version, *gpath_return is set to
* NULL. Otherwise, *gpath_return is set to point to the pathname of
* the file we tried to read - it should be freed by our caller - and
* *gopen_errno_return is set to the error if an open failed or
* *gread_errno_return is set to the error if a read failed.
*
* If we can open and read the personal version, *path_return is set to
* NULL. Otherwise, *path_return is set to point to the pathname of
* the file we tried to read - it should be freed by our caller - and
* *open_errno_return is set to the error if an open failed or
* *read_errno_return is set to the error if a read failed.
*/
static void
read_protos_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return, const char* filename,
GList **protos_list, GList **global_protos_list)
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return,
const char* filename,
GList **global_protos_list, GList **protos_list)
{
int err;
char *gff_path, *ff_path;
@ -410,8 +417,7 @@ read_protos_list(char **gpath_return, int *gopen_errno_return,
*gpath_return = NULL;
if ((ff = ws_fopen(gff_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
err = read_protos_list_file(gff_path, ff,
global_protos_list);
err = read_protos_list_file(gff_path, ff, global_protos_list);
if (err != 0) {
/* We had an error reading the file; return the errno and the
pathname, so our caller can report the error. */
@ -470,29 +476,6 @@ read_protos_list(char **gpath_return, int *gopen_errno_return,
* Disabling dissectors
************************************************************************/
/*
* Read in a list of disabled protocols.
*/
void
read_disabled_protos_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return)
{
read_protos_list(gpath_return, gopen_errno_return, gread_errno_return,
path_return, open_errno_return, read_errno_return,
DISABLED_PROTOCOLS_FILE_NAME, &disabled_protos, &global_disabled_protos);
}
/*
* Disable protocols as per the stored configuration
*/
void
set_disabled_protos_list(void)
{
set_protos_list(disabled_protos, global_disabled_protos, FALSE);
}
/*
* Disable a particular protocol by name
*/
@ -531,12 +514,6 @@ save_disabled_protos_list(char **pref_path_return, int *errno_return)
/************************************************************************
* Enabling dissectors (that are disabled by default)
************************************************************************/
void
set_enabled_protos_list(void)
{
set_protos_list(enabled_protos, global_enabled_protos, TRUE);
}
WS_DLL_PUBLIC void
proto_enable_proto_by_name(const char *name)
@ -573,27 +550,13 @@ save_enabled_protos_list(char **pref_path_return, int *errno_return)
enable_proto_list_check);
}
/*
* Read in a list of enabled protocols (that are disabled by default).
*/
void
read_enabled_protos_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return)
{
read_protos_list(gpath_return, gopen_errno_return, gread_errno_return,
path_return, open_errno_return, read_errno_return,
ENABLED_PROTOCOLS_FILE_NAME, &enabled_protos, &global_enabled_protos);
}
/************************************************************************
* Heuristic dissectors
************************************************************************/
void
static void
set_disabled_heur_dissector_list(void)
{
GList *fl_ent;
@ -634,8 +597,7 @@ skip:
}
static int
read_disabled_heur_dissector_list_file(const char *ff_path, FILE *ff,
GList **flp)
read_heur_dissector_list_file(const char *ff_path, FILE *ff, GList **flp)
{
heur_protocol_def *heur;
int c;
@ -737,7 +699,7 @@ read_disabled_heur_dissector_list_file(const char *ff_path, FILE *ff,
}
heuristic_name[name_index] = '\0';
/* Add the new protocol to the list of disabled protocols */
/* Add the new protocol to the list of protocols */
heur = (heur_protocol_def *) g_malloc(sizeof(heur_protocol_def));
heur->name = g_strdup(heuristic_name);
heur->enabled = enabled;
@ -751,28 +713,28 @@ error:
return errno;
}
void
read_disabled_heur_dissector_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return)
static void
read_heur_dissector_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return)
{
int err;
char *gff_path, *ff_path;
FILE *ff;
/* Construct the pathname of the global disabled heuristic dissectors file. */
gff_path = get_datafile_path(HEURISTICS_FILE_NAME);
/* If we already have a list of protocols, discard it. */
heur_discard_existing_list(&global_disabled_heuristics);
/* Construct the pathname of the global disabled heuristic dissectors file. */
gff_path = get_datafile_path(HEURISTICS_FILE_NAME);
/* Read the global disabled protocols file, if it exists. */
*gpath_return = NULL;
if ((ff = ws_fopen(gff_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
err = read_disabled_heur_dissector_list_file(gff_path, ff,
&global_disabled_heuristics);
err = read_heur_dissector_list_file(gff_path, ff,
&global_disabled_heuristics);
if (err != 0) {
/* We had an error reading the file; return the errno and the
pathname, so our caller can report the error. */
@ -804,7 +766,7 @@ read_disabled_heur_dissector_list(char **gpath_return, int *gopen_errno_return,
*path_return = NULL;
if ((ff = ws_fopen(ff_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
err = read_disabled_heur_dissector_list_file(ff_path, ff, &disabled_heuristics);
err = read_heur_dissector_list_file(ff_path, ff, &disabled_heuristics);
if (err != 0) {
/* We had an error reading the file; return the errno and the
pathname, so our caller can report the error. */
@ -933,12 +895,15 @@ save_disabled_heur_dissector_list(char **pref_path_return, int *errno_return)
g_free(ff_path);
}
void
gboolean
proto_enable_heuristic_by_name(const char *name, gboolean enable)
{
heur_dtbl_entry_t* heur = find_heur_dissector_by_unique_short_name(name);
if (heur != NULL) {
heur->enabled = enable;
return TRUE;
} else {
return FALSE;
}
}
@ -950,8 +915,122 @@ disabled_protos_free(gpointer p, gpointer user_data _U_)
g_free(p);
}
/*
* Read the files that enable and disable protocols and heuristic
* dissectors. Report errors through the UI.
*/
void
disabled_protos_cleanup(void)
read_enabled_and_disabled_protos(void)
{
char *gpath, *path;
int gopen_errno, gread_errno;
int open_errno, read_errno;
/*
* Read the global and personal disabled protocols files.
*/
read_protos_list(&gpath, &gopen_errno, &gread_errno,
&path, &open_errno, &read_errno,
DISABLED_PROTOCOLS_FILE_NAME,
&global_disabled_protos, &disabled_protos);
if (gpath != NULL) {
if (gopen_errno != 0) {
report_warning("Could not open global disabled protocols file\n\"%s\": %s.",
gpath, g_strerror(gopen_errno));
}
if (gread_errno != 0) {
report_warning("I/O error reading global disabled protocols file\n\"%s\": %s.",
gpath, g_strerror(gread_errno));
}
g_free(gpath);
gpath = NULL;
}
if (path != NULL) {
if (open_errno != 0) {
report_warning("Could not open your disabled protocols file\n\"%s\": %s.",
path, g_strerror(open_errno));
}
if (read_errno != 0) {
report_warning("I/O error reading your disabled protocols file\n\"%s\": %s.",
path, g_strerror(read_errno));
}
g_free(path);
path = NULL;
}
/*
* Read the global and personal enabled protocols files.
*/
read_protos_list(&gpath, &gopen_errno, &gread_errno,
&path, &open_errno, &read_errno,
ENABLED_PROTOCOLS_FILE_NAME,
&global_enabled_protos, &enabled_protos);
if (gpath != NULL) {
if (gopen_errno != 0) {
report_warning("Could not open global enabled protocols file\n\"%s\": %s.",
gpath, g_strerror(gopen_errno));
}
if (gread_errno != 0) {
report_warning("I/O error reading global enabled protocols file\n\"%s\": %s.",
gpath, g_strerror(gread_errno));
}
g_free(gpath);
gpath = NULL;
}
if (path != NULL) {
if (open_errno != 0) {
report_warning("Could not open your enabled protocols file\n\"%s\": %s.",
path, g_strerror(open_errno));
}
if (read_errno != 0) {
report_warning("I/O error reading your enabled protocols file\n\"%s\": %s.",
path, g_strerror(read_errno));
}
g_free(path);
path = NULL;
}
/*
* Read the global and personal heuristic dissector list files.
*/
read_heur_dissector_list(&gpath, &gopen_errno, &gread_errno,
&path, &open_errno, &read_errno);
if (gpath != NULL) {
if (gopen_errno != 0) {
report_warning("Could not open global heuristic dissectors file\n\"%s\": %s.",
gpath, g_strerror(gopen_errno));
}
if (gread_errno != 0) {
report_warning("I/O error reading global heuristic dissectors file\n\"%s\": %s.",
gpath, g_strerror(gread_errno));
}
g_free(gpath);
gpath = NULL;
}
if (path != NULL) {
if (open_errno != 0) {
report_warning("Could not open your heuristic dissectors file\n\"%s\": %s.",
path, g_strerror(open_errno));
}
if (read_errno != 0) {
report_warning("I/O error reading your heuristic dissectors file\n\"%s\": %s.",
path, g_strerror(read_errno));
}
g_free(path);
path = NULL;
}
/*
* Enable/disable protocols and heuristic dissectors as per the
* contents of the files we just read.
*/
set_protos_list(disabled_protos, global_disabled_protos, FALSE);
set_protos_list(enabled_protos, global_enabled_protos, TRUE);
set_disabled_heur_dissector_list();
}
void
enabled_and_disabled_protos_cleanup(void)
{
g_list_foreach(global_disabled_heuristics, disabled_protos_free, NULL);
g_list_free(global_disabled_heuristics);

View File

@ -6,7 +6,6 @@
* By Gerald Combs <gerald@wireshark.org>
* 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
* as published by the Free Software Foundation; either version 2
@ -29,28 +28,6 @@
extern "C" {
#endif /* __cplusplus */
/*
* Read in a list of disabled protocols.
*
* On success, "*pref_path_return" is set to NULL.
* On error, "*pref_path_return" is set to point to the pathname of
* the file we tried to read - it should be freed by our caller -
* and "*open_errno_return" is set to the error if we couldn't open the file
* or "*read_errno_return" is set to the error if we got an error reading
* the file.
*/
WS_DLL_PUBLIC void
read_disabled_protos_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return);
/*
* Disable protocols as per the stored configuration
*/
WS_DLL_PUBLIC void
set_disabled_protos_list(void);
/*
* Write out a list of disabled protocols.
*
@ -69,29 +46,6 @@ save_disabled_protos_list(char **pref_path_return, int *errno_return);
WS_DLL_PUBLIC void
proto_disable_proto_by_name(const char *name);
/*
* Read in a list of enabled protocols (who are disabled by default)
*
* On success, "*pref_path_return" is set to NULL.
* On error, "*pref_path_return" is set to point to the pathname of
* the file we tried to read - it should be freed by our caller -
* and "*open_errno_return" is set to the error if we couldn't open the file
* or "*read_errno_return" is set to the error if we got an error reading
* the file.
*/
WS_DLL_PUBLIC void
read_enabled_protos_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return);
/*
* Enable protocols (that default to disabled) as per the stored configuration
*/
WS_DLL_PUBLIC void
set_enabled_protos_list(void);
/*
* Write out a list of enabled protocols (that default to being disabled)
*
@ -111,28 +65,6 @@ save_enabled_protos_list(char **pref_path_return, int *errno_return);
WS_DLL_PUBLIC void
proto_enable_proto_by_name(const char *name);
/*
* Read in a list of disabled protocols.
*
* On success, "*pref_path_return" is set to NULL.
* On error, "*pref_path_return" is set to point to the pathname of
* the file we tried to read - it should be freed by our caller -
* and "*open_errno_return" is set to the error if we couldn't open the file
* or "*read_errno_return" is set to the error if we got an error reading
* the file.
*/
WS_DLL_PUBLIC void
read_disabled_heur_dissector_list(char **gpath_return, int *gopen_errno_return,
int *gread_errno_return,
char **path_return, int *open_errno_return,
int *read_errno_return);
/*
* Disable protocols as per the stored configuration
*/
WS_DLL_PUBLIC void
set_disabled_heur_dissector_list(void);
/*
* Write out a list of disabled heuristic dissectors.
*
@ -146,15 +78,24 @@ save_disabled_heur_dissector_list(char **pref_path_return, int *errno_return);
/*
* Enable/disable a particular heuristic dissector by name
* On success (found the protocol), return TRUE.
* On failure (didn't find the protocol), return FALSE.
*/
WS_DLL_PUBLIC gboolean
proto_enable_heuristic_by_name(const char *name, gboolean enable);
/*
* Read the files that enable and disable protocols and heuristic
* dissectors. Report errors through the UI.
*/
WS_DLL_PUBLIC void
proto_enable_heuristic_by_name(const char *name, gboolean enable);
read_enabled_and_disabled_protos(void);
/*
* Free the internal structures
*/
extern void
disabled_protos_cleanup(void);
enabled_and_disabled_protos_cleanup(void);
#ifdef __cplusplus
}

View File

@ -55,7 +55,7 @@
#include <epan/show_exception.h>
#include <epan/to_str.h>
#include <wsutil/filesystem.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "packet-tcp.h"
#include "packet-diameter.h"
#include "packet-e212.h"

View File

@ -33,7 +33,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <wsutil/file_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "packet-tcp.h"
void proto_register_etch(void);

View File

@ -293,7 +293,7 @@
#include <wsutil/file_util.h>
#include <wsutil/str_util.h>
#include <wsutil/pint.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/ws_printf.h> /* ws_debug_printf */
#include "packet-giop.h"

View File

@ -67,7 +67,7 @@
#include <epan/rtd_table.h>
#include <epan/addr_resolv.h>
#include <wsutil/filesystem.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/wsgcrypt.h>

View File

@ -26,7 +26,7 @@
#include <epan/packet.h>
#include <epan/epan_dissect.h>
#include <epan/tap.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "packet-dcerpc.h"
#include "packet-dcerpc-nt.h"
#include "packet-smb.h"

View File

@ -49,7 +49,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <epan/wmem/wmem.h>
#include <wiretap/wtap-int.h>

View File

@ -46,7 +46,7 @@
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/str_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/pint.h>
#include <wsutil/strtoi.h>
#include <ws_version_info.h>

View File

@ -32,7 +32,7 @@
#include <epan/to_str.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/strtoi.h>
#include "packet-tcp.h"

View File

@ -29,7 +29,7 @@
#include <epan/tap.h>
#endif
#include <epan/addr_resolv.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "packet-uaudp.h"

View File

@ -25,7 +25,7 @@
#include "epan/packet.h"
#include "epan/prefs.h"
#include "wsutil/report_err.h"
#include "wsutil/report_message.h"
#include "wsutil/inet_addr.h"
#include "packet-uaudp.h"

View File

@ -39,7 +39,7 @@
#include <epan/expert.h>
#include <epan/garrayfix.h>
#include <wsutil/str_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "packet-xml.h"

View File

@ -32,7 +32,7 @@
#include <glib.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <epan/exceptions.h>
@ -223,7 +223,7 @@ epan_cleanup(void)
expert_cleanup();
capture_dissector_cleanup();
export_pdu_cleanup();
disabled_protos_cleanup();
enabled_and_disabled_protos_cleanup();
stats_tree_cleanup();
dtd_location(NULL);
#ifdef HAVE_LUA

View File

@ -42,7 +42,7 @@
#include <epan/prefs.h>
#include <epan/value_string.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/file_util.h>
/* This needs to match NUM_GEOIP_COLS in hostlist_table.h */

View File

@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "wmem/wmem.h"
#include "uat.h"

View File

@ -6548,7 +6548,7 @@ proto_set_decoding(const int proto_id, const gboolean enabled)
}
void
proto_enable_all(void)
proto_reenable_all(void)
{
protocol_t *protocol;
GList *list_item = protocols;

View File

@ -2368,9 +2368,10 @@ WS_DLL_PUBLIC void proto_get_frame_protocols(const wmem_list_t *layers,
gboolean *is_ip, gboolean *is_tcp, gboolean *is_udp, gboolean *is_sctp,
gboolean *is_ssl, gboolean *is_rtp, gboolean *is_lte_rlc);
/** Find a protocol by name in a layer list.
/** Check whether a protocol, specified by name, is in a layer list.
* @param layers Protocol layer list
* @param proto_name Name of protocol to find
* @return TRUE if the protocol is found, FALSE if it isn't
*/
WS_DLL_PUBLIC gboolean proto_is_frame_protocol(const wmem_list_t *layers, const char* proto_name);
@ -2383,8 +2384,8 @@ WS_DLL_PUBLIC void proto_disable_by_default(const int proto_id);
@param enabled enable / disable the protocol */
WS_DLL_PUBLIC void proto_set_decoding(const int proto_id, const gboolean enabled);
/** Enable all protocols */
WS_DLL_PUBLIC void proto_enable_all(void);
/** Re-enable all protocols that are not marked as disabled by default. */
WS_DLL_PUBLIC void proto_reenable_all(void);
/** Disable disabling/enabling of protocol of the given item number.
@param proto_id protocol id (0-indexed) */
@ -2401,7 +2402,7 @@ extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const
tree. Only works with primed trees, and is fast.
@param tree tree of interest
@param hfindex primed hfindex
@return GPtrArry pointer */
@return GPtrArray pointer */
WS_DLL_PUBLIC GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex);
/** Return whether we're tracking any interesting fields.

View File

@ -36,7 +36,7 @@
#include <wsutil/file_util.h>
#include <wsutil/str_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/filesystem.h>
#include <epan/packet.h>

View File

@ -40,7 +40,7 @@
#include <wiretap/wtap.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/nstime.h>
#include <epan/packet.h>

View File

@ -55,7 +55,7 @@
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wiretap/merge.h>
@ -129,10 +129,11 @@ string_elem_print(gpointer data, gpointer not_used _U_)
#ifdef HAVE_PLUGINS
/*
* General errors are reported with an console message in mergecap.
* General errors and warnings are reported with an console message
* in mergecap.
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "mergecap: ");
vfprintf(stderr, msg_format, ap);
@ -310,7 +311,8 @@ main(int argc, char *argv[])
wtap_init();
#ifdef HAVE_PLUGINS
init_report_err(failure_message,NULL,NULL,NULL);
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
/* Scan for plugins. This does *not* call their registration routines;
that's done later.

View File

@ -39,7 +39,7 @@
#include <string.h>
#include <errno.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <epan/packet.h>
#include <epan/exceptions.h>

View File

@ -32,7 +32,7 @@
#include <epan/prefs.h>
#include <epan/dissectors/packet-tcp.h>
#include <epan/tap.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "packet-transum.h"
#include "preferences.h"
#include "extractors.h"

View File

@ -39,7 +39,7 @@
#include <epan/expert.h>
#include <epan/eap.h>
#include <wsutil/filesystem.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/ws_printf.h> /* ws_debug_printf */
#include "wimaxasncp_dict.h"

View File

@ -38,7 +38,7 @@
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
@ -54,10 +54,11 @@
#define CLOSE_ERROR 2
/*
* General errors are reported with an console message in randpkt.
* General errors and warnings are reported with an console message
* in randpkt.
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "randpkt: ");
vfprintf(stderr, msg_format, ap);
@ -148,7 +149,7 @@ main(int argc, char **argv)
wtap_init();
cmdarg_err_init(failure_message, failure_message_cont);
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
@ -157,7 +158,8 @@ main(int argc, char **argv)
#ifdef HAVE_PLUGINS
/* Register wiretap plugins */
init_report_err(failure_message,NULL,NULL,NULL);
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
/* Scan for plugins. This does *not* call their registration routines;
that's done later.

View File

@ -65,7 +65,7 @@
#include <wsutil/file_util.h>
#include <wsutil/plugins.h>
#include <wsutil/privileges.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "globals.h"
#include <epan/packet.h>
@ -81,6 +81,7 @@
#include "ui/capture_ui_utils.h"
#endif
#include "ui/util.h"
#include "ui/dissect_opts.h"
#include "register.h"
#include "conditions.h"
#include "capture_stop_conditions.h"
@ -155,9 +156,9 @@ static gboolean process_packet(capture_file *cf, epan_dissect_t *edt, gint64 off
struct wtap_pkthdr *whdr, const guchar *pd);
static void show_print_file_io_error(int err);
static void failure_warning_message(const char *msg_format, va_list ap);
static void open_failure_message(const char *filename, int err,
gboolean for_writing);
static void failure_message(const char *msg_format, va_list ap);
static void read_failure_message(const char *filename, int err);
static void write_failure_message(const char *filename, int err);
static void rawshark_cmdarg_err(const char *fmt, va_list ap);
@ -436,11 +437,8 @@ main(int argc, char *argv[])
#endif /* _WIN32 */
char *gpf_path, *pf_path;
char *gdp_path, *dp_path;
int gpf_open_errno, gpf_read_errno;
int pf_open_errno, pf_read_errno;
int gdp_open_errno, gdp_read_errno;
int dp_open_errno, dp_read_errno;
gchar *pipe_name = NULL;
gchar *rfilters[64];
e_prefs *prefs_p;
@ -526,8 +524,9 @@ main(int argc, char *argv[])
(GLogLevelFlags)log_flags,
log_func_ignore, NULL /* user_data */);
init_report_err(failure_message, open_failure_message, read_failure_message,
write_failure_message);
init_report_message(failure_warning_message, failure_warning_message,
open_failure_message, read_failure_message,
write_failure_message);
timestamp_set_type(TS_RELATIVE);
timestamp_set_precision(TS_PREC_AUTO);
@ -570,37 +569,11 @@ main(int argc, char *argv[])
pf_path = NULL;
}
/* 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) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
if (dp_path != NULL) {
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_read_errno));
}
g_free(dp_path);
}
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_protos();
#ifdef _WIN32
ws_init_dll_search_path();
@ -838,12 +811,11 @@ main(int argc, char *argv[])
of the filter. We can now process all the "-z" arguments. */
start_requested_stats();
/* 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();
}
/*
* Enabled and disabled protocols and heuristic dissectors as per
* command-line options.
*/
setup_enabled_and_disabled_protocols();
/* Build the column format array */
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
@ -1544,6 +1516,18 @@ show_print_file_io_error(int err)
}
}
/*
* General errors and warnings are reported with an console message
* in Rawshark.
*/
static void
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "rawshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Open/create errors are reported with an console message in Rawshark.
*/
@ -1625,18 +1609,6 @@ raw_cf_open(capture_file *cf, const char *fname)
return CF_OK;
}
/*
* General errors are reported with an console message in Rawshark.
*/
static void
failure_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "rawshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Read errors are reported with an console message in Rawshark.
*/

View File

@ -49,7 +49,7 @@
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#define INVALID_OPTION 1
#define OPEN_ERROR 2
@ -152,10 +152,11 @@ frames_compare(gconstpointer a, gconstpointer b)
#ifdef HAVE_PLUGINS
/*
* General errors are reported with an console message in reordercap.
* General errors and warnings are reported with an console message
* in reordercap.
*/
static void
failure_message(const char *msg_format, va_list ap)
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "reordercap: ");
vfprintf(stderr, msg_format, ap);
@ -238,7 +239,8 @@ main(int argc, char *argv[])
#ifdef HAVE_PLUGINS
/* Register wiretap plugins */
init_report_err(failure_message,NULL,NULL,NULL);
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
/* Scan for plugins. This does *not* call their registration routines;
that's done later.

View File

@ -42,7 +42,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/wtap_opttypes.h>
#include <wiretap/pcapng.h>
@ -88,9 +88,9 @@ static frame_data *prev_cap;
static const char *cf_open_error_message(int err, gchar *err_info,
gboolean for_writing, int file_type);
static void failure_warning_message(const char *msg_format, va_list ap);
static void open_failure_message(const char *filename, int err,
gboolean for_writing);
static void failure_message(const char *msg_format, va_list ap);
static void read_failure_message(const char *filename, int err);
static void write_failure_message(const char *filename, int err);
static void failure_message_cont(const char *msg_format, va_list ap);
@ -123,18 +123,15 @@ main(int argc, char *argv[])
char *init_progfile_dir_error;
char *gpf_path, *pf_path;
char *gdp_path, *dp_path;
char *cf_path;
char *err_msg = NULL;
int gpf_open_errno, gpf_read_errno;
int pf_open_errno, pf_read_errno;
int gdp_open_errno, gdp_read_errno;
int dp_open_errno, dp_read_errno;
int cf_open_errno;
e_prefs *prefs_p;
int ret = EXIT_SUCCESS;
cmdarg_err_init(failure_message, failure_message_cont);
cmdarg_err_init(failure_warning_message, failure_message_cont);
/*
* Get credential information for later use, and drop privileges
@ -177,8 +174,9 @@ main(int argc, char *argv[])
goto clean_exit;
}
init_report_err(failure_message, open_failure_message, read_failure_message,
write_failure_message);
init_report_message(failure_warning_message, failure_warning_message,
open_failure_message, read_failure_message,
write_failure_message);
timestamp_set_type(TS_RELATIVE);
timestamp_set_precision(TS_PREC_AUTO);
@ -248,35 +246,11 @@ main(int argc, char *argv[])
g_free(err_msg);
}
/* 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_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) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
if (dp_path != NULL) {
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_read_errno));
}
g_free(dp_path);
}
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_protos();
cap_file_init(&cfile);
@ -285,12 +259,6 @@ main(int argc, char *argv[])
line that their preferences have changed. */
prefs_apply_all();
/* disabled protocols as per configuration file */
if (gdp_path == NULL && dp_path == NULL) {
set_disabled_protos_list();
set_disabled_heur_dissector_list();
}
/* Build the column format array */
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
@ -484,7 +452,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
switch (err) {
case WTAP_ERR_UNSUPPORTED:
cmdarg_err("The file \"%s\" contains record data that TShark doesn't support.\n(%s)",
cmdarg_err("The file \"%s\" contains record data that sharkd doesn't support.\n(%s)",
cf->filename,
err_info != NULL ? err_info : "no information supplied");
g_free(err_info);
@ -598,18 +566,18 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
case WTAP_ERR_RANDOM_OPEN_PIPE:
/* Seen only when opening a capture file for reading. */
errmsg = "The file \"%s\" is a pipe or FIFO; TShark can't read pipe or FIFO files in two-pass mode.";
errmsg = "The file \"%s\" is a pipe or FIFO; sharkd can't read pipe or FIFO files in two-pass mode.";
break;
case WTAP_ERR_FILE_UNKNOWN_FORMAT:
/* Seen only when opening a capture file for reading. */
errmsg = "The file \"%s\" isn't a capture file in a format TShark understands.";
errmsg = "The file \"%s\" isn't a capture file in a format sharkd understands.";
break;
case WTAP_ERR_UNSUPPORTED:
/* Seen only when opening a capture file for reading. */
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" contains record data that TShark doesn't support.\n"
"The file \"%%s\" contains record data that sharkd doesn't support.\n"
"(%s)",
err_info != NULL ? err_info : "no information supplied");
g_free(err_info);
@ -626,13 +594,13 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
case WTAP_ERR_UNWRITABLE_FILE_TYPE:
/* Seen only when opening a capture file for writing. */
errmsg = "TShark doesn't support writing capture files in that format.";
errmsg = "sharkd doesn't support writing capture files in that format.";
break;
case WTAP_ERR_UNWRITABLE_ENCAP:
/* Seen only when opening a capture file for writing. */
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"TShark can't save this capture as a \"%s\" file.",
"sharkd can't save this capture as a \"%s\" file.",
wtap_file_type_subtype_short_string(file_type));
errmsg = errmsg_errno;
break;
@ -640,11 +608,11 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
if (for_writing) {
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"TShark can't save this capture as a \"%s\" file.",
"sharkd can't save this capture as a \"%s\" file.",
wtap_file_type_subtype_short_string(file_type));
errmsg = errmsg_errno;
} else
errmsg = "The file \"%s\" is a capture for a network type that TShark doesn't support.";
errmsg = "The file \"%s\" is a capture for a network type that sharkd doesn't support.";
break;
case WTAP_ERR_BAD_FILE:
@ -701,7 +669,19 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
}
/*
* Open/create errors are reported with an console message in TShark.
* General errors and warnings are reported with an console message
* in sharkd.
*/
static void
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "sharkd: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Open/create errors are reported with an console message in sharkd.
*/
static void
open_failure_message(const char *filename, int err, gboolean for_writing)
@ -712,18 +692,7 @@ open_failure_message(const char *filename, int err, gboolean for_writing)
}
/*
* General errors are reported with an console message in TShark.
*/
static void
failure_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "sharkd: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Read errors are reported with an console message in TShark.
* Read errors are reported with an console message in sharkd.
*/
static void
read_failure_message(const char *filename, int err)
@ -733,7 +702,7 @@ read_failure_message(const char *filename, int err)
}
/*
* Write errors are reported with an console message in TShark.
* Write errors are reported with an console message in sharkd.
*/
static void
write_failure_message(const char *filename, int err)

View File

@ -51,7 +51,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 "globals.h"
@ -146,9 +146,9 @@ static gboolean write_finale(void);
static const char *cf_open_error_message(int err, gchar *err_info,
gboolean for_writing, int file_type);
static void failure_warning_message(const char *msg_format, va_list ap);
static void open_failure_message(const char *filename, int err,
gboolean for_writing);
static void failure_message(const char *msg_format, va_list ap);
static void read_failure_message(const char *filename, int err);
static void write_failure_message(const char *filename, int err);
static void failure_message_cont(const char *msg_format, va_list ap);
@ -335,11 +335,8 @@ main(int argc, char *argv[])
gboolean arg_error = FALSE;
char *gpf_path, *pf_path;
char *gdp_path, *dp_path;
int gpf_open_errno, gpf_read_errno;
int pf_open_errno, pf_read_errno;
int gdp_open_errno, gdp_read_errno;
int dp_open_errno, dp_read_errno;
int err;
volatile int exit_status = 0;
gboolean quiet = FALSE;
@ -379,7 +376,7 @@ main(int argc, char *argv[])
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");
cmdarg_err_init(failure_message, failure_message_cont);
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
@ -501,8 +498,9 @@ main(int argc, char *argv[])
(GLogLevelFlags)log_flags,
tfshark_log_handler, NULL /* user_data */);
init_report_err(failure_message, open_failure_message, read_failure_message,
write_failure_message);
init_report_message(failure_warning_message, failure_warning_message,
open_failure_message, read_failure_message,
write_failure_message);
timestamp_set_type(TS_RELATIVE);
timestamp_set_precision(TS_PREC_AUTO);
@ -628,37 +626,11 @@ main(int argc, char *argv[])
pf_path = NULL;
}
/* 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) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
if (dp_path != NULL) {
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_read_errno));
}
g_free(dp_path);
}
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_protos();
cap_file_init(&cfile);
@ -855,6 +827,10 @@ main(int argc, char *argv[])
case 'K': /* Kerberos keytab file */
case 't': /* Time stamp type */
case 'u': /* Seconds type */
case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
case LONGOPT_ENABLE_PROTOCOL: /* enable dissection of protocol (that is disabled by default) */
if (!dissect_opts_handle_opt(opt, optarg)) {
exit_status = INVALID_OPTION;
goto clean_exit;
@ -946,12 +922,14 @@ main(int argc, char *argv[])
have a tap filter with one of MATE's late-registered fields as part
of the filter. We can now process all the "-z" arguments. */
start_requested_stats();
/* 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();
/*
* Enabled and disabled protocols and heuristic dissectors as per
* command-line options.
*/
if (!setup_enabled_and_disabled_protocols()) {
exit_status = INVALID_OPTION;
goto clean_exit;
}
/* Build the column format array */
@ -2305,6 +2283,18 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing,
return errmsg;
}
/*
* General errors and warnings are reported with an console message
* in TFShark.
*/
static void
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "tfshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Open/create errors are reported with an console message in TFShark.
*/
@ -2316,18 +2306,6 @@ open_failure_message(const char *filename, int err, gboolean for_writing)
fprintf(stderr, "\n");
}
/*
* General errors are reported with an console message in TFShark.
*/
static void
failure_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "tfshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Read errors are reported with an console message in TFShark.
*/

117
tshark.c
View File

@ -60,7 +60,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/wtap_opttypes.h>
#include <wiretap/pcapng.h>
@ -239,9 +239,9 @@ static gboolean write_finale(void);
static const char *cf_open_error_message(int err, gchar *err_info,
gboolean for_writing, int file_type);
static void failure_warning_message(const char *msg_format, va_list ap);
static void open_failure_message(const char *filename, int err,
gboolean for_writing);
static void failure_message(const char *msg_format, va_list ap);
static void read_failure_message(const char *filename, int err);
static void write_failure_message(const char *filename, int err);
static void failure_message_cont(const char *msg_format, va_list ap);
@ -666,12 +666,9 @@ main(int argc, char *argv[])
#endif /* _WIN32 */
char *gpf_path, *pf_path;
char *gdp_path, *dp_path;
char *cf_path;
int gpf_open_errno, gpf_read_errno;
int pf_open_errno, pf_read_errno;
int gdp_open_errno, gdp_read_errno;
int dp_open_errno, dp_read_errno;
int cf_open_errno;
int err;
volatile int exit_status = EXIT_SUCCESS;
@ -734,7 +731,7 @@ main(int argc, char *argv[])
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");
cmdarg_err_init(failure_message, failure_message_cont);
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
@ -888,8 +885,9 @@ main(int argc, char *argv[])
tshark_log_handler, NULL /* user_data */);
#endif
init_report_err(failure_message, open_failure_message, read_failure_message,
write_failure_message);
init_report_message(failure_warning_message, failure_warning_message,
open_failure_message, read_failure_message,
write_failure_message);
#ifdef HAVE_LIBPCAP
capture_opts_init(&global_capture_opts);
@ -1045,37 +1043,11 @@ main(int argc, char *argv[])
g_free(cf_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) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
if (dp_path != NULL) {
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
g_strerror(dp_read_errno));
}
g_free(dp_path);
}
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_protos();
cap_file_init(&cfile);
@ -1839,43 +1811,13 @@ main(int argc, char *argv[])
timestamp_set_type(global_dissect_options.time_format);
/* 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.enable_heur_slist) {
GSList *heur_enable;
for (heur_enable = global_dissect_options.enable_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()) {
exit_status = INVALID_OPTION;
goto clean_exit;
}
/* Build the column format array */
@ -4382,6 +4324,18 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
return errmsg;
}
/*
* General errors and warnings are reported with an console message
* in TShark.
*/
static void
failure_warning_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "tshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Open/create errors are reported with an console message in TShark.
*/
@ -4393,17 +4347,6 @@ open_failure_message(const char *filename, int err, gboolean for_writing)
fprintf(stderr, "\n");
}
/*
* General errors are reported with an console message in TShark.
*/
static void
failure_message(const char *msg_format, va_list ap)
{
fprintf(stderr, "tshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
/*
* Read errors are reported with an console message in TShark.
*/

View File

@ -52,6 +52,12 @@ vfailure_alert_box(const char *msg_format, va_list ap)
vsimple_error_message_box(msg_format, ap);
}
void
vwarning_alert_box(const char *msg_format, va_list ap)
{
vsimple_error_message_box(msg_format, ap);
}
/*
* Alert box for a failed attempt to open or create a file.
* "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if

View File

@ -34,6 +34,11 @@ extern "C" {
extern void failure_alert_box(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
extern void vfailure_alert_box(const char *msg_format, va_list ap);
/*
* Alert box for general warnings.
*/
extern void vwarning_alert_box(const char *msg_format, va_list ap);
/*
* Alert box for a failed attempt to open or create a file.
* "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if

View File

@ -27,7 +27,7 @@
#include <stdio.h>
#include <glib.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <epan/stats_tree_priv.h>
#include <epan/stat_tap_ui.h>

View File

@ -34,6 +34,7 @@
#include <epan/prefs.h>
#include <epan/timestamp.h>
#include <epan/addr_resolv.h>
#include <epan/disabled_protos.h>
#include "ui/decode_as_utils.h"
@ -161,6 +162,49 @@ dissect_opts_handle_opt(int opt, char *optarg_str_p)
return TRUE;
}
gboolean
setup_enabled_and_disabled_protocols(void)
{
gboolean success = TRUE;
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.enable_heur_slist) {
GSList *heur_enable;
for (heur_enable = global_dissect_options.enable_heur_slist; heur_enable != NULL; heur_enable = g_slist_next(heur_enable)) {
if (!proto_enable_heuristic_by_name((char*)heur_enable->data, TRUE)) {
cmdarg_err("No such protocol %s, can't enable", (char*)heur_enable->data);
success = FALSE;
}
}
}
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)) {
if (!proto_enable_heuristic_by_name((char*)heur_disable->data, FALSE)) {
cmdarg_err("No such protocol %s, can't disable", (char*)heur_disable->data);
success = FALSE;
}
}
}
return success;
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*

View File

@ -93,6 +93,16 @@ dissect_opts_init(void);
extern gboolean
dissect_opts_handle_opt(int opt, char *optarg_str_p);
/*
* Set up disabled protocols and enabled/disabled heuristic protocols
* as per specified command-line options.
*
* Returns TRUE if all specified heuristic protocols exist, FALSE
* otherwise.
*/
extern gboolean
setup_enabled_and_disabled_protocols(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -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>

View File

@ -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);

View File

@ -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"

View File

@ -544,6 +544,15 @@ simple_error_message_box(const char *msg_format, ...)
va_end(ap);
}
/*
* 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
*

View File

@ -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>

View File

@ -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>

View File

@ -277,6 +277,22 @@ vsimple_error_message_box(const char *msg_format, va_list ap)
sd.exec();
}
/*
* Warning alert box, taking a format and a va_list argument.
*/
void
vsimple_warning_message_box(const char *msg_format, va_list ap)
{
#ifdef HAVE_LIBPCAP
// We want to quit after reading the capture file, hence
// we don't actually open the error dialog.
if (global_commandline_info.quit_after_cap)
exit(0);
#endif
SimpleDialog sd(gbl_cur_main_window_, ESD_TYPE_WARN, ESD_BTN_OK, msg_format, ap);
sd.exec();
}
QMenu* MainWindow::findOrAddMenu(QMenu *parent_menu, QString& menu_text) {
QList<QAction *> actions = parent_menu->actions();

View File

@ -1527,8 +1527,7 @@ void MainWindow::reloadLuaPlugins()
proto_tree_->closeContextMenu();
main_ui_->preferenceEditorFrame->animatedHide();
char *gdp_path, *dp_path;
wsApp->readConfigurationFiles(&gdp_path, &dp_path, true);
wsApp->readConfigurationFiles(true);
prefs_apply_all();
fieldsChanged();

View File

@ -26,7 +26,7 @@
#include "epan/strutil.h"
#include "epan/uat-int.h"
#include "ui/help_url.h"
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include "qt_ui_utils.h"

View File

@ -326,7 +326,6 @@ int WiresharkApplication::monospaceTextSize(const char *str)
void WiresharkApplication::setConfigurationProfile(const gchar *profile_name, bool write_recent)
{
char *gdp_path, *dp_path;
char *rf_path;
int rf_open_errno;
gchar *err_msg = NULL;
@ -379,7 +378,7 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name, bo
emit profileNameChanged(profile_name);
/* Apply new preferences */
readConfigurationFiles (&gdp_path, &dp_path, true);
readConfigurationFiles(true);
if (!recent_read_profile_static(&rf_path, &rf_open_errno)) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
@ -413,14 +412,6 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name, bo
emit captureFilterListChanged();
emit displayFilterListChanged();
/* 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);
@ -1102,20 +1093,23 @@ void WiresharkApplication::allSystemsGo()
#endif
}
_e_prefs *WiresharkApplication::readConfigurationFiles(char **gdp_path, char **dp_path, bool reset)
_e_prefs *WiresharkApplication::readConfigurationFiles(bool reset)
{
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;
e_prefs *prefs_p;
if (reset) {
// reset preferences before reading
//
// Reset current preferences and enabled/disabled protocols and
// heuristic dissectors before reading.
// (Needed except when this is called at startup.)
//
prefs_reset();
proto_reenable_all();
}
/* load the decode as entries of this profile */
@ -1177,41 +1171,11 @@ _e_prefs *WiresharkApplication::readConfigurationFiles(char **gdp_path, char **d
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;
}

View File

@ -103,7 +103,7 @@ public:
void allSystemsGo();
void refreshLocalInterfaces();
struct _e_prefs * readConfigurationFiles(char **gdp_path, char **dp_path, bool reset);
struct _e_prefs * readConfigurationFiles(bool reset);
QList<recent_item_status *> recentItems() const;
void addRecentItem(const QString filename, qint64 size, bool accessible);
void removeRecentItem(const QString &filename);

View File

@ -148,6 +148,11 @@ extern void vsimple_error_message_box(const char *msg_format, va_list ap);
*/
extern void simple_error_message_box(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
/*
* Warning alert box, taking a format and a va_list argument.
*/
extern void vsimple_warning_message_box(const char *msg_format, va_list ap);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -45,7 +45,7 @@
#ifdef HAVE_PLUGINS
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/unicode-utils.h>
#include <ws_version_info.h>
@ -124,6 +124,7 @@
#include <QTextCodec>
#endif
#define INVALID_OPTION 1
#define INIT_FAILED 2
#define INVALID_CAPABILITY 2
#define INVALID_LINK_TYPE 2
@ -345,7 +346,6 @@ int main(int argc, char *qt_argv[])
char *rf_path;
int rf_open_errno;
char *gdp_path, *dp_path;
#ifdef HAVE_LIBPCAP
gchar *err_str;
#else
@ -571,8 +571,9 @@ int main(int argc, char *qt_argv[])
capture_opts_init(&global_capture_opts);
#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);
wtap_init();
@ -658,7 +659,7 @@ int main(int argc, char *qt_argv[])
splash_update(RA_PREFERENCES, NULL, NULL);
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Calling module preferences, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
global_commandline_info.prefs_p = ws_app.readConfigurationFiles(&gdp_path, &dp_path, false);
global_commandline_info.prefs_p = ws_app.readConfigurationFiles(false);
/* Now get our args */
commandline_other_options(argc, argv, TRUE);
@ -773,43 +774,13 @@ int main(int argc, char *qt_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.enable_heur_slist) {
GSList *heur_enable;
for (heur_enable = global_dissect_options.enable_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_val = INVALID_OPTION;
goto clean_exit;
}
build_column_format_array(&CaptureFile::globalCapFile()->cinfo, global_commandline_info.prefs_p->num_cols, TRUE);

View File

@ -58,7 +58,7 @@ set(WSUTIL_COMMON_FILES
strnatcmp.c
str_util.c
strtoi.c
report_err.c
report_message.c
tempfile.c
time_util.c
type_util.c

View File

@ -74,7 +74,7 @@ libwsutil_nonrepl_INCLUDES = \
plugins.h \
privileges.h \
processes.h \
report_err.h \
report_message.h \
sign_ext.h \
sober128.h \
socket.h \
@ -143,7 +143,7 @@ libwsutil_la_SOURCES = \
os_version_info.c \
plugins.c \
privileges.c \
report_err.c \
report_message.c \
sober128.c \
str_util.c \
strtoi.c \

View File

@ -59,7 +59,7 @@
#endif /* _WIN32 */
#include "filesystem.h"
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/privileges.h>
#include <wsutil/file_util.h>
#include <wsutil/utf8_entities.h>

View File

@ -37,7 +37,7 @@
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <wsutil/file_util.h>
#include <wsutil/report_err.h>
#include <wsutil/report_message.h>
#include <wsutil/plugins.h>
#include <wsutil/ws_printf.h> /* ws_debug_printf */

View File

@ -1,108 +0,0 @@
/* report_err.c
* Routines for code that can run in GUI and command-line environments to
* use to report errors to the user (e.g., I/O errors, or problems with
* preference settings).
*
* The application using libwireshark will register error-reporting
* routines, and the routines defined here will call the registered
* routines. That way, these routines can be called by code that
* doesn't itself know whether to pop up a dialog or print something
* to the standard error.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <glib.h>
#include "report_err.h"
static void (*vreport_failure_func)(const char *, va_list);
static void (*report_open_failure_func)(const char *, int, gboolean);
static void (*report_read_failure_func)(const char *, int);
static void (*report_write_failure_func)(const char *, int);
void init_report_err(void (*vreport_failure_fcn_p)(const char *, va_list),
void (*report_open_failure_fcn_p)(const char *, int, gboolean),
void (*report_read_failure_fcn_p)(const char *, int),
void (*report_write_failure_fcn_p)(const char *, int))
{
vreport_failure_func = vreport_failure_fcn_p;
report_open_failure_func = report_open_failure_fcn_p;
report_read_failure_func = report_read_failure_fcn_p;
report_write_failure_func = report_write_failure_fcn_p;
}
/*
* Report a general error.
*/
void
report_failure(const char *msg_format, ...)
{
va_list ap;
va_start(ap, msg_format);
(*vreport_failure_func)(msg_format, ap);
va_end(ap);
}
/*
* Report an error when trying to open or create a file.
* "err" is assumed to be an error code from Wiretap; positive values are
* UNIX-style errnos, so this can be used for open failures not from
* Wiretap as long as the failure code is just an errno.
*/
void
report_open_failure(const char *filename, int err,
gboolean for_writing)
{
(*report_open_failure_func)(filename, err, for_writing);
}
/*
* Report an error when trying to read a file.
* "err" is assumed to be a UNIX-style errno.
*/
void
report_read_failure(const char *filename, int err)
{
(*report_read_failure_func)(filename, err);
}
/*
* Report an error when trying to write a file.
* "err" is assumed to be a UNIX-style errno.
*/
void
report_write_failure(const char *filename, int err)
{
(*report_write_failure_func)(filename, err);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/

125
wsutil/report_message.c Normal file
View File

@ -0,0 +1,125 @@
/* report_message.c
* Routines for code that can run in GUI and command-line environments to
* use to report errors and warnings to the user (e.g., I/O errors, or
* problems with preference settings) if the message should be shown as
* a GUI error in a GUI environment.
*
* The application using libwsutil will register error-reporting
* routines, and the routines defined here will call the registered
* routines. That way, these routines can be called by code that
* doesn't itself know whether to pop up a dialog or print something
* to the standard error.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <glib.h>
#include "report_message.h"
static void (*vreport_failure_func)(const char *, va_list);
static void (*vreport_warning_func)(const char *, va_list);
static void (*report_open_failure_func)(const char *, int, gboolean);
static void (*report_read_failure_func)(const char *, int);
static void (*report_write_failure_func)(const char *, int);
void init_report_message(void (*vreport_failure_fcn_p)(const char *, va_list),
void (*vreport_warning_fcn_p)(const char *, va_list),
void (*report_open_failure_fcn_p)(const char *, int, gboolean),
void (*report_read_failure_fcn_p)(const char *, int),
void (*report_write_failure_fcn_p)(const char *, int))
{
vreport_failure_func = vreport_failure_fcn_p;
vreport_warning_func = vreport_warning_fcn_p;
report_open_failure_func = report_open_failure_fcn_p;
report_read_failure_func = report_read_failure_fcn_p;
report_write_failure_func = report_write_failure_fcn_p;
}
/*
* Report a general error.
*/
void
report_failure(const char *msg_format, ...)
{
va_list ap;
va_start(ap, msg_format);
(*vreport_failure_func)(msg_format, ap);
va_end(ap);
}
/*
* Report a general warning.
*/
void
report_warning(const char *msg_format, ...)
{
va_list ap;
va_start(ap, msg_format);
(*vreport_warning_func)(msg_format, ap);
va_end(ap);
}
/*
* Report an error when trying to open or create a file.
* "err" is assumed to be an error code from Wiretap; positive values are
* UNIX-style errnos, so this can be used for open failures not from
* Wiretap as long as the failure code is just an errno.
*/
void
report_open_failure(const char *filename, int err,
gboolean for_writing)
{
(*report_open_failure_func)(filename, err, for_writing);
}
/*
* Report an error when trying to read a file.
* "err" is assumed to be a UNIX-style errno.
*/
void
report_read_failure(const char *filename, int err)
{
(*report_read_failure_func)(filename, err);
}
/*
* Report an error when trying to write a file.
* "err" is assumed to be a UNIX-style errno.
*/
void
report_write_failure(const char *filename, int err)
{
(*report_write_failure_func)(filename, err);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/

View File

@ -1,9 +1,10 @@
/* report_err.h
/* report_message.h
* Declarations of routines for code that can run in GUI and command-line
* environments to use to report errors to the user (e.g., I/O errors, or
* problems with preference settings).
* environments to use to report errors and warnings to the user (e.g.,
* I/O errors, or problems with preference settings) if the message should
* be shown as a GUI error in a GUI environment.
*
* The application using libwireshark will register error-reporting
* The application using libwsutil will register message-reporting
* routines, and the routines declared here will call the registered
* routines. That way, these routines can be called by code that
* doesn't itself know whether to pop up a dialog or print something
@ -28,8 +29,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __REPORT_ERR_H__
#define __REPORT_ERR_H__
#ifndef __REPORT_MESSAGE_H__
#define __REPORT_MESSAGE_H__
#include "ws_symbol_export.h"
@ -38,10 +39,11 @@ extern "C" {
#endif /* __cplusplus */
/*
* Initialize the report err routines
* Initialize the report message routines
*/
WS_DLL_PUBLIC void init_report_err(
WS_DLL_PUBLIC void init_report_message(
void (*vreport_failure)(const char *, va_list),
void (*vreport_warning)(const char *, va_list),
void (*report_open_failure)(const char *, int, gboolean),
void (*report_read_failure)(const char *, int),
void (*report_write_failure)(const char *, int));
@ -51,6 +53,11 @@ WS_DLL_PUBLIC void init_report_err(
*/
WS_DLL_PUBLIC void report_failure(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
/*
* Report a general warning.
*/
WS_DLL_PUBLIC void report_warning(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
/*
* Report an error when trying to open a file.
* "err" is assumed to be an error code from Wiretap; positive values are
@ -76,4 +83,4 @@ WS_DLL_PUBLIC void report_write_failure(const char *filename, int err);
}
#endif /* __cplusplus */
#endif /* __REPORT_ERR_H__ */
#endif /* __REPORT_MESSAGE_H__ */