Add command-line argument to request the version to a number of the utilities.

In some cases "-v" was already used so "-V" is the option.
Note that the version information in these utilities is much shorter than what
is presented by the big programs.

As requested by https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5804

Bug: 5804
Change-Id: I35db35a4eace2797afd895f9be7322ef39928480
Reviewed-on: https://code.wireshark.org/review/2489
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Jeff Morriss 2014-06-20 14:48:27 -04:00 committed by Guy Harris
parent c11ae8ac82
commit 3773a7561c
10 changed files with 124 additions and 40 deletions

View File

@ -991,6 +991,16 @@ process_cap_file(wtap *wth, const char *filename)
return status;
}
static void
print_version(FILE *output)
{
fprintf(output, "Capinfos %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
}
static void
usage(gboolean is_error)
{
@ -1004,11 +1014,7 @@ usage(gboolean is_error)
output = stderr;
}
fprintf(output, "Capinfos %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
print_version(output);
fprintf(output, "Prints various information (infos) about capture files.\n");
fprintf(output, "See http://www.wireshark.org for more information.\n");
fprintf(output, "\n");
@ -1352,6 +1358,11 @@ main(int argc, char *argv[])
exit(0);
break;
case 'v':
print_version(stdout);
exit(0);
break;
case '?': /* Bad flag - print usage message */
usage(TRUE);
exit(1);

View File

@ -33,6 +33,7 @@ S<[ B<-S> ]>
S<[ B<-t> ]>
S<[ B<-T> ]>
S<[ B<-u> ]>
S<[ B<-v> ]>
S<[ B<-x> ]>
S<[ B<-y> ]>
S<[ B<-z> ]>
@ -267,6 +268,10 @@ Displays the capture duration, in seconds. This is the
difference in time between the earliest packet seen and
latest packet seen.
=item -v
Displays the tool's version and exits.
=item -x
Displays the average packet rate, in packets/sec

View File

@ -33,6 +33,9 @@ S<[ B<-v> ]>
I<infile>
I<outfile>
B<editcap>
S<[ B<-V> ]>
=head1 DESCRIPTION
B<Editcap> is a program that reads some or all of the captured packets from the
@ -263,6 +266,10 @@ Use of B<-v> with the de-duplication switches of B<-d>, B<-D> or B<-w>
will cause all MD5 hashes to be printed whether the packet is skipped
or not.
=item -V
Print the version and exit.
=item -w E<lt>dup time windowE<gt>
Attempts to remove duplicate packets. The current packet's arrival time

View File

@ -12,6 +12,7 @@ S<[ B<-h> ]>
S<[ B<-s> E<lt>I<snaplen>E<gt> ]>
S<[ B<-T> E<lt>I<encapsulation type>E<gt> ]>
S<[ B<-v> ]>
S<[ B<-V> ]>
S<B<-w> E<lt>I<outfile>E<gt>|->
E<lt>I<infile>E<gt> [E<lt>I<infile>E<gt> I<...>]
@ -111,6 +112,10 @@ fddi>' is specified).
Causes B<mergecap> to print a number of messages while it's working.
=item -V
Print the version and exit.
=item -w E<lt>outfileE<gt>|-
Sets the output filename. If the name is 'B<->', stdout will be used.

View File

@ -7,6 +7,7 @@ reordercap - Reorder input file by timestamp into output file
B<reordercap>
S<[ B<-n> ]>
S<[ B<-v> ]>
E<lt>I<infile>E<gt> E<lt>I<outfile>E<gt>
=head1 DESCRIPTION
@ -40,6 +41,10 @@ the same way B<reordercap> handles this.
When the B<-n> option is used, B<reordercap> will not write out the output
file if it finds that the input file is already in order.
=item -v
Print the version and exit.
=back
=head1 SEE ALSO

View File

@ -22,6 +22,7 @@ S<[ B<-S> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt> ]>
S<[ B<-t> E<lt>timefmtE<gt> ]>
S<[ B<-T> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
S<[ B<-u> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
S<[ B<-v> ]>
E<lt>I<infile>E<gt>|-
E<lt>I<outfile>E<gt>|-
@ -218,6 +219,10 @@ IP or Ethernet headers. Note that appropriate Ethernet and IP headers
are automatically also included with each packet.
Example: I<-u1000,69> to make the packets look like TFTP/UDP packets.
=item -v
Print the version and exit.
=item -4 E<lt>srcipE<gt>,E<lt>destipE<gt>
Prepend dummy IP header with specified IPv4 dest and source address.
@ -230,7 +235,7 @@ Example: I<-4 10.0.0.1,10.0.0.2> to use 10.0.0.1 and 10.0.0.2 for all IP packets
Prepend dummy IP header with specified IPv6 dest and source address.
This option should be accompanied by one of the following options: -i, -s, -S, -T, -u
Use this option to apply "custom" IP addresses.
Example: I<-6 fe80:0:0:0:202:b3ff:fe1e:8329, 2001:0db8:85a3:0000:0000:8a2e:0370:7334> to
Example: I<-6 fe80:0:0:0:202:b3ff:fe1e:8329, 2001:0db8:85a3:0000:0000:8a2e:0370:7334> to
use fe80:0:0:0:202:b3ff:fe1e:8329 and 2001:0db8:85a3:0000:0000:8a2e:0370:7334 for all IP packets.
=back

View File

@ -657,6 +657,16 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) {
return FALSE;
}
static void
print_version(FILE *output)
{
fprintf(output, "Editcap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
}
static void
usage(gboolean is_error)
{
@ -667,11 +677,7 @@ usage(gboolean is_error)
else
output = stderr;
fprintf(output, "Editcap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
print_version(output);
fprintf(output, "Edit and/or translate the format of capture files.\n");
fprintf(output, "See http://www.wireshark.org for more information.\n");
fprintf(output, "\n");
@ -899,7 +905,7 @@ main(int argc, char *argv[])
#endif
/* Process the options */
while ((opt = getopt(argc, argv, "A:B:c:C:dD:E:F:hi:Lrs:S:t:T:vw:")) != -1) {
while ((opt = getopt(argc, argv, "A:B:c:C:dD:E:F:hi:Lrs:S:t:T:vVw:")) != -1) {
switch (opt) {
case 'A':
{
@ -1083,6 +1089,11 @@ main(int argc, char *argv[])
verbose = !verbose; /* Just invert */
break;
case 'V':
print_version(stdout);
exit(0);
break;
case 'w':
dup_detect = FALSE;
dup_detect_by_time = TRUE;
@ -1297,13 +1308,13 @@ main(int argc, char *argv[])
ts_okay = (phdr->ts.secs >= starttime) && (phdr->ts.secs < stoptime);
else
ts_okay = FALSE;
} else {
/*
* No selected timeframe, so all packets are "in the
* selected timeframe".
*/
ts_okay = TRUE;
}
} else {
/*
* No selected timeframe, so all packets are "in the
* selected timeframe".
*/
ts_okay = TRUE;
}
if (ts_okay && ((!selected(count) && !keep_em)
|| (selected(count) && keep_em))) {

View File

@ -99,6 +99,16 @@ get_positive_int(const char *string, const char *name)
return number;
}
static void
print_version(FILE *output)
{
fprintf(output, "Mergecap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
}
/*
* Show the usage
*/
@ -114,11 +124,7 @@ usage(gboolean is_error)
output = stderr;
}
fprintf(output, "Mergecap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
print_version(output);
fprintf(output, "Merge two or more capture files into one.\n");
fprintf(output, "See http://www.wireshark.org for more information.\n");
fprintf(output, "\n");
@ -239,7 +245,7 @@ main(int argc, char *argv[])
#endif /* _WIN32 */
/* Process the options first */
while ((opt = getopt(argc, argv, "aF:hs:T:vw:")) != -1) {
while ((opt = getopt(argc, argv, "aF:hs:T:vVw:")) != -1) {
switch (opt) {
case 'a':
@ -279,6 +285,11 @@ main(int argc, char *argv[])
verbose = TRUE;
break;
case 'V':
print_version(stdout);
exit(0);
break;
case 'w':
out_filename = optarg;
break;

View File

@ -38,8 +38,21 @@
#include "wsutil/wsgetopt.h"
#endif
#include "version.h"
static void
print_version(FILE *output)
{
fprintf(output, "Reordercap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
}
/* Show command-line usage */
static void usage(gboolean is_error)
static void
usage(gboolean is_error)
{
FILE *output;
@ -50,11 +63,7 @@ static void usage(gboolean is_error)
output = stderr;
}
fprintf(output, "Reordercap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
print_version(output);
fprintf(output, "Reorder timestamps of input file frames into output file.\n");
fprintf(output, "See http://www.wireshark.org for more information.\n");
fprintf(output, "\n");
@ -155,7 +164,8 @@ frames_compare(gconstpointer a, gconstpointer b)
/********************************************************************/
/* Main function. */
/********************************************************************/
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
wtap *wth = NULL;
wtap_dumper *pdh = NULL;
@ -179,7 +189,7 @@ int main(int argc, char *argv[])
char *outfile;
/* Process the options first */
while ((opt = getopt(argc, argv, "hn")) != -1) {
while ((opt = getopt(argc, argv, "hnv")) != -1) {
switch (opt) {
case 'n':
write_output_regardless = FALSE;
@ -187,6 +197,9 @@ int main(int argc, char *argv[])
case 'h':
usage(FALSE);
exit(0);
case 'v':
print_version(stdout);
exit(0);
case '?':
usage(TRUE);
exit(1);

View File

@ -1420,6 +1420,16 @@ fail_null_str:
}
static void
print_version(FILE *output)
{
fprintf(output, "Text2pcap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n", VERSION);
}
/*----------------------------------------------------------------------
* Print usage string and exit
*/
@ -1435,12 +1445,8 @@ usage (gboolean is_error)
output = stderr;
}
print_version(output);
fprintf(output,
"Text2pcap %s"
#ifdef GITVERSION
" (" GITVERSION " from " GITBRANCH ")"
#endif
"\n"
"Generate a capture file from an ASCII hexdump of packets.\n"
"See http://www.wireshark.org for more information.\n"
"\n"
@ -1520,7 +1526,7 @@ usage (gboolean is_error)
" -q generate no output at all (automatically disables -d).\n"
" -n use PCAP-NG instead of PCAP as output format.\n"
"",
VERSION, MAX_PACKET);
MAX_PACKET);
exit(is_error ? 1 : 0);
}
@ -1540,7 +1546,7 @@ parse_options (int argc, char *argv[])
#endif /* _WIN32 */
/* Scan CLI parameters */
while ((c = getopt(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:4:6:")) != -1) {
while ((c = getopt(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:")) != -1) {
switch (c) {
case '?': usage(TRUE); break;
case 'h': usage(FALSE); break;
@ -1720,6 +1726,11 @@ parse_options (int argc, char *argv[])
identify_ascii = TRUE;
break;
case 'v':
print_version(stdout);
exit(0);
break;
case '4':
case '6':
p = strchr(optarg, ',');