bin/51091: [FEATURE] Add -A (print ASCII) flag to tcpdump
Rene de Vries
rene at tunix.nl
Thu Apr 17 04:40:17 PDT 2003
>Number: 51091
>Category: bin
>Synopsis: [FEATURE] Add -A (print ASCII) flag to tcpdump
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Apr 17 04:40:15 PDT 2003
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:
More information about the freebsd-bugs
mailing list