]>
The Tcpdump Group git mirrors - tcpdump/blob - print-nfs.c
bba661fe0ea507c0ca395c4b44d93cbcd089e944
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 /* \summary: Network File System (NFS) printer */
28 #include <netdissect-stdinc.h>
33 #include "netdissect.h"
34 #include "addrtoname.h"
45 static const char tstr
[] = " [|nfs]";
47 static void nfs_printfh(netdissect_options
*, const uint32_t *, const u_int
);
48 static int xid_map_enter(netdissect_options
*, const struct sunrpc_msg
*, const u_char
*);
49 static int xid_map_find(const struct sunrpc_msg
*, const u_char
*,
50 uint32_t *, uint32_t *);
51 static void interp_reply(netdissect_options
*, const struct sunrpc_msg
*, uint32_t, uint32_t, int);
52 static const uint32_t *parse_post_op_attr(netdissect_options
*, const uint32_t *, int);
55 * Mapping of old NFS Version 2 RPC numbers to generic numbers.
57 static uint32_t nfsv3_procid
[NFS_NPROCS
] = {
86 static const struct tok nfsproc_str
[] = {
87 { NFSPROC_NOOP
, "nop" },
88 { NFSPROC_NULL
, "null" },
89 { NFSPROC_GETATTR
, "getattr" },
90 { NFSPROC_SETATTR
, "setattr" },
91 { NFSPROC_LOOKUP
, "lookup" },
92 { NFSPROC_ACCESS
, "access" },
93 { NFSPROC_READLINK
, "readlink" },
94 { NFSPROC_READ
, "read" },
95 { NFSPROC_WRITE
, "write" },
96 { NFSPROC_CREATE
, "create" },
97 { NFSPROC_MKDIR
, "mkdir" },
98 { NFSPROC_SYMLINK
, "symlink" },
99 { NFSPROC_MKNOD
, "mknod" },
100 { NFSPROC_REMOVE
, "remove" },
101 { NFSPROC_RMDIR
, "rmdir" },
102 { NFSPROC_RENAME
, "rename" },
103 { NFSPROC_LINK
, "link" },
104 { NFSPROC_READDIR
, "readdir" },
105 { NFSPROC_READDIRPLUS
, "readdirplus" },
106 { NFSPROC_FSSTAT
, "fsstat" },
107 { NFSPROC_FSINFO
, "fsinfo" },
108 { NFSPROC_PATHCONF
, "pathconf" },
109 { NFSPROC_COMMIT
, "commit" },
114 * NFS V2 and V3 status values.
116 * Some of these come from the RFCs for NFS V2 and V3, with the message
117 * strings taken from the FreeBSD C library "errlst.c".
119 * Others are errors that are not in the RFC but that I suspect some
120 * NFS servers could return; the values are FreeBSD errno values, as
121 * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
122 * was primarily BSD-derived.
124 static const struct tok status2str
[] = {
125 { 1, "Operation not permitted" }, /* EPERM */
126 { 2, "No such file or directory" }, /* ENOENT */
127 { 5, "Input/output error" }, /* EIO */
128 { 6, "Device not configured" }, /* ENXIO */
129 { 11, "Resource deadlock avoided" }, /* EDEADLK */
130 { 12, "Cannot allocate memory" }, /* ENOMEM */
131 { 13, "Permission denied" }, /* EACCES */
132 { 17, "File exists" }, /* EEXIST */
133 { 18, "Cross-device link" }, /* EXDEV */
134 { 19, "Operation not supported by device" }, /* ENODEV */
135 { 20, "Not a directory" }, /* ENOTDIR */
136 { 21, "Is a directory" }, /* EISDIR */
137 { 22, "Invalid argument" }, /* EINVAL */
138 { 26, "Text file busy" }, /* ETXTBSY */
139 { 27, "File too large" }, /* EFBIG */
140 { 28, "No space left on device" }, /* ENOSPC */
141 { 30, "Read-only file system" }, /* EROFS */
142 { 31, "Too many links" }, /* EMLINK */
143 { 45, "Operation not supported" }, /* EOPNOTSUPP */
144 { 62, "Too many levels of symbolic links" }, /* ELOOP */
145 { 63, "File name too long" }, /* ENAMETOOLONG */
146 { 66, "Directory not empty" }, /* ENOTEMPTY */
147 { 69, "Disc quota exceeded" }, /* EDQUOT */
148 { 70, "Stale NFS file handle" }, /* ESTALE */
149 { 71, "Too many levels of remote in path" }, /* EREMOTE */
150 { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */
151 { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */
152 { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */
153 { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */
154 { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */
155 { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */
156 { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */
157 { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */
158 { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */
162 static const struct tok nfsv3_writemodes
[] = {
169 static const struct tok type2str
[] = {
180 static const struct tok sunrpc_auth_str
[] = {
181 { SUNRPC_AUTH_OK
, "OK" },
182 { SUNRPC_AUTH_BADCRED
, "Bogus Credentials (seal broken)" },
183 { SUNRPC_AUTH_REJECTEDCRED
, "Rejected Credentials (client should begin new session)" },
184 { SUNRPC_AUTH_BADVERF
, "Bogus Verifier (seal broken)" },
185 { SUNRPC_AUTH_REJECTEDVERF
, "Verifier expired or was replayed" },
186 { SUNRPC_AUTH_TOOWEAK
, "Credentials are too weak" },
187 { SUNRPC_AUTH_INVALIDRESP
, "Bogus response verifier" },
188 { SUNRPC_AUTH_FAILED
, "Unknown failure" },
192 static const struct tok sunrpc_str
[] = {
193 { SUNRPC_PROG_UNAVAIL
, "PROG_UNAVAIL" },
194 { SUNRPC_PROG_MISMATCH
, "PROG_MISMATCH" },
195 { SUNRPC_PROC_UNAVAIL
, "PROC_UNAVAIL" },
196 { SUNRPC_GARBAGE_ARGS
, "GARBAGE_ARGS" },
197 { SUNRPC_SYSTEM_ERR
, "SYSTEM_ERR" },
202 print_nfsaddr(netdissect_options
*ndo
,
203 const u_char
*bp
, const char *s
, const char *d
)
206 const struct ip6_hdr
*ip6
;
207 char srcaddr
[INET6_ADDRSTRLEN
], dstaddr
[INET6_ADDRSTRLEN
];
209 srcaddr
[0] = dstaddr
[0] = '\0';
210 switch (IP_V((const struct ip
*)bp
)) {
212 ip
= (const struct ip
*)bp
;
213 strlcpy(srcaddr
, ipaddr_string(ndo
, &ip
->ip_src
), sizeof(srcaddr
));
214 strlcpy(dstaddr
, ipaddr_string(ndo
, &ip
->ip_dst
), sizeof(dstaddr
));
217 ip6
= (const struct ip6_hdr
*)bp
;
218 strlcpy(srcaddr
, ip6addr_string(ndo
, &ip6
->ip6_src
),
220 strlcpy(dstaddr
, ip6addr_string(ndo
, &ip6
->ip6_dst
),
224 strlcpy(srcaddr
, "?", sizeof(srcaddr
));
225 strlcpy(dstaddr
, "?", sizeof(dstaddr
));
229 ND_PRINT("%s.%s > %s.%s: ", srcaddr
, s
, dstaddr
, d
);
232 static const uint32_t *
233 parse_sattr3(netdissect_options
*ndo
,
234 const uint32_t *dp
, struct nfsv3_sattr
*sa3
)
237 sa3
->sa_modeset
= EXTRACT_BE_U_4(dp
);
239 if (sa3
->sa_modeset
) {
241 sa3
->sa_mode
= EXTRACT_BE_U_4(dp
);
246 sa3
->sa_uidset
= EXTRACT_BE_U_4(dp
);
248 if (sa3
->sa_uidset
) {
250 sa3
->sa_uid
= EXTRACT_BE_U_4(dp
);
255 sa3
->sa_gidset
= EXTRACT_BE_U_4(dp
);
257 if (sa3
->sa_gidset
) {
259 sa3
->sa_gid
= EXTRACT_BE_U_4(dp
);
264 sa3
->sa_sizeset
= EXTRACT_BE_U_4(dp
);
266 if (sa3
->sa_sizeset
) {
268 sa3
->sa_size
= EXTRACT_BE_U_4(dp
);
273 sa3
->sa_atimetype
= EXTRACT_BE_U_4(dp
);
275 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
) {
277 sa3
->sa_atime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
279 sa3
->sa_atime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
284 sa3
->sa_mtimetype
= EXTRACT_BE_U_4(dp
);
286 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
) {
288 sa3
->sa_mtime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
290 sa3
->sa_mtime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
299 static int nfserr
; /* true if we error rather than trunc */
302 print_sattr3(netdissect_options
*ndo
,
303 const struct nfsv3_sattr
*sa3
, int verbose
)
306 ND_PRINT(" mode %o", sa3
->sa_mode
);
308 ND_PRINT(" uid %u", sa3
->sa_uid
);
310 ND_PRINT(" gid %u", sa3
->sa_gid
);
312 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
)
313 ND_PRINT(" atime %u.%06u", sa3
->sa_atime
.nfsv3_sec
,
314 sa3
->sa_atime
.nfsv3_nsec
);
315 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
)
316 ND_PRINT(" mtime %u.%06u", sa3
->sa_mtime
.nfsv3_sec
,
317 sa3
->sa_mtime
.nfsv3_nsec
);
322 nfsreply_print(netdissect_options
*ndo
,
323 const u_char
*bp
, u_int length
,
326 const struct sunrpc_msg
*rp
;
327 char srcid
[20], dstid
[20]; /*fits 32bit*/
329 nfserr
= 0; /* assume no error */
330 rp
= (const struct sunrpc_msg
*)bp
;
332 ND_TCHECK(rp
->rm_xid
);
333 if (!ndo
->ndo_nflag
) {
334 strlcpy(srcid
, "nfs", sizeof(srcid
));
335 snprintf(dstid
, sizeof(dstid
), "%u",
336 EXTRACT_BE_U_4(rp
->rm_xid
));
338 snprintf(srcid
, sizeof(srcid
), "%u", NFS_PORT
);
339 snprintf(dstid
, sizeof(dstid
), "%u",
340 EXTRACT_BE_U_4(rp
->rm_xid
));
342 print_nfsaddr(ndo
, bp2
, srcid
, dstid
);
344 nfsreply_noaddr_print(ndo
, bp
, length
, bp2
);
349 ND_PRINT("%s", tstr
);
353 nfsreply_noaddr_print(netdissect_options
*ndo
,
354 const u_char
*bp
, u_int length
,
357 const struct sunrpc_msg
*rp
;
358 uint32_t proc
, vers
, reply_stat
;
359 enum sunrpc_reject_stat rstat
;
362 enum sunrpc_auth_stat rwhy
;
364 nfserr
= 0; /* assume no error */
365 rp
= (const struct sunrpc_msg
*)bp
;
367 ND_TCHECK(rp
->rm_reply
.rp_stat
);
368 reply_stat
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_stat
);
369 switch (reply_stat
) {
371 case SUNRPC_MSG_ACCEPTED
:
372 ND_PRINT("reply ok %u", length
);
373 if (xid_map_find(rp
, bp2
, &proc
, &vers
) >= 0)
374 interp_reply(ndo
, rp
, proc
, vers
, length
);
377 case SUNRPC_MSG_DENIED
:
378 ND_PRINT("reply ERR %u: ", length
);
379 ND_TCHECK(rp
->rm_reply
.rp_reject
.rj_stat
);
380 rstat
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_stat
);
383 case SUNRPC_RPC_MISMATCH
:
384 ND_TCHECK(rp
->rm_reply
.rp_reject
.rj_vers
.high
);
385 rlow
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.low
);
386 rhigh
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.high
);
387 ND_PRINT("RPC Version mismatch (%u-%u)", rlow
, rhigh
);
390 case SUNRPC_AUTH_ERROR
:
391 ND_TCHECK(rp
->rm_reply
.rp_reject
.rj_why
);
392 rwhy
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_why
);
393 ND_PRINT("Auth %s", tok2str(sunrpc_auth_str
, "Invalid failure code %u", rwhy
));
397 ND_PRINT("Unknown reason for rejecting rpc message %u", (unsigned int)rstat
);
403 ND_PRINT("reply Unknown rpc response code=%u %u", reply_stat
, length
);
410 ND_PRINT("%s", tstr
);
414 * Return a pointer to the first file handle in the packet.
415 * If the packet was truncated, return 0.
417 static const uint32_t *
418 parsereq(netdissect_options
*ndo
,
419 const struct sunrpc_msg
*rp
, u_int length
)
425 * find the start of the req data (if we captured it)
427 dp
= (const uint32_t *)&rp
->rm_call
.cb_cred
;
429 len
= EXTRACT_BE_U_4(dp
+ 1);
431 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
433 len
= EXTRACT_BE_U_4(dp
+ 1);
435 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
436 ND_TCHECK_LEN(dp
, 0);
445 * Print out an NFS file handle and return a pointer to following word.
446 * If packet was truncated, return 0.
448 static const uint32_t *
449 parsefh(netdissect_options
*ndo
,
450 const uint32_t *dp
, int v3
)
456 len
= EXTRACT_BE_U_4(dp
) / 4;
461 if (ND_TTEST_LEN(dp
, len
* sizeof(*dp
))) {
462 nfs_printfh(ndo
, dp
, len
);
470 * Print out a file name and return pointer to 32-bit word past it.
471 * If packet was truncated, return 0.
473 static const uint32_t *
474 parsefn(netdissect_options
*ndo
,
480 /* Bail if we don't have the string length */
483 /* Fetch big-endian string length */
484 len
= EXTRACT_BE_U_4(dp
);
487 ND_TCHECK_LEN(dp
, ((len
+ 3) & ~3));
489 cp
= (const u_char
*)dp
;
490 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
491 dp
+= ((len
+ 3) & ~3) / sizeof(*dp
);
493 if (fn_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
505 * Print out file handle and file name.
506 * Return pointer to 32-bit word past file name.
507 * If packet was truncated (or there was some other error), return 0.
509 static const uint32_t *
510 parsefhn(netdissect_options
*ndo
,
511 const uint32_t *dp
, int v3
)
513 dp
= parsefh(ndo
, dp
, v3
);
517 return (parsefn(ndo
, dp
));
521 nfsreq_noaddr_print(netdissect_options
*ndo
,
522 const u_char
*bp
, u_int length
,
525 const struct sunrpc_msg
*rp
;
530 uint32_t access_flags
;
531 struct nfsv3_sattr sa3
;
533 ND_PRINT("%u", length
);
534 nfserr
= 0; /* assume no error */
535 rp
= (const struct sunrpc_msg
*)bp
;
537 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
540 v3
= (EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
541 proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
543 if (!v3
&& proc
< NFS_NPROCS
)
544 proc
= nfsv3_procid
[proc
];
546 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
549 case NFSPROC_GETATTR
:
550 case NFSPROC_SETATTR
:
551 case NFSPROC_READLINK
:
554 case NFSPROC_PATHCONF
:
555 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
556 parsefh(ndo
, dp
, v3
) != NULL
)
565 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
566 parsefhn(ndo
, dp
, v3
) != NULL
)
571 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
572 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
574 access_flags
= EXTRACT_BE_U_4(dp
);
575 if (access_flags
& ~NFSV3ACCESS_FULL
) {
576 /* NFSV3ACCESS definitions aren't up to date */
577 ND_PRINT(" %04x", access_flags
);
578 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
579 ND_PRINT(" NFS_ACCESS_FULL");
581 char separator
= ' ';
582 if (access_flags
& NFSV3ACCESS_READ
) {
583 ND_PRINT(" NFS_ACCESS_READ");
586 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
587 ND_PRINT("%cNFS_ACCESS_LOOKUP", separator
);
590 if (access_flags
& NFSV3ACCESS_MODIFY
) {
591 ND_PRINT("%cNFS_ACCESS_MODIFY", separator
);
594 if (access_flags
& NFSV3ACCESS_EXTEND
) {
595 ND_PRINT("%cNFS_ACCESS_EXTEND", separator
);
598 if (access_flags
& NFSV3ACCESS_DELETE
) {
599 ND_PRINT("%cNFS_ACCESS_DELETE", separator
);
602 if (access_flags
& NFSV3ACCESS_EXECUTE
)
603 ND_PRINT("%cNFS_ACCESS_EXECUTE", separator
);
610 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
611 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
614 ND_PRINT(" %u bytes @ %" PRIu64
,
615 EXTRACT_BE_U_4(dp
+ 2),
619 ND_PRINT(" %u bytes @ %u",
620 EXTRACT_BE_U_4(dp
+ 1),
628 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
629 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
632 ND_PRINT(" %u (%u) bytes @ %" PRIu64
,
633 EXTRACT_BE_U_4(dp
+ 4),
634 EXTRACT_BE_U_4(dp
+ 2),
636 if (ndo
->ndo_vflag
) {
638 tok2str(nfsv3_writemodes
,
639 NULL
, EXTRACT_BE_U_4(dp
+ 3)));
643 ND_PRINT(" %u (%u) bytes @ %u (%u)",
644 EXTRACT_BE_U_4(dp
+ 3),
645 EXTRACT_BE_U_4(dp
+ 2),
646 EXTRACT_BE_U_4(dp
+ 1),
653 case NFSPROC_SYMLINK
:
654 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
655 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
657 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
659 if (parsefn(ndo
, dp
) == NULL
)
661 if (v3
&& ndo
->ndo_vflag
)
662 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
668 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
669 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
671 type
= (nfs_type
) EXTRACT_BE_U_4(dp
);
673 if ((dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
675 ND_PRINT(" %s", tok2str(type2str
, "unk-ft %u", type
));
676 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
680 EXTRACT_BE_U_4(dp
+ 1));
684 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
690 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
691 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
693 if (parsefhn(ndo
, dp
, v3
) != NULL
)
699 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
700 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
702 if (parsefhn(ndo
, dp
, v3
) != NULL
)
707 case NFSPROC_READDIR
:
708 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
709 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
713 * We shouldn't really try to interpret the
714 * offset cookie here.
716 ND_PRINT(" %u bytes @ %" PRId64
,
717 EXTRACT_BE_U_4(dp
+ 4),
719 if (ndo
->ndo_vflag
) {
721 * This displays the 8 bytes
722 * of the verifier in order,
723 * from the low-order byte
724 * to the high-order byte.
726 ND_PRINT(" verf %08x%08x",
727 EXTRACT_BE_U_4(dp
+ 2),
728 EXTRACT_BE_U_4(dp
+ 3));
733 * Print the offset as signed, since -1 is
734 * common, but offsets > 2^31 aren't.
736 ND_PRINT(" %u bytes @ %u",
737 EXTRACT_BE_U_4(dp
+ 1),
744 case NFSPROC_READDIRPLUS
:
745 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
746 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
749 * We don't try to interpret the offset
752 ND_PRINT(" %u bytes @ %" PRId64
,
753 EXTRACT_BE_U_4(dp
+ 4),
755 if (ndo
->ndo_vflag
) {
758 * This displays the 8 bytes
759 * of the verifier in order,
760 * from the low-order byte
761 * to the high-order byte.
763 ND_PRINT(" max %u verf %08x%08x",
764 EXTRACT_BE_U_4(dp
+ 5),
765 EXTRACT_BE_U_4(dp
+ 2),
766 EXTRACT_BE_U_4(dp
+ 3));
773 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
774 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
776 ND_PRINT(" %u bytes @ %" PRIu64
,
777 EXTRACT_BE_U_4(dp
+ 2),
789 ND_PRINT("%s", tstr
);
793 * Print out an NFS file handle.
794 * We assume packet was not truncated before the end of the
795 * file handle pointed to by dp.
797 * Note: new version (using portable file-handle parser) doesn't produce
798 * generation number. It probably could be made to do that, with some
799 * additional hacking on the parser code.
802 nfs_printfh(netdissect_options
*ndo
,
803 const uint32_t *dp
, const u_int len
)
807 const char *sfsname
= NULL
;
810 if (ndo
->ndo_uflag
) {
812 char const *sep
= "";
815 for (i
=0; i
<len
; i
++) {
817 * This displays 4 bytes in big-endian byte
818 * order. That's as good a choice as little-
819 * endian, as there's no guarantee that the
820 * server is big-endian or little-endian or
821 * that the file handle contains 4-byte
822 * integral fields, and is better than "the
823 * byte order of the host running tcpdump", as
824 * the latter means that different hosts
825 * running tcpdump may show the same file
826 * handle in different ways.
828 ND_PRINT("%s%x", sep
, EXTRACT_BE_U_4(dp
+ i
));
835 Parse_fh((const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
838 /* file system ID is ASCII, not numeric, for this server OS */
839 char temp
[NFSX_V3FHMAX
+1];
842 /* Make sure string is null-terminated */
844 if (stringlen
> NFSX_V3FHMAX
)
845 stringlen
= NFSX_V3FHMAX
;
846 strncpy(temp
, sfsname
, stringlen
);
847 temp
[stringlen
] = '\0';
848 /* Remove trailing spaces */
849 spacep
= strchr(temp
, ' ');
853 ND_PRINT(" fh %s/", temp
);
855 ND_PRINT(" fh %u,%u/",
856 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
);
859 if(fsid
.Fsid_dev
.Minor
== 257)
860 /* Print the undecoded handle */
861 ND_PRINT("%s", fsid
.Opaque_Handle
);
863 ND_PRINT("%ld", (long) ino
);
867 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
868 * us to match up replies with requests and thus to know how to parse
872 struct xid_map_entry
{
873 uint32_t xid
; /* transaction ID (net order) */
874 int ipver
; /* IP version (4 or 6) */
875 struct in6_addr client
; /* client IP address (net order) */
876 struct in6_addr server
; /* server IP address (net order) */
877 uint32_t proc
; /* call proc number (host order) */
878 uint32_t vers
; /* program version (host order) */
882 * Map entries are kept in an array that we manage as a ring;
883 * new entries are always added at the tail of the ring. Initially,
884 * all the entries are zero and hence don't match anything.
887 #define XIDMAPSIZE 64
889 static struct xid_map_entry xid_map
[XIDMAPSIZE
];
891 static int xid_map_next
= 0;
892 static int xid_map_hint
= 0;
895 xid_map_enter(netdissect_options
*ndo
,
896 const struct sunrpc_msg
*rp
, const u_char
*bp
)
898 const struct ip
*ip
= NULL
;
899 const struct ip6_hdr
*ip6
= NULL
;
900 struct xid_map_entry
*xmep
;
902 if (!ND_TTEST(rp
->rm_call
.cb_proc
))
904 switch (IP_V((const struct ip
*)bp
)) {
906 ip
= (const struct ip
*)bp
;
909 ip6
= (const struct ip6_hdr
*)bp
;
915 xmep
= &xid_map
[xid_map_next
];
917 if (++xid_map_next
>= XIDMAPSIZE
)
920 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
923 UNALIGNED_MEMCPY(&xmep
->client
, &ip
->ip_src
, sizeof(ip
->ip_src
));
924 UNALIGNED_MEMCPY(&xmep
->server
, &ip
->ip_dst
, sizeof(ip
->ip_dst
));
928 UNALIGNED_MEMCPY(&xmep
->client
, &ip6
->ip6_src
, sizeof(ip6
->ip6_src
));
929 UNALIGNED_MEMCPY(&xmep
->server
, &ip6
->ip6_dst
, sizeof(ip6
->ip6_dst
));
931 xmep
->proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
932 xmep
->vers
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
);
937 * Returns 0 and puts NFSPROC_xxx in proc return and
938 * version in vers return, or returns -1 on failure
941 xid_map_find(const struct sunrpc_msg
*rp
, const u_char
*bp
, uint32_t *proc
,
945 struct xid_map_entry
*xmep
;
947 const struct ip
*ip
= (const struct ip
*)bp
;
948 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
951 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
952 /* Start searching from where we last left off */
957 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
959 switch (xmep
->ipver
) {
961 if (UNALIGNED_MEMCMP(&ip
->ip_src
, &xmep
->server
,
962 sizeof(ip
->ip_src
)) != 0 ||
963 UNALIGNED_MEMCMP(&ip
->ip_dst
, &xmep
->client
,
964 sizeof(ip
->ip_dst
)) != 0) {
969 if (UNALIGNED_MEMCMP(&ip6
->ip6_src
, &xmep
->server
,
970 sizeof(ip6
->ip6_src
)) != 0 ||
971 UNALIGNED_MEMCMP(&ip6
->ip6_dst
, &xmep
->client
,
972 sizeof(ip6
->ip6_dst
)) != 0) {
988 if (++i
>= XIDMAPSIZE
)
990 } while (i
!= xid_map_hint
);
997 * Routines for parsing reply packets
1001 * Return a pointer to the beginning of the actual results.
1002 * If the packet was truncated, return 0.
1004 static const uint32_t *
1005 parserep(netdissect_options
*ndo
,
1006 const struct sunrpc_msg
*rp
, u_int length
)
1010 enum sunrpc_accept_stat astat
;
1014 * Here we find the address of the ar_verf credentials.
1015 * Originally, this calculation was
1016 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
1017 * On the wire, the rp_acpt field starts immediately after
1018 * the (32 bit) rp_stat field. However, rp_acpt (which is a
1019 * "struct accepted_reply") contains a "struct opaque_auth",
1020 * whose internal representation contains a pointer, so on a
1021 * 64-bit machine the compiler inserts 32 bits of padding
1022 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
1023 * the internal representation to parse the on-the-wire
1024 * representation. Instead, we skip past the rp_stat field,
1025 * which is an "enum" and so occupies one 32-bit word.
1027 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
1028 ND_TCHECK_4(dp
+ 1);
1029 len
= EXTRACT_BE_U_4(dp
+ 1);
1033 * skip past the ar_verf credentials.
1035 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1038 * now we can check the ar_stat field
1041 astat
= (enum sunrpc_accept_stat
) EXTRACT_BE_U_4(dp
);
1042 if (astat
!= SUNRPC_SUCCESS
) {
1043 ND_PRINT(" %s", tok2str(sunrpc_str
, "ar_stat %u", astat
));
1044 nfserr
= 1; /* suppress trunc string */
1047 /* successful return */
1048 ND_TCHECK_LEN(dp
, sizeof(astat
));
1049 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1054 static const uint32_t *
1055 parsestatus(netdissect_options
*ndo
,
1056 const uint32_t *dp
, u_int
*er
)
1062 errnum
= EXTRACT_BE_U_4(dp
);
1066 if (!ndo
->ndo_qflag
)
1067 ND_PRINT(" ERROR: %s",
1068 tok2str(status2str
, "unk %u", errnum
));
1076 static const uint32_t *
1077 parsefattr(netdissect_options
*ndo
,
1078 const uint32_t *dp
, int verbose
, int v3
)
1080 const struct nfs_fattr
*fap
;
1082 fap
= (const struct nfs_fattr
*)dp
;
1083 ND_TCHECK(fap
->fa_gid
);
1086 * XXX - UIDs and GIDs are unsigned in NFS and in
1087 * at least some UN*Xes, but we'll show them as
1088 * signed because -2 has traditionally been the
1089 * UID for "nobody", rather than 4294967294.
1091 ND_PRINT(" %s %o ids %d/%d",
1092 tok2str(type2str
, "unk-ft %u ",
1093 EXTRACT_BE_U_4(&fap
->fa_type
)),
1094 EXTRACT_BE_U_4(&fap
->fa_mode
),
1095 EXTRACT_BE_S_4(&fap
->fa_uid
),
1096 EXTRACT_BE_S_4(&fap
->fa_gid
));
1098 ND_TCHECK(fap
->fa3_size
);
1099 ND_PRINT(" sz %" PRIu64
,
1100 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_size
));
1102 ND_TCHECK(fap
->fa2_size
);
1103 ND_PRINT(" sz %u", EXTRACT_BE_U_4(&fap
->fa2_size
));
1106 /* print lots more stuff */
1109 ND_TCHECK(fap
->fa3_ctime
);
1110 ND_PRINT(" nlink %u rdev %u/%u",
1111 EXTRACT_BE_U_4(&fap
->fa_nlink
),
1112 EXTRACT_BE_U_4(&fap
->fa3_rdev
.specdata1
),
1113 EXTRACT_BE_U_4(&fap
->fa3_rdev
.specdata2
));
1114 ND_PRINT(" fsid %" PRIx64
,
1115 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_fsid
));
1116 ND_PRINT(" fileid %" PRIx64
,
1117 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_fileid
));
1118 ND_PRINT(" a/m/ctime %u.%06u",
1119 EXTRACT_BE_U_4(&fap
->fa3_atime
.nfsv3_sec
),
1120 EXTRACT_BE_U_4(&fap
->fa3_atime
.nfsv3_nsec
));
1121 ND_PRINT(" %u.%06u",
1122 EXTRACT_BE_U_4(&fap
->fa3_mtime
.nfsv3_sec
),
1123 EXTRACT_BE_U_4(&fap
->fa3_mtime
.nfsv3_nsec
));
1124 ND_PRINT(" %u.%06u",
1125 EXTRACT_BE_U_4(&fap
->fa3_ctime
.nfsv3_sec
),
1126 EXTRACT_BE_U_4(&fap
->fa3_ctime
.nfsv3_nsec
));
1128 ND_TCHECK(fap
->fa2_ctime
);
1129 ND_PRINT(" nlink %u rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1130 EXTRACT_BE_U_4(&fap
->fa_nlink
),
1131 EXTRACT_BE_U_4(&fap
->fa2_rdev
),
1132 EXTRACT_BE_U_4(&fap
->fa2_fsid
),
1133 EXTRACT_BE_U_4(&fap
->fa2_fileid
));
1134 ND_PRINT(" %u.%06u",
1135 EXTRACT_BE_U_4(&fap
->fa2_atime
.nfsv2_sec
),
1136 EXTRACT_BE_U_4(&fap
->fa2_atime
.nfsv2_usec
));
1137 ND_PRINT(" %u.%06u",
1138 EXTRACT_BE_U_4(&fap
->fa2_mtime
.nfsv2_sec
),
1139 EXTRACT_BE_U_4(&fap
->fa2_mtime
.nfsv2_usec
));
1140 ND_PRINT(" %u.%06u",
1141 EXTRACT_BE_U_4(&fap
->fa2_ctime
.nfsv2_sec
),
1142 EXTRACT_BE_U_4(&fap
->fa2_ctime
.nfsv2_usec
));
1145 return ((const uint32_t *)((const unsigned char *)dp
+
1146 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1152 parseattrstat(netdissect_options
*ndo
,
1153 const uint32_t *dp
, int verbose
, int v3
)
1157 dp
= parsestatus(ndo
, dp
, &er
);
1163 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1167 parsediropres(netdissect_options
*ndo
,
1172 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1177 dp
= parsefh(ndo
, dp
, 0);
1181 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1185 parselinkres(netdissect_options
*ndo
,
1186 const uint32_t *dp
, int v3
)
1190 dp
= parsestatus(ndo
, dp
, &er
);
1195 if (v3
&& !(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1198 return (parsefn(ndo
, dp
) != NULL
);
1202 parsestatfs(netdissect_options
*ndo
,
1203 const uint32_t *dp
, int v3
)
1205 const struct nfs_statfs
*sfsp
;
1208 dp
= parsestatus(ndo
, dp
, &er
);
1220 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1224 ND_TCHECK_LEN(dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1226 sfsp
= (const struct nfs_statfs
*)dp
;
1229 ND_PRINT(" tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1230 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_tbytes
),
1231 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_fbytes
),
1232 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_abytes
));
1233 if (ndo
->ndo_vflag
) {
1234 ND_PRINT(" tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1235 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_tfiles
),
1236 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_ffiles
),
1237 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_afiles
),
1238 EXTRACT_BE_U_4(&sfsp
->sf_invarsec
));
1241 ND_PRINT(" tsize %u bsize %u blocks %u bfree %u bavail %u",
1242 EXTRACT_BE_U_4(&sfsp
->sf_tsize
),
1243 EXTRACT_BE_U_4(&sfsp
->sf_bsize
),
1244 EXTRACT_BE_U_4(&sfsp
->sf_blocks
),
1245 EXTRACT_BE_U_4(&sfsp
->sf_bfree
),
1246 EXTRACT_BE_U_4(&sfsp
->sf_bavail
));
1255 parserddires(netdissect_options
*ndo
,
1260 dp
= parsestatus(ndo
, dp
, &er
);
1268 ND_TCHECK_4(dp
+ 2);
1269 ND_PRINT(" offset 0x%x size %u ",
1270 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1271 if (EXTRACT_BE_U_4(dp
+ 2) != 0)
1279 static const uint32_t *
1280 parse_wcc_attr(netdissect_options
*ndo
,
1283 /* Our caller has already checked this */
1284 ND_PRINT(" sz %" PRIu64
, EXTRACT_BE_U_8(dp
));
1285 ND_PRINT(" mtime %u.%06u ctime %u.%06u",
1286 EXTRACT_BE_U_4(dp
+ 2), EXTRACT_BE_U_4(dp
+ 3),
1287 EXTRACT_BE_U_4(dp
+ 4), EXTRACT_BE_U_4(dp
+ 5));
1292 * Pre operation attributes. Print only if vflag > 1.
1294 static const uint32_t *
1295 parse_pre_op_attr(netdissect_options
*ndo
,
1296 const uint32_t *dp
, int verbose
)
1299 if (!EXTRACT_BE_U_4(dp
))
1302 ND_TCHECK_LEN(dp
, 24);
1304 return parse_wcc_attr(ndo
, dp
);
1306 /* If not verbose enough, just skip over wcc_attr */
1314 * Post operation attributes are printed if vflag >= 1
1316 static const uint32_t *
1317 parse_post_op_attr(netdissect_options
*ndo
,
1318 const uint32_t *dp
, int verbose
)
1321 if (!EXTRACT_BE_U_4(dp
))
1325 return parsefattr(ndo
, dp
, verbose
, 1);
1327 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1332 static const uint32_t *
1333 parse_wcc_data(netdissect_options
*ndo
,
1334 const uint32_t *dp
, int verbose
)
1338 if (!(dp
= parse_pre_op_attr(ndo
, dp
, verbose
)))
1343 return parse_post_op_attr(ndo
, dp
, verbose
);
1346 static const uint32_t *
1347 parsecreateopres(netdissect_options
*ndo
,
1348 const uint32_t *dp
, int verbose
)
1352 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1355 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1358 if (!EXTRACT_BE_U_4(dp
))
1361 if (!(dp
= parsefh(ndo
, dp
, 1)))
1364 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1366 if (ndo
->ndo_vflag
> 1) {
1367 ND_PRINT(" dir attr:");
1368 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1378 parsewccres(netdissect_options
*ndo
,
1379 const uint32_t *dp
, int verbose
)
1383 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1385 return parse_wcc_data(ndo
, dp
, verbose
) != NULL
;
1388 static const uint32_t *
1389 parsev3rddirres(netdissect_options
*ndo
,
1390 const uint32_t *dp
, int verbose
)
1394 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1398 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1402 if (ndo
->ndo_vflag
) {
1403 ND_TCHECK_4(dp
+ 1);
1405 * This displays the 8 bytes of the verifier in order,
1406 * from the low-order byte to the high-order byte.
1408 ND_PRINT(" verf %08x%08x",
1409 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1418 parsefsinfo(netdissect_options
*ndo
,
1421 const struct nfsv3_fsinfo
*sfp
;
1424 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1428 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1433 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1434 ND_TCHECK_SIZE(sfp
);
1435 ND_PRINT(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1436 EXTRACT_BE_U_4(&sfp
->fs_rtmax
),
1437 EXTRACT_BE_U_4(&sfp
->fs_rtpref
),
1438 EXTRACT_BE_U_4(&sfp
->fs_wtmax
),
1439 EXTRACT_BE_U_4(&sfp
->fs_wtpref
),
1440 EXTRACT_BE_U_4(&sfp
->fs_dtpref
));
1441 if (ndo
->ndo_vflag
) {
1442 ND_PRINT(" rtmult %u wtmult %u maxfsz %" PRIu64
,
1443 EXTRACT_BE_U_4(&sfp
->fs_rtmult
),
1444 EXTRACT_BE_U_4(&sfp
->fs_wtmult
),
1445 EXTRACT_BE_U_8((const uint32_t *)&sfp
->fs_maxfilesize
));
1446 ND_PRINT(" delta %u.%06u ",
1447 EXTRACT_BE_U_4(&sfp
->fs_timedelta
.nfsv3_sec
),
1448 EXTRACT_BE_U_4(&sfp
->fs_timedelta
.nfsv3_nsec
));
1456 parsepathconf(netdissect_options
*ndo
,
1460 const struct nfsv3_pathconf
*spp
;
1462 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1466 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1471 spp
= (const struct nfsv3_pathconf
*)dp
;
1472 ND_TCHECK_SIZE(spp
);
1474 ND_PRINT(" linkmax %u namemax %u %s %s %s %s",
1475 EXTRACT_BE_U_4(&spp
->pc_linkmax
),
1476 EXTRACT_BE_U_4(&spp
->pc_namemax
),
1477 EXTRACT_BE_U_4(&spp
->pc_notrunc
) ? "notrunc" : "",
1478 EXTRACT_BE_U_4(&spp
->pc_chownrestricted
) ? "chownres" : "",
1479 EXTRACT_BE_U_4(&spp
->pc_caseinsensitive
) ? "igncase" : "",
1480 EXTRACT_BE_U_4(&spp
->pc_casepreserving
) ? "keepcase" : "");
1487 interp_reply(netdissect_options
*ndo
,
1488 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
, int length
)
1494 v3
= (vers
== NFS_VER3
);
1496 if (!v3
&& proc
< NFS_NPROCS
)
1497 proc
= nfsv3_procid
[proc
];
1499 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
1502 case NFSPROC_GETATTR
:
1503 dp
= parserep(ndo
, rp
, length
);
1504 if (dp
!= NULL
&& parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
) != 0)
1508 case NFSPROC_SETATTR
:
1509 if (!(dp
= parserep(ndo
, rp
, length
)))
1512 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1515 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0) != 0)
1520 case NFSPROC_LOOKUP
:
1521 if (!(dp
= parserep(ndo
, rp
, length
)))
1524 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1527 if (ndo
->ndo_vflag
> 1) {
1528 ND_PRINT(" post dattr:");
1529 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1532 if (!(dp
= parsefh(ndo
, dp
, v3
)))
1534 if ((dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)) &&
1535 ndo
->ndo_vflag
> 1) {
1536 ND_PRINT(" post dattr:");
1537 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1543 if (parsediropres(ndo
, dp
) != 0)
1548 case NFSPROC_ACCESS
:
1549 if (!(dp
= parserep(ndo
, rp
, length
)))
1551 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1555 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1559 ND_PRINT(" c %04x", EXTRACT_BE_U_4(dp
));
1563 case NFSPROC_READLINK
:
1564 dp
= parserep(ndo
, rp
, length
);
1565 if (dp
!= NULL
&& parselinkres(ndo
, dp
, v3
) != 0)
1570 if (!(dp
= parserep(ndo
, rp
, length
)))
1573 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1575 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1579 if (ndo
->ndo_vflag
) {
1580 ND_TCHECK_4(dp
+ 1);
1581 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1582 if (EXTRACT_BE_U_4(dp
+ 1))
1587 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0) != 0)
1593 if (!(dp
= parserep(ndo
, rp
, length
)))
1596 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1598 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1602 if (ndo
->ndo_vflag
) {
1604 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1605 if (ndo
->ndo_vflag
> 1) {
1606 ND_TCHECK_4(dp
+ 1);
1608 tok2str(nfsv3_writemodes
,
1609 NULL
, EXTRACT_BE_U_4(dp
+ 1)));
1614 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
) != 0)
1619 case NFSPROC_CREATE
:
1621 if (!(dp
= parserep(ndo
, rp
, length
)))
1624 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1627 if (parsediropres(ndo
, dp
) != 0)
1632 case NFSPROC_SYMLINK
:
1633 if (!(dp
= parserep(ndo
, rp
, length
)))
1636 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1639 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1645 if (!(dp
= parserep(ndo
, rp
, length
)))
1647 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1651 case NFSPROC_REMOVE
:
1653 if (!(dp
= parserep(ndo
, rp
, length
)))
1656 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1659 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1664 case NFSPROC_RENAME
:
1665 if (!(dp
= parserep(ndo
, rp
, length
)))
1668 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1670 if (ndo
->ndo_vflag
) {
1672 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1675 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1680 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1686 if (!(dp
= parserep(ndo
, rp
, length
)))
1689 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1691 if (ndo
->ndo_vflag
) {
1692 ND_PRINT(" file POST:");
1693 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1696 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1701 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1706 case NFSPROC_READDIR
:
1707 if (!(dp
= parserep(ndo
, rp
, length
)))
1710 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1713 if (parserddires(ndo
, dp
) != 0)
1718 case NFSPROC_READDIRPLUS
:
1719 if (!(dp
= parserep(ndo
, rp
, length
)))
1721 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1725 case NFSPROC_FSSTAT
:
1726 dp
= parserep(ndo
, rp
, length
);
1727 if (dp
!= NULL
&& parsestatfs(ndo
, dp
, v3
) != 0)
1731 case NFSPROC_FSINFO
:
1732 dp
= parserep(ndo
, rp
, length
);
1733 if (dp
!= NULL
&& parsefsinfo(ndo
, dp
) != 0)
1737 case NFSPROC_PATHCONF
:
1738 dp
= parserep(ndo
, rp
, length
);
1739 if (dp
!= NULL
&& parsepathconf(ndo
, dp
) != 0)
1743 case NFSPROC_COMMIT
:
1744 dp
= parserep(ndo
, rp
, length
);
1745 if (dp
!= NULL
&& parsewccres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1754 ND_PRINT("%s", tstr
);