]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-nfs.c
Make "-x" and "-X" work with PPPoE interfaces; based on code from Darren
[tcpdump] / print-nfs.c
index 395107bfecac36e956c04eea5e5578a7e9cedaa3..c295fd7a8f7a79653747012a61cf49c19d700c4e 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.82 2000-09-23 08:03:38 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.91 2002-04-24 06:27:06 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -34,14 +34,8 @@ static const char rcsid[] =
 
 struct mbuf;
 struct rtentry;
-#include <net/if.h>
 
 #include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
 
 #include <rpc/rpc.h>
 
@@ -56,6 +50,11 @@ struct rtentry;
 #include "nfs.h"
 #include "nfsfh.h"
 
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
 static void nfs_printfh(const u_int32_t *, const u_int);
 static void xid_map_enter(const struct rpc_msg *, const u_char *);
 static int32_t xid_map_find(const struct rpc_msg *, const u_char *,
@@ -227,7 +226,7 @@ print_nfsaddr(const u_char *bp, const char *s, const char *d)
 #endif
 
        srcaddr[0] = dstaddr[0] = '\0';
-       switch (((struct ip *)bp)->ip_v) {
+       switch (IP_V((struct ip *)bp)) {
        case 4:
                ip = (struct ip *)bp;
                strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
@@ -757,9 +756,10 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
 {
        my_fsid fsid;
        ino_t ino;
-       char *sfsname = NULL;
+       const char *sfsname = NULL;
+       char *spacep;
 
-       Parse_fh((caddr_t*)dp, len, &fsid, &ino, NULL, &sfsname, 0);
+       Parse_fh((const u_char *)dp, len, &fsid, &ino, NULL, &sfsname, 0);
 
        if (sfsname) {
                /* file system ID is ASCII, not numeric, for this server OS */
@@ -769,9 +769,9 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
                strncpy(temp, sfsname, NFSX_V3FHMAX);
                temp[sizeof(temp) - 1] = '\0';
                /* Remove trailing spaces */
-               sfsname = strchr(temp, ' ');
-               if (sfsname)
-                       *sfsname = 0;
+               spacep = strchr(temp, ' ');
+               if (spacep)
+                       *spacep = '\0';
 
                (void)printf(" fh %s/", temp);
        } else {
@@ -828,7 +828,7 @@ xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
 #endif
        struct xid_map_entry *xmep;
 
-       switch (((struct ip *)bp)->ip_v) {
+       switch (IP_V((struct ip *)bp)) {
        case 4:
                ip = (struct ip *)bp;
                break;
@@ -885,7 +885,7 @@ xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
        do {
                xmep = &xid_map[i];
                cmp = 1;
-               if (xmep->ipver != ip->ip_v || xmep->xid != xid)
+               if (xmep->ipver != IP_V(ip) || xmep->xid != xid)
                        goto nextitem;
                switch (xmep->ipver) {
                case 4:
@@ -1206,7 +1206,7 @@ parserddires(const u_int32_t *dp)
        int er;
 
        dp = parsestatus(dp, &er);
-       if (dp == 0 || er)
+       if (dp == NULL || er)
                return (0);
        if (qflag)
                return (1);
@@ -1488,7 +1488,8 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
 
        case NFSPROC_ACCESS:
                printf(" access");
-               dp = parserep(rp, length);
+               if (!(dp = parserep(rp, length)))
+                       break;
                if (!(dp = parsestatus(dp, &er)))
                        break;
                if (vflag)