Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/tcpdump IPv6 support for sunrpc. from tcpdump.org.



details:   https://anonhg.NetBSD.org/src/rev/928e90566147
branches:  trunk
changeset: 487630:928e90566147
user:      itojun <itojun%NetBSD.org@localhost>
date:      Sat Jun 10 05:39:16 2000 +0000

description:
IPv6 support for sunrpc.  from tcpdump.org.

diffstat:

 usr.sbin/tcpdump/print-sunrpc.c |  59 ++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 18 deletions(-)

diffs (98 lines):

diff -r 2ec78525daa2 -r 928e90566147 usr.sbin/tcpdump/print-sunrpc.c
--- a/usr.sbin/tcpdump/print-sunrpc.c   Sat Jun 10 05:27:27 2000 +0000
+++ b/usr.sbin/tcpdump/print-sunrpc.c   Sat Jun 10 05:39:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print-sunrpc.c,v 1.5 1997/10/03 19:55:45 christos Exp $        */
+/*     $NetBSD: print-sunrpc.c,v 1.6 2000/06/10 05:39:16 itojun Exp $  */
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995, 1996
@@ -27,7 +27,7 @@
 static const char rcsid[] =
     "@(#) Header: print-sunrpc.c,v 1.26 96/12/31 21:27:43 leres Exp  (LBL)";
 #else
-__RCSID("$NetBSD: print-sunrpc.c,v 1.5 1997/10/03 19:55:45 christos Exp $");
+__RCSID("$NetBSD: print-sunrpc.c,v 1.6 2000/06/10 05:39:16 itojun Exp $");
 #endif
 #endif
 
@@ -50,6 +50,9 @@
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
 
 #include <rpc/rpc.h>
 #ifdef HAVE_RPC_RPCENT_H
@@ -84,24 +87,44 @@
 {
        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) {
+               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);
+       }
 
-       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);
+       switch (((struct ip *)bp2)->ip_v) {
+       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);
@@ -136,8 +159,8 @@
                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);
 }



Home | Main Index | Thread Index | Old Index