From rene@tunix.nl  Thu Apr 17 04:34:17 2003
Return-Path: <rene@tunix.nl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C3BEB37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Apr 2003 04:34:17 -0700 (PDT)
Received: from bastix.tunix.nl (bastix.tunix.nl [193.79.201.39])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 45B0C43FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Apr 2003 04:34:16 -0700 (PDT)
	(envelope-from rene@tunix.nl)
Received: (from root@localhost) by bastix.tunix.nl (8.9.3c/8.6.12) id NAA60385 for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Apr 2003 13:34:32 +0200 (CEST)
Received: by bastix.tunix.nl (TUNIX txp2/smap)
	for <FreeBSD-gnats-submit@freebsd.org> id sma060071; Thu, 17 Apr 03 13:33:21 +0200
Received: from upsilix.tunix.nl (upsilix.tunix.nl [172.16.2.22])
	by fix.tunix.nl (8.10.2+Sun/8.10.2) with ESMTP id h3HBX4902702
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Apr 2003 13:33:04 +0200 (MEST)
Received: from upsilix.tunix.nl (localhost.tunix.nl [127.0.0.1])
	by upsilix.tunix.nl (8.12.6/8.12.6) with ESMTP id h3HBX0c5053460
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Apr 2003 13:33:00 +0200 (CEST)
	(envelope-from rene@upsilix.tunix.nl)
Received: (from rene@localhost)
	by upsilix.tunix.nl (8.12.6/8.12.6/Submit) id h3HBX0gN053459;
	Thu, 17 Apr 2003 13:33:00 +0200 (CEST)
	(envelope-from rene)
Message-Id: <200304171133.h3HBX0gN053459@upsilix.tunix.nl>
Date: Thu, 17 Apr 2003 13:33:00 +0200 (CEST)
From: Rene de Vries <rene@tunix.nl>
Reply-To: Rene de Vries <rene@tunix.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [FEATURE] Add -A (print ASCII) flag to tcpdump
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         51091
>Category:       bin
>Synopsis:       [FEATURE] Add -A (print ASCII) flag to tcpdump
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    fenner
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 17 04:40:15 PDT 2003
>Closed-Date:    Mon Jun 14 13:48:57 GMT 2004
>Last-Modified:  Mon Jun 14 13:48:57 GMT 2004
>Originator:     Rene de Vries
>Release:        FreeBSD 4.7-RELEASE-p3 i386 / FreeBSD 5.0-20030401 i386
>Organization:
Tunix Internet Security & Training
>Environment:
>Description:
	Print the payload of TCP packets in human-readable (ASCII)
	format. This can be usefull when debugging readable protocols
	(like SMTP, HTTP, etc).

>How-To-Repeat:
>Fix:

See Also:
	https://sourceforge.net/tracker/index.php?func=detail&aid=723026&group_id=53066&atid=469575

Files:
	src/contrib/tcpdump/interface.h
	src/contrib/tcpdump/print-tcp.c
	src/contrib/tcpdump/tcpdump.1
	src/contrib/tcpdump/tcpdump.c

Author: Edwin H. Kremer <edwin@tunix.nl>

Diff against FreeBSD 5 (current as of 01 Apr 2003):

Index: contrib/tcpdump/interface.h
===================================================================
RCS file: /home/fbsd-cvsrepo/src/contrib/tcpdump/interface.h,v
retrieving revision 1.8
diff -u -r1.8 interface.h
--- contrib/tcpdump/interface.h	2 Mar 2003 08:25:48 -0000	1.8
+++ contrib/tcpdump/interface.h	1 Apr 2003 11:36:54 -0000
@@ -67,6 +67,7 @@
 };
 
 extern int aflag;		/* translate network and broadcast addresses */
+extern int Aflag;		/* ASCII print of the payload of TCP packets */
 extern int dflag;		/* print filter code */
 extern int eflag;		/* print ethernet header */
 extern int fflag;		/* don't translate "foreign" IP address */
