]>
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
, GET_IPADDR_STRING(ip
->ip_src
), sizeof(srcaddr
));
213 strlcpy(dstaddr
, GET_IPADDR_STRING(ip
->ip_dst
), sizeof(dstaddr
));
216 ip6
= (const struct ip6_hdr
*)bp
;
217 strlcpy(srcaddr
, GET_IP6ADDR_STRING(ip6
->ip6_src
),
219 strlcpy(dstaddr
, GET_IP6ADDR_STRING(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
,
527 uint32_t len
, rounded_len
;
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 rounded_len
= roundup2(len
, 4);
544 ND_TCHECK_LEN(dp
, rounded_len
);
546 cp
= (const u_char
*)dp
;
547 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
548 dp
+= rounded_len
/ sizeof(*dp
);
550 if (nd_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
562 * Print out file handle and file name.
563 * Return pointer to 32-bit word past file name.
564 * If packet was truncated (or there was some other error), return 0.
566 static const uint32_t *
567 parsefhn(netdissect_options
*ndo
,
568 const uint32_t *dp
, int v3
)
570 dp
= parsefh(ndo
, dp
, v3
);
574 return (parsefn(ndo
, dp
));
578 nfsreq_noaddr_print(netdissect_options
*ndo
,
579 const u_char
*bp
, u_int length
,
582 const struct sunrpc_msg
*rp
;
587 uint32_t access_flags
;
588 struct nfsv3_sattr sa3
;
590 ndo
->ndo_protocol
= "nfs";
591 ND_PRINT("%u", length
);
592 rp
= (const struct sunrpc_msg
*)bp
;
594 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
597 v3
= (GET_BE_U_4(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
598 proc
= GET_BE_U_4(&rp
->rm_call
.cb_proc
);
600 if (!v3
&& proc
< NFS_NPROCS
)
601 proc
= nfsv3_procid
[proc
];
603 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
606 case NFSPROC_GETATTR
:
607 case NFSPROC_SETATTR
:
608 case NFSPROC_READLINK
:
611 case NFSPROC_PATHCONF
:
612 dp
= parsereq(ndo
, rp
, length
);
615 if (parsefh(ndo
, dp
, v3
) == NULL
)
624 dp
= parsereq(ndo
, rp
, length
);
627 if (parsefhn(ndo
, dp
, v3
) == NULL
)
632 dp
= parsereq(ndo
, rp
, length
);
635 dp
= parsefh(ndo
, dp
, v3
);
639 access_flags
= GET_BE_U_4(dp
);
640 if (access_flags
& ~NFSV3ACCESS_FULL
) {
641 /* NFSV3ACCESS definitions aren't up to date */
642 ND_PRINT(" %04x", access_flags
);
643 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
644 ND_PRINT(" NFS_ACCESS_FULL");
646 char separator
= ' ';
647 if (access_flags
& NFSV3ACCESS_READ
) {
648 ND_PRINT(" NFS_ACCESS_READ");
651 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
652 ND_PRINT("%cNFS_ACCESS_LOOKUP", separator
);
655 if (access_flags
& NFSV3ACCESS_MODIFY
) {
656 ND_PRINT("%cNFS_ACCESS_MODIFY", separator
);
659 if (access_flags
& NFSV3ACCESS_EXTEND
) {
660 ND_PRINT("%cNFS_ACCESS_EXTEND", separator
);
663 if (access_flags
& NFSV3ACCESS_DELETE
) {
664 ND_PRINT("%cNFS_ACCESS_DELETE", separator
);
667 if (access_flags
& NFSV3ACCESS_EXECUTE
)
668 ND_PRINT("%cNFS_ACCESS_EXECUTE", separator
);
673 dp
= parsereq(ndo
, rp
, length
);
676 dp
= parsefh(ndo
, dp
, v3
);
681 ND_PRINT(" %u bytes @ %" PRIu64
,
686 ND_PRINT(" %u bytes @ %u",
693 dp
= parsereq(ndo
, rp
, length
);
696 dp
= parsefh(ndo
, dp
, v3
);
701 ND_PRINT(" %u (%u) bytes @ %" PRIu64
,
705 if (ndo
->ndo_vflag
) {
707 tok2str(nfsv3_writemodes
,
708 NULL
, GET_BE_U_4(dp
+ 3)));
712 ND_PRINT(" %u (%u) bytes @ %u (%u)",
720 case NFSPROC_SYMLINK
:
721 dp
= parsereq(ndo
, rp
, length
);
724 dp
= parsefhn(ndo
, dp
, v3
);
728 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
730 if (parsefn(ndo
, dp
) == NULL
)
732 if (v3
&& ndo
->ndo_vflag
)
733 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
737 dp
= parsereq(ndo
, rp
, length
);
740 dp
= parsefhn(ndo
, dp
, v3
);
744 type
= (nfs_type
) GET_BE_U_4(dp
);
746 dp
= parse_sattr3(ndo
, dp
, &sa3
);
749 ND_PRINT(" %s", tok2str(type2str
, "unk-ft %u", type
));
750 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
758 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
762 dp
= parsereq(ndo
, rp
, length
);
765 dp
= parsefhn(ndo
, dp
, v3
);
769 if (parsefhn(ndo
, dp
, v3
) == NULL
)
774 dp
= parsereq(ndo
, rp
, length
);
777 dp
= parsefh(ndo
, dp
, v3
);
781 if (parsefhn(ndo
, dp
, v3
) == NULL
)
785 case NFSPROC_READDIR
:
786 dp
= parsereq(ndo
, rp
, length
);
789 dp
= parsefh(ndo
, dp
, v3
);
795 * We shouldn't really try to interpret the
796 * offset cookie here.
798 ND_PRINT(" %u bytes @ %" PRId64
,
801 if (ndo
->ndo_vflag
) {
803 * This displays the 8 bytes
804 * of the verifier in order,
805 * from the low-order byte
806 * to the high-order byte.
808 ND_PRINT(" verf %08x%08x",
815 * Print the offset as signed, since -1 is
816 * common, but offsets > 2^31 aren't.
818 ND_PRINT(" %u bytes @ %u",
824 case NFSPROC_READDIRPLUS
:
825 dp
= parsereq(ndo
, rp
, length
);
828 dp
= parsefh(ndo
, dp
, v3
);
833 * We don't try to interpret the offset
836 ND_PRINT(" %u bytes @ %" PRId64
,
839 if (ndo
->ndo_vflag
) {
842 * This displays the 8 bytes
843 * of the verifier in order,
844 * from the low-order byte
845 * to the high-order byte.
847 ND_PRINT(" max %u verf %08x%08x",
855 dp
= parsereq(ndo
, rp
, length
);
858 dp
= parsefh(ndo
, dp
, v3
);
862 ND_PRINT(" %u bytes @ %" PRIu64
,
877 * Print out an NFS file handle.
878 * We assume packet was not truncated before the end of the
879 * file handle pointed to by dp.
881 * Note: new version (using portable file-handle parser) doesn't produce
882 * generation number. It probably could be made to do that, with some
883 * additional hacking on the parser code.
886 nfs_printfh(netdissect_options
*ndo
,
887 const uint32_t *dp
, const u_int len
)
891 const char *sfsname
= NULL
;
894 if (ndo
->ndo_uflag
) {
896 char const *sep
= "";
899 for (i
=0; i
<len
; i
++) {
901 * This displays 4 bytes in big-endian byte
902 * order. That's as good a choice as little-
903 * endian, as there's no guarantee that the
904 * server is big-endian or little-endian or
905 * that the file handle contains 4-byte
906 * integral fields, and is better than "the
907 * byte order of the host running tcpdump", as
908 * the latter means that different hosts
909 * running tcpdump may show the same file
910 * handle in different ways.
912 ND_PRINT("%s%x", sep
, GET_BE_U_4(dp
+ i
));
919 Parse_fh(ndo
, (const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
922 /* file system ID is ASCII, not numeric, for this server OS */
923 char temp
[NFSX_V3FHMAX
+1];
926 /* Make sure string is null-terminated */
928 if (stringlen
> NFSX_V3FHMAX
)
929 stringlen
= NFSX_V3FHMAX
;
930 strncpy(temp
, sfsname
, stringlen
);
931 temp
[stringlen
] = '\0';
932 /* Remove trailing spaces */
933 spacep
= strchr(temp
, ' ');
937 ND_PRINT(" fh %s/", temp
);
939 ND_PRINT(" fh %u,%u/",
940 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
);
943 if(fsid
.Fsid_dev
.Minor
== 257)
944 /* Print the undecoded handle */
945 ND_PRINT("%s", fsid
.Opaque_Handle
);
947 ND_PRINT("%ld", (long) ino
);
951 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
952 * us to match up replies with requests and thus to know how to parse
956 struct xid_map_entry
{
957 uint32_t xid
; /* transaction ID (net order) */
958 int ipver
; /* IP version (4 or 6) */
959 nd_ipv6 client
; /* client IP address (net order) */
960 nd_ipv6 server
; /* server IP address (net order) */
961 uint32_t proc
; /* call proc number (host order) */
962 uint32_t vers
; /* program version (host order) */
966 * Map entries are kept in an array that we manage as a ring;
967 * new entries are always added at the tail of the ring. Initially,
968 * all the entries are zero and hence don't match anything.
971 #define XIDMAPSIZE 64
973 static struct xid_map_entry xid_map
[XIDMAPSIZE
];
975 static int xid_map_next
= 0;
976 static int xid_map_hint
= 0;
979 xid_map_enter(netdissect_options
*ndo
,
980 const struct sunrpc_msg
*rp
, const u_char
*bp
)
982 const struct ip
*ip
= NULL
;
983 const struct ip6_hdr
*ip6
= NULL
;
984 struct xid_map_entry
*xmep
;
986 if (!ND_TTEST_4(rp
->rm_call
.cb_proc
))
988 switch (IP_V((const struct ip
*)bp
)) {
990 ip
= (const struct ip
*)bp
;
993 ip6
= (const struct ip6_hdr
*)bp
;
999 xmep
= &xid_map
[xid_map_next
];
1001 if (++xid_map_next
>= XIDMAPSIZE
)
1004 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
1007 UNALIGNED_MEMCPY(&xmep
->client
, ip
->ip_src
,
1008 sizeof(ip
->ip_src
));
1009 UNALIGNED_MEMCPY(&xmep
->server
, ip
->ip_dst
,
1010 sizeof(ip
->ip_dst
));
1014 UNALIGNED_MEMCPY(&xmep
->client
, ip6
->ip6_src
,
1015 sizeof(ip6
->ip6_src
));
1016 UNALIGNED_MEMCPY(&xmep
->server
, ip6
->ip6_dst
,
1017 sizeof(ip6
->ip6_dst
));
1019 xmep
->proc
= GET_BE_U_4(&rp
->rm_call
.cb_proc
);
1020 xmep
->vers
= GET_BE_U_4(&rp
->rm_call
.cb_vers
);
1025 * Returns 0 and puts NFSPROC_xxx in proc return and
1026 * version in vers return, or returns -1 on failure
1029 xid_map_find(netdissect_options
*ndo
, const struct sunrpc_msg
*rp
,
1030 const u_char
*bp
, uint32_t *proc
, uint32_t *vers
)
1033 struct xid_map_entry
*xmep
;
1035 const struct ip
*ip
= (const struct ip
*)bp
;
1036 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
1039 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
1040 /* Start searching from where we last left off */
1045 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
1047 switch (xmep
->ipver
) {
1049 if (UNALIGNED_MEMCMP(ip
->ip_src
, &xmep
->server
,
1050 sizeof(ip
->ip_src
)) != 0 ||
1051 UNALIGNED_MEMCMP(ip
->ip_dst
, &xmep
->client
,
1052 sizeof(ip
->ip_dst
)) != 0) {
1057 if (UNALIGNED_MEMCMP(ip6
->ip6_src
, &xmep
->server
,
1058 sizeof(ip6
->ip6_src
)) != 0 ||
1059 UNALIGNED_MEMCMP(ip6
->ip6_dst
, &xmep
->client
,
1060 sizeof(ip6
->ip6_dst
)) != 0) {
1076 if (++i
>= XIDMAPSIZE
)
1078 } while (i
!= xid_map_hint
);
1085 * Routines for parsing reply packets
1089 * Return a pointer to the beginning of the actual results.
1090 * If the packet was truncated, return 0.
1092 static const uint32_t *
1093 parserep(netdissect_options
*ndo
,
1094 const struct sunrpc_msg
*rp
, u_int length
, int *nfserrp
)
1098 enum sunrpc_accept_stat astat
;
1102 * Here we find the address of the ar_verf credentials.
1103 * Originally, this calculation was
1104 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
1105 * On the wire, the rp_acpt field starts immediately after
1106 * the (32 bit) rp_stat field. However, rp_acpt (which is a
1107 * "struct accepted_reply") contains a "struct opaque_auth",
1108 * whose internal representation contains a pointer, so on a
1109 * 64-bit machine the compiler inserts 32 bits of padding
1110 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
1111 * the internal representation to parse the on-the-wire
1112 * representation. Instead, we skip past the rp_stat field,
1113 * which is an "enum" and so occupies one 32-bit word.
1115 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
1116 ND_TCHECK_4(dp
+ 1);
1117 len
= GET_BE_U_4(dp
+ 1);
1121 * skip past the ar_verf credentials.
1123 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1126 * now we can check the ar_stat field
1129 astat
= (enum sunrpc_accept_stat
) GET_BE_U_4(dp
);
1130 if (astat
!= SUNRPC_SUCCESS
) {
1131 ND_PRINT(" %s", tok2str(sunrpc_str
, "ar_stat %u", astat
));
1132 *nfserrp
= 1; /* suppress trunc string */
1135 /* successful return */
1136 ND_TCHECK_LEN(dp
, sizeof(astat
));
1137 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1142 static const uint32_t *
1143 parsestatus(netdissect_options
*ndo
,
1144 const uint32_t *dp
, u_int
*er
, int *nfserrp
)
1150 errnum
= GET_BE_U_4(dp
);
1154 if (!ndo
->ndo_qflag
)
1155 ND_PRINT(" ERROR: %s",
1156 tok2str(status2str
, "unk %u", errnum
));
1164 static const uint32_t *
1165 parsefattr(netdissect_options
*ndo
,
1166 const uint32_t *dp
, int verbose
, int v3
)
1168 const struct nfs_fattr
*fap
;
1170 fap
= (const struct nfs_fattr
*)dp
;
1171 ND_TCHECK_4(fap
->fa_gid
);
1174 * XXX - UIDs and GIDs are unsigned in NFS and in
1175 * at least some UN*Xes, but we'll show them as
1176 * signed because -2 has traditionally been the
1177 * UID for "nobody", rather than 4294967294.
1179 ND_PRINT(" %s %o ids %d/%d",
1180 tok2str(type2str
, "unk-ft %u ",
1181 GET_BE_U_4(fap
->fa_type
)),
1182 GET_BE_U_4(fap
->fa_mode
),
1183 GET_BE_S_4(fap
->fa_uid
),
1184 GET_BE_S_4(fap
->fa_gid
));
1186 ND_TCHECK_8(fap
->fa3_size
);
1187 ND_PRINT(" sz %" PRIu64
,
1188 GET_BE_U_8(fap
->fa3_size
));
1190 ND_TCHECK_4(fap
->fa2_size
);
1191 ND_PRINT(" sz %u", GET_BE_U_4(fap
->fa2_size
));
1194 /* print lots more stuff */
1197 ND_TCHECK_8(&fap
->fa3_ctime
);
1198 ND_PRINT(" nlink %u rdev %u/%u",
1199 GET_BE_U_4(fap
->fa_nlink
),
1200 GET_BE_U_4(fap
->fa3_rdev
.specdata1
),
1201 GET_BE_U_4(fap
->fa3_rdev
.specdata2
));
1202 ND_PRINT(" fsid %" PRIx64
,
1203 GET_BE_U_8(fap
->fa3_fsid
));
1204 ND_PRINT(" fileid %" PRIx64
,
1205 GET_BE_U_8(fap
->fa3_fileid
));
1206 ND_PRINT(" a/m/ctime %u.%06u",
1207 GET_BE_U_4(fap
->fa3_atime
.nfsv3_sec
),
1208 GET_BE_U_4(fap
->fa3_atime
.nfsv3_nsec
));
1209 ND_PRINT(" %u.%06u",
1210 GET_BE_U_4(fap
->fa3_mtime
.nfsv3_sec
),
1211 GET_BE_U_4(fap
->fa3_mtime
.nfsv3_nsec
));
1212 ND_PRINT(" %u.%06u",
1213 GET_BE_U_4(fap
->fa3_ctime
.nfsv3_sec
),
1214 GET_BE_U_4(fap
->fa3_ctime
.nfsv3_nsec
));
1216 ND_TCHECK_8(&fap
->fa2_ctime
);
1217 ND_PRINT(" nlink %u rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1218 GET_BE_U_4(fap
->fa_nlink
),
1219 GET_BE_U_4(fap
->fa2_rdev
),
1220 GET_BE_U_4(fap
->fa2_fsid
),
1221 GET_BE_U_4(fap
->fa2_fileid
));
1222 ND_PRINT(" %u.%06u",
1223 GET_BE_U_4(fap
->fa2_atime
.nfsv2_sec
),
1224 GET_BE_U_4(fap
->fa2_atime
.nfsv2_usec
));
1225 ND_PRINT(" %u.%06u",
1226 GET_BE_U_4(fap
->fa2_mtime
.nfsv2_sec
),
1227 GET_BE_U_4(fap
->fa2_mtime
.nfsv2_usec
));
1228 ND_PRINT(" %u.%06u",
1229 GET_BE_U_4(fap
->fa2_ctime
.nfsv2_sec
),
1230 GET_BE_U_4(fap
->fa2_ctime
.nfsv2_usec
));
1233 return ((const uint32_t *)((const unsigned char *)dp
+
1234 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1240 parseattrstat(netdissect_options
*ndo
,
1241 const uint32_t *dp
, int verbose
, int v3
, int *nfserrp
)
1245 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1251 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1255 parsediropres(netdissect_options
*ndo
,
1256 const uint32_t *dp
, int *nfserrp
)
1260 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1266 dp
= parsefh(ndo
, dp
, 0);
1270 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1274 parselinkres(netdissect_options
*ndo
,
1275 const uint32_t *dp
, int v3
, int *nfserrp
)
1279 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1285 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1290 return (parsefn(ndo
, dp
) != NULL
);
1294 parsestatfs(netdissect_options
*ndo
,
1295 const uint32_t *dp
, int v3
, int *nfserrp
)
1297 const struct nfs_statfs
*sfsp
;
1300 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1312 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1317 ND_TCHECK_LEN(dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1319 sfsp
= (const struct nfs_statfs
*)dp
;
1322 ND_PRINT(" tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1323 GET_BE_U_8(sfsp
->sf_tbytes
),
1324 GET_BE_U_8(sfsp
->sf_fbytes
),
1325 GET_BE_U_8(sfsp
->sf_abytes
));
1326 if (ndo
->ndo_vflag
) {
1327 ND_PRINT(" tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1328 GET_BE_U_8(sfsp
->sf_tfiles
),
1329 GET_BE_U_8(sfsp
->sf_ffiles
),
1330 GET_BE_U_8(sfsp
->sf_afiles
),
1331 GET_BE_U_4(sfsp
->sf_invarsec
));
1334 ND_PRINT(" tsize %u bsize %u blocks %u bfree %u bavail %u",
1335 GET_BE_U_4(sfsp
->sf_tsize
),
1336 GET_BE_U_4(sfsp
->sf_bsize
),
1337 GET_BE_U_4(sfsp
->sf_blocks
),
1338 GET_BE_U_4(sfsp
->sf_bfree
),
1339 GET_BE_U_4(sfsp
->sf_bavail
));
1348 parserddires(netdissect_options
*ndo
,
1349 const uint32_t *dp
, int *nfserrp
)
1353 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1361 ND_TCHECK_4(dp
+ 2);
1362 ND_PRINT(" offset 0x%x size %u ",
1363 GET_BE_U_4(dp
), GET_BE_U_4(dp
+ 1));
1364 if (GET_BE_U_4(dp
+ 2) != 0)
1372 static const uint32_t *
1373 parse_wcc_attr(netdissect_options
*ndo
,
1376 /* Our caller has already checked this */
1377 ND_PRINT(" sz %" PRIu64
, GET_BE_U_8(dp
));
1378 ND_PRINT(" mtime %u.%06u ctime %u.%06u",
1379 GET_BE_U_4(dp
+ 2), GET_BE_U_4(dp
+ 3),
1380 GET_BE_U_4(dp
+ 4), GET_BE_U_4(dp
+ 5));
1385 * Pre operation attributes. Print only if vflag > 1.
1387 static const uint32_t *
1388 parse_pre_op_attr(netdissect_options
*ndo
,
1389 const uint32_t *dp
, int verbose
)
1392 if (!GET_BE_U_4(dp
))
1395 ND_TCHECK_LEN(dp
, 24);
1397 return parse_wcc_attr(ndo
, dp
);
1399 /* If not verbose enough, just skip over wcc_attr */
1407 * Post operation attributes are printed if vflag >= 1
1409 static const uint32_t *
1410 parse_post_op_attr(netdissect_options
*ndo
,
1411 const uint32_t *dp
, int verbose
)
1414 if (!GET_BE_U_4(dp
))
1418 return parsefattr(ndo
, dp
, verbose
, 1);
1420 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1425 static const uint32_t *
1426 parse_wcc_data(netdissect_options
*ndo
,
1427 const uint32_t *dp
, int verbose
)
1431 dp
= parse_pre_op_attr(ndo
, dp
, verbose
);
1437 return parse_post_op_attr(ndo
, dp
, verbose
);
1440 static const uint32_t *
1441 parsecreateopres(netdissect_options
*ndo
,
1442 const uint32_t *dp
, int verbose
, int *nfserrp
)
1446 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1450 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1453 if (!GET_BE_U_4(dp
))
1456 dp
= parsefh(ndo
, dp
, 1);
1460 dp
= parse_post_op_attr(ndo
, dp
, verbose
);
1463 if (ndo
->ndo_vflag
> 1) {
1464 ND_PRINT(" dir attr:");
1465 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1474 static const uint32_t *
1475 parsewccres(netdissect_options
*ndo
,
1476 const uint32_t *dp
, int verbose
, int *nfserrp
)
1480 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1483 return parse_wcc_data(ndo
, dp
, verbose
);
1486 static const uint32_t *
1487 parsev3rddirres(netdissect_options
*ndo
,
1488 const uint32_t *dp
, int verbose
, int *nfserrp
)
1492 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1497 dp
= parse_post_op_attr(ndo
, dp
, verbose
);
1502 if (ndo
->ndo_vflag
) {
1503 ND_TCHECK_4(dp
+ 1);
1505 * This displays the 8 bytes of the verifier in order,
1506 * from the low-order byte to the high-order byte.
1508 ND_PRINT(" verf %08x%08x",
1509 GET_BE_U_4(dp
), GET_BE_U_4(dp
+ 1));
1518 parsefsinfo(netdissect_options
*ndo
,
1519 const uint32_t *dp
, int *nfserrp
)
1521 const struct nfsv3_fsinfo
*sfp
;
1524 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1529 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1535 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1536 ND_TCHECK_SIZE(sfp
);
1537 ND_PRINT(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1538 GET_BE_U_4(sfp
->fs_rtmax
),
1539 GET_BE_U_4(sfp
->fs_rtpref
),
1540 GET_BE_U_4(sfp
->fs_wtmax
),
1541 GET_BE_U_4(sfp
->fs_wtpref
),
1542 GET_BE_U_4(sfp
->fs_dtpref
));
1543 if (ndo
->ndo_vflag
) {
1544 ND_PRINT(" rtmult %u wtmult %u maxfsz %" PRIu64
,
1545 GET_BE_U_4(sfp
->fs_rtmult
),
1546 GET_BE_U_4(sfp
->fs_wtmult
),
1547 GET_BE_U_8(sfp
->fs_maxfilesize
));
1548 ND_PRINT(" delta %u.%06u ",
1549 GET_BE_U_4(sfp
->fs_timedelta
.nfsv3_sec
),
1550 GET_BE_U_4(sfp
->fs_timedelta
.nfsv3_nsec
));
1558 parsepathconf(netdissect_options
*ndo
,
1559 const uint32_t *dp
, int *nfserrp
)
1562 const struct nfsv3_pathconf
*spp
;
1564 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1569 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1575 spp
= (const struct nfsv3_pathconf
*)dp
;
1576 ND_TCHECK_SIZE(spp
);
1578 ND_PRINT(" linkmax %u namemax %u %s %s %s %s",
1579 GET_BE_U_4(spp
->pc_linkmax
),
1580 GET_BE_U_4(spp
->pc_namemax
),
1581 GET_BE_U_4(spp
->pc_notrunc
) ? "notrunc" : "",
1582 GET_BE_U_4(spp
->pc_chownrestricted
) ? "chownres" : "",
1583 GET_BE_U_4(spp
->pc_caseinsensitive
) ? "igncase" : "",
1584 GET_BE_U_4(spp
->pc_casepreserving
) ? "keepcase" : "");
1591 interp_reply(netdissect_options
*ndo
,
1592 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
,
1600 v3
= (vers
== NFS_VER3
);
1602 if (!v3
&& proc
< NFS_NPROCS
)
1603 proc
= nfsv3_procid
[proc
];
1605 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
1608 case NFSPROC_GETATTR
:
1609 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1612 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
, &nfserr
) == 0)
1616 case NFSPROC_SETATTR
:
1617 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1621 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == 0)
1624 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0, &nfserr
) == 0)
1629 case NFSPROC_LOOKUP
:
1630 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1634 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1638 if (ndo
->ndo_vflag
> 1) {
1639 ND_PRINT(" post dattr:");
1640 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1645 dp
= parsefh(ndo
, dp
, v3
);
1648 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1651 if (ndo
->ndo_vflag
> 1) {
1652 ND_PRINT(" post dattr:");
1653 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1659 if (parsediropres(ndo
, dp
, &nfserr
) == 0)
1664 case NFSPROC_ACCESS
:
1665 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1668 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1673 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1678 ND_PRINT(" c %04x", GET_BE_U_4(dp
));
1682 case NFSPROC_READLINK
:
1683 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1686 if (parselinkres(ndo
, dp
, v3
, &nfserr
) == 0)
1691 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1695 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1698 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1702 if (ndo
->ndo_vflag
) {
1703 ND_TCHECK_4(dp
+ 1);
1704 ND_PRINT(" %u bytes", GET_BE_U_4(dp
));
1705 if (GET_BE_U_4(dp
+ 1))
1710 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0, &nfserr
) == 0)
1716 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1720 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1723 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1727 if (ndo
->ndo_vflag
) {
1729 ND_PRINT(" %u bytes", GET_BE_U_4(dp
));
1730 if (ndo
->ndo_vflag
> 1) {
1731 ND_TCHECK_4(dp
+ 1);
1733 tok2str(nfsv3_writemodes
,
1734 NULL
, GET_BE_U_4(dp
+ 1)));
1736 /* write-verf-cookie */
1737 ND_TCHECK_8(dp
+ 2);
1738 ND_PRINT(" verf %" PRIx64
,
1739 GET_BE_U_8(dp
+ 2));
1745 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
, &nfserr
) == 0)
1750 case NFSPROC_CREATE
:
1752 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1756 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1759 if (parsediropres(ndo
, dp
, &nfserr
) == 0)
1764 case NFSPROC_SYMLINK
:
1765 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1769 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1772 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1778 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1781 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1785 case NFSPROC_REMOVE
:
1787 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1791 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1794 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1799 case NFSPROC_RENAME
:
1800 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1804 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1807 if (ndo
->ndo_vflag
) {
1809 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1813 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1818 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1824 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1828 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1831 if (ndo
->ndo_vflag
) {
1832 ND_PRINT(" file POST:");
1833 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1837 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1843 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1848 case NFSPROC_READDIR
:
1849 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1853 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1856 if (parserddires(ndo
, dp
, &nfserr
) == 0)
1861 case NFSPROC_READDIRPLUS
:
1862 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1865 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1869 case NFSPROC_FSSTAT
:
1870 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1873 if (parsestatfs(ndo
, dp
, v3
, &nfserr
) == 0)
1877 case NFSPROC_FSINFO
:
1878 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1881 if (parsefsinfo(ndo
, dp
, &nfserr
) == 0)
1885 case NFSPROC_PATHCONF
:
1886 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1889 if (parsepathconf(ndo
, dp
, &nfserr
) == 0)
1893 case NFSPROC_COMMIT
:
1894 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1897 dp
= parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
);
1900 if (ndo
->ndo_vflag
> 1) {
1901 /* write-verf-cookie */
1903 ND_PRINT(" verf %" PRIx64
, GET_BE_U_8(dp
));
1914 nd_print_trunc(ndo
);