diff options
author | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2014-06-20 14:48:27 -0400 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-06-21 01:05:02 +0000 |
commit | 3773a7561c79e3545fca664c2a25cf2312de0ada (patch) | |
tree | 083e9fda037f4811ebe3cf7aa9564ee57df33c9b | |
parent | c11ae8ac827afa50ef226ebaef134f54ac0e532b (diff) | |
download | wireshark-3773a7561c79e3545fca664c2a25cf2312de0ada.tar.gz wireshark-3773a7561c79e3545fca664c2a25cf2312de0ada.tar.bz2 wireshark-3773a7561c79e3545fca664c2a25cf2312de0ada.zip |
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>
-rw-r--r-- | capinfos.c | 21 | ||||
-rw-r--r-- | doc/capinfos.pod | 5 | ||||
-rw-r--r-- | doc/editcap.pod | 7 | ||||
-rw-r--r-- | doc/mergecap.pod | 5 | ||||
-rw-r--r-- | doc/reordercap.pod | 5 | ||||
-rw-r--r-- | doc/text2pcap.pod | 7 | ||||
-rw-r--r-- | editcap.c | 37 | ||||
-rw-r--r-- | mergecap.c | 23 | ||||
-rw-r--r-- | reordercap.c | 29 | ||||
-rw-r--r-- | text2pcap.c | 25 |
10 files changed, 124 insertions, 40 deletions
diff --git a/capinfos.c b/capinfos.c index 811f5af8bd..e43fa049b5 100644 --- a/capinfos.c +++ b/capinfos.c @@ -992,6 +992,16 @@ process_cap_file(wtap *wth, const char *filename) } static void +print_version(FILE *output) +{ + fprintf(output, "Capinfos %s" +#ifdef GITVERSION + " (" GITVERSION " from " GITBRANCH ")" +#endif + "\n", VERSION); +} + +static void usage(gboolean is_error) { FILE *output; @@ -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); diff --git a/doc/capinfos.pod b/doc/capinfos.pod index 9359cf79ee..c3247414bd 100644 --- a/doc/capinfos.pod +++ b/doc/capinfos.pod @@ -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 diff --git a/doc/editcap.pod b/doc/editcap.pod index d93264409a..c9b7ee32fe 100644 --- a/doc/editcap.pod +++ b/doc/editcap.pod @@ -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 diff --git a/doc/mergecap.pod b/doc/mergecap.pod index c19ec6dc98..65e75d4f6a 100644 --- a/doc/mergecap.pod +++ b/doc/mergecap.pod @@ -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. diff --git a/doc/reordercap.pod b/doc/reordercap.pod index 3aa3918e33..50dc9b7493 100644 --- a/doc/reordercap.pod +++ b/doc/reordercap.pod @@ -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 diff --git a/doc/text2pcap.pod b/doc/text2pcap.pod index 30981131ee..62f09ebe76 100644 --- a/doc/text2pcap.pod +++ b/doc/text2pcap.pod @@ -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 @@ -658,6 +658,16 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) { } static void +print_version(FILE *output) +{ + fprintf(output, "Editcap %s" +#ifdef GITVERSION + " (" GITVERSION " from " GITBRANCH ")" +#endif + "\n", VERSION); +} + +static void usage(gboolean is_error) { FILE *output; @@ -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))) { diff --git a/mergecap.c b/mergecap.c index a9c1ef9e08..85654adfbc 100644 --- a/mergecap.c +++ b/mergecap.c @@ -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; diff --git a/reordercap.c b/reordercap.c index ce563bea72..7b107fa329 100644 --- a/reordercap.c +++ b/reordercap.c @@ -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); diff --git a/text2pcap.c b/text2pcap.c index 4b1a349a89..5c17436baa 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -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, ','); |