]>
The Tcpdump Group git mirrors - tcpdump/blob - print-nfs.c
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"
34 #include "netdissect.h"
35 #include "addrtoname.h"
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(netdissect_options
*, const struct sunrpc_msg
*, const u_char
*, uint32_t *, uint32_t *);
50 static void interp_reply(netdissect_options
*, const struct sunrpc_msg
*, uint32_t, uint32_t, int);
51 static const uint32_t *parse_post_op_attr(netdissect_options
*, const uint32_t *, int);
54 * Mapping of old NFS Version 2 RPC numbers to generic numbers.
56 static uint32_t nfsv3_procid
[NFS_NPROCS
] = {
85 static const struct tok nfsproc_str
[] = {
86 { NFSPROC_NOOP
, "nop" },
87 { NFSPROC_NULL
, "null" },
88 { NFSPROC_GETATTR
, "getattr" },
89 { NFSPROC_SETATTR
, "setattr" },
90 { NFSPROC_LOOKUP
, "lookup" },
91 { NFSPROC_ACCESS
, "access" },
92 { NFSPROC_READLINK
, "readlink" },
93 { NFSPROC_READ
, "read" },
94 { NFSPROC_WRITE
, "write" },
95 { NFSPROC_CREATE
, "create" },
96 { NFSPROC_MKDIR
, "mkdir" },
97 { NFSPROC_SYMLINK
, "symlink" },
98 { NFSPROC_MKNOD
, "mknod" },
99 { NFSPROC_REMOVE
, "remove" },
100 { NFSPROC_RMDIR
, "rmdir" },
101 { NFSPROC_RENAME
, "rename" },
102 { NFSPROC_LINK
, "link" },
103 { NFSPROC_READDIR
, "readdir" },
104 { NFSPROC_READDIRPLUS
, "readdirplus" },
105 { NFSPROC_FSSTAT
, "fsstat" },
106 { NFSPROC_FSINFO
, "fsinfo" },
107 { NFSPROC_PATHCONF
, "pathconf" },
108 { NFSPROC_COMMIT
, "commit" },
113 * NFS V2 and V3 status values.
115 * Some of these come from the RFCs for NFS V2 and V3, with the message
116 * strings taken from the FreeBSD C library "errlst.c".
118 * Others are errors that are not in the RFC but that I suspect some
119 * NFS servers could return; the values are FreeBSD errno values, as
120 * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
121 * was primarily BSD-derived.
123 static const struct tok status2str
[] = {
124 { 1, "Operation not permitted" }, /* EPERM */
125 { 2, "No such file or directory" }, /* ENOENT */
126 { 5, "Input/output error" }, /* EIO */
127 { 6, "Device not configured" }, /* ENXIO */
128 { 11, "Resource deadlock avoided" }, /* EDEADLK */
129 { 12, "Cannot allocate memory" }, /* ENOMEM */
130 { 13, "Permission denied" }, /* EACCES */
131 { 17, "File exists" }, /* EEXIST */
132 { 18, "Cross-device link" }, /* EXDEV */
133 { 19, "Operation not supported by device" }, /* ENODEV */
134 { 20, "Not a directory" }, /* ENOTDIR */
135 { 21, "Is a directory" }, /* EISDIR */
136 { 22, "Invalid argument" }, /* EINVAL */
137 { 26, "Text file busy" }, /* ETXTBSY */
138 { 27, "File too large" }, /* EFBIG */
139 { 28, "No space left on device" }, /* ENOSPC */
140 { 30, "Read-only file system" }, /* EROFS */
141 { 31, "Too many links" }, /* EMLINK */
142 { 45, "Operation not supported" }, /* EOPNOTSUPP */
143 { 62, "Too many levels of symbolic links" }, /* ELOOP */
144 { 63, "File name too long" }, /* ENAMETOOLONG */
145 { 66, "Directory not empty" }, /* ENOTEMPTY */
146 { 69, "Disc quota exceeded" }, /* EDQUOT */
147 { 70, "Stale NFS file handle" }, /* ESTALE */
148 { 71, "Too many levels of remote in path" }, /* EREMOTE */
149 { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */
150 { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */
151 { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */
152 { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */
153 { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */
154 { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */
155 { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */
156 { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */
157 { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */
161 static const struct tok nfsv3_writemodes
[] = {
168 static const struct tok type2str
[] = {
179 static const struct tok sunrpc_auth_str
[] = {
180 { SUNRPC_AUTH_OK
, "OK" },
181 { SUNRPC_AUTH_BADCRED
, "Bogus Credentials (seal broken)" },
182 { SUNRPC_AUTH_REJECTEDCRED
, "Rejected Credentials (client should begin new session)" },
183 { SUNRPC_AUTH_BADVERF
, "Bogus Verifier (seal broken)" },
184 { SUNRPC_AUTH_REJECTEDVERF
, "Verifier expired or was replayed" },
185 { SUNRPC_AUTH_TOOWEAK
, "Credentials are too weak" },
186 { SUNRPC_AUTH_INVALIDRESP
, "Bogus response verifier" },
187 { SUNRPC_AUTH_FAILED
, "Unknown failure" },
191 static const struct tok sunrpc_str
[] = {
192 { SUNRPC_PROG_UNAVAIL
, "PROG_UNAVAIL" },
193 { SUNRPC_PROG_MISMATCH
, "PROG_MISMATCH" },
194 { SUNRPC_PROC_UNAVAIL
, "PROC_UNAVAIL" },
195 { SUNRPC_GARBAGE_ARGS
, "GARBAGE_ARGS" },
196 { SUNRPC_SYSTEM_ERR
, "SYSTEM_ERR" },
201 print_nfsaddr(netdissect_options
*ndo
,
202 const u_char
*bp
, const char *s
, const char *d
)
205 const struct ip6_hdr
*ip6
;
206 char srcaddr
[INET6_ADDRSTRLEN
], dstaddr
[INET6_ADDRSTRLEN
];
208 srcaddr
[0] = dstaddr
[0] = '\0';
209 switch (IP_V((const struct ip
*)bp
)) {
211 ip
= (const struct ip
*)bp
;
212 strlcpy(srcaddr
, ipaddr_string(ndo
, ip
->ip_src
), sizeof(srcaddr
));
213 strlcpy(dstaddr
, ipaddr_string(ndo
, ip
->ip_dst
), sizeof(dstaddr
));
216 ip6
= (const struct ip6_hdr
*)bp
;
217 strlcpy(srcaddr
, ip6addr_string(ndo
, ip6
->ip6_src
),
219 strlcpy(dstaddr
, ip6addr_string(ndo
, ip6
->ip6_dst
),
223 strlcpy(srcaddr
, "?", sizeof(srcaddr
));
224 strlcpy(dstaddr
, "?", sizeof(dstaddr
));
228 ND_PRINT("%s.%s > %s.%s: ", srcaddr
, s
, dstaddr
, d
);
232 * NFS Version 3 sattr3 structure for the new node creation case.
233 * This does not have a fixed layout on the network, so this
234 * structure does not correspond to the layout of the data on
235 * the network; it's used to store the data when the sattr3
236 * is parsed for use when it's later printed.
247 uint32_t sa_atimetype
;
252 uint32_t sa_mtimetype
;
259 static const uint32_t *
260 parse_sattr3(netdissect_options
*ndo
,
261 const uint32_t *dp
, struct nfsv3_sattr
*sa3
)
264 sa3
->sa_modeset
= GET_BE_U_4(dp
);
266 if (sa3
->sa_modeset
) {
268 sa3
->sa_mode
= GET_BE_U_4(dp
);
273 sa3
->sa_uidset
= GET_BE_U_4(dp
);
275 if (sa3
->sa_uidset
) {
277 sa3
->sa_uid
= GET_BE_U_4(dp
);
282 sa3
->sa_gidset
= GET_BE_U_4(dp
);
284 if (sa3
->sa_gidset
) {
286 sa3
->sa_gid
= GET_BE_U_4(dp
);
291 sa3
->sa_sizeset
= GET_BE_U_4(dp
);
293 if (sa3
->sa_sizeset
) {
295 sa3
->sa_size
= GET_BE_U_4(dp
);
300 sa3
->sa_atimetype
= GET_BE_U_4(dp
);
302 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
) {
304 sa3
->sa_atime
.nfsv3_sec
= GET_BE_U_4(dp
);
306 sa3
->sa_atime
.nfsv3_nsec
= GET_BE_U_4(dp
);
311 sa3
->sa_mtimetype
= GET_BE_U_4(dp
);
313 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
) {
315 sa3
->sa_mtime
.nfsv3_sec
= GET_BE_U_4(dp
);
317 sa3
->sa_mtime
.nfsv3_nsec
= GET_BE_U_4(dp
);
327 print_sattr3(netdissect_options
*ndo
,
328 const struct nfsv3_sattr
*sa3
, int verbose
)
331 ND_PRINT(" mode %o", sa3
->sa_mode
);
333 ND_PRINT(" uid %u", sa3
->sa_uid
);
335 ND_PRINT(" gid %u", sa3
->sa_gid
);
337 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
)
338 ND_PRINT(" atime %u.%06u", sa3
->sa_atime
.nfsv3_sec
,
339 sa3
->sa_atime
.nfsv3_nsec
);
340 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
)
341 ND_PRINT(" mtime %u.%06u", sa3
->sa_mtime
.nfsv3_sec
,
342 sa3
->sa_mtime
.nfsv3_nsec
);
347 nfsreply_print(netdissect_options
*ndo
,
348 const u_char
*bp
, u_int length
,
351 const struct sunrpc_msg
*rp
;
352 char srcid
[20], dstid
[20]; /*fits 32bit*/
354 ndo
->ndo_protocol
= "nfs";
355 rp
= (const struct sunrpc_msg
*)bp
;
357 ND_TCHECK_4(rp
->rm_xid
);
358 if (!ndo
->ndo_nflag
) {
359 strlcpy(srcid
, "nfs", sizeof(srcid
));
360 snprintf(dstid
, sizeof(dstid
), "%u",
361 GET_BE_U_4(rp
->rm_xid
));
363 snprintf(srcid
, sizeof(srcid
), "%u", NFS_PORT
);
364 snprintf(dstid
, sizeof(dstid
), "%u",
365 GET_BE_U_4(rp
->rm_xid
));
367 print_nfsaddr(ndo
, bp2
, srcid
, dstid
);
369 nfsreply_noaddr_print(ndo
, bp
, length
, bp2
);
377 nfsreply_noaddr_print(netdissect_options
*ndo
,
378 const u_char
*bp
, u_int length
,
381 const struct sunrpc_msg
*rp
;
382 uint32_t proc
, vers
, reply_stat
;
383 enum sunrpc_reject_stat rstat
;
386 enum sunrpc_auth_stat rwhy
;
388 ndo
->ndo_protocol
= "nfs";
389 rp
= (const struct sunrpc_msg
*)bp
;
391 ND_TCHECK_4(rp
->rm_reply
.rp_stat
);
392 reply_stat
= GET_BE_U_4(&rp
->rm_reply
.rp_stat
);
393 switch (reply_stat
) {
395 case SUNRPC_MSG_ACCEPTED
:
396 ND_PRINT("reply ok %u", length
);
397 if (xid_map_find(ndo
, rp
, bp2
, &proc
, &vers
) >= 0)
398 interp_reply(ndo
, rp
, proc
, vers
, length
);
401 case SUNRPC_MSG_DENIED
:
402 ND_PRINT("reply ERR %u: ", length
);
403 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_stat
);
404 rstat
= GET_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_stat
);
407 case SUNRPC_RPC_MISMATCH
:
408 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_vers
.high
);
409 rlow
= GET_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.low
);
410 rhigh
= GET_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.high
);
411 ND_PRINT("RPC Version mismatch (%u-%u)", rlow
, rhigh
);
414 case SUNRPC_AUTH_ERROR
:
415 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_why
);
416 rwhy
= GET_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_why
);
417 ND_PRINT("Auth %s", tok2str(sunrpc_auth_str
, "Invalid failure code %u", rwhy
));
421 ND_PRINT("Unknown reason for rejecting rpc message %u", (unsigned int)rstat
);
427 ND_PRINT("reply Unknown rpc response code=%u %u", reply_stat
, length
);
437 * Return a pointer to the first file handle in the packet.
438 * If the packet was truncated, return 0.
440 static const uint32_t *
441 parsereq(netdissect_options
*ndo
,
442 const struct sunrpc_msg
*rp
, u_int length
)
445 u_int len
, rounded_len
;
448 * Find the start of the req data (if we captured it).
449 * First, get the length of the credentials, and make sure
450 * we have all of the opaque part of the credentials.
452 dp
= (const uint32_t *)&rp
->rm_call
.cb_cred
;
453 if (length
< 2 * sizeof(*dp
))
456 len
= GET_BE_U_4(dp
+ 1);
457 rounded_len
= roundup2(len
, 4);
458 ND_TCHECK_LEN(dp
+ 2, rounded_len
);
459 if (2 * sizeof(*dp
) + rounded_len
<= length
) {
461 * We have all of the credentials. Skip past them; they
462 * consist of 4 bytes of flavor, 4 bytes of length,
463 * and len-rounded-up-to-a-multiple-of-4 bytes of
466 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
467 length
-= 2 * sizeof(*dp
) + rounded_len
;
470 * Now get the length of the verifier, and make sure
471 * we have all of the opaque part of the verifier.
473 if (length
< 2 * sizeof(*dp
))
476 len
= GET_BE_U_4(dp
+ 1);
477 rounded_len
= roundup2(len
, 4);
478 ND_TCHECK_LEN(dp
+ 2, rounded_len
);
479 if (2 * sizeof(*dp
) + rounded_len
< length
) {
481 * We have all of the verifier. Skip past it;
482 * it consists of 4 bytes of flavor, 4 bytes of
483 * length, and len-rounded-up-to-a-multiple-of-4
486 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
495 * Print out an NFS file handle and return a pointer to following word.
496 * If packet was truncated, return 0.
498 static const uint32_t *
499 parsefh(netdissect_options
*ndo
,
500 const uint32_t *dp
, int v3
)
506 len
= GET_BE_U_4(dp
) / 4;
511 if (ND_TTEST_LEN(dp
, len
* sizeof(*dp
))) {
512 nfs_printfh(ndo
, dp
, len
);
520 * Print out a file name and return pointer to 32-bit word past it.
521 * If packet was truncated, return 0.
523 static const uint32_t *
524 parsefn(netdissect_options
*ndo
,
530 /* Bail if we don't have the string length */
533 /* Fetch big-endian string length */
534 len
= GET_BE_U_4(dp
);
537 if (UINT_MAX
- len
< 3) {
538 ND_PRINT("[cannot pad to 32-bit boundaries]");
539 nd_print_invalid(ndo
);
543 ND_TCHECK_LEN(dp
, ((len
+ 3) & ~3));
545 cp
= (const u_char
*)dp
;
546 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
547 dp
+= ((len
+ 3) & ~3) / sizeof(*dp
);
549 if (nd_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
561 * Print out file handle and file name.
562 * Return pointer to 32-bit word past file name.
563 * If packet was truncated (or there was some other error), return 0.
565 static const uint32_t *
566 parsefhn(netdissect_options
*ndo
,
567 const uint32_t *dp
, int v3
)
569 dp
= parsefh(ndo
, dp
, v3
);
573 return (parsefn(ndo
, dp
));
577 nfsreq_noaddr_print(netdissect_options
*ndo
,
578 const u_char
*bp
, u_int length
,
581 const struct sunrpc_msg
*rp
;
586 uint32_t access_flags
;
587 struct nfsv3_sattr sa3
;
589 ndo
->ndo_protocol
= "nfs";
590 ND_PRINT("%u", length
);
591 rp
= (const struct sunrpc_msg
*)bp
;
593 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
596 v3
= (GET_BE_U_4(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
597 proc
= GET_BE_U_4(&rp
->rm_call
.cb_proc
);
599 if (!v3
&& proc
< NFS_NPROCS
)
600 proc
= nfsv3_procid
[proc
];
602 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
605 case NFSPROC_GETATTR
:
606 case NFSPROC_SETATTR
:
607 case NFSPROC_READLINK
:
610 case NFSPROC_PATHCONF
:
611 dp
= parsereq(ndo
, rp
, length
);
614 if (parsefh(ndo
, dp
, v3
) == NULL
)
623 dp
= parsereq(ndo
, rp
, length
);
626 if (parsefhn(ndo
, dp
, v3
) == NULL
)
631 dp
= parsereq(ndo
, rp
, length
);
634 dp
= parsefh(ndo
, dp
, v3
);
638 access_flags
= GET_BE_U_4(dp
);
639 if (access_flags
& ~NFSV3ACCESS_FULL
) {
640 /* NFSV3ACCESS definitions aren't up to date */
641 ND_PRINT(" %04x", access_flags
);
642 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
643 ND_PRINT(" NFS_ACCESS_FULL");
645 char separator
= ' ';
646 if (access_flags
& NFSV3ACCESS_READ
) {
647 ND_PRINT(" NFS_ACCESS_READ");
650 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
651 ND_PRINT("%cNFS_ACCESS_LOOKUP", separator
);
654 if (access_flags
& NFSV3ACCESS_MODIFY
) {
655 ND_PRINT("%cNFS_ACCESS_MODIFY", separator
);
658 if (access_flags
& NFSV3ACCESS_EXTEND
) {
659 ND_PRINT("%cNFS_ACCESS_EXTEND", separator
);
662 if (access_flags
& NFSV3ACCESS_DELETE
) {
663 ND_PRINT("%cNFS_ACCESS_DELETE", separator
);
666 if (access_flags
& NFSV3ACCESS_EXECUTE
)
667 ND_PRINT("%cNFS_ACCESS_EXECUTE", separator
);
672 dp
= parsereq(ndo
, rp
, length
);
675 dp
= parsefh(ndo
, dp
, v3
);
680 ND_PRINT(" %u bytes @ %" PRIu64
,
685 ND_PRINT(" %u bytes @ %u",
692 dp
= parsereq(ndo
, rp
, length
);
695 dp
= parsefh(ndo
, dp
, v3
);
700 ND_PRINT(" %u (%u) bytes @ %" PRIu64
,
704 if (ndo
->ndo_vflag
) {
706 tok2str(nfsv3_writemodes
,
707 NULL
, GET_BE_U_4(dp
+ 3)));
711 ND_PRINT(" %u (%u) bytes @ %u (%u)",
719 case NFSPROC_SYMLINK
:
720 dp
= parsereq(ndo
, rp
, length
);
723 dp
= parsefhn(ndo
, dp
, v3
);
727 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
729 if (parsefn(ndo
, dp
) == NULL
)
731 if (v3
&& ndo
->ndo_vflag
)
732 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
736 dp
= parsereq(ndo
, rp
, length
);
739 dp
= parsefhn(ndo
, dp
, v3
);
743 type
= (nfs_type
) GET_BE_U_4(dp
);
745 dp
= parse_sattr3(ndo
, dp
, &sa3
);
748 ND_PRINT(" %s", tok2str(type2str
, "unk-ft %u", type
));
749 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
757 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
761 dp
= parsereq(ndo
, rp
, length
);
764 dp
= parsefhn(ndo
, dp
, v3
);
768 if (parsefhn(ndo
, dp
, v3
) == NULL
)
773 dp
= parsereq(ndo
, rp
, length
);
776 dp
= parsefh(ndo
, dp
, v3
);
780 if (parsefhn(ndo
, dp
, v3
) == NULL
)
784 case NFSPROC_READDIR
:
785 dp
= parsereq(ndo
, rp
, length
);
788 dp
= parsefh(ndo
, dp
, v3
);
794 * We shouldn't really try to interpret the
795 * offset cookie here.
797 ND_PRINT(" %u bytes @ %" PRId64
,
800 if (ndo
->ndo_vflag
) {
802 * This displays the 8 bytes
803 * of the verifier in order,
804 * from the low-order byte
805 * to the high-order byte.
807 ND_PRINT(" verf %08x%08x",
814 * Print the offset as signed, since -1 is
815 * common, but offsets > 2^31 aren't.
817 ND_PRINT(" %u bytes @ %u",
823 case NFSPROC_READDIRPLUS
:
824 dp
= parsereq(ndo
, rp
, length
);
827 dp
= parsefh(ndo
, dp
, v3
);
832 * We don't try to interpret the offset
835 ND_PRINT(" %u bytes @ %" PRId64
,
838 if (ndo
->ndo_vflag
) {
841 * This displays the 8 bytes
842 * of the verifier in order,
843 * from the low-order byte
844 * to the high-order byte.
846 ND_PRINT(" max %u verf %08x%08x",
854 dp
= parsereq(ndo
, rp
, length
);
857 dp
= parsefh(ndo
, dp
, v3
);
861 ND_PRINT(" %u bytes @ %" PRIu64
,
876 * Print out an NFS file handle.
877 * We assume packet was not truncated before the end of the
878 * file handle pointed to by dp.
880 * Note: new version (using portable file-handle parser) doesn't produce
881 * generation number. It probably could be made to do that, with some
882 * additional hacking on the parser code.
885 nfs_printfh(netdissect_options
*ndo
,
886 const uint32_t *dp
, const u_int len
)
890 const char *sfsname
= NULL
;
893 if (ndo
->ndo_uflag
) {
895 char const *sep
= "";
898 for (i
=0; i
<len
; i
++) {
900 * This displays 4 bytes in big-endian byte
901 * order. That's as good a choice as little-
902 * endian, as there's no guarantee that the
903 * server is big-endian or little-endian or
904 * that the file handle contains 4-byte
905 * integral fields, and is better than "the
906 * byte order of the host running tcpdump", as
907 * the latter means that different hosts
908 * running tcpdump may show the same file
909 * handle in different ways.
911 ND_PRINT("%s%x", sep
, GET_BE_U_4(dp
+ i
));
918 Parse_fh(ndo
, (const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
921 /* file system ID is ASCII, not numeric, for this server OS */
922 char temp
[NFSX_V3FHMAX
+1];
925 /* Make sure string is null-terminated */
927 if (stringlen
> NFSX_V3FHMAX
)
928 stringlen
= NFSX_V3FHMAX
;
929 strncpy(temp
, sfsname
, stringlen
);
930 temp
[stringlen
] = '\0';
931 /* Remove trailing spaces */
932 spacep
= strchr(temp
, ' ');
936 ND_PRINT(" fh %s/", temp
);
938 ND_PRINT(" fh %u,%u/",
939 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
);
942 if(fsid
.Fsid_dev
.Minor
== 257)
943 /* Print the undecoded handle */
944 ND_PRINT("%s", fsid
.Opaque_Handle
);
946 ND_PRINT("%ld", (long) ino
);
950 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
951 * us to match up replies with requests and thus to know how to parse
955 struct xid_map_entry
{
956 uint32_t xid
; /* transaction ID (net order) */
957 int ipver
; /* IP version (4 or 6) */
958 nd_ipv6 client
; /* client IP address (net order) */
959 nd_ipv6 server
; /* server IP address (net order) */
960 uint32_t proc
; /* call proc number (host order) */
961 uint32_t vers
; /* program version (host order) */
965 * Map entries are kept in an array that we manage as a ring;
966 * new entries are always added at the tail of the ring. Initially,
967 * all the entries are zero and hence don't match anything.
970 #define XIDMAPSIZE 64
972 static struct xid_map_entry xid_map
[XIDMAPSIZE
];
974 static int xid_map_next
= 0;
975 static int xid_map_hint
= 0;
978 xid_map_enter(netdissect_options
*ndo
,
979 const struct sunrpc_msg
*rp
, const u_char
*bp
)
981 const struct ip
*ip
= NULL
;
982 const struct ip6_hdr
*ip6
= NULL
;
983 struct xid_map_entry
*xmep
;
985 if (!ND_TTEST_4(rp
->rm_call
.cb_proc
))
987 switch (IP_V((const struct ip
*)bp
)) {
989 ip
= (const struct ip
*)bp
;
992 ip6
= (const struct ip6_hdr
*)bp
;
998 xmep
= &xid_map
[xid_map_next
];
1000 if (++xid_map_next
>= XIDMAPSIZE
)
1003 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
1006 UNALIGNED_MEMCPY(&xmep
->client
, ip
->ip_src
,
1007 sizeof(ip
->ip_src
));
1008 UNALIGNED_MEMCPY(&xmep
->server
, ip
->ip_dst
,
1009 sizeof(ip
->ip_dst
));
1013 UNALIGNED_MEMCPY(&xmep
->client
, ip6
->ip6_src
,
1014 sizeof(ip6
->ip6_src
));
1015 UNALIGNED_MEMCPY(&xmep
->server
, ip6
->ip6_dst
,
1016 sizeof(ip6
->ip6_dst
));
1018 xmep
->proc
= GET_BE_U_4(&rp
->rm_call
.cb_proc
);
1019 xmep
->vers
= GET_BE_U_4(&rp
->rm_call
.cb_vers
);
1024 * Returns 0 and puts NFSPROC_xxx in proc return and
1025 * version in vers return, or returns -1 on failure
1028 xid_map_find(netdissect_options
*ndo
, const struct sunrpc_msg
*rp
,
1029 const u_char
*bp
, uint32_t *proc
, uint32_t *vers
)
1032 struct xid_map_entry
*xmep
;
1034 const struct ip
*ip
= (const struct ip
*)bp
;
1035 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
1038 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
1039 /* Start searching from where we last left off */
1044 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
1046 switch (xmep
->ipver
) {
1048 if (UNALIGNED_MEMCMP(ip
->ip_src
, &xmep
->server
,
1049 sizeof(ip
->ip_src
)) != 0 ||
1050 UNALIGNED_MEMCMP(ip
->ip_dst
, &xmep
->client
,
1051 sizeof(ip
->ip_dst
)) != 0) {
1056 if (UNALIGNED_MEMCMP(ip6
->ip6_src
, &xmep
->server
,
1057 sizeof(ip6
->ip6_src
)) != 0 ||
1058 UNALIGNED_MEMCMP(ip6
->ip6_dst
, &xmep
->client
,
1059 sizeof(ip6
->ip6_dst
)) != 0) {
1075 if (++i
>= XIDMAPSIZE
)
1077 } while (i
!= xid_map_hint
);
1084 * Routines for parsing reply packets
1088 * Return a pointer to the beginning of the actual results.
1089 * If the packet was truncated, return 0.
1091 static const uint32_t *
1092 parserep(netdissect_options
*ndo
,
1093 const struct sunrpc_msg
*rp
, u_int length
, int *nfserrp
)
1097 enum sunrpc_accept_stat astat
;
1101 * Here we find the address of the ar_verf credentials.
1102 * Originally, this calculation was
1103 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
1104 * On the wire, the rp_acpt field starts immediately after
1105 * the (32 bit) rp_stat field. However, rp_acpt (which is a
1106 * "struct accepted_reply") contains a "struct opaque_auth",
1107 * whose internal representation contains a pointer, so on a
1108 * 64-bit machine the compiler inserts 32 bits of padding
1109 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
1110 * the internal representation to parse the on-the-wire
1111 * representation. Instead, we skip past the rp_stat field,
1112 * which is an "enum" and so occupies one 32-bit word.
1114 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
1115 ND_TCHECK_4(dp
+ 1);
1116 len
= GET_BE_U_4(dp
+ 1);
1120 * skip past the ar_verf credentials.
1122 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1125 * now we can check the ar_stat field
1128 astat
= (enum sunrpc_accept_stat
) GET_BE_U_4(dp
);
1129 if (astat
!= SUNRPC_SUCCESS
) {
1130 ND_PRINT(" %s", tok2str(sunrpc_str
, "ar_stat %u", astat
));
1131 *nfserrp
= 1; /* suppress trunc string */
1134 /* successful return */
1135 ND_TCHECK_LEN(dp
, sizeof(astat
));
1136 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1141 static const uint32_t *
1142 parsestatus(netdissect_options
*ndo
,
1143 const uint32_t *dp
, u_int
*er
, int *nfserrp
)
1149 errnum
= GET_BE_U_4(dp
);
1153 if (!ndo
->ndo_qflag
)
1154 ND_PRINT(" ERROR: %s",
1155 tok2str(status2str
, "unk %u", errnum
));
1163 static const uint32_t *
1164 parsefattr(netdissect_options
*ndo
,
1165 const uint32_t *dp
, int verbose
, int v3
)
1167 const struct nfs_fattr
*fap
;
1169 fap
= (const struct nfs_fattr
*)dp
;
1170 ND_TCHECK_4(fap
->fa_gid
);
1173 * XXX - UIDs and GIDs are unsigned in NFS and in
1174 * at least some UN*Xes, but we'll show them as
1175 * signed because -2 has traditionally been the
1176 * UID for "nobody", rather than 4294967294.
1178 ND_PRINT(" %s %o ids %d/%d",
1179 tok2str(type2str
, "unk-ft %u ",
1180 GET_BE_U_4(fap
->fa_type
)),
1181 GET_BE_U_4(fap
->fa_mode
),
1182 GET_BE_S_4(fap
->fa_uid
),
1183 GET_BE_S_4(fap
->fa_gid
));
1185 ND_TCHECK_8(fap
->fa3_size
);
1186 ND_PRINT(" sz %" PRIu64
,
1187 GET_BE_U_8(fap
->fa3_size
));
1189 ND_TCHECK_4(fap
->fa2_size
);
1190 ND_PRINT(" sz %u", GET_BE_U_4(fap
->fa2_size
));
1193 /* print lots more stuff */
1196 ND_TCHECK_8(&fap
->fa3_ctime
);
1197 ND_PRINT(" nlink %u rdev %u/%u",
1198 GET_BE_U_4(fap
->fa_nlink
),
1199 GET_BE_U_4(fap
->fa3_rdev
.specdata1
),
1200 GET_BE_U_4(fap
->fa3_rdev
.specdata2
));
1201 ND_PRINT(" fsid %" PRIx64
,
1202 GET_BE_U_8(fap
->fa3_fsid
));
1203 ND_PRINT(" fileid %" PRIx64
,
1204 GET_BE_U_8(fap
->fa3_fileid
));
1205 ND_PRINT(" a/m/ctime %u.%06u",
1206 GET_BE_U_4(fap
->fa3_atime
.nfsv3_sec
),
1207 GET_BE_U_4(fap
->fa3_atime
.nfsv3_nsec
));
1208 ND_PRINT(" %u.%06u",
1209 GET_BE_U_4(fap
->fa3_mtime
.nfsv3_sec
),
1210 GET_BE_U_4(fap
->fa3_mtime
.nfsv3_nsec
));
1211 ND_PRINT(" %u.%06u",
1212 GET_BE_U_4(fap
->fa3_ctime
.nfsv3_sec
),
1213 GET_BE_U_4(fap
->fa3_ctime
.nfsv3_nsec
));
1215 ND_TCHECK_8(&fap
->fa2_ctime
);
1216 ND_PRINT(" nlink %u rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1217 GET_BE_U_4(fap
->fa_nlink
),
1218 GET_BE_U_4(fap
->fa2_rdev
),
1219 GET_BE_U_4(fap
->fa2_fsid
),
1220 GET_BE_U_4(fap
->fa2_fileid
));
1221 ND_PRINT(" %u.%06u",
1222 GET_BE_U_4(fap
->fa2_atime
.nfsv2_sec
),
1223 GET_BE_U_4(fap
->fa2_atime
.nfsv2_usec
));
1224 ND_PRINT(" %u.%06u",
1225 GET_BE_U_4(fap
->fa2_mtime
.nfsv2_sec
),
1226 GET_BE_U_4(fap
->fa2_mtime
.nfsv2_usec
));
1227 ND_PRINT(" %u.%06u",
1228 GET_BE_U_4(fap
->fa2_ctime
.nfsv2_sec
),
1229 GET_BE_U_4(fap
->fa2_ctime
.nfsv2_usec
));
1232 return ((const uint32_t *)((const unsigned char *)dp
+
1233 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1239 parseattrstat(netdissect_options
*ndo
,
1240 const uint32_t *dp
, int verbose
, int v3
, int *nfserrp
)
1244 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1250 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1254 parsediropres(netdissect_options
*ndo
,
1255 const uint32_t *dp
, int *nfserrp
)
1259 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1265 dp
= parsefh(ndo
, dp
, 0);
1269 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1273 parselinkres(netdissect_options
*ndo
,
1274 const uint32_t *dp
, int v3
, int *nfserrp
)
1278 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1284 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1289 return (parsefn(ndo
, dp
) != NULL
);
1293 parsestatfs(netdissect_options
*ndo
,
1294 const uint32_t *dp
, int v3
, int *nfserrp
)
1296 const struct nfs_statfs
*sfsp
;
1299 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1311 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1316 ND_TCHECK_LEN(dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1318 sfsp
= (const struct nfs_statfs
*)dp
;
1321 ND_PRINT(" tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1322 GET_BE_U_8(sfsp
->sf_tbytes
),
1323 GET_BE_U_8(sfsp
->sf_fbytes
),
1324 GET_BE_U_8(sfsp
->sf_abytes
));
1325 if (ndo
->ndo_vflag
) {
1326 ND_PRINT(" tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1327 GET_BE_U_8(sfsp
->sf_tfiles
),
1328 GET_BE_U_8(sfsp
->sf_ffiles
),
1329 GET_BE_U_8(sfsp
->sf_afiles
),
1330 GET_BE_U_4(sfsp
->sf_invarsec
));
1333 ND_PRINT(" tsize %u bsize %u blocks %u bfree %u bavail %u",
1334 GET_BE_U_4(sfsp
->sf_tsize
),
1335 GET_BE_U_4(sfsp
->sf_bsize
),
1336 GET_BE_U_4(sfsp
->sf_blocks
),
1337 GET_BE_U_4(sfsp
->sf_bfree
),
1338 GET_BE_U_4(sfsp
->sf_bavail
));
1347 parserddires(netdissect_options
*ndo
,
1348 const uint32_t *dp
, int *nfserrp
)
1352 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1360 ND_TCHECK_4(dp
+ 2);
1361 ND_PRINT(" offset 0x%x size %u ",
1362 GET_BE_U_4(dp
), GET_BE_U_4(dp
+ 1));
1363 if (GET_BE_U_4(dp
+ 2) != 0)
1371 static const uint32_t *
1372 parse_wcc_attr(netdissect_options
*ndo
,
1375 /* Our caller has already checked this */
1376 ND_PRINT(" sz %" PRIu64
, GET_BE_U_8(dp
));
1377 ND_PRINT(" mtime %u.%06u ctime %u.%06u",
1378 GET_BE_U_4(dp
+ 2), GET_BE_U_4(dp
+ 3),
1379 GET_BE_U_4(dp
+ 4), GET_BE_U_4(dp
+ 5));
1384 * Pre operation attributes. Print only if vflag > 1.
1386 static const uint32_t *
1387 parse_pre_op_attr(netdissect_options
*ndo
,
1388 const uint32_t *dp
, int verbose
)
1391 if (!GET_BE_U_4(dp
))
1394 ND_TCHECK_LEN(dp
, 24);
1396 return parse_wcc_attr(ndo
, dp
);
1398 /* If not verbose enough, just skip over wcc_attr */
1406 * Post operation attributes are printed if vflag >= 1
1408 static const uint32_t *
1409 parse_post_op_attr(netdissect_options
*ndo
,
1410 const uint32_t *dp
, int verbose
)
1413 if (!GET_BE_U_4(dp
))
1417 return parsefattr(ndo
, dp
, verbose
, 1);
1419 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1424 static const uint32_t *
1425 parse_wcc_data(netdissect_options
*ndo
,
1426 const uint32_t *dp
, int verbose
)
1430 dp
= parse_pre_op_attr(ndo
, dp
, verbose
);
1436 return parse_post_op_attr(ndo
, dp
, verbose
);
1439 static const uint32_t *
1440 parsecreateopres(netdissect_options
*ndo
,
1441 const uint32_t *dp
, int verbose
, int *nfserrp
)
1445 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1449 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1452 if (!GET_BE_U_4(dp
))
1455 dp
= parsefh(ndo
, dp
, 1);
1459 dp
= parse_post_op_attr(ndo
, dp
, verbose
);
1462 if (ndo
->ndo_vflag
> 1) {
1463 ND_PRINT(" dir attr:");
1464 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1473 static const uint32_t *
1474 parsewccres(netdissect_options
*ndo
,
1475 const uint32_t *dp
, int verbose
, int *nfserrp
)
1479 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1482 return parse_wcc_data(ndo
, dp
, verbose
);
1485 static const uint32_t *
1486 parsev3rddirres(netdissect_options
*ndo
,
1487 const uint32_t *dp
, int verbose
, int *nfserrp
)
1491 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1496 dp
= parse_post_op_attr(ndo
, dp
, verbose
);
1501 if (ndo
->ndo_vflag
) {
1502 ND_TCHECK_4(dp
+ 1);
1504 * This displays the 8 bytes of the verifier in order,
1505 * from the low-order byte to the high-order byte.
1507 ND_PRINT(" verf %08x%08x",
1508 GET_BE_U_4(dp
), GET_BE_U_4(dp
+ 1));
1517 parsefsinfo(netdissect_options
*ndo
,
1518 const uint32_t *dp
, int *nfserrp
)
1520 const struct nfsv3_fsinfo
*sfp
;
1523 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1528 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1534 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1535 ND_TCHECK_SIZE(sfp
);
1536 ND_PRINT(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1537 GET_BE_U_4(sfp
->fs_rtmax
),
1538 GET_BE_U_4(sfp
->fs_rtpref
),
1539 GET_BE_U_4(sfp
->fs_wtmax
),
1540 GET_BE_U_4(sfp
->fs_wtpref
),
1541 GET_BE_U_4(sfp
->fs_dtpref
));
1542 if (ndo
->ndo_vflag
) {
1543 ND_PRINT(" rtmult %u wtmult %u maxfsz %" PRIu64
,
1544 GET_BE_U_4(sfp
->fs_rtmult
),
1545 GET_BE_U_4(sfp
->fs_wtmult
),
1546 GET_BE_U_8(sfp
->fs_maxfilesize
));
1547 ND_PRINT(" delta %u.%06u ",
1548 GET_BE_U_4(sfp
->fs_timedelta
.nfsv3_sec
),
1549 GET_BE_U_4(sfp
->fs_timedelta
.nfsv3_nsec
));
1557 parsepathconf(netdissect_options
*ndo
,
1558 const uint32_t *dp
, int *nfserrp
)
1561 const struct nfsv3_pathconf
*spp
;
1563 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1568 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1574 spp
= (const struct nfsv3_pathconf
*)dp
;
1575 ND_TCHECK_SIZE(spp
);
1577 ND_PRINT(" linkmax %u namemax %u %s %s %s %s",
1578 GET_BE_U_4(spp
->pc_linkmax
),
1579 GET_BE_U_4(spp
->pc_namemax
),
1580 GET_BE_U_4(spp
->pc_notrunc
) ? "notrunc" : "",
1581 GET_BE_U_4(spp
->pc_chownrestricted
) ? "chownres" : "",
1582 GET_BE_U_4(spp
->pc_caseinsensitive
) ? "igncase" : "",
1583 GET_BE_U_4(spp
->pc_casepreserving
) ? "keepcase" : "");
1590 interp_reply(netdissect_options
*ndo
,
1591 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
,
1599 v3
= (vers
== NFS_VER3
);
1601 if (!v3
&& proc
< NFS_NPROCS
)
1602 proc
= nfsv3_procid
[proc
];
1604 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
1607 case NFSPROC_GETATTR
:
1608 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1611 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
, &nfserr
) == 0)
1615 case NFSPROC_SETATTR
:
1616 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1620 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == 0)
1623 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0, &nfserr
) == 0)
1628 case NFSPROC_LOOKUP
:
1629 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1633 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1637 if (ndo
->ndo_vflag
> 1) {
1638 ND_PRINT(" post dattr:");
1639 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1644 dp
= parsefh(ndo
, dp
, v3
);
1647 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1650 if (ndo
->ndo_vflag
> 1) {
1651 ND_PRINT(" post dattr:");
1652 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1658 if (parsediropres(ndo
, dp
, &nfserr
) == 0)
1663 case NFSPROC_ACCESS
:
1664 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1667 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1672 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1677 ND_PRINT(" c %04x", GET_BE_U_4(dp
));
1681 case NFSPROC_READLINK
:
1682 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1685 if (parselinkres(ndo
, dp
, v3
, &nfserr
) == 0)
1690 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1694 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1697 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1701 if (ndo
->ndo_vflag
) {
1702 ND_TCHECK_4(dp
+ 1);
1703 ND_PRINT(" %u bytes", GET_BE_U_4(dp
));
1704 if (GET_BE_U_4(dp
+ 1))
1709 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0, &nfserr
) == 0)
1715 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1719 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1722 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1726 if (ndo
->ndo_vflag
) {
1728 ND_PRINT(" %u bytes", GET_BE_U_4(dp
));
1729 if (ndo
->ndo_vflag
> 1) {
1730 ND_TCHECK_4(dp
+ 1);
1732 tok2str(nfsv3_writemodes
,
1733 NULL
, GET_BE_U_4(dp
+ 1)));
1735 /* write-verf-cookie */
1736 ND_TCHECK_8(dp
+ 2);
1737 ND_PRINT(" verf %" PRIx64
,
1738 GET_BE_U_8(dp
+ 2));
1744 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
, &nfserr
) == 0)
1749 case NFSPROC_CREATE
:
1751 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1755 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1758 if (parsediropres(ndo
, dp
, &nfserr
) == 0)
1763 case NFSPROC_SYMLINK
:
1764 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1768 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1771 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1777 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1780 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1784 case NFSPROC_REMOVE
:
1786 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1790 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1793 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1798 case NFSPROC_RENAME
:
1799 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1803 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1806 if (ndo
->ndo_vflag
) {
1808 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1812 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1817 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1823 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1827 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1830 if (ndo
->ndo_vflag
) {
1831 ND_PRINT(" file POST:");
1832 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1836 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1842 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1847 case NFSPROC_READDIR
:
1848 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1852 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1855 if (parserddires(ndo
, dp
, &nfserr
) == 0)
1860 case NFSPROC_READDIRPLUS
:
1861 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1864 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1868 case NFSPROC_FSSTAT
:
1869 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1872 if (parsestatfs(ndo
, dp
, v3
, &nfserr
) == 0)
1876 case NFSPROC_FSINFO
:
1877 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1880 if (parsefsinfo(ndo
, dp
, &nfserr
) == 0)
1884 case NFSPROC_PATHCONF
:
1885 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1888 if (parsepathconf(ndo
, dp
, &nfserr
) == 0)
1892 case NFSPROC_COMMIT
:
1893 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1896 dp
= parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
);
1899 if (ndo
->ndo_vflag
> 1) {
1900 /* write-verf-cookie */
1902 ND_PRINT(" verf %" PRIx64
, GET_BE_U_8(dp
));
1913 nd_print_trunc(ndo
);