diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-01-17 07:49:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-01-17 07:49:03 +0000 |
commit | 1108f9f609fc72e5059e04a896a292e91502d610 (patch) | |
tree | 2ecc44b1b5ff0aadc5ebc72de0077ed394f35dc6 | |
parent | cfb98c14c400df86a9771145a427f7aea88079fe (diff) | |
download | wireshark-1108f9f609fc72e5059e04a896a292e91502d610.tar.gz wireshark-1108f9f609fc72e5059e04a896a292e91502d610.tar.bz2 wireshark-1108f9f609fc72e5059e04a896a292e91502d610.zip |
Add a "-x" flag to Tethereal, to make it print a hex and ASCII dump of
the packet data.
svn path=/trunk/; revision=1497
-rw-r--r-- | doc/tethereal.pod.template | 6 | ||||
-rw-r--r-- | tethereal.c | 24 |
2 files changed, 25 insertions, 5 deletions
diff --git a/doc/tethereal.pod.template b/doc/tethereal.pod.template index 5a2836b4f8..e7f0ac97e8 100644 --- a/doc/tethereal.pod.template +++ b/doc/tethereal.pod.template @@ -18,6 +18,7 @@ S<[ B<-t> time stamp format ]> S<[ B<-v> ]> S<[ B<-V> ]> S<[ B<-w> savefile]> +S<[ B<-x> ]> =head1 DESCRIPTION @@ -131,6 +132,11 @@ a one-line summary of the packet. Sets the default capture file name. +=item -x + +Causes B<Tethereal> to print a hex and ASCII dump of the packet data +after printing the summary or protocol tree. + =back =head1 CAPTURE FILTER SYNTAX diff --git a/tethereal.c b/tethereal.c index 65c39516dd..aa77f7a87f 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.8 2000/01/16 02:47:46 guy Exp $ + * $Id: tethereal.c,v 1.9 2000/01/17 07:48:57 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -83,6 +83,7 @@ static guint32 firstsec, firstusec; static guint32 prevsec, prevusec; static gchar comp_info_str[256]; static gboolean verbose; +static gboolean print_hex; #ifdef HAVE_LIBPCAP typedef struct _loop_data { @@ -136,7 +137,7 @@ print_usage(void) { fprintf(stderr, "t%s [ -vVh ] [ -c count ] [ -f <filter expression> ] [ -i iface ]\n", PACKAGE); fprintf(stderr, "\t[ -r infile ] [ -R <filter expression> ] [ -s snaplen ]\n"); - fprintf(stderr, "\t[ -t <time stamp format> ] [ -w savefile ]\n"); + fprintf(stderr, "\t[ -t <time stamp format> ] [ -w savefile ] [ -x ]\n"); } int @@ -248,7 +249,7 @@ main(int argc, char *argv[]) ); /* Now get our args */ - while ((opt = getopt(argc, argv, "c:f:hi:nr:R:s:t:vw:V")) != EOF) { + while ((opt = getopt(argc, argv, "c:f:hi:nr:R:s:t:vw:Vx")) != EOF) { switch (opt) { case 'c': /* Capture xxx packets */ #ifdef HAVE_LIBPCAP @@ -325,6 +326,9 @@ main(int argc, char *argv[]) case 'V': /* Verbose */ verbose = TRUE; break; + case 'x': /* Print packet data in hex (and ASCII) */ + print_hex = TRUE; + break; } } @@ -700,11 +704,16 @@ wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset, print_args.to_file = TRUE; print_args.format = PR_FMT_TEXT; print_args.print_summary = FALSE; - print_args.print_hex = FALSE; + print_args.print_hex = print_hex; print_args.expand_all = TRUE; proto_tree_print(FALSE, &print_args, (GNode *)protocol_tree, buf, &fdata, stdout); - printf("\n"); + if (!print_hex) { + /* "print_hex_data()" will put out a leading blank line, as well + as a trailing one; print one here, to separate the packets, + only if "print_hex_data()" won't be called. */ + printf("\n"); + } } else { /* Just fill in the columns. */ fill_in_columns(&fdata); @@ -724,6 +733,11 @@ wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset, col_info(&fdata, COL_INFO)); } } + if (print_hex) { + print_hex_data(stdout, print_args.format, buf, + fdata.cap_len, fdata.encoding); + printf("\n"); + } fdata.cinfo = NULL; } if (protocol_tree != NULL) |