wireshark/ui/dissect_opts.h
Guy Harris 2c44a7f930 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>
2017-04-08 20:40:08 +00:00

124 lines
3.6 KiB
C

/* dissect_opts.h
* Dissection options (parameters that affect dissection)
*
* 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.
*/
/** @file
*
* Dissection options (parameters that affect dissection)
*
*/
#ifndef __DISSECT_OPTS_H__
#define __DISSECT_OPTS_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Long options.
* We do not currently have long options corresponding to all short
* options; we should probably pick appropriate option names for them.
*
* For long options with no corresponding short options, we define values
* outside the range of ASCII graphic characters, make that the last
* component of the entry for the long option, and have a case for that
* option in the switch statement.
*
* We also pick values >= 4096, so as not to collide with capture options,
* and <= 65535, so as to leave values > 65535 for options specific to a
* program.
*/
/*
* Non-capture long-only options should start here, to avoid collision
* with capture options.
*/
#define LONGOPT_DISABLE_PROTOCOL 4096
#define LONGOPT_ENABLE_HEURISTIC 4097
#define LONGOPT_DISABLE_HEURISTIC 4098
#define LONGOPT_ENABLE_PROTOCOL 4099
/*
* Options for dissecting common to all dissecting programs.
*/
#define LONGOPT_DISSECT_COMMON \
{"disable-protocol", required_argument, NULL, LONGOPT_DISABLE_PROTOCOL }, \
{"enable-heuristic", required_argument, NULL, LONGOPT_ENABLE_HEURISTIC }, \
{"disable-heuristic", required_argument, NULL, LONGOPT_DISABLE_HEURISTIC }, \
{"enable-protocol", required_argument, NULL, LONGOPT_ENABLE_PROTOCOL }, \
#define OPTSTRING_DISSECT_COMMON \
"d:K:nN:t:u:"
/** Capture options coming from user interface */
typedef struct dissect_options_tag {
ts_type time_format;
GSList *enable_protocol_slist; //enable protocols that are disabled by default
GSList *disable_protocol_slist;
GSList *enable_heur_slist;
GSList *disable_heur_slist;
} dissect_options;
extern dissect_options global_dissect_options;
/* initialize the dissect_options with some reasonable values */
extern void
dissect_opts_init(void);
/*
* Handle a command line option.
* Returns TRUE if the option is valid, FALSE if not; an error message
* is reported with cmdarg_err() if it's not valid.
*/
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 */
#endif /* dissect_opts.h */
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/