diff options
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r-- | usr.sbin/tcpdump/print-nfs.c | 37 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-sunrpc.c | 18 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-tcp.c | 42 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-udp.c | 24 |
4 files changed, 50 insertions, 71 deletions
diff --git a/usr.sbin/tcpdump/print-nfs.c b/usr.sbin/tcpdump/print-nfs.c index 9059a1e6da0..10eef79258d 100644 --- a/usr.sbin/tcpdump/print-nfs.c +++ b/usr.sbin/tcpdump/print-nfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-nfs.c,v 1.8 2000/10/03 14:31:58 ho Exp $ */ +/* $OpenBSD: print-nfs.c,v 1.9 2000/12/05 08:17:45 jakob Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -75,24 +75,9 @@ nfsreply_print(register const u_char *bp, u_int length, rp = (const struct rpc_msg *)bp; ip = (const struct ip *)bp2; - if (!nflag) - (void)printf("%s.nfs > %s.%x: reply %s %d", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst), - (u_int32_t)ntohl(rp->rm_xid), - ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED? - "ok":"ERR", - length); - else - (void)printf("%s.%x > %s.%x: reply %s %d", - ipaddr_string(&ip->ip_src), - NFS_PORT, - ipaddr_string(&ip->ip_dst), - (u_int32_t)ntohl(rp->rm_xid), - ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED? - "ok":"ERR", - length); - + printf("xid 0x%x reply %s %d", (u_int32_t)ntohl(rp->rm_xid), + ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED ? "ok":"ERR", + length); if (xid_map_find(rp, ip, &proc)) interp_reply(rp, proc, length); } @@ -198,19 +183,7 @@ nfsreq_print(register const u_char *bp, u_int length, nfserr = 0; /* assume no error */ rp = (const struct rpc_msg *)bp; ip = (const struct ip *)bp2; - if (!nflag) - (void)printf("%s.%x > %s.nfs: %d", - ipaddr_string(&ip->ip_src), - (u_int32_t)ntohl(rp->rm_xid), - ipaddr_string(&ip->ip_dst), - length); - else - (void)printf("%s.%x > %s.%x: %d", - ipaddr_string(&ip->ip_src), - (u_int32_t)ntohl(rp->rm_xid), - ipaddr_string(&ip->ip_dst), - NFS_PORT, - length); + printf("xid 0x%x %d", (u_int32_t)ntohl(rp->rm_xid), length); xid_map_enter(rp, ip); /* record proc number for later on */ diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c index 0b262dbba4d..69d50df7108 100644 --- a/usr.sbin/tcpdump/print-sunrpc.c +++ b/usr.sbin/tcpdump/print-sunrpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-sunrpc.c,v 1.9 2000/10/03 14:31:58 ho Exp $ */ +/* $OpenBSD: print-sunrpc.c,v 1.10 2000/12/05 08:17:45 jakob Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.9 2000/10/03 14:31:58 ho Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.10 2000/12/05 08:17:45 jakob Exp $ (LBL)"; #endif #include <sys/param.h> @@ -80,19 +80,7 @@ sunrpcrequest_print(register const u_char *bp, register u_int length, rp = (struct rpc_msg *)bp; ip = (struct ip *)bp2; - if (!nflag) - (void)printf("%s.%x > %s.sunrpc: %d", - ipaddr_string(&ip->ip_src), - (u_int32_t)ntohl(rp->rm_xid), - ipaddr_string(&ip->ip_dst), - length); - else - (void)printf("%s.%x > %s.%x: %d", - ipaddr_string(&ip->ip_src), - (u_int32_t)ntohl(rp->rm_xid), - ipaddr_string(&ip->ip_dst), - PMAPPORT, - length); + printf("xid 0x%x %d", (u_int32_t)ntohl(rp->rm_xid), length); printf(" %s", tok2str(proc2str, " proc #%u", (u_int32_t)ntohl(rp->rm_call.cb_proc))); x = ntohl(rp->rm_call.cb_rpcvers); diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index aa47da701b1..c0cd9f7701f 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-tcp.c,v 1.12 2000/10/03 14:21:56 ho Exp $ */ +/* $OpenBSD: print-tcp.c,v 1.13 2000/12/05 08:17:45 jakob Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.12 2000/10/03 14:21:56 ho Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.13 2000/12/05 08:17:45 jakob Exp $ (LBL)"; #endif #include <sys/param.h> @@ -205,26 +205,6 @@ tcp_print(register const u_char *bp, register u_int length, urp = ntohs(tp->th_urp); hlen = tp->th_off * 4; - /* - * 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) { - u_int len = length - hlen; - if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && - dport == NFS_PORT) { - nfsreq_print((u_char *)tp + hlen + 4, len, - (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, len, - (u_char *)ip); - return; - } - } #ifdef INET6 if (ip6) { @@ -256,6 +236,24 @@ tcp_print(register const u_char *bp, register u_int length, if (qflag) { (void)printf("tcp %d", length - tp->th_off * 4); return; + } else { + /* + * 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. + */ + u_int len = length - hlen; + if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && + dport == NFS_PORT) { + nfsreq_print((u_char *)tp + hlen + 4, len, + (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, len, + (u_char *)ip); + return; + } } if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH| TH_ECNECHO|TH_CWR)) { diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index 370f5a1e488..5905e952c1c 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-udp.c,v 1.14 2000/10/03 14:21:57 ho Exp $ */ +/* $OpenBSD: print-udp.c,v 1.15 2000/12/05 08:17:45 jakob Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udp.c,v 1.14 2000/10/03 14:21:57 ho Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udp.c,v 1.15 2000/12/05 08:17:45 jakob Exp $ (LBL)"; #endif #include <sys/param.h> @@ -423,6 +423,11 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) break; case PT_RPC: + (void)printf("%s.%s > %s.%s: ", + ipaddr_string(&ip->ip_src), + udpport_string(sport), + ipaddr_string(&ip->ip_dst), + udpport_string(dport)); rp = (struct rpc_msg *)(up + 1); direction = (enum msg_type)ntohl(rp->rm_direction); if (direction == CALL) @@ -466,17 +471,32 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) if (TTEST(rp->rm_direction)) { direction = (enum msg_type)ntohl(rp->rm_direction); if (dport == NFS_PORT && direction == CALL) { + (void)printf("%s.%s > %s.%s: ", + ipaddr_string(&ip->ip_src), + udpport_string(sport), + ipaddr_string(&ip->ip_dst), + udpport_string(dport)); nfsreq_print((u_char *)rp, length, (u_char *)ip); return; } if (sport == NFS_PORT && direction == REPLY) { + (void)printf("%s.%s > %s.%s: ", + ipaddr_string(&ip->ip_src), + udpport_string(sport), + ipaddr_string(&ip->ip_dst), + udpport_string(dport)); nfsreply_print((u_char *)rp, length, (u_char *)ip); return; } #ifdef notdef if (dport == SUNRPC_PORT && direction == CALL) { + (void)printf("%s.%s > %s.%s: ", + ipaddr_string(&ip->ip_src), + udpport_string(sport), + ipaddr_string(&ip->ip_dst), + udpport_string(dport)); sunrpcrequest_print((u_char *)rp, length, (u_char *)ip); return; } |