summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Young <jyoung@gsu.edu>2015-07-14 00:28:49 -0400
committerMichael Mann <mmann78@netscape.net>2015-07-17 11:27:52 +0000
commitad82dfd5547e460359eb3597ddb6760a29c40439 (patch)
tree7e13c660c502985fef6eb075e5efe09c5e020d9a
parent9d24a26c9b8c78260fca9c4f6ecf480e12010229 (diff)
downloadwireshark-ad82dfd5547e460359eb3597ddb6760a29c40439.tar.gz
Add new long options to GUIs to allow arbitrary protocols and heuristics to be disabled via command-line
Future: Allow multiple protocols to be disabled in one option statement (perhaps using a comma or colon delmited set of names in <proto_name>) instead of having to specify --disable-protocol <proto_name> multiple times. Change-Id: I9b8f960acf75298ebb098d9b667fca49dca52306 Reviewed-on: https://code.wireshark.org/review/9631 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--capture_opts.h10
-rw-r--r--docbook/wsug_src/WSUG_app_tools.asciidoc7
-rw-r--r--docbook/wsug_src/WSUG_chapter_customize.asciidoc6
-rw-r--r--epan/disabled_protos.c30
-rw-r--r--epan/disabled_protos.h13
-rw-r--r--tshark.c43
-rw-r--r--ui/gtk/main.c42
-rw-r--r--wireshark-qt.cpp43
8 files changed, 192 insertions, 2 deletions
diff --git a/capture_opts.h b/capture_opts.h
index 4ace0bf974..4d99cc759c 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -63,7 +63,10 @@ extern "C" {
* Non-capture long-only options should start here, to avoid collision
* with capture options.
*/
-#define MIN_NON_CAPTURE_LONGOPT 129
+#define MIN_NON_CAPTURE_LONGOPT 129
+#define LONGOPT_DISABLE_PROTOCOL 130
+#define LONGOPT_ENABLE_HEURISTIC 131
+#define LONGOPT_DISABLE_HEURISTIC 132
/*
* Options for capturing common to all capturing programs.
@@ -102,7 +105,10 @@ extern "C" {
{(char *)"list-data-link-types", no_argument, NULL, 'L'}, \
{(char *)"no-promiscuous-mode", no_argument, NULL, 'p'}, \
{(char *)"snapshot-length", required_argument, NULL, 's'}, \
- {(char *)"linktype", required_argument, NULL, 'y'},
+ {(char *)"linktype", required_argument, NULL, 'y'}, \
+ {(char *)"disable-protocol", required_argument, NULL, LONGOPT_DISABLE_PROTOCOL }, \
+ {(char *)"enable-heuristic", required_argument, NULL, LONGOPT_ENABLE_HEURISTIC }, \
+ {(char *)"disable-heuristic", required_argument, NULL, LONGOPT_DISABLE_HEURISTIC },
#define OPTSTRING_CAPTURE_COMMON \
"a:" OPTSTRING_A "b:" OPTSTRING_B "c:Df:i:" OPTSTRING_I "Lps:y:"
diff --git a/docbook/wsug_src/WSUG_app_tools.asciidoc b/docbook/wsug_src/WSUG_app_tools.asciidoc
index 49e81b5824..1a5c3098cd 100644
--- a/docbook/wsug_src/WSUG_app_tools.asciidoc
+++ b/docbook/wsug_src/WSUG_app_tools.asciidoc
@@ -73,6 +73,13 @@ Processing:
Example: tcp.port==8888,http
-H <hosts file> read a list of entries from a hosts file, which will
then be written to a capture file. (Implies -W n)
+ --disable-protocol <proto_name> disable dissection of proto_name
+ Repeat option for each protocol
+ --enable-heuristic <short_name> enable dissection of heuristic protocol
+ Repeat option for each protocol
+ --disable-heuristic <short_name> disable dissection of heuristic protocol
+ Repeat option for each protocol
+
Output:
-w <outfile|-> write packets to a pcap-format file named "outfile"
(or to the standard output for "-")
diff --git a/docbook/wsug_src/WSUG_chapter_customize.asciidoc b/docbook/wsug_src/WSUG_chapter_customize.asciidoc
index 48d9b3e039..f33b54430d 100644
--- a/docbook/wsug_src/WSUG_chapter_customize.asciidoc
+++ b/docbook/wsug_src/WSUG_chapter_customize.asciidoc
@@ -78,6 +78,12 @@ Processing:
-R <read filter> packet filter in Wireshark display filter syntax
-n disable all name resolutions (def: all enabled)
-N <name resolve flags> enable specific name resolution(s): "mntC"
+ --disable-protocol <proto_name> disable dissection of proto_name
+ Repeat option for each protocol
+ --enable-heuristic <short_name> enable dissection of heuristic protocol
+ Repeat option for each protocol
+ --disable-heuristic <short_name> disable dissection of heuristic protocol
+ Repeat option for each protocol
User interface:
-C <config profile> start with specified configuration profile
diff --git a/epan/disabled_protos.c b/epan/disabled_protos.c
index 4d30e13510..602f48d57d 100644
--- a/epan/disabled_protos.c
+++ b/epan/disabled_protos.c
@@ -356,6 +356,27 @@ skip:
}
/*
+ * Disable a particular protocol by name
+ */
+
+void
+proto_disable_proto_by_name(const char *name)
+{
+ protocol_t *protocol;
+ int proto_id;
+
+ proto_id = proto_get_id_by_filter_name(name);
+ if (proto_id >= 0 ) {
+ protocol = find_protocol_by_id(proto_id);
+ if (proto_is_protocol_enabled(protocol) == TRUE) {
+ if (proto_can_toggle_protocol(proto_id) == TRUE) {
+ proto_set_decoding(proto_id, FALSE);
+ }
+ }
+ }
+}
+
+/*
* Write out a list of disabled protocols.
*
* On success, "*pref_path_return" is set to NULL.
@@ -792,6 +813,15 @@ save_disabled_heur_dissector_list(char **pref_path_return, int *errno_return)
g_free(ff_path);
}
+void
+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;
+ }
+}
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
diff --git a/epan/disabled_protos.h b/epan/disabled_protos.h
index 2f06c22fc5..33e56f7d9b 100644
--- a/epan/disabled_protos.h
+++ b/epan/disabled_protos.h
@@ -62,6 +62,13 @@ WS_DLL_PUBLIC void
save_disabled_protos_list(char **pref_path_return, int *errno_return);
/*
+ * Disable a particular protocol by name
+ */
+
+WS_DLL_PUBLIC void
+proto_disable_proto_by_name(const char *name);
+
+/*
* Read in a list of disabled protocols.
*
* On success, "*pref_path_return" is set to NULL.
@@ -94,6 +101,12 @@ set_disabled_heur_dissector_list(void);
WS_DLL_PUBLIC void
save_disabled_heur_dissector_list(char **pref_path_return, int *errno_return);
+/*
+ * Enable/disable a particular heuristic dissector by name
+ */
+WS_DLL_PUBLIC void
+proto_enable_heuristic_by_name(const char *name, gboolean enable);
+
#ifdef __cplusplus
}
diff --git a/tshark.c b/tshark.c
index 06771c2171..42ac5daca0 100644
--- a/tshark.c
+++ b/tshark.c
@@ -351,6 +351,12 @@ print_usage(FILE *output)
fprintf(output, " Example: tcp.port==8888,http\n");
fprintf(output, " -H <hosts file> read a list of entries from a hosts file, which will\n");
fprintf(output, " then be written to a capture file. (Implies -W n)\n");
+ fprintf(output, " --disable-protocol <proto_name>\n");
+ fprintf(output, " disable dissection of proto_name\n");
+ fprintf(output, " --enable-heuristic <short_name>\n");
+ fprintf(output, " enable dissection of heuristic protocol\n");
+ fprintf(output, " --disable-heuristic <short_name>\n");
+ fprintf(output, " disable dissection of heuristic protocol\n");
/*fprintf(output, "\n");*/
fprintf(output, "Output:\n");
@@ -1003,6 +1009,9 @@ DIAG_ON(cast-qual)
char badopt;
int log_flags;
gchar *output_only = NULL;
+ GSList *disable_protocol_slist = NULL;
+ GSList *enable_heur_slist = NULL;
+ GSList *disable_heur_slist = NULL;
/*
* The leading + ensures that getopt_long() does not permute the argv[]
@@ -1702,6 +1711,16 @@ DIAG_ON(cast-qual)
return 1;
}
break;
+ case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
+ disable_protocol_slist = g_slist_append(disable_protocol_slist, optarg);
+ break;
+ case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
+ enable_heur_slist = g_slist_append(enable_heur_slist, optarg);
+ break;
+ case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
+ disable_heur_slist = g_slist_append(disable_heur_slist, optarg);
+ break;
+
default:
case '?': /* Bad flag - print usage message */
switch(optopt) {
@@ -2032,6 +2051,30 @@ DIAG_ON(cast-qual)
set_disabled_heur_dissector_list();
}
+ if(disable_protocol_slist) {
+ GSList *proto_disable;
+ for (proto_disable = disable_protocol_slist; proto_disable != NULL; proto_disable = g_slist_next(proto_disable))
+ {
+ proto_disable_proto_by_name((char*)proto_disable->data);
+ }
+ }
+
+ if(enable_heur_slist) {
+ GSList *heur_enable;
+ for (heur_enable = enable_heur_slist; heur_enable != NULL; heur_enable = g_slist_next(heur_enable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_enable->data, TRUE);
+ }
+ }
+
+ if(disable_heur_slist) {
+ GSList *heur_disable;
+ for (heur_disable = disable_heur_slist; heur_disable != NULL; heur_disable = g_slist_next(heur_disable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_disable->data, FALSE);
+ }
+ }
+
/* Build the column format array */
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index 643d9c7f3a..c69ba84eba 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -1232,6 +1232,12 @@ print_usage(gboolean for_help_option) {
fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n");
fprintf(output, " -n disable all name resolutions (def: all enabled)\n");
fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n");
+ fprintf(output, " --disable-protocol <proto_name>\n");
+ fprintf(output, " disable dissection of proto_name\n");
+ fprintf(output, " --enable-heuristic <short_name>\n");
+ fprintf(output, " enable dissection of heuristic protocol\n");
+ fprintf(output, " --disable-heuristic <short_name>\n");
+ fprintf(output, " disable dissection of heuristic protocol\n");
fprintf(output, "\n");
fprintf(output, "User interface:\n");
@@ -2180,6 +2186,9 @@ main(int argc, char *argv[])
#ifdef HAVE_GTKOSXAPPLICATION
GtkosxApplication *theApp;
#endif
+ GSList *disable_protocol_slist = NULL;
+ GSList *enable_heur_slist = NULL;
+ GSList *disable_heur_slist = NULL;
#define OPTSTRING OPTSTRING_CAPTURE_COMMON "C:g:Hh" "jJ:kK:lm:nN:o:P:r:R:St:u:vw:X:Y:z:"
DIAG_OFF(cast-qual)
@@ -2807,6 +2816,15 @@ DIAG_ON(cast-qual)
exit(1);
}
break;
+ case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
+ disable_protocol_slist = g_slist_append(disable_protocol_slist, optarg);
+ break;
+ case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
+ enable_heur_slist = g_slist_append(enable_heur_slist, optarg);
+ break;
+ case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
+ disable_heur_slist = g_slist_append(disable_heur_slist, optarg);
+ break;
default:
case '?': /* Bad flag - print usage message */
arg_error = TRUE;
@@ -3007,6 +3025,30 @@ DIAG_ON(cast-qual)
set_disabled_heur_dissector_list();
}
+ if(disable_protocol_slist) {
+ GSList *proto_disable;
+ for (proto_disable = disable_protocol_slist; proto_disable != NULL; proto_disable = g_slist_next(proto_disable))
+ {
+ proto_disable_proto_by_name((char*)proto_disable->data);
+ }
+ }
+
+ if(enable_heur_slist) {
+ GSList *heur_enable;
+ for (heur_enable = enable_heur_slist; heur_enable != NULL; heur_enable = g_slist_next(heur_enable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_enable->data, TRUE);
+ }
+ }
+
+ if(disable_heur_slist) {
+ GSList *heur_disable;
+ for (heur_disable = disable_heur_slist; heur_disable != NULL; heur_disable = g_slist_next(heur_disable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_disable->data, FALSE);
+ }
+ }
+
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
/* read in rc file from global and personal configuration paths. */
diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp
index cac303197d..28ce67fd2a 100644
--- a/wireshark-qt.cpp
+++ b/wireshark-qt.cpp
@@ -216,6 +216,12 @@ print_usage(gboolean for_help_option) {
fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n");
fprintf(output, " -n disable all name resolutions (def: all enabled)\n");
fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n");
+ fprintf(output, " --disable-protocol <proto_name>\n");
+ fprintf(output, " disable dissection of proto_name\n");
+ fprintf(output, " --enable-heuristic <short_name>\n");
+ fprintf(output, " enable dissection of heuristic protocol\n");
+ fprintf(output, " --disable-heuristic <short_name>\n");
+ fprintf(output, " disable dissection of heuristic protocol\n");
fprintf(output, "\n");
fprintf(output, "User interface:\n");
@@ -467,6 +473,9 @@ int main(int argc, char *argv[])
guint go_to_packet = 0;
QString dfilter, read_filter;
+ GSList *disable_protocol_slist = NULL;
+ GSList *enable_heur_slist = NULL;
+ GSList *disable_heur_slist = NULL;
cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont);
@@ -1093,6 +1102,16 @@ DIAG_ON(cast-qual)
exit(1);
}
break;
+ case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
+ disable_protocol_slist = g_slist_append(disable_protocol_slist, optarg);
+ break;
+ case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
+ enable_heur_slist = g_slist_append(enable_heur_slist, optarg);
+ break;
+ case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
+ disable_heur_slist = g_slist_append(disable_heur_slist, optarg);
+ break;
+
default:
case '?': /* Bad flag - print usage message */
print_usage(FALSE);
@@ -1293,6 +1312,30 @@ DIAG_ON(cast-qual)
set_disabled_heur_dissector_list();
}
+ if(disable_protocol_slist) {
+ GSList *proto_disable;
+ for (proto_disable = disable_protocol_slist; proto_disable != NULL; proto_disable = g_slist_next(proto_disable))
+ {
+ proto_disable_proto_by_name((char*)proto_disable->data);
+ }
+ }
+
+ if(enable_heur_slist) {
+ GSList *heur_enable;
+ for (heur_enable = enable_heur_slist; heur_enable != NULL; heur_enable = g_slist_next(heur_enable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_enable->data, TRUE);
+ }
+ }
+
+ if(disable_heur_slist) {
+ GSList *heur_disable;
+ for (heur_disable = disable_heur_slist; heur_disable != NULL; heur_disable = g_slist_next(heur_disable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_disable->data, FALSE);
+ }
+ }
+
build_column_format_array(&CaptureFile::globalCapFile()->cinfo, prefs_p->num_cols, TRUE);
wsApp->emitAppSignal(WiresharkApplication::ColumnsChanged); // We read "recent" widths above.
wsApp->emitAppSignal(WiresharkApplication::RecentFilesRead); // Must be emitted after PreferencesChanged.