]> The Tcpdump Group git mirrors - tcpdump/commitdiff
From Sebastien Vincent <[email protected]>: fix the handling of "-x" and
authorguy <guy>
Sat, 4 Sep 2004 00:04:49 +0000 (00:04 +0000)
committerguy <guy>
Sat, 4 Sep 2004 00:04:49 +0000 (00:04 +0000)
"-X" so that "-x" prints only hex, not hex and ASCII.

CREDITS
tcpdump.c

diff --git a/CREDITS b/CREDITS
index e4f477a0d12f0142f8223c20436b34a23935ffd5..0e347bbaedb5c423fe5e889957602f1150091dfc 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -109,6 +109,7 @@ Additional people who have contributed patches:
        Sami Farin                      <[email protected]>
        Scott Rose                      <[email protected]>
        Sebastian Krahmer               <[email protected]>
+       Sebastien Vincent               <[email protected]>
        Seth Webster                    <[email protected]>
        Shinsuke Suzuki                 <[email protected]>
        Takashi Yamamoto                <[email protected]>
index 3f175c28fa15f5d082f82748aff1c16aa445d0ea..24d38c8b8a751b7d7ae927235496575acb4c3ee8 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216.2.12 2004-06-15 00:01:52 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216.2.13 2004-09-04 00:04:49 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -585,7 +585,6 @@ main(int argc, char **argv)
                        break;
 
                case 'X':
-                       ++xflag;
                        ++Xflag;
                        break;
 
@@ -1017,7 +1016,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
                        /*
                         * Include the link-layer header.
                         */
-                       default_print(sp, h->caplen);
+                       hex_print("\n\t", sp, h->caplen);
                } else {
                        /*
                         * Don't include the link-layer header - and if
@@ -1025,7 +1024,26 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
                         * print nothing.
                         */
                        if (h->caplen > hdrlen)
-                               default_print(sp + hdrlen,
+                               hex_print("\n\t", sp + hdrlen,
+                                   h->caplen - hdrlen);
+               }
+       } else if (Xflag) {
+               /*
+                * Print the raw packet data.
+                */
+               if (Xflag > 1) {
+                       /*
+                        * Include the link-layer header.
+                        */
+                       ascii_print("\n\t", sp, h->caplen);
+               } else {
+                       /*
+                        * Don't include the link-layer header - and if
+                        * we have nothing past the link-layer header,
+                        * print nothing.
+                        */
+                       if (h->caplen > hdrlen)
+                               ascii_print("\n\t", sp + hdrlen,
                                    h->caplen - hdrlen);
                }
        }
@@ -1068,7 +1086,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 void
 default_print(register const u_char *bp, register u_int length)
 {
-    ascii_print("\n\t", bp, length); /* pass on lf and identation string */
+       ascii_print("\n\t", bp, length); /* pass on lf and identation string */
 }
 
 #ifdef SIGINFO