Index: contrib/tcpdump/print-tcp.c
===================================================================
RCS file: /home/fbsd-cvsrepo/src/contrib/tcpdump/print-tcp.c,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 print-tcp.c
--- contrib/tcpdump/print-tcp.c	21 Jun 2002 00:43:23 -0000	1.1.1.6
+++ contrib/tcpdump/print-tcp.c	1 Apr 2003 11:36:54 -0000
@@ -614,6 +614,16 @@
 			ns_print(bp + 2, length - 2);
 		} else if (sport == MSDP_PORT || dport == MSDP_PORT) {
 			msdp_print(bp, length);
+		} else if ( Aflag ) {
+			int	c;
+			putchar(' '); putchar('['); putchar(' ');
+			/* avoid reading beyond the snapped number of bytes */
+			while ( length-- > 0 && bp <= snapend ) {
+				c = *bp++;
+				safeputchar(c);
+			}
+			putchar(' ');
+			putchar(']');
 		}
 	}
 	return;
Index: contrib/tcpdump/tcpdump.1
===================================================================
RCS file: /home/fbsd-cvsrepo/src/contrib/tcpdump/tcpdump.1,v
retrieving revision 1.12
diff -u -r1.12 tcpdump.1
--- contrib/tcpdump/tcpdump.1	26 Jan 2003 01:23:26 -0000	1.12
+++ contrib/tcpdump/tcpdump.1	1 Apr 2003 11:36:54 -0000
@@ -192,6 +192,9 @@
 .B \-a
 Attempt to convert network and broadcast addresses to names.
 .TP
+.B \-A
+Print the payload of TCP packets in human-readable (ASCII) format.
+.TP
 .B \-c
 Exit after receiving \fIcount\fP packets.
 .TP
Index: contrib/tcpdump/tcpdump.c
===================================================================
RCS file: /home/fbsd-cvsrepo/src/contrib/tcpdump/tcpdump.c,v
retrieving revision 1.7
diff -u -r1.7 tcpdump.c
--- contrib/tcpdump/tcpdump.c	26 Jan 2003 01:23:26 -0000	1.7
+++ contrib/tcpdump/tcpdump.c	1 Apr 2003 11:36:54 -0000
@@ -68,6 +68,7 @@
 #include "gmt2local.h"
 
 int aflag;			/* translate network and broadcast addresses */
+int Aflag;			/* ASCII print of the payload of TCP packets */
 int dflag;			/* print filter code */
 int eflag;			/* print ethernet header */
 int fflag;			/* don't translate "foreign" IP address */
