2016-10-30 21:07:33 +00:00
|
|
|
/* dissect_opts.c
|
|
|
|
* Routines for dissection options setting
|
|
|
|
*
|
|
|
|
* 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 <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2016-10-31 01:47:59 +00:00
|
|
|
#include <epan/prefs.h>
|
2016-10-30 21:07:33 +00:00
|
|
|
#include <epan/timestamp.h>
|
2016-10-31 01:47:59 +00:00
|
|
|
#include <epan/addr_resolv.h>
|
2016-10-30 21:07:33 +00:00
|
|
|
|
|
|
|
#include "ui/decode_as_utils.h"
|
|
|
|
|
2016-10-31 01:47:59 +00:00
|
|
|
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
|
|
|
|
#include <epan/dissectors/read_keytab_file.h>
|
|
|
|
#endif
|
|
|
|
|
2016-10-30 21:07:33 +00:00
|
|
|
#include <wsutil/clopts_common.h>
|
|
|
|
#include <wsutil/cmdarg_err.h>
|
|
|
|
#include <wsutil/file_util.h>
|
|
|
|
|
|
|
|
#include "ui/dissect_opts.h"
|
|
|
|
|
|
|
|
dissect_options global_dissect_options;
|
|
|
|
|
|
|
|
void
|
|
|
|
dissect_opts_init(void)
|
|
|
|
{
|
|
|
|
global_dissect_options.time_format = TS_NOT_SET;
|
|
|
|
global_dissect_options.disable_protocol_slist = NULL;
|
|
|
|
global_dissect_options.enable_heur_slist = NULL;
|
|
|
|
global_dissect_options.disable_heur_slist = NULL;
|
|
|
|
}
|
|
|
|
|
2016-10-31 00:37:10 +00:00
|
|
|
gboolean
|
|
|
|
dissect_opts_handle_opt(int opt, char *optarg_str_p)
|
2016-10-30 21:07:33 +00:00
|
|
|
{
|
2016-10-31 01:47:59 +00:00
|
|
|
char badopt;
|
|
|
|
|
2016-10-30 21:07:33 +00:00
|
|
|
switch(opt) {
|
|
|
|
case 'd': /* Decode as rule */
|
|
|
|
if (!decode_as_command_option(optarg_str_p))
|
2016-10-31 00:37:10 +00:00
|
|
|
return FALSE;
|
2016-10-30 21:07:33 +00:00
|
|
|
break;
|
2016-10-31 01:47:59 +00:00
|
|
|
case 'K': /* Kerberos keytab file */
|
|
|
|
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
|
|
|
|
read_keytab_file(optarg_str_p);
|
|
|
|
#else
|
|
|
|
cmdarg_err("-K specified, but Kerberos keytab file support isn't present");
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 'n': /* No name resolution */
|
|
|
|
disable_name_resolution();
|
|
|
|
break;
|
|
|
|
case 'N': /* Select what types of addresses/port #s to resolve */
|
|
|
|
badopt = string_to_name_resolve(optarg_str_p, &gbl_resolv_flags);
|
|
|
|
if (badopt != '\0') {
|
|
|
|
cmdarg_err("-N specifies unknown resolving option '%c'; valid options are:",
|
|
|
|
badopt);
|
|
|
|
cmdarg_err_cont("\t'd' to enable address resolution from captured DNS packets\n"
|
|
|
|
"\t'm' to enable MAC address resolution\n"
|
|
|
|
"\t'n' to enable network address resolution\n"
|
|
|
|
"\t'N' to enable using external resolvers (e.g., DNS)\n"
|
|
|
|
"\t for network address resolution\n"
|
|
|
|
"\t't' to enable transport-layer port number resolution");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2016-10-30 21:07:33 +00:00
|
|
|
case 't': /* Time stamp type */
|
|
|
|
if (strcmp(optarg_str_p, "r") == 0)
|
|
|
|
global_dissect_options.time_format = TS_RELATIVE;
|
|
|
|
else if (strcmp(optarg_str_p, "a") == 0)
|
|
|
|
global_dissect_options.time_format = TS_ABSOLUTE;
|
|
|
|
else if (strcmp(optarg_str_p, "ad") == 0)
|
|
|
|
global_dissect_options.time_format = TS_ABSOLUTE_WITH_YMD;
|
|
|
|
else if (strcmp(optarg_str_p, "adoy") == 0)
|
|
|
|
global_dissect_options.time_format = TS_ABSOLUTE_WITH_YDOY;
|
|
|
|
else if (strcmp(optarg_str_p, "d") == 0)
|
|
|
|
global_dissect_options.time_format = TS_DELTA;
|
|
|
|
else if (strcmp(optarg_str_p, "dd") == 0)
|
|
|
|
global_dissect_options.time_format = TS_DELTA_DIS;
|
|
|
|
else if (strcmp(optarg_str_p, "e") == 0)
|
|
|
|
global_dissect_options.time_format = TS_EPOCH;
|
|
|
|
else if (strcmp(optarg_str_p, "u") == 0)
|
|
|
|
global_dissect_options.time_format = TS_UTC;
|
|
|
|
else if (strcmp(optarg_str_p, "ud") == 0)
|
|
|
|
global_dissect_options.time_format = TS_UTC_WITH_YMD;
|
|
|
|
else if (strcmp(optarg_str_p, "udoy") == 0)
|
|
|
|
global_dissect_options.time_format = TS_UTC_WITH_YDOY;
|
|
|
|
else {
|
|
|
|
cmdarg_err("Invalid time stamp type \"%s\"; it must be one of:", optarg_str_p);
|
|
|
|
cmdarg_err_cont("\t\"a\" for absolute\n"
|
|
|
|
"\t\"ad\" for absolute with YYYY-MM-DD date\n"
|
|
|
|
"\t\"adoy\" for absolute with YYYY/DOY date\n"
|
|
|
|
"\t\"d\" for delta\n"
|
|
|
|
"\t\"dd\" for delta displayed\n"
|
|
|
|
"\t\"e\" for epoch\n"
|
|
|
|
"\t\"r\" for relative\n"
|
|
|
|
"\t\"u\" for absolute UTC\n"
|
|
|
|
"\t\"ud\" for absolute UTC with YYYY-MM-DD date\n"
|
|
|
|
"\t\"udoy\" for absolute UTC with YYYY/DOY date");
|
2016-10-31 00:37:10 +00:00
|
|
|
return FALSE;
|
2016-10-30 21:07:33 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-10-31 01:47:59 +00:00
|
|
|
case 'u': /* Seconds type */
|
|
|
|
if (strcmp(optarg_str_p, "s") == 0)
|
|
|
|
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
|
|
|
|
else if (strcmp(optarg_str_p, "hms") == 0)
|
|
|
|
timestamp_set_seconds_type(TS_SECONDS_HOUR_MIN_SEC);
|
|
|
|
else {
|
|
|
|
cmdarg_err("Invalid seconds type \"%s\"; it must be one of:", optarg_str_p);
|
|
|
|
cmdarg_err_cont("\t\"s\" for seconds\n"
|
|
|
|
"\t\"hms\" for hours, minutes and seconds");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2016-10-30 21:07:33 +00:00
|
|
|
case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
|
|
|
|
global_dissect_options.disable_protocol_slist = g_slist_append(global_dissect_options.disable_protocol_slist, optarg_str_p);
|
|
|
|
break;
|
|
|
|
case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
|
|
|
|
global_dissect_options.enable_heur_slist = g_slist_append(global_dissect_options.enable_heur_slist, optarg_str_p);
|
|
|
|
break;
|
|
|
|
case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
|
|
|
|
global_dissect_options.disable_heur_slist = g_slist_append(global_dissect_options.disable_heur_slist, optarg_str_p);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* the caller is responsible to send us only the right opt's */
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2016-10-31 00:37:10 +00:00
|
|
|
return TRUE;
|
2016-10-30 21:07:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
*/
|