summaryrefslogtreecommitdiff
path: root/usr.sbin/tcpdump/print-tcp.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-10 07:48:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-10 07:48:01 +0000
commit3fb1d3fc24dae7c5506be7d6bae54ecc97348ba0 (patch)
treedc5119d72c4bd5e50838971ecc04cd7364e3f6aa /usr.sbin/tcpdump/print-tcp.c
parentbb6af93821af2776feaaf29a9b579c504d5686df (diff)
sync to latest
Diffstat (limited to 'usr.sbin/tcpdump/print-tcp.c')
-rw-r--r--usr.sbin/tcpdump/print-tcp.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c
index f658dc35fcf..e8db63a3357 100644
--- a/usr.sbin/tcpdump/print-tcp.c
+++ b/usr.sbin/tcpdump/print-tcp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: print-tcp.c,v 1.2 1996/03/04 15:59:39 mickey Exp $ */
-/* $NetBSD: print-tcp.c,v 1.5 1995/03/06 19:11:33 mycroft Exp $ */
+/**//* $OpenBSD: print-tcp.c,v 1.3 1996/06/10 07:47:50 deraadt Exp $ */
+/* $NetBSD: print-tcp.c,v 1.6.4.1 1996/05/26 18:36:15 fvdl Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
@@ -38,6 +38,8 @@ static char rcsid[] =
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
+#include <rpc/rpc.h>
+
#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
@@ -47,6 +49,8 @@ static char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "nfs.h"
+
#ifndef TCPOPT_WSCALE
#define TCPOPT_WSCALE 3 /* window scale factor (rfc1072) */
#endif
@@ -93,7 +97,7 @@ tcp_print(register const u_char *bp, register int length,
register u_char flags;
register int hlen;
u_short sport, dport, win, urp;
- u_int32 seq, ack;
+ tcp_seq seq, ack;
tp = (struct tcphdr *)bp;
ip = (struct ip *)bp2;
@@ -112,13 +116,36 @@ tcp_print(register const u_char *bp, register int length,
ack = ntohl(tp->th_ack);
win = ntohs(tp->th_win);
urp = ntohs(tp->th_urp);
+ hlen = tp->th_off * 4;
+ length -= hlen;
+
+ /*
+ * If data present and NFS port used, assume NFS.
+ * Pass offset of data plus 4 bytes for RPC TCP msg length
+ * to NFS print routines.
+ */
+ if (!qflag) {
+ if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend &&
+ dport == NFS_PORT) {
+ nfsreq_print((u_char *)tp + hlen + 4, length,
+ (u_char *)ip);
+ return;
+ }
+ else if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend &&
+ sport == NFS_PORT) {
+ nfsreply_print((u_char *)tp + hlen + 4, length,
+ (u_char *)ip);
+ return;
+ }
+ }
+
(void)printf("%s.%s > %s.%s: ",
ipaddr_string(&ip->ip_src), tcpport_string(sport),
ipaddr_string(&ip->ip_dst), tcpport_string(dport));
if (qflag) {
- (void)printf("tcp %d", length - tp->th_off * 4);
+ (void)printf("tcp %d", length);
return;
}
if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {
@@ -178,10 +205,8 @@ tcp_print(register const u_char *bp, register int length,
seq -= th->seq, ack -= th->ack;
}
}
- hlen = tp->th_off * 4;
- length -= hlen;
if (length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
- (void)printf(" %u:%u(%d)", seq, seq + length, length);
+ (void)printf(" %lu:%lu(%d)", seq, seq + length, length);
if (flags & TH_ACK)
(void)printf(" ack %u", ack);