diff options
author | fenner <fenner@FreeBSD.org> | 2001-04-03 07:45:48 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 2001-04-03 07:45:48 +0000 |
commit | ace14a2b50f2cc05c079d0b9137b49066dbb1206 (patch) | |
tree | 4953fdd47c44b8ec88d34a4db7b698841365e22f /contrib/tcpdump/print-sunrpc.c | |
parent | 54c4a9c9f2aca2e032cbf41f5eb012e2e9628dd4 (diff) | |
download | FreeBSD-src-ace14a2b50f2cc05c079d0b9137b49066dbb1206.zip FreeBSD-src-ace14a2b50f2cc05c079d0b9137b49066dbb1206.tar.gz |
Virgin import of tcpdump.org tcpdump v3.6.2
Diffstat (limited to 'contrib/tcpdump/print-sunrpc.c')
-rw-r--r-- | contrib/tcpdump/print-sunrpc.c | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c index 0c686d7..7ab39d0 100644 --- a/contrib/tcpdump/print-sunrpc.c +++ b/contrib/tcpdump/print-sunrpc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.29 1999/11/21 09:37:02 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.39 2000/10/07 05:53:13 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -32,17 +32,10 @@ static const char rcsid[] = #include <sys/time.h> #include <sys/socket.h> -#if __STDC__ struct mbuf; struct rtentry; -#endif -#include <net/if.h> #include <netinet/in.h> -#include <netinet/if_ether.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#include <netinet/ip_var.h> #include <rpc/rpc.h> #ifdef HAVE_RPC_RPCENT_H @@ -58,6 +51,11 @@ struct rtentry; #include "interface.h" #include "addrtoname.h" +#include "ip.h" +#ifdef INET6 +#include "ip6.h" +#endif + static struct tok proc2str[] = { { PMAPPROC_NULL, "null" }, { PMAPPROC_SET, "set" }, @@ -77,24 +75,44 @@ sunrpcrequest_print(register const u_char *bp, register u_int length, { register const struct rpc_msg *rp; register const struct ip *ip; +#ifdef INET6 + register const struct ip6_hdr *ip6; +#endif u_int32_t x; + char srcid[20], dstid[20]; /*fits 32bit*/ 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); + + if (!nflag) { + snprintf(srcid, sizeof(srcid), "0x%x", + (u_int32_t)ntohl(rp->rm_xid)); + strlcpy(dstid, "sunrpc", sizeof(dstid)); + } else { + snprintf(srcid, sizeof(srcid), "0x%x", + (u_int32_t)ntohl(rp->rm_xid)); + snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT); + } + + switch (IP_V((struct ip *)bp2)) { + case 4: + ip = (struct ip *)bp2; + printf("%s.%s > %s.%s: %d", + ipaddr_string(&ip->ip_src), srcid, + ipaddr_string(&ip->ip_dst), dstid, length); + break; +#ifdef INET6 + case 6: + ip6 = (struct ip6_hdr *)bp2; + printf("%s.%s > %s.%s: %d", + ip6addr_string(&ip6->ip6_src), srcid, + ip6addr_string(&ip6->ip6_dst), dstid, length); + break; +#endif + default: + printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length); + break; + } + printf(" %s", tok2str(proc2str, " proc #%u", (u_int32_t)ntohl(rp->rm_call.cb_proc))); x = ntohl(rp->rm_call.cb_rpcvers); @@ -129,8 +147,8 @@ progstr(prog) return (buf); rp = getrpcbynumber(prog); if (rp == NULL) - (void) sprintf(buf, "#%u", prog); + (void) snprintf(buf, sizeof(buf), "#%u", prog); else - strcpy(buf, rp->r_name); + strlcpy(buf, rp->r_name, sizeof(buf)); return (buf); } |