@@ -313,13 +314,17 @@
 	
 	opterr = 0;
 	while (
-	    (op = getopt(argc, argv, "ac:C:deE:fF:i:lLm:nNOpqr:Rs:StT:uvw:xXy:Y")) != -1)
+	    (op = getopt(argc, argv, "aAc:C:deE:fF:i:lLm:nNOpqr:Rs:StT:uvw:xXy:Y")) != -1)
 		switch (op) {
 
 		case 'a':
 			++aflag;
 			break;
 
+ 		case 'A':
+ 			++Aflag;
+ 			break;
+
 		case 'c':
 			cnt = atoi(optarg);
 			if (cnt <= 0)
@@ -762,7 +767,7 @@
 	(void)fprintf(stderr, "%s version %s\n", program_name, version);
 	(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
 	(void)fprintf(stderr,
-"Usage: %s [-adeflLnNOpqRStuvxX] [ -c count ] [ -C file_size ]\n", program_name);
+"Usage: %s [-aAdeflLnNOpqRStuvxX] [ -c count ] [ -C file_size ]\n", program_name);
 	(void)fprintf(stderr,
 "\t\t[ -F file ] [ -i interface ] [ -r file ] [ -s snaplen ]\n");
 	(void)fprintf(stderr,
>Release-Note:
>Audit-Trail:

From: Tony Finch <dot@dotat.at>
To: rene@tunix.nl
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/51091: [FEATURE] Add -A (print ASCII) flag to tcpdump
Date: Thu, 17 Apr 2003 16:10:27 +0100

 Rene de Vries <rene@tunix.nl> wrote:
 >
 >	Print the payload of TCP packets in human-readable (ASCII)
 >	format. This can be usefull when debugging readable protocols
 >	(like SMTP, HTTP, etc).
 
 What's wrong with the -X option?
 
 Tony.
 -- 
 f.a.n.finch  <dot@dotat.at>  http://dotat.at/
 BERWICK ON TWEED TO WHITBY: EAST TO SOUTHEAST 3 OR 4 EASING 2 OR 3. HAZE
 CLEARING. MODERATE OR GOOD. SLIGHT TO MODERATE DECAYING SLIGHT.

From: Rene de Vries <rene@tunix.nl>
To: Tony Finch <dot@dotat.at>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/51091: [FEATURE] Add -A (print ASCII) flag to tcpdump
Date: Thu, 17 Apr 2003 17:27:36 +0200

 This option is less verbose (or better different). The -X also displays 
 the hex output (as far as I know) and this can be very disturbing. The 
 -A only shows printable stuff.
 
 Rene
 
 Example dump with -A:
 
 17:20:12.966613 a.b.c.49295 > d.e.f.smtp: S 3701272078:3701272078(0) 
 win 57344 <mss 1460,nop,wscale 0,nop,nop,timestamp 27812521 0> (DF) 
 [tos 0x10]
 17:20:12.978494 d.e.f.smtp > a.b.c.49295: S 2014425195:2014425195(0) 
 ack 3701272079 win 57344 <mss 1460,nop,wscale 0,nop,nop,timestamp 
 9281858 27812521> (DF)
 17:20:12.978546 a.b.c.49295 > d.e.f.smtp: . ack 1 win 57920 
 <nop,nop,timestamp 27812522 9281858> (DF) [tos 0x10]
 17:20:13.782583 d.e.f.smtp > a.b.c.49295: P 1:36(35) ack 1 win 57920 
 <nop,nop,timestamp 9281938 27812522> [ 220 d.e.f ESMTP Postfix\015\012 
 ] (DF)
 17:20:13.874241 a.b.c.49295 > d.e.f.smtp: . ack 36 win 57920 
 <nop,nop,timestamp 27812612 9281938> (DF) [tos 0x10]
 17:20:18.412530 a.b.c.49295 > d.e.f.smtp: P 1:12(11) ack 36 win 57920 
 <nop,nop,timestamp 27813065 9281938> [ HELO test\015\012 ] (DF) [tos 
 0x10]
 17:20:18.442240 d.e.f.smtp > a.b.c.49295: P 36:57(21) ack 12 win 57920 
 <nop,nop,timestamp 9282404 27813065> [ 250 d.e.f\015\012 ] (DF)
 17:20:18.534269 a.b.c.49295 > d.e.f.smtp: . ack 57 win 57920 
 <nop,nop,timestamp 27813078 9282404> (DF) [tos 0x10]
 17:20:20.056281 a.b.c.49295 > d.e.f.smtp: P 12:18(6) ack 57 win 57920 
 <nop,nop,timestamp 27813230 9282404> [ QUIT\015\012 ] (DF) [tos 0x10]
 17:20:20.082060 d.e.f.smtp > a.b.c.49295: P 57:66(9) ack 18 win 57920 
 <nop,nop,timestamp 9282568 27813230> [ 221 Bye\015\012 ] (DF)
 17:20:20.082993 d.e.f.smtp > a.b.c.49295: F 66:66(0) ack 18 win 57920 
 <nop,nop,timestamp 9282568 27813230> (DF)
 17:20:20.083026 a.b.c.49295 > d.e.f.smtp: . ack 67 win 57920 
 <nop,nop,timestamp 27813232 9282568> (DF) [tos 0x10]
 17:20:20.083175 a.b.c.49295 > d.e.f.smtp: F 18:18(0) ack 67 win 57920 
 <nop,nop,timestamp 27813232 9282568> (DF) [tos 0x10]
 17:20:20.111825 d.e.f.smtp > a.b.c.49295: . ack 19 win 57920 
 <nop,nop,timestamp 9282571 27813232> (DF)
 
 Same dump with -X:
 
 17:20:12.966613 a.b.c.49295 > d.e.f.smtp: S 3701272078:3701272078(0) 
 win 57344 <mss 1460,nop,wscale 0,nop,nop,timestamp 27812521 0> (DF) 
 [tos 0x10]
 0x0000   4510 003c d3d9 4000 4006 0000 c14f c985        E..<..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee0e 0000 0000        ..>.............
 0x0020   a002 e000 ef5a 0000 0204 05b4 0103 0300        .....Z..........
 0x0030   0101 080a 01a8 62a9 0000 0000                  ......b.....
 17:20:12.978494 d.e.f.smtp > a.b.c.49295: S 2014425195:2014425195(0) 
 ack 3701272079 win 57344 <mss 1460,nop,wscale 0,nop,nop,timestamp 
 9281858 27812521> (DF)
 0x0000   4500 003c 2887 4000 3d06 892e c2b2 3e7f        E..<(.@.=.....>.
 0x0010   c14f c985 0019 c08f 7811 b06b dc9c ee0f        .O......x..k....
 0x0020   a012 e000 24fd 0000 0204 05b4 0103 0300        ....$...........
 0x0030   0101 080a 008d a142 01a8 62a9                  .......B..b.
 17:20:12.978546 a.b.c.49295 > d.e.f.smtp: . ack 1 win 57920 
 <nop,nop,timestamp 27812522 9281858> (DF) [tos 0x10]
 0x0000   4510 0034 d3da 4000 4006 0000 c14f c985        E..4..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee0f 7811 b06c        ..>.........x..l
 0x0020   8010 e240 4e80 0000 0101 080a 01a8 62aa        ...@N.........b.
 0x0030   008d a142                                      ...B
 17:20:13.782583 d.e.f.smtp > a.b.c.49295: P 1:36(35) ack 1 win 57920 
 <nop,nop,timestamp 9281938 27812522> (DF)
 0x0000   4500 0057 288b 4000 3d06 890f c2b2 3e7f        E..W(.@.=.....>.
 0x0010   c14f c985 0019 c08f 7811 b06c dc9c ee0f        .O......x..l....
 0x0020   8018 e240 41cb 0000 0101 080a 008d a192        ...@A...........
 0x0030   01a8 62aa 3232 3020 6d61 696c 6875 622e        ..b.220.mailhub.
 0x0040   7463 6a61 2e6e 6c20 4553 4d54 5020 506f        tcja.nl.ESMTP.Po
 0x0050   7374 6669 780d 0a                              stfix..
 17:20:13.874241 a.b.c.49295 > d.e.f.smtp: . ack 36 win 57920 
 <nop,nop,timestamp 27812612 9281938> (DF) [tos 0x10]
 0x0000   4510 0034 d3dd 4000 4006 0000 c14f c985        E..4..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee0f 7811 b08f        ..>.........x...
 0x0020   8010 e240 4db3 0000 0101 080a 01a8 6304        ...@M.........c.
 0x0030   008d a192                                      ....
 17:20:18.412530 a.b.c.49295 > d.e.f.smtp: P 1:12(11) ack 36 win 57920 
 <nop,nop,timestamp 27813065 9281938> (DF) [tos 0x10]
 0x0000   4510 003f d3e7 4000 4006 0000 c14f c985        E..?..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee0f 7811 b08f        ..>.........x...
 0x0020   8018 e240 b351 0000 0101 080a 01a8 64c9        ...@.Q........d.
 0x0030   008d a192 4845 4c4f 2074 6573 740d 0a          ....HELO.test..
 17:20:18.442240 d.e.f.smtp > a.b.c.49295: P 36:57(21) ack 12 win 57920 
 <nop,nop,timestamp 9282404 27813065> (DF)
 0x0000   4500 0049 2890 4000 3d06 8918 c2b2 3e7f        E..I(.@.=.....>.
 0x0010   c14f c985 0019 c08f 7811 b08f dc9c ee1a        .O......x.......
 0x0020   8018 e240 c2ec 0000 0101 080a 008d a364        ...@...........d
 0x0030   01a8 64c9 3235 3020 6d61 696c 6875 622e        ..d.250.mailhub.
 0x0040   7463 6a61 2e6e 6c0d 0a                         tcja.nl..
 17:20:18.534269 a.b.c.49295 > d.e.f.smtp: . ack 57 win 57920 
 <nop,nop,timestamp 27813078 9282404> (DF) [tos 0x10]
 0x0000   4510 0034 d3ea 4000 4006 0000 c14f c985        E..4..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee1a 7811 b0a4        ..>.........x...
 0x0020   8010 e240 49ef 0000 0101 080a 01a8 64d6        ...@I.........d.
 0x0030   008d a364                                      ...d
 17:20:20.056281 a.b.c.49295 > d.e.f.smtp: P 12:18(6) ack 57 win 57920 
 <nop,nop,timestamp 27813230 9282404> (DF) [tos 0x10]
 0x0000   4510 003a d3ef 4000 4006 0000 c14f c985        E..:..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee1a 7811 b0a4        ..>.........x...
 0x0020   8018 e240 a195 0000 0101 080a 01a8 656e        ...@..........en
 0x0030   008d a364 5155 4954 0d0a                       ...dQUIT..
 17:20:20.082060 d.e.f.smtp > a.b.c.49295: P 57:66(9) ack 18 win 57920 
 <nop,nop,timestamp 9282568 27813230> (DF)
 0x0000   4500 003d 2891 4000 3d06 8923 c2b2 3e7f        E..=(.@.=..#..>.
 0x0010   c14f c985 0019 c08f 7811 b0a4 dc9c ee20        .O......x.......
 0x0020   8018 e240 33c3 0000 0101 080a 008d a408        ...@3...........
 0x0030   01a8 656e 3232 3120 4279 650d 0a               ..en221.Bye..
 17:20:20.082993 d.e.f.smtp > a.b.c.49295: F 66:66(0) ack 18 win 57920 
 <nop,nop,timestamp 9282568 27813230> (DF)
 0x0000   4500 0034 2892 4000 3d06 892b c2b2 3e7f        E..4(.@.=..+..>.
 0x0010   c14f c985 0019 c08f 7811 b0ad dc9c ee20        .O......x.......
 0x0020   8011 e240 48a3 0000 0101 080a 008d a408        ...@H...........
 0x0030   01a8 656e                                      ..en
 17:20:20.083026 a.b.c.49295 > d.e.f.smtp: . ack 67 win 57920 
 <nop,nop,timestamp 27813232 9282568> (DF) [tos 0x10]
 0x0000   4510 0034 d3f1 4000 4006 0000 c14f c985        E..4..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee20 7811 b0ae        ..>.........x...
 0x0020   8010 e240 48a1 0000 0101 080a 01a8 6570        ...@H.........ep
 0x0030   008d a408                                      ....
 17:20:20.083175 a.b.c.49295 > d.e.f.smtp: F 18:18(0) ack 67 win 57920 
 <nop,nop,timestamp 27813232 9282568> (DF) [tos 0x10]
 0x0000   4510 0034 d3f2 4000 4006 0000 c14f c985        E..4..@.@....O..
 0x0010   c2b2 3e7f c08f 0019 dc9c ee20 7811 b0ae        ..>.........x...
 0x0020   8011 e240 48a0 0000 0101 080a 01a8 6570        ...@H.........ep
 0x0030   008d a408                                      ....
 17:20:20.111825 d.e.f.smtp > a.b.c.49295: . ack 19 win 57920 
 <nop,nop,timestamp 9282571 27813232> (DF)
 0x0000   4500 0034 2893 4000 3d06 892a c2b2 3e7f        E..4(.@.=..*..>.
 0x0010   c14f c985 0019 c08f 7811 b0ae dc9c ee21        .O......x......!
 0x0020   8010 e240 489d 0000 0101 080a 008d a40b        ...@H...........
 0x0030   01a8 6570
 
 On Thursday, Apr 17, 2003, at 17:10 Europe/Amsterdam, Tony Finch wrote:
 > Rene de Vries <rene@tunix.nl> wrote:
 >>
 >> 	Print the payload of TCP packets in human-readable (ASCII)
 >> 	format. This can be usefull when debugging readable protocols
 >> 	(like SMTP, HTTP, etc).
 >
 > What's wrong with the -X option?
 >
 > Tony.
 --
 Rene de Vries <rene@tunix.nl>
 TUNIX Internet Security & Training
 
Responsible-Changed-From-To: freebsd-bugs->fenner 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 22:39:05 PDT 2003 
Responsible-Changed-Why:  
Over to the tcpdump maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51091 
State-Changed-From-To: open->closed 
State-Changed-By: bms 
State-Changed-When: Mon Jun 14 13:48:36 GMT 2004 
State-Changed-Why:  
This was incorporated in the recent tcpdump vendor branch update. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51091 
>Unformatted:
