]>
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"
33 #include "netdissect.h"
34 #include "addrtoname.h"
46 static void nfs_printfh(netdissect_options
*, const uint32_t *, const u_int
);
47 static int xid_map_enter(netdissect_options
*, const struct sunrpc_msg
*, const u_char
*);
48 static int xid_map_find(const struct sunrpc_msg
*, const u_char
*,
49 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
= EXTRACT_BE_U_4(dp
);
266 if (sa3
->sa_modeset
) {
268 sa3
->sa_mode
= EXTRACT_BE_U_4(dp
);
273 sa3
->sa_uidset
= EXTRACT_BE_U_4(dp
);
275 if (sa3
->sa_uidset
) {
277 sa3
->sa_uid
= EXTRACT_BE_U_4(dp
);
282 sa3
->sa_gidset
= EXTRACT_BE_U_4(dp
);
284 if (sa3
->sa_gidset
) {
286 sa3
->sa_gid
= EXTRACT_BE_U_4(dp
);
291 sa3
->sa_sizeset
= EXTRACT_BE_U_4(dp
);
293 if (sa3
->sa_sizeset
) {
295 sa3
->sa_size
= EXTRACT_BE_U_4(dp
);
300 sa3
->sa_atimetype
= EXTRACT_BE_U_4(dp
);
302 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
) {
304 sa3
->sa_atime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
306 sa3
->sa_atime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
311 sa3
->sa_mtimetype
= EXTRACT_BE_U_4(dp
);
313 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
) {
315 sa3
->sa_mtime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
317 sa3
->sa_mtime
.nfsv3_nsec
= EXTRACT_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 nd_snprintf(dstid
, sizeof(dstid
), "%u",
361 EXTRACT_BE_U_4(rp
->rm_xid
));
363 nd_snprintf(srcid
, sizeof(srcid
), "%u", NFS_PORT
);
364 nd_snprintf(dstid
, sizeof(dstid
), "%u",
365 EXTRACT_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
= EXTRACT_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(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
= EXTRACT_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
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.low
);
410 rhigh
= EXTRACT_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
= EXTRACT_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
= EXTRACT_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
= EXTRACT_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
= EXTRACT_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
= EXTRACT_BE_U_4(dp
);
537 ND_TCHECK_LEN(dp
, ((len
+ 3) & ~3));
539 cp
= (const u_char
*)dp
;
540 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
541 dp
+= ((len
+ 3) & ~3) / sizeof(*dp
);
543 if (nd_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
555 * Print out file handle and file name.
556 * Return pointer to 32-bit word past file name.
557 * If packet was truncated (or there was some other error), return 0.
559 static const uint32_t *
560 parsefhn(netdissect_options
*ndo
,
561 const uint32_t *dp
, int v3
)
563 dp
= parsefh(ndo
, dp
, v3
);
567 return (parsefn(ndo
, dp
));
571 nfsreq_noaddr_print(netdissect_options
*ndo
,
572 const u_char
*bp
, u_int length
,
575 const struct sunrpc_msg
*rp
;
580 uint32_t access_flags
;
581 struct nfsv3_sattr sa3
;
583 ndo
->ndo_protocol
= "nfs";
584 ND_PRINT("%u", length
);
585 rp
= (const struct sunrpc_msg
*)bp
;
587 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
590 v3
= (EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
591 proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
593 if (!v3
&& proc
< NFS_NPROCS
)
594 proc
= nfsv3_procid
[proc
];
596 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
599 case NFSPROC_GETATTR
:
600 case NFSPROC_SETATTR
:
601 case NFSPROC_READLINK
:
604 case NFSPROC_PATHCONF
:
605 dp
= parsereq(ndo
, rp
, length
);
608 if (parsefh(ndo
, dp
, v3
) == NULL
)
617 dp
= parsereq(ndo
, rp
, length
);
620 if (parsefhn(ndo
, dp
, v3
) == NULL
)
625 dp
= parsereq(ndo
, rp
, length
);
628 dp
= parsefh(ndo
, dp
, v3
);
632 access_flags
= EXTRACT_BE_U_4(dp
);
633 if (access_flags
& ~NFSV3ACCESS_FULL
) {
634 /* NFSV3ACCESS definitions aren't up to date */
635 ND_PRINT(" %04x", access_flags
);
636 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
637 ND_PRINT(" NFS_ACCESS_FULL");
639 char separator
= ' ';
640 if (access_flags
& NFSV3ACCESS_READ
) {
641 ND_PRINT(" NFS_ACCESS_READ");
644 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
645 ND_PRINT("%cNFS_ACCESS_LOOKUP", separator
);
648 if (access_flags
& NFSV3ACCESS_MODIFY
) {
649 ND_PRINT("%cNFS_ACCESS_MODIFY", separator
);
652 if (access_flags
& NFSV3ACCESS_EXTEND
) {
653 ND_PRINT("%cNFS_ACCESS_EXTEND", separator
);
656 if (access_flags
& NFSV3ACCESS_DELETE
) {
657 ND_PRINT("%cNFS_ACCESS_DELETE", separator
);
660 if (access_flags
& NFSV3ACCESS_EXECUTE
)
661 ND_PRINT("%cNFS_ACCESS_EXECUTE", separator
);
666 dp
= parsereq(ndo
, rp
, length
);
669 dp
= parsefh(ndo
, dp
, v3
);
674 ND_PRINT(" %u bytes @ %" PRIu64
,
675 EXTRACT_BE_U_4(dp
+ 2),
679 ND_PRINT(" %u bytes @ %u",
680 EXTRACT_BE_U_4(dp
+ 1),
686 dp
= parsereq(ndo
, rp
, length
);
689 dp
= parsefh(ndo
, dp
, v3
);
694 ND_PRINT(" %u (%u) bytes @ %" PRIu64
,
695 EXTRACT_BE_U_4(dp
+ 4),
696 EXTRACT_BE_U_4(dp
+ 2),
698 if (ndo
->ndo_vflag
) {
700 tok2str(nfsv3_writemodes
,
701 NULL
, EXTRACT_BE_U_4(dp
+ 3)));
705 ND_PRINT(" %u (%u) bytes @ %u (%u)",
706 EXTRACT_BE_U_4(dp
+ 3),
707 EXTRACT_BE_U_4(dp
+ 2),
708 EXTRACT_BE_U_4(dp
+ 1),
713 case NFSPROC_SYMLINK
:
714 dp
= parsereq(ndo
, rp
, length
);
717 dp
= parsefhn(ndo
, dp
, v3
);
721 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
723 if (parsefn(ndo
, dp
) == NULL
)
725 if (v3
&& ndo
->ndo_vflag
)
726 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
730 dp
= parsereq(ndo
, rp
, length
);
733 dp
= parsefhn(ndo
, dp
, v3
);
737 type
= (nfs_type
) EXTRACT_BE_U_4(dp
);
739 dp
= parse_sattr3(ndo
, dp
, &sa3
);
742 ND_PRINT(" %s", tok2str(type2str
, "unk-ft %u", type
));
743 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
747 EXTRACT_BE_U_4(dp
+ 1));
751 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
755 dp
= parsereq(ndo
, rp
, length
);
758 dp
= parsefhn(ndo
, dp
, v3
);
762 if (parsefhn(ndo
, dp
, v3
) == NULL
)
767 dp
= parsereq(ndo
, rp
, length
);
770 dp
= parsefh(ndo
, dp
, v3
);
774 if (parsefhn(ndo
, dp
, v3
) == NULL
)
778 case NFSPROC_READDIR
:
779 dp
= parsereq(ndo
, rp
, length
);
782 dp
= parsefh(ndo
, dp
, v3
);
788 * We shouldn't really try to interpret the
789 * offset cookie here.
791 ND_PRINT(" %u bytes @ %" PRId64
,
792 EXTRACT_BE_U_4(dp
+ 4),
794 if (ndo
->ndo_vflag
) {
796 * This displays the 8 bytes
797 * of the verifier in order,
798 * from the low-order byte
799 * to the high-order byte.
801 ND_PRINT(" verf %08x%08x",
802 EXTRACT_BE_U_4(dp
+ 2),
803 EXTRACT_BE_U_4(dp
+ 3));
808 * Print the offset as signed, since -1 is
809 * common, but offsets > 2^31 aren't.
811 ND_PRINT(" %u bytes @ %u",
812 EXTRACT_BE_U_4(dp
+ 1),
817 case NFSPROC_READDIRPLUS
:
818 dp
= parsereq(ndo
, rp
, length
);
821 dp
= parsefh(ndo
, dp
, v3
);
826 * We don't try to interpret the offset
829 ND_PRINT(" %u bytes @ %" PRId64
,
830 EXTRACT_BE_U_4(dp
+ 4),
832 if (ndo
->ndo_vflag
) {
835 * This displays the 8 bytes
836 * of the verifier in order,
837 * from the low-order byte
838 * to the high-order byte.
840 ND_PRINT(" max %u verf %08x%08x",
841 EXTRACT_BE_U_4(dp
+ 5),
842 EXTRACT_BE_U_4(dp
+ 2),
843 EXTRACT_BE_U_4(dp
+ 3));
848 dp
= parsereq(ndo
, rp
, length
);
851 dp
= parsefh(ndo
, dp
, v3
);
855 ND_PRINT(" %u bytes @ %" PRIu64
,
856 EXTRACT_BE_U_4(dp
+ 2),
870 * Print out an NFS file handle.
871 * We assume packet was not truncated before the end of the
872 * file handle pointed to by dp.
874 * Note: new version (using portable file-handle parser) doesn't produce
875 * generation number. It probably could be made to do that, with some
876 * additional hacking on the parser code.
879 nfs_printfh(netdissect_options
*ndo
,
880 const uint32_t *dp
, const u_int len
)
884 const char *sfsname
= NULL
;
887 if (ndo
->ndo_uflag
) {
889 char const *sep
= "";
892 for (i
=0; i
<len
; i
++) {
894 * This displays 4 bytes in big-endian byte
895 * order. That's as good a choice as little-
896 * endian, as there's no guarantee that the
897 * server is big-endian or little-endian or
898 * that the file handle contains 4-byte
899 * integral fields, and is better than "the
900 * byte order of the host running tcpdump", as
901 * the latter means that different hosts
902 * running tcpdump may show the same file
903 * handle in different ways.
905 ND_PRINT("%s%x", sep
, EXTRACT_BE_U_4(dp
+ i
));
912 Parse_fh((const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
915 /* file system ID is ASCII, not numeric, for this server OS */
916 char temp
[NFSX_V3FHMAX
+1];
919 /* Make sure string is null-terminated */
921 if (stringlen
> NFSX_V3FHMAX
)
922 stringlen
= NFSX_V3FHMAX
;
923 strncpy(temp
, sfsname
, stringlen
);
924 temp
[stringlen
] = '\0';
925 /* Remove trailing spaces */
926 spacep
= strchr(temp
, ' ');
930 ND_PRINT(" fh %s/", temp
);
932 ND_PRINT(" fh %u,%u/",
933 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
);
936 if(fsid
.Fsid_dev
.Minor
== 257)
937 /* Print the undecoded handle */
938 ND_PRINT("%s", fsid
.Opaque_Handle
);
940 ND_PRINT("%ld", (long) ino
);
944 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
945 * us to match up replies with requests and thus to know how to parse
949 struct xid_map_entry
{
950 uint32_t xid
; /* transaction ID (net order) */
951 int ipver
; /* IP version (4 or 6) */
952 struct in6_addr client
; /* client IP address (net order) */
953 struct in6_addr server
; /* server IP address (net order) */
954 uint32_t proc
; /* call proc number (host order) */
955 uint32_t vers
; /* program version (host order) */
959 * Map entries are kept in an array that we manage as a ring;
960 * new entries are always added at the tail of the ring. Initially,
961 * all the entries are zero and hence don't match anything.
964 #define XIDMAPSIZE 64
966 static struct xid_map_entry xid_map
[XIDMAPSIZE
];
968 static int xid_map_next
= 0;
969 static int xid_map_hint
= 0;
972 xid_map_enter(netdissect_options
*ndo
,
973 const struct sunrpc_msg
*rp
, const u_char
*bp
)
975 const struct ip
*ip
= NULL
;
976 const struct ip6_hdr
*ip6
= NULL
;
977 struct xid_map_entry
*xmep
;
979 if (!ND_TTEST_4(rp
->rm_call
.cb_proc
))
981 switch (IP_V((const struct ip
*)bp
)) {
983 ip
= (const struct ip
*)bp
;
986 ip6
= (const struct ip6_hdr
*)bp
;
992 xmep
= &xid_map
[xid_map_next
];
994 if (++xid_map_next
>= XIDMAPSIZE
)
997 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
1000 UNALIGNED_MEMCPY(&xmep
->client
, ip
->ip_src
,
1001 sizeof(ip
->ip_src
));
1002 UNALIGNED_MEMCPY(&xmep
->server
, ip
->ip_dst
,
1003 sizeof(ip
->ip_dst
));
1007 UNALIGNED_MEMCPY(&xmep
->client
, ip6
->ip6_src
,
1008 sizeof(ip6
->ip6_src
));
1009 UNALIGNED_MEMCPY(&xmep
->server
, ip6
->ip6_dst
,
1010 sizeof(ip6
->ip6_dst
));
1012 xmep
->proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
1013 xmep
->vers
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
);
1018 * Returns 0 and puts NFSPROC_xxx in proc return and
1019 * version in vers return, or returns -1 on failure
1022 xid_map_find(const struct sunrpc_msg
*rp
, const u_char
*bp
, uint32_t *proc
,
1026 struct xid_map_entry
*xmep
;
1028 const struct ip
*ip
= (const struct ip
*)bp
;
1029 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
1032 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
1033 /* Start searching from where we last left off */
1038 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
1040 switch (xmep
->ipver
) {
1042 if (UNALIGNED_MEMCMP(ip
->ip_src
, &xmep
->server
,
1043 sizeof(ip
->ip_src
)) != 0 ||
1044 UNALIGNED_MEMCMP(ip
->ip_dst
, &xmep
->client
,
1045 sizeof(ip
->ip_dst
)) != 0) {
1050 if (UNALIGNED_MEMCMP(ip6
->ip6_src
, &xmep
->server
,
1051 sizeof(ip6
->ip6_src
)) != 0 ||
1052 UNALIGNED_MEMCMP(ip6
->ip6_dst
, &xmep
->client
,
1053 sizeof(ip6
->ip6_dst
)) != 0) {
1069 if (++i
>= XIDMAPSIZE
)
1071 } while (i
!= xid_map_hint
);
1078 * Routines for parsing reply packets
1082 * Return a pointer to the beginning of the actual results.
1083 * If the packet was truncated, return 0.
1085 static const uint32_t *
1086 parserep(netdissect_options
*ndo
,
1087 const struct sunrpc_msg
*rp
, u_int length
, int *nfserrp
)
1091 enum sunrpc_accept_stat astat
;
1095 * Here we find the address of the ar_verf credentials.
1096 * Originally, this calculation was
1097 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
1098 * On the wire, the rp_acpt field starts immediately after
1099 * the (32 bit) rp_stat field. However, rp_acpt (which is a
1100 * "struct accepted_reply") contains a "struct opaque_auth",
1101 * whose internal representation contains a pointer, so on a
1102 * 64-bit machine the compiler inserts 32 bits of padding
1103 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
1104 * the internal representation to parse the on-the-wire
1105 * representation. Instead, we skip past the rp_stat field,
1106 * which is an "enum" and so occupies one 32-bit word.
1108 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
1109 ND_TCHECK_4(dp
+ 1);
1110 len
= EXTRACT_BE_U_4(dp
+ 1);
1114 * skip past the ar_verf credentials.
1116 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1119 * now we can check the ar_stat field
1122 astat
= (enum sunrpc_accept_stat
) EXTRACT_BE_U_4(dp
);
1123 if (astat
!= SUNRPC_SUCCESS
) {
1124 ND_PRINT(" %s", tok2str(sunrpc_str
, "ar_stat %u", astat
));
1125 *nfserrp
= 1; /* suppress trunc string */
1128 /* successful return */
1129 ND_TCHECK_LEN(dp
, sizeof(astat
));
1130 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1135 static const uint32_t *
1136 parsestatus(netdissect_options
*ndo
,
1137 const uint32_t *dp
, u_int
*er
, int *nfserrp
)
1143 errnum
= EXTRACT_BE_U_4(dp
);
1147 if (!ndo
->ndo_qflag
)
1148 ND_PRINT(" ERROR: %s",
1149 tok2str(status2str
, "unk %u", errnum
));
1157 static const uint32_t *
1158 parsefattr(netdissect_options
*ndo
,
1159 const uint32_t *dp
, int verbose
, int v3
)
1161 const struct nfs_fattr
*fap
;
1163 fap
= (const struct nfs_fattr
*)dp
;
1164 ND_TCHECK_4(fap
->fa_gid
);
1167 * XXX - UIDs and GIDs are unsigned in NFS and in
1168 * at least some UN*Xes, but we'll show them as
1169 * signed because -2 has traditionally been the
1170 * UID for "nobody", rather than 4294967294.
1172 ND_PRINT(" %s %o ids %d/%d",
1173 tok2str(type2str
, "unk-ft %u ",
1174 EXTRACT_BE_U_4(fap
->fa_type
)),
1175 EXTRACT_BE_U_4(fap
->fa_mode
),
1176 EXTRACT_BE_S_4(fap
->fa_uid
),
1177 EXTRACT_BE_S_4(fap
->fa_gid
));
1179 ND_TCHECK_8(fap
->fa3_size
);
1180 ND_PRINT(" sz %" PRIu64
,
1181 EXTRACT_BE_U_8(fap
->fa3_size
));
1183 ND_TCHECK_4(fap
->fa2_size
);
1184 ND_PRINT(" sz %u", EXTRACT_BE_U_4(fap
->fa2_size
));
1187 /* print lots more stuff */
1190 ND_TCHECK_8(&fap
->fa3_ctime
);
1191 ND_PRINT(" nlink %u rdev %u/%u",
1192 EXTRACT_BE_U_4(fap
->fa_nlink
),
1193 EXTRACT_BE_U_4(fap
->fa3_rdev
.specdata1
),
1194 EXTRACT_BE_U_4(fap
->fa3_rdev
.specdata2
));
1195 ND_PRINT(" fsid %" PRIx64
,
1196 EXTRACT_BE_U_8(fap
->fa3_fsid
));
1197 ND_PRINT(" fileid %" PRIx64
,
1198 EXTRACT_BE_U_8(fap
->fa3_fileid
));
1199 ND_PRINT(" a/m/ctime %u.%06u",
1200 EXTRACT_BE_U_4(fap
->fa3_atime
.nfsv3_sec
),
1201 EXTRACT_BE_U_4(fap
->fa3_atime
.nfsv3_nsec
));
1202 ND_PRINT(" %u.%06u",
1203 EXTRACT_BE_U_4(fap
->fa3_mtime
.nfsv3_sec
),
1204 EXTRACT_BE_U_4(fap
->fa3_mtime
.nfsv3_nsec
));
1205 ND_PRINT(" %u.%06u",
1206 EXTRACT_BE_U_4(fap
->fa3_ctime
.nfsv3_sec
),
1207 EXTRACT_BE_U_4(fap
->fa3_ctime
.nfsv3_nsec
));
1209 ND_TCHECK_8(&fap
->fa2_ctime
);
1210 ND_PRINT(" nlink %u rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1211 EXTRACT_BE_U_4(fap
->fa_nlink
),
1212 EXTRACT_BE_U_4(fap
->fa2_rdev
),
1213 EXTRACT_BE_U_4(fap
->fa2_fsid
),
1214 EXTRACT_BE_U_4(fap
->fa2_fileid
));
1215 ND_PRINT(" %u.%06u",
1216 EXTRACT_BE_U_4(fap
->fa2_atime
.nfsv2_sec
),
1217 EXTRACT_BE_U_4(fap
->fa2_atime
.nfsv2_usec
));
1218 ND_PRINT(" %u.%06u",
1219 EXTRACT_BE_U_4(fap
->fa2_mtime
.nfsv2_sec
),
1220 EXTRACT_BE_U_4(fap
->fa2_mtime
.nfsv2_usec
));
1221 ND_PRINT(" %u.%06u",
1222 EXTRACT_BE_U_4(fap
->fa2_ctime
.nfsv2_sec
),
1223 EXTRACT_BE_U_4(fap
->fa2_ctime
.nfsv2_usec
));
1226 return ((const uint32_t *)((const unsigned char *)dp
+
1227 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1233 parseattrstat(netdissect_options
*ndo
,
1234 const uint32_t *dp
, int verbose
, int v3
, int *nfserrp
)
1238 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1244 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1248 parsediropres(netdissect_options
*ndo
,
1249 const uint32_t *dp
, int *nfserrp
)
1253 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1259 dp
= parsefh(ndo
, dp
, 0);
1263 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1267 parselinkres(netdissect_options
*ndo
,
1268 const uint32_t *dp
, int v3
, int *nfserrp
)
1272 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1278 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1283 return (parsefn(ndo
, dp
) != NULL
);
1287 parsestatfs(netdissect_options
*ndo
,
1288 const uint32_t *dp
, int v3
, int *nfserrp
)
1290 const struct nfs_statfs
*sfsp
;
1293 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1305 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1310 ND_TCHECK_LEN(dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1312 sfsp
= (const struct nfs_statfs
*)dp
;
1315 ND_PRINT(" tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1316 EXTRACT_BE_U_8(sfsp
->sf_tbytes
),
1317 EXTRACT_BE_U_8(sfsp
->sf_fbytes
),
1318 EXTRACT_BE_U_8(sfsp
->sf_abytes
));
1319 if (ndo
->ndo_vflag
) {
1320 ND_PRINT(" tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1321 EXTRACT_BE_U_8(sfsp
->sf_tfiles
),
1322 EXTRACT_BE_U_8(sfsp
->sf_ffiles
),
1323 EXTRACT_BE_U_8(sfsp
->sf_afiles
),
1324 EXTRACT_BE_U_4(sfsp
->sf_invarsec
));
1327 ND_PRINT(" tsize %u bsize %u blocks %u bfree %u bavail %u",
1328 EXTRACT_BE_U_4(sfsp
->sf_tsize
),
1329 EXTRACT_BE_U_4(sfsp
->sf_bsize
),
1330 EXTRACT_BE_U_4(sfsp
->sf_blocks
),
1331 EXTRACT_BE_U_4(sfsp
->sf_bfree
),
1332 EXTRACT_BE_U_4(sfsp
->sf_bavail
));
1341 parserddires(netdissect_options
*ndo
,
1342 const uint32_t *dp
, int *nfserrp
)
1346 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1354 ND_TCHECK_4(dp
+ 2);
1355 ND_PRINT(" offset 0x%x size %u ",
1356 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1357 if (EXTRACT_BE_U_4(dp
+ 2) != 0)
1365 static const uint32_t *
1366 parse_wcc_attr(netdissect_options
*ndo
,
1369 /* Our caller has already checked this */
1370 ND_PRINT(" sz %" PRIu64
, EXTRACT_BE_U_8(dp
));
1371 ND_PRINT(" mtime %u.%06u ctime %u.%06u",
1372 EXTRACT_BE_U_4(dp
+ 2), EXTRACT_BE_U_4(dp
+ 3),
1373 EXTRACT_BE_U_4(dp
+ 4), EXTRACT_BE_U_4(dp
+ 5));
1378 * Pre operation attributes. Print only if vflag > 1.
1380 static const uint32_t *
1381 parse_pre_op_attr(netdissect_options
*ndo
,
1382 const uint32_t *dp
, int verbose
)
1385 if (!EXTRACT_BE_U_4(dp
))
1388 ND_TCHECK_LEN(dp
, 24);
1390 return parse_wcc_attr(ndo
, dp
);
1392 /* If not verbose enough, just skip over wcc_attr */
1400 * Post operation attributes are printed if vflag >= 1
1402 static const uint32_t *
1403 parse_post_op_attr(netdissect_options
*ndo
,
1404 const uint32_t *dp
, int verbose
)
1407 if (!EXTRACT_BE_U_4(dp
))
1411 return parsefattr(ndo
, dp
, verbose
, 1);
1413 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1418 static const uint32_t *
1419 parse_wcc_data(netdissect_options
*ndo
,
1420 const uint32_t *dp
, int verbose
)
1424 dp
= parse_pre_op_attr(ndo
, dp
, verbose
);
1430 return parse_post_op_attr(ndo
, dp
, verbose
);
1433 static const uint32_t *
1434 parsecreateopres(netdissect_options
*ndo
,
1435 const uint32_t *dp
, int verbose
, int *nfserrp
)
1439 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1443 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1446 if (!EXTRACT_BE_U_4(dp
))
1449 dp
= parsefh(ndo
, dp
, 1);
1453 dp
= parse_post_op_attr(ndo
, dp
, verbose
);
1456 if (ndo
->ndo_vflag
> 1) {
1457 ND_PRINT(" dir attr:");
1458 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1467 static const uint32_t *
1468 parsewccres(netdissect_options
*ndo
,
1469 const uint32_t *dp
, int verbose
, int *nfserrp
)
1473 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1476 return parse_wcc_data(ndo
, dp
, verbose
);
1479 static const uint32_t *
1480 parsev3rddirres(netdissect_options
*ndo
,
1481 const uint32_t *dp
, int verbose
, int *nfserrp
)
1485 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1490 dp
= parse_post_op_attr(ndo
, dp
, verbose
);
1495 if (ndo
->ndo_vflag
) {
1496 ND_TCHECK_4(dp
+ 1);
1498 * This displays the 8 bytes of the verifier in order,
1499 * from the low-order byte to the high-order byte.
1501 ND_PRINT(" verf %08x%08x",
1502 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1511 parsefsinfo(netdissect_options
*ndo
,
1512 const uint32_t *dp
, int *nfserrp
)
1514 const struct nfsv3_fsinfo
*sfp
;
1517 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1522 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1528 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1529 ND_TCHECK_SIZE(sfp
);
1530 ND_PRINT(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1531 EXTRACT_BE_U_4(sfp
->fs_rtmax
),
1532 EXTRACT_BE_U_4(sfp
->fs_rtpref
),
1533 EXTRACT_BE_U_4(sfp
->fs_wtmax
),
1534 EXTRACT_BE_U_4(sfp
->fs_wtpref
),
1535 EXTRACT_BE_U_4(sfp
->fs_dtpref
));
1536 if (ndo
->ndo_vflag
) {
1537 ND_PRINT(" rtmult %u wtmult %u maxfsz %" PRIu64
,
1538 EXTRACT_BE_U_4(sfp
->fs_rtmult
),
1539 EXTRACT_BE_U_4(sfp
->fs_wtmult
),
1540 EXTRACT_BE_U_8(sfp
->fs_maxfilesize
));
1541 ND_PRINT(" delta %u.%06u ",
1542 EXTRACT_BE_U_4(sfp
->fs_timedelta
.nfsv3_sec
),
1543 EXTRACT_BE_U_4(sfp
->fs_timedelta
.nfsv3_nsec
));
1551 parsepathconf(netdissect_options
*ndo
,
1552 const uint32_t *dp
, int *nfserrp
)
1555 const struct nfsv3_pathconf
*spp
;
1557 dp
= parsestatus(ndo
, dp
, &er
, nfserrp
);
1562 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1568 spp
= (const struct nfsv3_pathconf
*)dp
;
1569 ND_TCHECK_SIZE(spp
);
1571 ND_PRINT(" linkmax %u namemax %u %s %s %s %s",
1572 EXTRACT_BE_U_4(spp
->pc_linkmax
),
1573 EXTRACT_BE_U_4(spp
->pc_namemax
),
1574 EXTRACT_BE_U_4(spp
->pc_notrunc
) ? "notrunc" : "",
1575 EXTRACT_BE_U_4(spp
->pc_chownrestricted
) ? "chownres" : "",
1576 EXTRACT_BE_U_4(spp
->pc_caseinsensitive
) ? "igncase" : "",
1577 EXTRACT_BE_U_4(spp
->pc_casepreserving
) ? "keepcase" : "");
1584 interp_reply(netdissect_options
*ndo
,
1585 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
,
1593 v3
= (vers
== NFS_VER3
);
1595 if (!v3
&& proc
< NFS_NPROCS
)
1596 proc
= nfsv3_procid
[proc
];
1598 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
1601 case NFSPROC_GETATTR
:
1602 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1605 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
, &nfserr
) == 0)
1609 case NFSPROC_SETATTR
:
1610 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1614 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == 0)
1617 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0, &nfserr
) == 0)
1622 case NFSPROC_LOOKUP
:
1623 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1627 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1631 if (ndo
->ndo_vflag
> 1) {
1632 ND_PRINT(" post dattr:");
1633 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1638 dp
= parsefh(ndo
, dp
, v3
);
1641 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1644 if (ndo
->ndo_vflag
> 1) {
1645 ND_PRINT(" post dattr:");
1646 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1652 if (parsediropres(ndo
, dp
, &nfserr
) == 0)
1657 case NFSPROC_ACCESS
:
1658 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1661 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1666 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1671 ND_PRINT(" c %04x", EXTRACT_BE_U_4(dp
));
1675 case NFSPROC_READLINK
:
1676 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1679 if (parselinkres(ndo
, dp
, v3
, &nfserr
) == 0)
1684 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1688 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1691 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1695 if (ndo
->ndo_vflag
) {
1696 ND_TCHECK_4(dp
+ 1);
1697 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1698 if (EXTRACT_BE_U_4(dp
+ 1))
1703 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0, &nfserr
) == 0)
1709 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1713 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1716 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1720 if (ndo
->ndo_vflag
) {
1722 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1723 if (ndo
->ndo_vflag
> 1) {
1724 ND_TCHECK_4(dp
+ 1);
1726 tok2str(nfsv3_writemodes
,
1727 NULL
, EXTRACT_BE_U_4(dp
+ 1)));
1729 /* write-verf-cookie */
1730 ND_TCHECK_8(dp
+ 2);
1731 ND_PRINT(" verf %" PRIx64
, EXTRACT_BE_U_8(dp
+ 2));
1737 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
, &nfserr
) == 0)
1742 case NFSPROC_CREATE
:
1744 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1748 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1751 if (parsediropres(ndo
, dp
, &nfserr
) == 0)
1756 case NFSPROC_SYMLINK
:
1757 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1761 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1764 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1770 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1773 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1777 case NFSPROC_REMOVE
:
1779 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1783 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1786 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1791 case NFSPROC_RENAME
:
1792 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1796 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1799 if (ndo
->ndo_vflag
) {
1801 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1805 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1810 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1816 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1820 dp
= parsestatus(ndo
, dp
, &er
, &nfserr
);
1823 if (ndo
->ndo_vflag
) {
1824 ND_PRINT(" file POST:");
1825 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1829 dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
);
1835 if (parsestatus(ndo
, dp
, &er
, &nfserr
) == NULL
)
1840 case NFSPROC_READDIR
:
1841 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1845 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1848 if (parserddires(ndo
, dp
, &nfserr
) == 0)
1853 case NFSPROC_READDIRPLUS
:
1854 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1857 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
) == NULL
)
1861 case NFSPROC_FSSTAT
:
1862 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1865 if (parsestatfs(ndo
, dp
, v3
, &nfserr
) == 0)
1869 case NFSPROC_FSINFO
:
1870 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1873 if (parsefsinfo(ndo
, dp
, &nfserr
) == 0)
1877 case NFSPROC_PATHCONF
:
1878 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1881 if (parsepathconf(ndo
, dp
, &nfserr
) == 0)
1885 case NFSPROC_COMMIT
:
1886 dp
= parserep(ndo
, rp
, length
, &nfserr
);
1889 dp
= parsewccres(ndo
, dp
, ndo
->ndo_vflag
, &nfserr
);
1892 if (ndo
->ndo_vflag
> 1) {
1893 /* write-verf-cookie */
1895 ND_PRINT(" verf %" PRIx64
, EXTRACT_BE_U_8(dp
));
1906 nd_print_trunc(ndo
);