summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/tcpdump/interface.h3
-rw-r--r--usr.sbin/tcpdump/print-tcp.c49
-rw-r--r--usr.sbin/tcpdump/tcpdump.83
-rw-r--r--usr.sbin/tcpdump/tcpdump.c4
4 files changed, 41 insertions, 18 deletions
diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h
index bbe66dc817c..2743f7b8d72 100644
--- a/usr.sbin/tcpdump/interface.h
+++ b/usr.sbin/tcpdump/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.9 1998/06/25 19:42:45 mickey Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.10 1998/09/22 22:03:00 provos Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -66,6 +66,7 @@ extern int packettype; /* as specified by -T */
* 14 bytes of data (assuming no ip options).
*/
#define DEFAULT_SNAPLEN 68
+#define SACK_SNAPLEN 94
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c
index 0277aa8981d..55aade745f4 100644
--- a/usr.sbin/tcpdump/print-tcp.c
+++ b/usr.sbin/tcpdump/print-tcp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.5 1996/12/12 16:22:26 bitblt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.6 1998/09/22 22:03:01 provos Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -48,10 +48,13 @@ static const char rcsid[] =
#define TCPOPT_WSCALE 3 /* window scale factor (rfc1072) */
#endif
#ifndef TCPOPT_SACKOK
-#define TCPOPT_SACKOK 4 /* selective ack ok (rfc1072) */
+#define TCPOPT_SACKOK 4 /* selective ack ok (rfc2018) */
#endif
#ifndef TCPOPT_SACK
-#define TCPOPT_SACK 5 /* selective ack (rfc1072) */
+#define TCPOPT_SACK 5 /* selective ack (rfc2018) */
+#endif
+#ifndef TCPOLEN_SACK
+#define TCPOLEN_SACK 8 /* length of a SACK block */
#endif
#ifndef TCPOPT_ECHO
#define TCPOPT_ECHO 6 /* echo (rfc1072) */
@@ -102,6 +105,8 @@ tcp_print(register const u_char *bp, register u_int length,
register u_char flags;
register int hlen;
register char ch;
+ register struct tcp_seq_hash *th;
+ register int rev;
u_short sport, dport, win, urp;
u_int32_t seq, ack;
@@ -142,8 +147,6 @@ tcp_print(register const u_char *bp, register u_int length,
putchar('.');
if (!Sflag && (flags & TH_ACK)) {
- register struct tcp_seq_hash *th;
- register int rev;
struct tha tha;
/*
* Find (or record) the initial sequence numbers for
@@ -260,22 +263,38 @@ tcp_print(register const u_char *bp, register u_int length,
case TCPOPT_SACKOK:
(void)printf("sackOK");
+ if (len != 2)
+ (void)printf("[len %d]", len);
break;
case TCPOPT_SACK:
- (void)printf("sack");
+ {
+ u_long s, e;
+
datalen = len - 2;
- for (i = 0; i < datalen; i += 4) {
- LENCHECK(i + 4);
- /* block-size@relative-origin */
- (void)printf(" %u@%u",
- EXTRACT_16BITS(cp + i + 2),
- EXTRACT_16BITS(cp + i));
+ if ((datalen % TCPOLEN_SACK) != 0 ||
+ !(flags & TH_ACK)) {
+ (void)printf("malformed sack ");
+ (void)printf("[len %d] ", datalen);
+ break;
+ }
+ printf("sack %d ", datalen/TCPOLEN_SACK);
+ for (i = 0; i < datalen; i += TCPOLEN_SACK) {
+ LENCHECK (i + TCPOLEN_SACK);
+ s = EXTRACT_32BITS(cp + i);
+ e = EXTRACT_32BITS(cp + i + 4);
+ if (!Sflag)
+ if (rev) {
+ s -= th->seq;
+ e -= th->seq;
+ } else {
+ s -= th->ack;
+ e -= th->ack;
+ }
+ (void) printf("{%u:%u} ", s, e);
}
- if (datalen % 4)
- (void)printf("[len %d]", len);
break;
-
+ }
case TCPOPT_ECHO:
(void)printf("echo");
datalen = 4;
diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8
index 7f56765a00d..e43c539f669 100644
--- a/usr.sbin/tcpdump/tcpdump.8
+++ b/usr.sbin/tcpdump/tcpdump.8
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.8,v 1.9 1998/09/13 03:50:23 aaron Exp $ (LBL)
+.\" @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.8,v 1.10 1998/09/22 22:03:01 provos Exp $ (LBL)
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
.\" The Regents of the University of California. All rights reserved.
@@ -179,6 +179,7 @@ specified \fItype\fR. Currently known types are
\fBrpc\fR (Remote Procedure Call),
\fBrtp\fR (Real-Time Applications protocol),
\fBrtcp\fR (Real-Time Applications control protocol),
+\fBsack\fR (RFC 2018 Selective Acknowledgements),
\fBvat\fR (Visual Audio Tool),
and
\fBwb\fR (distributed White Board).
diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c
index 8840e0953c7..8b5f0d0bd53 100644
--- a/usr.sbin/tcpdump/tcpdump.c
+++ b/usr.sbin/tcpdump/tcpdump.c
@@ -24,7 +24,7 @@ static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.10 1998/06/25 19:42:48 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.11 1998/09/22 22:03:02 provos Exp $ (LBL)";
#endif
/*
@@ -235,6 +235,8 @@ main(int argc, char **argv)
packettype = PT_RTCP;
else if (strcasecmp(optarg, "cnfp") == 0)
packettype = PT_CNFP;
+ else if (strcasecmp(optarg, "sack") == 0)
+ snaplen = SACK_SNAPLEN;
else
error("unknown packet type `%s'", optarg);
break;