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>
pespin/osmux-stats
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,