[tshark] Document -U option and create a list of tap names when entering

an empty name "".

Change-Id: I2b8332ff6900c8a88514a25a416f342d7b696d34
Reviewed-on: https://code.wireshark.org/review/15332
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
AndersBroman 2016-05-10 15:16:26 +02:00 committed by Anders Broman
parent 6bfa7a8b41
commit 505bf5945b
2 changed files with 25 additions and 10 deletions

View File

@ -41,6 +41,7 @@ S<[ B<-S> E<lt>separatorE<gt> ]>
S<[ B<-t> a|ad|adoy|d|dd|e|r|u|ud|udoy ]>
S<[ B<-T> fields|pdml|ps|psml|text ]>
S<[ B<-u> E<lt>seconds typeE<gt>]>
S<[ B<-U> E<lt>tap_nameE<gt>]>
S<[ B<-v> ]>
S<[ B<-V> ]>
S<[ B<-w> E<lt>outfileE<gt>|- ]>
@ -757,6 +758,12 @@ B<s> for seconds
B<hms> for hours, minutes and seconds
=item -U E<lt>tap nameE<gt>
PDUs export, exports PDUs from infile to outfile according to the tap name given. Use -Y to filter.
Enter an empty tap name "" to get a list of available names.
=item -v
Print the version and exit.

View File

@ -94,6 +94,7 @@
#include <epan/srt_table.h>
#include <epan/rtd_table.h>
#include <epan/ex-opt.h>
#include <epan/exported_pdu.h>
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
#include <epan/asn1.h>
@ -391,7 +392,7 @@ print_usage(FILE *output)
fprintf(output, " -W n Save extra information in the file, if supported.\n");
fprintf(output, " n = write network address resolution information\n");
fprintf(output, " -X <key>:<value> eXtension options, see the man page for details\n");
fprintf(output, " -U tap_name[,filter] PDUs export mode, see the man page for details\n");
fprintf(output, " -U tap_name PDUs export mode, see the man page for details\n");
fprintf(output, " -z <statistics> various statistics, see the man page for details\n");
fprintf(output, " --capture-comment <comment>\n");
fprintf(output, " add a capture comment to the newly created\n");
@ -995,7 +996,7 @@ main(int argc, char *argv[])
GSList *disable_protocol_slist = NULL;
GSList *enable_heur_slist = NULL;
GSList *disable_heur_slist = NULL;
gchar **volatile pdu_export_args = NULL;
gchar *volatile pdu_export_arg = NULL;
exp_pdu_t exp_pdu_tap_data;
/*
@ -1670,12 +1671,19 @@ main(int argc, char *argv[])
}
break;
case 'U': /* Export PDUs to file */
{
GSList *export_pdu_tap_name_list = NULL;
if (!*optarg) {
cmdarg_err("Tap name is required!");
cmdarg_err("Tap name is required! Valid names are:");
for (export_pdu_tap_name_list = get_export_pdu_tap_list(); export_pdu_tap_name_list; export_pdu_tap_name_list = g_slist_next(export_pdu_tap_name_list)) {
cmdarg_err("%s\n", (const char*)(export_pdu_tap_name_list->data));
}
return 1;
}
pdu_export_args = g_strsplit(optarg, ",", 2);
pdu_export_arg = g_strdup(optarg);
break;
}
case 'v': /* Show version and exit */
comp_info_str = get_compiled_version_info(get_tshark_compiled_version_info,
epan_get_compiled_version_info);
@ -2176,10 +2184,10 @@ main(int argc, char *argv[])
/* PDU export requested. Take the ownership of the '-w' file, apply tap
* filters and start tapping. */
if (pdu_export_args) {
if (pdu_export_arg) {
const char *exp_pdu_filename;
const char *exp_pdu_tap_name = pdu_export_args[0];
const char *exp_pdu_filter = pdu_export_args[1]; /* may be NULL to disable filter */
const char *exp_pdu_tap_name = pdu_export_arg;
const char *exp_pdu_filter = dfilter; /* may be NULL to disable filter */
char *exp_pdu_error;
int exp_fd;
@ -2234,7 +2242,7 @@ main(int argc, char *argv[])
we're exporting PDUs;
we're using any taps that need dissection. */
do_dissection = print_packet_info || rfcode || dfcode || pdu_export_args ||
do_dissection = print_packet_info || rfcode || dfcode || pdu_export_arg ||
tap_listeners_require_dissection();
tshark_debug("tshark: do_dissection = %s", do_dissection ? "TRUE" : "FALSE");
@ -2276,13 +2284,13 @@ main(int argc, char *argv[])
exit_status = 2;
}
if (pdu_export_args) {
if (pdu_export_arg) {
err = exp_pdu_close(&exp_pdu_tap_data);
if (err) {
cmdarg_err("%s", wtap_strerror(err));
exit_status = 2;
}
g_strfreev(pdu_export_args);
g_free(pdu_export_arg);
}
} else {
tshark_debug("tshark: no capture file specified");