]>
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
);
231 static const uint32_t *
232 parse_sattr3(netdissect_options
*ndo
,
233 const uint32_t *dp
, struct nfsv3_sattr
*sa3
)
236 sa3
->sa_modeset
= EXTRACT_BE_U_4(dp
);
238 if (sa3
->sa_modeset
) {
240 sa3
->sa_mode
= EXTRACT_BE_U_4(dp
);
245 sa3
->sa_uidset
= EXTRACT_BE_U_4(dp
);
247 if (sa3
->sa_uidset
) {
249 sa3
->sa_uid
= EXTRACT_BE_U_4(dp
);
254 sa3
->sa_gidset
= EXTRACT_BE_U_4(dp
);
256 if (sa3
->sa_gidset
) {
258 sa3
->sa_gid
= EXTRACT_BE_U_4(dp
);
263 sa3
->sa_sizeset
= EXTRACT_BE_U_4(dp
);
265 if (sa3
->sa_sizeset
) {
267 sa3
->sa_size
= EXTRACT_BE_U_4(dp
);
272 sa3
->sa_atimetype
= EXTRACT_BE_U_4(dp
);
274 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
) {
276 sa3
->sa_atime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
278 sa3
->sa_atime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
283 sa3
->sa_mtimetype
= EXTRACT_BE_U_4(dp
);
285 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
) {
287 sa3
->sa_mtime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
289 sa3
->sa_mtime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
298 static int nfserr
; /* true if we error rather than trunc */
301 print_sattr3(netdissect_options
*ndo
,
302 const struct nfsv3_sattr
*sa3
, int verbose
)
305 ND_PRINT(" mode %o", sa3
->sa_mode
);
307 ND_PRINT(" uid %u", sa3
->sa_uid
);
309 ND_PRINT(" gid %u", sa3
->sa_gid
);
311 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
)
312 ND_PRINT(" atime %u.%06u", sa3
->sa_atime
.nfsv3_sec
,
313 sa3
->sa_atime
.nfsv3_nsec
);
314 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
)
315 ND_PRINT(" mtime %u.%06u", sa3
->sa_mtime
.nfsv3_sec
,
316 sa3
->sa_mtime
.nfsv3_nsec
);
321 nfsreply_print(netdissect_options
*ndo
,
322 const u_char
*bp
, u_int length
,
325 const struct sunrpc_msg
*rp
;
326 char srcid
[20], dstid
[20]; /*fits 32bit*/
328 ndo
->ndo_protocol
= "nfs";
329 nfserr
= 0; /* assume no error */
330 rp
= (const struct sunrpc_msg
*)bp
;
332 ND_TCHECK_4(rp
->rm_xid
);
333 if (!ndo
->ndo_nflag
) {
334 strlcpy(srcid
, "nfs", sizeof(srcid
));
335 nd_snprintf(dstid
, sizeof(dstid
), "%u",
336 EXTRACT_BE_U_4(rp
->rm_xid
));
338 nd_snprintf(srcid
, sizeof(srcid
), "%u", NFS_PORT
);
339 nd_snprintf(dstid
, sizeof(dstid
), "%u",
340 EXTRACT_BE_U_4(rp
->rm_xid
));
342 print_nfsaddr(ndo
, bp2
, srcid
, dstid
);
344 nfsreply_noaddr_print(ndo
, bp
, length
, bp2
);
353 nfsreply_noaddr_print(netdissect_options
*ndo
,
354 const u_char
*bp
, u_int length
,
357 const struct sunrpc_msg
*rp
;
358 uint32_t proc
, vers
, reply_stat
;
359 enum sunrpc_reject_stat rstat
;
362 enum sunrpc_auth_stat rwhy
;
364 ndo
->ndo_protocol
= "nfs";
365 nfserr
= 0; /* assume no error */
366 rp
= (const struct sunrpc_msg
*)bp
;
368 ND_TCHECK_4(rp
->rm_reply
.rp_stat
);
369 reply_stat
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_stat
);
370 switch (reply_stat
) {
372 case SUNRPC_MSG_ACCEPTED
:
373 ND_PRINT("reply ok %u", length
);
374 if (xid_map_find(rp
, bp2
, &proc
, &vers
) >= 0)
375 interp_reply(ndo
, rp
, proc
, vers
, length
);
378 case SUNRPC_MSG_DENIED
:
379 ND_PRINT("reply ERR %u: ", length
);
380 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_stat
);
381 rstat
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_stat
);
384 case SUNRPC_RPC_MISMATCH
:
385 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_vers
.high
);
386 rlow
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.low
);
387 rhigh
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.high
);
388 ND_PRINT("RPC Version mismatch (%u-%u)", rlow
, rhigh
);
391 case SUNRPC_AUTH_ERROR
:
392 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_why
);
393 rwhy
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_why
);
394 ND_PRINT("Auth %s", tok2str(sunrpc_auth_str
, "Invalid failure code %u", rwhy
));
398 ND_PRINT("Unknown reason for rejecting rpc message %u", (unsigned int)rstat
);
404 ND_PRINT("reply Unknown rpc response code=%u %u", reply_stat
, length
);
415 * Return a pointer to the first file handle in the packet.
416 * If the packet was truncated, return 0.
418 static const uint32_t *
419 parsereq(netdissect_options
*ndo
,
420 const struct sunrpc_msg
*rp
, u_int length
)
426 * find the start of the req data (if we captured it)
428 dp
= (const uint32_t *)&rp
->rm_call
.cb_cred
;
430 len
= EXTRACT_BE_U_4(dp
+ 1);
432 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
434 len
= EXTRACT_BE_U_4(dp
+ 1);
436 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
437 ND_TCHECK_LEN(dp
, 0);
446 * Print out an NFS file handle and return a pointer to following word.
447 * If packet was truncated, return 0.
449 static const uint32_t *
450 parsefh(netdissect_options
*ndo
,
451 const uint32_t *dp
, int v3
)
457 len
= EXTRACT_BE_U_4(dp
) / 4;
462 if (ND_TTEST_LEN(dp
, len
* sizeof(*dp
))) {
463 nfs_printfh(ndo
, dp
, len
);
471 * Print out a file name and return pointer to 32-bit word past it.
472 * If packet was truncated, return 0.
474 static const uint32_t *
475 parsefn(netdissect_options
*ndo
,
481 /* Bail if we don't have the string length */
484 /* Fetch big-endian string length */
485 len
= EXTRACT_BE_U_4(dp
);
488 ND_TCHECK_LEN(dp
, ((len
+ 3) & ~3));
490 cp
= (const u_char
*)dp
;
491 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
492 dp
+= ((len
+ 3) & ~3) / sizeof(*dp
);
494 if (nd_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
506 * Print out file handle and file name.
507 * Return pointer to 32-bit word past file name.
508 * If packet was truncated (or there was some other error), return 0.
510 static const uint32_t *
511 parsefhn(netdissect_options
*ndo
,
512 const uint32_t *dp
, int v3
)
514 dp
= parsefh(ndo
, dp
, v3
);
518 return (parsefn(ndo
, dp
));
522 nfsreq_noaddr_print(netdissect_options
*ndo
,
523 const u_char
*bp
, u_int length
,
526 const struct sunrpc_msg
*rp
;
531 uint32_t access_flags
;
532 struct nfsv3_sattr sa3
;
534 ndo
->ndo_protocol
= "nfs";
535 ND_PRINT("%u", length
);
536 nfserr
= 0; /* assume no error */
537 rp
= (const struct sunrpc_msg
*)bp
;
539 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
542 v3
= (EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
543 proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
545 if (!v3
&& proc
< NFS_NPROCS
)
546 proc
= nfsv3_procid
[proc
];
548 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
551 case NFSPROC_GETATTR
:
552 case NFSPROC_SETATTR
:
553 case NFSPROC_READLINK
:
556 case NFSPROC_PATHCONF
:
557 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
558 parsefh(ndo
, dp
, v3
) != NULL
)
567 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
568 parsefhn(ndo
, dp
, v3
) != NULL
)
573 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
574 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
576 access_flags
= EXTRACT_BE_U_4(dp
);
577 if (access_flags
& ~NFSV3ACCESS_FULL
) {
578 /* NFSV3ACCESS definitions aren't up to date */
579 ND_PRINT(" %04x", access_flags
);
580 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
581 ND_PRINT(" NFS_ACCESS_FULL");
583 char separator
= ' ';
584 if (access_flags
& NFSV3ACCESS_READ
) {
585 ND_PRINT(" NFS_ACCESS_READ");
588 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
589 ND_PRINT("%cNFS_ACCESS_LOOKUP", separator
);
592 if (access_flags
& NFSV3ACCESS_MODIFY
) {
593 ND_PRINT("%cNFS_ACCESS_MODIFY", separator
);
596 if (access_flags
& NFSV3ACCESS_EXTEND
) {
597 ND_PRINT("%cNFS_ACCESS_EXTEND", separator
);
600 if (access_flags
& NFSV3ACCESS_DELETE
) {
601 ND_PRINT("%cNFS_ACCESS_DELETE", separator
);
604 if (access_flags
& NFSV3ACCESS_EXECUTE
)
605 ND_PRINT("%cNFS_ACCESS_EXECUTE", separator
);
612 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
613 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
616 ND_PRINT(" %u bytes @ %" PRIu64
,
617 EXTRACT_BE_U_4(dp
+ 2),
621 ND_PRINT(" %u bytes @ %u",
622 EXTRACT_BE_U_4(dp
+ 1),
630 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
631 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
634 ND_PRINT(" %u (%u) bytes @ %" PRIu64
,
635 EXTRACT_BE_U_4(dp
+ 4),
636 EXTRACT_BE_U_4(dp
+ 2),
638 if (ndo
->ndo_vflag
) {
640 tok2str(nfsv3_writemodes
,
641 NULL
, EXTRACT_BE_U_4(dp
+ 3)));
645 ND_PRINT(" %u (%u) bytes @ %u (%u)",
646 EXTRACT_BE_U_4(dp
+ 3),
647 EXTRACT_BE_U_4(dp
+ 2),
648 EXTRACT_BE_U_4(dp
+ 1),
655 case NFSPROC_SYMLINK
:
656 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
657 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
659 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
661 if (parsefn(ndo
, dp
) == NULL
)
663 if (v3
&& ndo
->ndo_vflag
)
664 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
670 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
671 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
673 type
= (nfs_type
) EXTRACT_BE_U_4(dp
);
675 if ((dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
677 ND_PRINT(" %s", tok2str(type2str
, "unk-ft %u", type
));
678 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
682 EXTRACT_BE_U_4(dp
+ 1));
686 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
692 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
693 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
695 if (parsefhn(ndo
, dp
, v3
) != NULL
)
701 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
702 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
704 if (parsefhn(ndo
, dp
, v3
) != NULL
)
709 case NFSPROC_READDIR
:
710 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
711 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
715 * We shouldn't really try to interpret the
716 * offset cookie here.
718 ND_PRINT(" %u bytes @ %" PRId64
,
719 EXTRACT_BE_U_4(dp
+ 4),
721 if (ndo
->ndo_vflag
) {
723 * This displays the 8 bytes
724 * of the verifier in order,
725 * from the low-order byte
726 * to the high-order byte.
728 ND_PRINT(" verf %08x%08x",
729 EXTRACT_BE_U_4(dp
+ 2),
730 EXTRACT_BE_U_4(dp
+ 3));
735 * Print the offset as signed, since -1 is
736 * common, but offsets > 2^31 aren't.
738 ND_PRINT(" %u bytes @ %u",
739 EXTRACT_BE_U_4(dp
+ 1),
746 case NFSPROC_READDIRPLUS
:
747 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
748 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
751 * We don't try to interpret the offset
754 ND_PRINT(" %u bytes @ %" PRId64
,
755 EXTRACT_BE_U_4(dp
+ 4),
757 if (ndo
->ndo_vflag
) {
760 * This displays the 8 bytes
761 * of the verifier in order,
762 * from the low-order byte
763 * to the high-order byte.
765 ND_PRINT(" max %u verf %08x%08x",
766 EXTRACT_BE_U_4(dp
+ 5),
767 EXTRACT_BE_U_4(dp
+ 2),
768 EXTRACT_BE_U_4(dp
+ 3));
775 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
776 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
778 ND_PRINT(" %u bytes @ %" PRIu64
,
779 EXTRACT_BE_U_4(dp
+ 2),
795 * Print out an NFS file handle.
796 * We assume packet was not truncated before the end of the
797 * file handle pointed to by dp.
799 * Note: new version (using portable file-handle parser) doesn't produce
800 * generation number. It probably could be made to do that, with some
801 * additional hacking on the parser code.
804 nfs_printfh(netdissect_options
*ndo
,
805 const uint32_t *dp
, const u_int len
)
809 const char *sfsname
= NULL
;
812 if (ndo
->ndo_uflag
) {
814 char const *sep
= "";
817 for (i
=0; i
<len
; i
++) {
819 * This displays 4 bytes in big-endian byte
820 * order. That's as good a choice as little-
821 * endian, as there's no guarantee that the
822 * server is big-endian or little-endian or
823 * that the file handle contains 4-byte
824 * integral fields, and is better than "the
825 * byte order of the host running tcpdump", as
826 * the latter means that different hosts
827 * running tcpdump may show the same file
828 * handle in different ways.
830 ND_PRINT("%s%x", sep
, EXTRACT_BE_U_4(dp
+ i
));
837 Parse_fh((const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
840 /* file system ID is ASCII, not numeric, for this server OS */
841 char temp
[NFSX_V3FHMAX
+1];
844 /* Make sure string is null-terminated */
846 if (stringlen
> NFSX_V3FHMAX
)
847 stringlen
= NFSX_V3FHMAX
;
848 strncpy(temp
, sfsname
, stringlen
);
849 temp
[stringlen
] = '\0';
850 /* Remove trailing spaces */
851 spacep
= strchr(temp
, ' ');
855 ND_PRINT(" fh %s/", temp
);
857 ND_PRINT(" fh %u,%u/",
858 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
);
861 if(fsid
.Fsid_dev
.Minor
== 257)
862 /* Print the undecoded handle */
863 ND_PRINT("%s", fsid
.Opaque_Handle
);
865 ND_PRINT("%ld", (long) ino
);
869 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
870 * us to match up replies with requests and thus to know how to parse
874 struct xid_map_entry
{
875 uint32_t xid
; /* transaction ID (net order) */
876 int ipver
; /* IP version (4 or 6) */
877 struct in6_addr client
; /* client IP address (net order) */
878 struct in6_addr server
; /* server IP address (net order) */
879 uint32_t proc
; /* call proc number (host order) */
880 uint32_t vers
; /* program version (host order) */
884 * Map entries are kept in an array that we manage as a ring;
885 * new entries are always added at the tail of the ring. Initially,
886 * all the entries are zero and hence don't match anything.
889 #define XIDMAPSIZE 64
891 static struct xid_map_entry xid_map
[XIDMAPSIZE
];
893 static int xid_map_next
= 0;
894 static int xid_map_hint
= 0;
897 xid_map_enter(netdissect_options
*ndo
,
898 const struct sunrpc_msg
*rp
, const u_char
*bp
)
900 const struct ip
*ip
= NULL
;
901 const struct ip6_hdr
*ip6
= NULL
;
902 struct xid_map_entry
*xmep
;
904 if (!ND_TTEST_4(rp
->rm_call
.cb_proc
))
906 switch (IP_V((const struct ip
*)bp
)) {
908 ip
= (const struct ip
*)bp
;
911 ip6
= (const struct ip6_hdr
*)bp
;
917 xmep
= &xid_map
[xid_map_next
];
919 if (++xid_map_next
>= XIDMAPSIZE
)
922 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
925 UNALIGNED_MEMCPY(&xmep
->client
, ip
->ip_src
,
927 UNALIGNED_MEMCPY(&xmep
->server
, ip
->ip_dst
,
932 UNALIGNED_MEMCPY(&xmep
->client
, ip6
->ip6_src
,
933 sizeof(ip6
->ip6_src
));
934 UNALIGNED_MEMCPY(&xmep
->server
, ip6
->ip6_dst
,
935 sizeof(ip6
->ip6_dst
));
937 xmep
->proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
938 xmep
->vers
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
);
943 * Returns 0 and puts NFSPROC_xxx in proc return and
944 * version in vers return, or returns -1 on failure
947 xid_map_find(const struct sunrpc_msg
*rp
, const u_char
*bp
, uint32_t *proc
,
951 struct xid_map_entry
*xmep
;
953 const struct ip
*ip
= (const struct ip
*)bp
;
954 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
957 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
958 /* Start searching from where we last left off */
963 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
965 switch (xmep
->ipver
) {
967 if (UNALIGNED_MEMCMP(ip
->ip_src
, &xmep
->server
,
968 sizeof(ip
->ip_src
)) != 0 ||
969 UNALIGNED_MEMCMP(ip
->ip_dst
, &xmep
->client
,
970 sizeof(ip
->ip_dst
)) != 0) {
975 if (UNALIGNED_MEMCMP(ip6
->ip6_src
, &xmep
->server
,
976 sizeof(ip6
->ip6_src
)) != 0 ||
977 UNALIGNED_MEMCMP(ip6
->ip6_dst
, &xmep
->client
,
978 sizeof(ip6
->ip6_dst
)) != 0) {
994 if (++i
>= XIDMAPSIZE
)
996 } while (i
!= xid_map_hint
);
1003 * Routines for parsing reply packets
1007 * Return a pointer to the beginning of the actual results.
1008 * If the packet was truncated, return 0.
1010 static const uint32_t *
1011 parserep(netdissect_options
*ndo
,
1012 const struct sunrpc_msg
*rp
, u_int length
)
1016 enum sunrpc_accept_stat astat
;
1020 * Here we find the address of the ar_verf credentials.
1021 * Originally, this calculation was
1022 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
1023 * On the wire, the rp_acpt field starts immediately after
1024 * the (32 bit) rp_stat field. However, rp_acpt (which is a
1025 * "struct accepted_reply") contains a "struct opaque_auth",
1026 * whose internal representation contains a pointer, so on a
1027 * 64-bit machine the compiler inserts 32 bits of padding
1028 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
1029 * the internal representation to parse the on-the-wire
1030 * representation. Instead, we skip past the rp_stat field,
1031 * which is an "enum" and so occupies one 32-bit word.
1033 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
1034 ND_TCHECK_4(dp
+ 1);
1035 len
= EXTRACT_BE_U_4(dp
+ 1);
1039 * skip past the ar_verf credentials.
1041 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1044 * now we can check the ar_stat field
1047 astat
= (enum sunrpc_accept_stat
) EXTRACT_BE_U_4(dp
);
1048 if (astat
!= SUNRPC_SUCCESS
) {
1049 ND_PRINT(" %s", tok2str(sunrpc_str
, "ar_stat %u", astat
));
1050 nfserr
= 1; /* suppress trunc string */
1053 /* successful return */
1054 ND_TCHECK_LEN(dp
, sizeof(astat
));
1055 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1060 static const uint32_t *
1061 parsestatus(netdissect_options
*ndo
,
1062 const uint32_t *dp
, u_int
*er
)
1068 errnum
= EXTRACT_BE_U_4(dp
);
1072 if (!ndo
->ndo_qflag
)
1073 ND_PRINT(" ERROR: %s",
1074 tok2str(status2str
, "unk %u", errnum
));
1082 static const uint32_t *
1083 parsefattr(netdissect_options
*ndo
,
1084 const uint32_t *dp
, int verbose
, int v3
)
1086 const struct nfs_fattr
*fap
;
1088 fap
= (const struct nfs_fattr
*)dp
;
1089 ND_TCHECK_4(&fap
->fa_gid
);
1092 * XXX - UIDs and GIDs are unsigned in NFS and in
1093 * at least some UN*Xes, but we'll show them as
1094 * signed because -2 has traditionally been the
1095 * UID for "nobody", rather than 4294967294.
1097 ND_PRINT(" %s %o ids %d/%d",
1098 tok2str(type2str
, "unk-ft %u ",
1099 EXTRACT_BE_U_4(&fap
->fa_type
)),
1100 EXTRACT_BE_U_4(&fap
->fa_mode
),
1101 EXTRACT_BE_S_4(&fap
->fa_uid
),
1102 EXTRACT_BE_S_4(&fap
->fa_gid
));
1104 ND_TCHECK_8(&fap
->fa3_size
);
1105 ND_PRINT(" sz %" PRIu64
,
1106 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_size
));
1108 ND_TCHECK_4(&fap
->fa2_size
);
1109 ND_PRINT(" sz %u", EXTRACT_BE_U_4(&fap
->fa2_size
));
1112 /* print lots more stuff */
1115 ND_TCHECK_8(&fap
->fa3_ctime
);
1116 ND_PRINT(" nlink %u rdev %u/%u",
1117 EXTRACT_BE_U_4(&fap
->fa_nlink
),
1118 EXTRACT_BE_U_4(&fap
->fa3_rdev
.specdata1
),
1119 EXTRACT_BE_U_4(&fap
->fa3_rdev
.specdata2
));
1120 ND_PRINT(" fsid %" PRIx64
,
1121 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_fsid
));
1122 ND_PRINT(" fileid %" PRIx64
,
1123 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_fileid
));
1124 ND_PRINT(" a/m/ctime %u.%06u",
1125 EXTRACT_BE_U_4(&fap
->fa3_atime
.nfsv3_sec
),
1126 EXTRACT_BE_U_4(&fap
->fa3_atime
.nfsv3_nsec
));
1127 ND_PRINT(" %u.%06u",
1128 EXTRACT_BE_U_4(&fap
->fa3_mtime
.nfsv3_sec
),
1129 EXTRACT_BE_U_4(&fap
->fa3_mtime
.nfsv3_nsec
));
1130 ND_PRINT(" %u.%06u",
1131 EXTRACT_BE_U_4(&fap
->fa3_ctime
.nfsv3_sec
),
1132 EXTRACT_BE_U_4(&fap
->fa3_ctime
.nfsv3_nsec
));
1134 ND_TCHECK_8(&fap
->fa2_ctime
);
1135 ND_PRINT(" nlink %u rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1136 EXTRACT_BE_U_4(&fap
->fa_nlink
),
1137 EXTRACT_BE_U_4(&fap
->fa2_rdev
),
1138 EXTRACT_BE_U_4(&fap
->fa2_fsid
),
1139 EXTRACT_BE_U_4(&fap
->fa2_fileid
));
1140 ND_PRINT(" %u.%06u",
1141 EXTRACT_BE_U_4(&fap
->fa2_atime
.nfsv2_sec
),
1142 EXTRACT_BE_U_4(&fap
->fa2_atime
.nfsv2_usec
));
1143 ND_PRINT(" %u.%06u",
1144 EXTRACT_BE_U_4(&fap
->fa2_mtime
.nfsv2_sec
),
1145 EXTRACT_BE_U_4(&fap
->fa2_mtime
.nfsv2_usec
));
1146 ND_PRINT(" %u.%06u",
1147 EXTRACT_BE_U_4(&fap
->fa2_ctime
.nfsv2_sec
),
1148 EXTRACT_BE_U_4(&fap
->fa2_ctime
.nfsv2_usec
));
1151 return ((const uint32_t *)((const unsigned char *)dp
+
1152 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1158 parseattrstat(netdissect_options
*ndo
,
1159 const uint32_t *dp
, int verbose
, int v3
)
1163 dp
= parsestatus(ndo
, dp
, &er
);
1169 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1173 parsediropres(netdissect_options
*ndo
,
1178 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1183 dp
= parsefh(ndo
, dp
, 0);
1187 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1191 parselinkres(netdissect_options
*ndo
,
1192 const uint32_t *dp
, int v3
)
1196 dp
= parsestatus(ndo
, dp
, &er
);
1201 if (v3
&& !(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1204 return (parsefn(ndo
, dp
) != NULL
);
1208 parsestatfs(netdissect_options
*ndo
,
1209 const uint32_t *dp
, int v3
)
1211 const struct nfs_statfs
*sfsp
;
1214 dp
= parsestatus(ndo
, dp
, &er
);
1226 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1230 ND_TCHECK_LEN(dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1232 sfsp
= (const struct nfs_statfs
*)dp
;
1235 ND_PRINT(" tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1236 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_tbytes
),
1237 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_fbytes
),
1238 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_abytes
));
1239 if (ndo
->ndo_vflag
) {
1240 ND_PRINT(" tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1241 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_tfiles
),
1242 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_ffiles
),
1243 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_afiles
),
1244 EXTRACT_BE_U_4(&sfsp
->sf_invarsec
));
1247 ND_PRINT(" tsize %u bsize %u blocks %u bfree %u bavail %u",
1248 EXTRACT_BE_U_4(&sfsp
->sf_tsize
),
1249 EXTRACT_BE_U_4(&sfsp
->sf_bsize
),
1250 EXTRACT_BE_U_4(&sfsp
->sf_blocks
),
1251 EXTRACT_BE_U_4(&sfsp
->sf_bfree
),
1252 EXTRACT_BE_U_4(&sfsp
->sf_bavail
));
1261 parserddires(netdissect_options
*ndo
,
1266 dp
= parsestatus(ndo
, dp
, &er
);
1274 ND_TCHECK_4(dp
+ 2);
1275 ND_PRINT(" offset 0x%x size %u ",
1276 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1277 if (EXTRACT_BE_U_4(dp
+ 2) != 0)
1285 static const uint32_t *
1286 parse_wcc_attr(netdissect_options
*ndo
,
1289 /* Our caller has already checked this */
1290 ND_PRINT(" sz %" PRIu64
, EXTRACT_BE_U_8(dp
));
1291 ND_PRINT(" mtime %u.%06u ctime %u.%06u",
1292 EXTRACT_BE_U_4(dp
+ 2), EXTRACT_BE_U_4(dp
+ 3),
1293 EXTRACT_BE_U_4(dp
+ 4), EXTRACT_BE_U_4(dp
+ 5));
1298 * Pre operation attributes. Print only if vflag > 1.
1300 static const uint32_t *
1301 parse_pre_op_attr(netdissect_options
*ndo
,
1302 const uint32_t *dp
, int verbose
)
1305 if (!EXTRACT_BE_U_4(dp
))
1308 ND_TCHECK_LEN(dp
, 24);
1310 return parse_wcc_attr(ndo
, dp
);
1312 /* If not verbose enough, just skip over wcc_attr */
1320 * Post operation attributes are printed if vflag >= 1
1322 static const uint32_t *
1323 parse_post_op_attr(netdissect_options
*ndo
,
1324 const uint32_t *dp
, int verbose
)
1327 if (!EXTRACT_BE_U_4(dp
))
1331 return parsefattr(ndo
, dp
, verbose
, 1);
1333 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1338 static const uint32_t *
1339 parse_wcc_data(netdissect_options
*ndo
,
1340 const uint32_t *dp
, int verbose
)
1344 if (!(dp
= parse_pre_op_attr(ndo
, dp
, verbose
)))
1349 return parse_post_op_attr(ndo
, dp
, verbose
);
1352 static const uint32_t *
1353 parsecreateopres(netdissect_options
*ndo
,
1354 const uint32_t *dp
, int verbose
)
1358 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1361 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1364 if (!EXTRACT_BE_U_4(dp
))
1367 if (!(dp
= parsefh(ndo
, dp
, 1)))
1370 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1372 if (ndo
->ndo_vflag
> 1) {
1373 ND_PRINT(" dir attr:");
1374 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1384 parsewccres(netdissect_options
*ndo
,
1385 const uint32_t *dp
, int verbose
)
1389 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1391 return parse_wcc_data(ndo
, dp
, verbose
) != NULL
;
1394 static const uint32_t *
1395 parsev3rddirres(netdissect_options
*ndo
,
1396 const uint32_t *dp
, int verbose
)
1400 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1404 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1408 if (ndo
->ndo_vflag
) {
1409 ND_TCHECK_4(dp
+ 1);
1411 * This displays the 8 bytes of the verifier in order,
1412 * from the low-order byte to the high-order byte.
1414 ND_PRINT(" verf %08x%08x",
1415 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1424 parsefsinfo(netdissect_options
*ndo
,
1427 const struct nfsv3_fsinfo
*sfp
;
1430 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1434 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1439 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1440 ND_TCHECK_SIZE(sfp
);
1441 ND_PRINT(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1442 EXTRACT_BE_U_4(&sfp
->fs_rtmax
),
1443 EXTRACT_BE_U_4(&sfp
->fs_rtpref
),
1444 EXTRACT_BE_U_4(&sfp
->fs_wtmax
),
1445 EXTRACT_BE_U_4(&sfp
->fs_wtpref
),
1446 EXTRACT_BE_U_4(&sfp
->fs_dtpref
));
1447 if (ndo
->ndo_vflag
) {
1448 ND_PRINT(" rtmult %u wtmult %u maxfsz %" PRIu64
,
1449 EXTRACT_BE_U_4(&sfp
->fs_rtmult
),
1450 EXTRACT_BE_U_4(&sfp
->fs_wtmult
),
1451 EXTRACT_BE_U_8((const uint32_t *)&sfp
->fs_maxfilesize
));
1452 ND_PRINT(" delta %u.%06u ",
1453 EXTRACT_BE_U_4(&sfp
->fs_timedelta
.nfsv3_sec
),
1454 EXTRACT_BE_U_4(&sfp
->fs_timedelta
.nfsv3_nsec
));
1462 parsepathconf(netdissect_options
*ndo
,
1466 const struct nfsv3_pathconf
*spp
;
1468 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1472 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1477 spp
= (const struct nfsv3_pathconf
*)dp
;
1478 ND_TCHECK_SIZE(spp
);
1480 ND_PRINT(" linkmax %u namemax %u %s %s %s %s",
1481 EXTRACT_BE_U_4(&spp
->pc_linkmax
),
1482 EXTRACT_BE_U_4(&spp
->pc_namemax
),
1483 EXTRACT_BE_U_4(&spp
->pc_notrunc
) ? "notrunc" : "",
1484 EXTRACT_BE_U_4(&spp
->pc_chownrestricted
) ? "chownres" : "",
1485 EXTRACT_BE_U_4(&spp
->pc_caseinsensitive
) ? "igncase" : "",
1486 EXTRACT_BE_U_4(&spp
->pc_casepreserving
) ? "keepcase" : "");
1493 interp_reply(netdissect_options
*ndo
,
1494 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
, int length
)
1500 v3
= (vers
== NFS_VER3
);
1502 if (!v3
&& proc
< NFS_NPROCS
)
1503 proc
= nfsv3_procid
[proc
];
1505 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
1508 case NFSPROC_GETATTR
:
1509 dp
= parserep(ndo
, rp
, length
);
1510 if (dp
!= NULL
&& parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
) != 0)
1514 case NFSPROC_SETATTR
:
1515 if (!(dp
= parserep(ndo
, rp
, length
)))
1518 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1521 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0) != 0)
1526 case NFSPROC_LOOKUP
:
1527 if (!(dp
= parserep(ndo
, rp
, length
)))
1530 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1533 if (ndo
->ndo_vflag
> 1) {
1534 ND_PRINT(" post dattr:");
1535 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1538 if (!(dp
= parsefh(ndo
, dp
, v3
)))
1540 if ((dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)) &&
1541 ndo
->ndo_vflag
> 1) {
1542 ND_PRINT(" post dattr:");
1543 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1549 if (parsediropres(ndo
, dp
) != 0)
1554 case NFSPROC_ACCESS
:
1555 if (!(dp
= parserep(ndo
, rp
, length
)))
1557 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1561 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1565 ND_PRINT(" c %04x", EXTRACT_BE_U_4(dp
));
1569 case NFSPROC_READLINK
:
1570 dp
= parserep(ndo
, rp
, length
);
1571 if (dp
!= NULL
&& parselinkres(ndo
, dp
, v3
) != 0)
1576 if (!(dp
= parserep(ndo
, rp
, length
)))
1579 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1581 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1585 if (ndo
->ndo_vflag
) {
1586 ND_TCHECK_4(dp
+ 1);
1587 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1588 if (EXTRACT_BE_U_4(dp
+ 1))
1593 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0) != 0)
1599 if (!(dp
= parserep(ndo
, rp
, length
)))
1602 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1604 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1608 if (ndo
->ndo_vflag
) {
1610 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1611 if (ndo
->ndo_vflag
> 1) {
1612 ND_TCHECK_4(dp
+ 1);
1614 tok2str(nfsv3_writemodes
,
1615 NULL
, EXTRACT_BE_U_4(dp
+ 1)));
1620 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
) != 0)
1625 case NFSPROC_CREATE
:
1627 if (!(dp
= parserep(ndo
, rp
, length
)))
1630 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1633 if (parsediropres(ndo
, dp
) != 0)
1638 case NFSPROC_SYMLINK
:
1639 if (!(dp
= parserep(ndo
, rp
, length
)))
1642 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1645 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1651 if (!(dp
= parserep(ndo
, rp
, length
)))
1653 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1657 case NFSPROC_REMOVE
:
1659 if (!(dp
= parserep(ndo
, rp
, length
)))
1662 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1665 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1670 case NFSPROC_RENAME
:
1671 if (!(dp
= parserep(ndo
, rp
, length
)))
1674 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1676 if (ndo
->ndo_vflag
) {
1678 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1681 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1686 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1692 if (!(dp
= parserep(ndo
, rp
, length
)))
1695 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1697 if (ndo
->ndo_vflag
) {
1698 ND_PRINT(" file POST:");
1699 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1702 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1707 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1712 case NFSPROC_READDIR
:
1713 if (!(dp
= parserep(ndo
, rp
, length
)))
1716 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1719 if (parserddires(ndo
, dp
) != 0)
1724 case NFSPROC_READDIRPLUS
:
1725 if (!(dp
= parserep(ndo
, rp
, length
)))
1727 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1731 case NFSPROC_FSSTAT
:
1732 dp
= parserep(ndo
, rp
, length
);
1733 if (dp
!= NULL
&& parsestatfs(ndo
, dp
, v3
) != 0)
1737 case NFSPROC_FSINFO
:
1738 dp
= parserep(ndo
, rp
, length
);
1739 if (dp
!= NULL
&& parsefsinfo(ndo
, dp
) != 0)
1743 case NFSPROC_PATHCONF
:
1744 dp
= parserep(ndo
, rp
, length
);
1745 if (dp
!= NULL
&& parsepathconf(ndo
, dp
) != 0)
1749 case NFSPROC_COMMIT
:
1750 dp
= parserep(ndo
, rp
, length
);
1751 if (dp
!= NULL
&& parsewccres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1760 nd_print_trunc(ndo
);