]>
The Tcpdump Group git mirrors - tcpdump/blob - print-nfs.c
6866b1d39cb650dd9867ba2c45810daec5ba97a1
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 /* \summary: Network File System (NFS) printer */
28 #include "netdissect-stdinc.h"
33 #include "netdissect.h"
34 #include "addrtoname.h"
45 static const char tstr
[] = " [|nfs]";
47 static void nfs_printfh(netdissect_options
*, const uint32_t *, const u_int
);
48 static int xid_map_enter(netdissect_options
*, const struct sunrpc_msg
*, const u_char
*);
49 static int xid_map_find(const struct sunrpc_msg
*, const u_char
*,
50 uint32_t *, uint32_t *);
51 static void interp_reply(netdissect_options
*, const struct sunrpc_msg
*, uint32_t, uint32_t, int);
52 static const uint32_t *parse_post_op_attr(netdissect_options
*, const uint32_t *, int);
55 * Mapping of old NFS Version 2 RPC numbers to generic numbers.
57 static uint32_t nfsv3_procid
[NFS_NPROCS
] = {
86 static const struct tok nfsproc_str
[] = {
87 { NFSPROC_NOOP
, "nop" },
88 { NFSPROC_NULL
, "null" },
89 { NFSPROC_GETATTR
, "getattr" },
90 { NFSPROC_SETATTR
, "setattr" },
91 { NFSPROC_LOOKUP
, "lookup" },
92 { NFSPROC_ACCESS
, "access" },
93 { NFSPROC_READLINK
, "readlink" },
94 { NFSPROC_READ
, "read" },
95 { NFSPROC_WRITE
, "write" },
96 { NFSPROC_CREATE
, "create" },
97 { NFSPROC_MKDIR
, "mkdir" },
98 { NFSPROC_SYMLINK
, "symlink" },
99 { NFSPROC_MKNOD
, "mknod" },
100 { NFSPROC_REMOVE
, "remove" },
101 { NFSPROC_RMDIR
, "rmdir" },
102 { NFSPROC_RENAME
, "rename" },
103 { NFSPROC_LINK
, "link" },
104 { NFSPROC_READDIR
, "readdir" },
105 { NFSPROC_READDIRPLUS
, "readdirplus" },
106 { NFSPROC_FSSTAT
, "fsstat" },
107 { NFSPROC_FSINFO
, "fsinfo" },
108 { NFSPROC_PATHCONF
, "pathconf" },
109 { NFSPROC_COMMIT
, "commit" },
114 * NFS V2 and V3 status values.
116 * Some of these come from the RFCs for NFS V2 and V3, with the message
117 * strings taken from the FreeBSD C library "errlst.c".
119 * Others are errors that are not in the RFC but that I suspect some
120 * NFS servers could return; the values are FreeBSD errno values, as
121 * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
122 * was primarily BSD-derived.
124 static const struct tok status2str
[] = {
125 { 1, "Operation not permitted" }, /* EPERM */
126 { 2, "No such file or directory" }, /* ENOENT */
127 { 5, "Input/output error" }, /* EIO */
128 { 6, "Device not configured" }, /* ENXIO */
129 { 11, "Resource deadlock avoided" }, /* EDEADLK */
130 { 12, "Cannot allocate memory" }, /* ENOMEM */
131 { 13, "Permission denied" }, /* EACCES */
132 { 17, "File exists" }, /* EEXIST */
133 { 18, "Cross-device link" }, /* EXDEV */
134 { 19, "Operation not supported by device" }, /* ENODEV */
135 { 20, "Not a directory" }, /* ENOTDIR */
136 { 21, "Is a directory" }, /* EISDIR */
137 { 22, "Invalid argument" }, /* EINVAL */
138 { 26, "Text file busy" }, /* ETXTBSY */
139 { 27, "File too large" }, /* EFBIG */
140 { 28, "No space left on device" }, /* ENOSPC */
141 { 30, "Read-only file system" }, /* EROFS */
142 { 31, "Too many links" }, /* EMLINK */
143 { 45, "Operation not supported" }, /* EOPNOTSUPP */
144 { 62, "Too many levels of symbolic links" }, /* ELOOP */
145 { 63, "File name too long" }, /* ENAMETOOLONG */
146 { 66, "Directory not empty" }, /* ENOTEMPTY */
147 { 69, "Disc quota exceeded" }, /* EDQUOT */
148 { 70, "Stale NFS file handle" }, /* ESTALE */
149 { 71, "Too many levels of remote in path" }, /* EREMOTE */
150 { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */
151 { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */
152 { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */
153 { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */
154 { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */
155 { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */
156 { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */
157 { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */
158 { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */
162 static const struct tok nfsv3_writemodes
[] = {
169 static const struct tok type2str
[] = {
180 static const struct tok sunrpc_auth_str
[] = {
181 { SUNRPC_AUTH_OK
, "OK" },
182 { SUNRPC_AUTH_BADCRED
, "Bogus Credentials (seal broken)" },
183 { SUNRPC_AUTH_REJECTEDCRED
, "Rejected Credentials (client should begin new session)" },
184 { SUNRPC_AUTH_BADVERF
, "Bogus Verifier (seal broken)" },
185 { SUNRPC_AUTH_REJECTEDVERF
, "Verifier expired or was replayed" },
186 { SUNRPC_AUTH_TOOWEAK
, "Credentials are too weak" },
187 { SUNRPC_AUTH_INVALIDRESP
, "Bogus response verifier" },
188 { SUNRPC_AUTH_FAILED
, "Unknown failure" },
192 static const struct tok sunrpc_str
[] = {
193 { SUNRPC_PROG_UNAVAIL
, "PROG_UNAVAIL" },
194 { SUNRPC_PROG_MISMATCH
, "PROG_MISMATCH" },
195 { SUNRPC_PROC_UNAVAIL
, "PROC_UNAVAIL" },
196 { SUNRPC_GARBAGE_ARGS
, "GARBAGE_ARGS" },
197 { SUNRPC_SYSTEM_ERR
, "SYSTEM_ERR" },
202 print_nfsaddr(netdissect_options
*ndo
,
203 const u_char
*bp
, const char *s
, const char *d
)
206 const struct ip6_hdr
*ip6
;
207 char srcaddr
[INET6_ADDRSTRLEN
], dstaddr
[INET6_ADDRSTRLEN
];
209 srcaddr
[0] = dstaddr
[0] = '\0';
210 switch (IP_V((const struct ip
*)bp
)) {
212 ip
= (const struct ip
*)bp
;
213 strlcpy(srcaddr
, ipaddr_string(ndo
, ip
->ip_src
), sizeof(srcaddr
));
214 strlcpy(dstaddr
, ipaddr_string(ndo
, ip
->ip_dst
), sizeof(dstaddr
));
217 ip6
= (const struct ip6_hdr
*)bp
;
218 strlcpy(srcaddr
, ip6addr_string(ndo
, ip6
->ip6_src
),
220 strlcpy(dstaddr
, ip6addr_string(ndo
, ip6
->ip6_dst
),
224 strlcpy(srcaddr
, "?", sizeof(srcaddr
));
225 strlcpy(dstaddr
, "?", sizeof(dstaddr
));
229 ND_PRINT("%s.%s > %s.%s: ", srcaddr
, s
, dstaddr
, d
);
232 static const uint32_t *
233 parse_sattr3(netdissect_options
*ndo
,
234 const uint32_t *dp
, struct nfsv3_sattr
*sa3
)
237 sa3
->sa_modeset
= EXTRACT_BE_U_4(dp
);
239 if (sa3
->sa_modeset
) {
241 sa3
->sa_mode
= EXTRACT_BE_U_4(dp
);
246 sa3
->sa_uidset
= EXTRACT_BE_U_4(dp
);
248 if (sa3
->sa_uidset
) {
250 sa3
->sa_uid
= EXTRACT_BE_U_4(dp
);
255 sa3
->sa_gidset
= EXTRACT_BE_U_4(dp
);
257 if (sa3
->sa_gidset
) {
259 sa3
->sa_gid
= EXTRACT_BE_U_4(dp
);
264 sa3
->sa_sizeset
= EXTRACT_BE_U_4(dp
);
266 if (sa3
->sa_sizeset
) {
268 sa3
->sa_size
= EXTRACT_BE_U_4(dp
);
273 sa3
->sa_atimetype
= EXTRACT_BE_U_4(dp
);
275 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
) {
277 sa3
->sa_atime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
279 sa3
->sa_atime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
284 sa3
->sa_mtimetype
= EXTRACT_BE_U_4(dp
);
286 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
) {
288 sa3
->sa_mtime
.nfsv3_sec
= EXTRACT_BE_U_4(dp
);
290 sa3
->sa_mtime
.nfsv3_nsec
= EXTRACT_BE_U_4(dp
);
299 static int nfserr
; /* true if we error rather than trunc */
302 print_sattr3(netdissect_options
*ndo
,
303 const struct nfsv3_sattr
*sa3
, int verbose
)
306 ND_PRINT(" mode %o", sa3
->sa_mode
);
308 ND_PRINT(" uid %u", sa3
->sa_uid
);
310 ND_PRINT(" gid %u", sa3
->sa_gid
);
312 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
)
313 ND_PRINT(" atime %u.%06u", sa3
->sa_atime
.nfsv3_sec
,
314 sa3
->sa_atime
.nfsv3_nsec
);
315 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
)
316 ND_PRINT(" mtime %u.%06u", sa3
->sa_mtime
.nfsv3_sec
,
317 sa3
->sa_mtime
.nfsv3_nsec
);
322 nfsreply_print(netdissect_options
*ndo
,
323 const u_char
*bp
, u_int length
,
326 const struct sunrpc_msg
*rp
;
327 char srcid
[20], dstid
[20]; /*fits 32bit*/
329 ndo
->ndo_protocol
= "nfsreply";
330 nfserr
= 0; /* assume no error */
331 rp
= (const struct sunrpc_msg
*)bp
;
333 ND_TCHECK_4(rp
->rm_xid
);
334 if (!ndo
->ndo_nflag
) {
335 strlcpy(srcid
, "nfs", sizeof(srcid
));
336 nd_snprintf(dstid
, sizeof(dstid
), "%u",
337 EXTRACT_BE_U_4(rp
->rm_xid
));
339 nd_snprintf(srcid
, sizeof(srcid
), "%u", NFS_PORT
);
340 nd_snprintf(dstid
, sizeof(dstid
), "%u",
341 EXTRACT_BE_U_4(rp
->rm_xid
));
343 print_nfsaddr(ndo
, bp2
, srcid
, dstid
);
345 nfsreply_noaddr_print(ndo
, bp
, length
, bp2
);
350 ND_PRINT("%s", tstr
);
354 nfsreply_noaddr_print(netdissect_options
*ndo
,
355 const u_char
*bp
, u_int length
,
358 const struct sunrpc_msg
*rp
;
359 uint32_t proc
, vers
, reply_stat
;
360 enum sunrpc_reject_stat rstat
;
363 enum sunrpc_auth_stat rwhy
;
365 ndo
->ndo_protocol
= "nfsreply_noaddr";
366 nfserr
= 0; /* assume no error */
367 rp
= (const struct sunrpc_msg
*)bp
;
369 ND_TCHECK_4(rp
->rm_reply
.rp_stat
);
370 reply_stat
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_stat
);
371 switch (reply_stat
) {
373 case SUNRPC_MSG_ACCEPTED
:
374 ND_PRINT("reply ok %u", length
);
375 if (xid_map_find(rp
, bp2
, &proc
, &vers
) >= 0)
376 interp_reply(ndo
, rp
, proc
, vers
, length
);
379 case SUNRPC_MSG_DENIED
:
380 ND_PRINT("reply ERR %u: ", length
);
381 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_stat
);
382 rstat
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_stat
);
385 case SUNRPC_RPC_MISMATCH
:
386 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_vers
.high
);
387 rlow
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.low
);
388 rhigh
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_vers
.high
);
389 ND_PRINT("RPC Version mismatch (%u-%u)", rlow
, rhigh
);
392 case SUNRPC_AUTH_ERROR
:
393 ND_TCHECK_4(rp
->rm_reply
.rp_reject
.rj_why
);
394 rwhy
= EXTRACT_BE_U_4(&rp
->rm_reply
.rp_reject
.rj_why
);
395 ND_PRINT("Auth %s", tok2str(sunrpc_auth_str
, "Invalid failure code %u", rwhy
));
399 ND_PRINT("Unknown reason for rejecting rpc message %u", (unsigned int)rstat
);
405 ND_PRINT("reply Unknown rpc response code=%u %u", reply_stat
, length
);
412 ND_PRINT("%s", tstr
);
416 * Return a pointer to the first file handle in the packet.
417 * If the packet was truncated, return 0.
419 static const uint32_t *
420 parsereq(netdissect_options
*ndo
,
421 const struct sunrpc_msg
*rp
, u_int length
)
427 * find the start of the req data (if we captured it)
429 dp
= (const uint32_t *)&rp
->rm_call
.cb_cred
;
431 len
= EXTRACT_BE_U_4(dp
+ 1);
433 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
435 len
= EXTRACT_BE_U_4(dp
+ 1);
437 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
438 ND_TCHECK_LEN(dp
, 0);
447 * Print out an NFS file handle and return a pointer to following word.
448 * If packet was truncated, return 0.
450 static const uint32_t *
451 parsefh(netdissect_options
*ndo
,
452 const uint32_t *dp
, int v3
)
458 len
= EXTRACT_BE_U_4(dp
) / 4;
463 if (ND_TTEST_LEN(dp
, len
* sizeof(*dp
))) {
464 nfs_printfh(ndo
, dp
, len
);
472 * Print out a file name and return pointer to 32-bit word past it.
473 * If packet was truncated, return 0.
475 static const uint32_t *
476 parsefn(netdissect_options
*ndo
,
482 /* Bail if we don't have the string length */
485 /* Fetch big-endian string length */
486 len
= EXTRACT_BE_U_4(dp
);
489 ND_TCHECK_LEN(dp
, ((len
+ 3) & ~3));
491 cp
= (const u_char
*)dp
;
492 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
493 dp
+= ((len
+ 3) & ~3) / sizeof(*dp
);
495 if (fn_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
507 * Print out file handle and file name.
508 * Return pointer to 32-bit word past file name.
509 * If packet was truncated (or there was some other error), return 0.
511 static const uint32_t *
512 parsefhn(netdissect_options
*ndo
,
513 const uint32_t *dp
, int v3
)
515 dp
= parsefh(ndo
, dp
, v3
);
519 return (parsefn(ndo
, dp
));
523 nfsreq_noaddr_print(netdissect_options
*ndo
,
524 const u_char
*bp
, u_int length
,
527 const struct sunrpc_msg
*rp
;
532 uint32_t access_flags
;
533 struct nfsv3_sattr sa3
;
535 ndo
->ndo_protocol
= "nfsreq_noaddr";
536 ND_PRINT("%u", length
);
537 nfserr
= 0; /* assume no error */
538 rp
= (const struct sunrpc_msg
*)bp
;
540 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
543 v3
= (EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
544 proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
546 if (!v3
&& proc
< NFS_NPROCS
)
547 proc
= nfsv3_procid
[proc
];
549 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
552 case NFSPROC_GETATTR
:
553 case NFSPROC_SETATTR
:
554 case NFSPROC_READLINK
:
557 case NFSPROC_PATHCONF
:
558 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
559 parsefh(ndo
, dp
, v3
) != NULL
)
568 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
569 parsefhn(ndo
, dp
, v3
) != NULL
)
574 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
575 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
577 access_flags
= EXTRACT_BE_U_4(dp
);
578 if (access_flags
& ~NFSV3ACCESS_FULL
) {
579 /* NFSV3ACCESS definitions aren't up to date */
580 ND_PRINT(" %04x", access_flags
);
581 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
582 ND_PRINT(" NFS_ACCESS_FULL");
584 char separator
= ' ';
585 if (access_flags
& NFSV3ACCESS_READ
) {
586 ND_PRINT(" NFS_ACCESS_READ");
589 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
590 ND_PRINT("%cNFS_ACCESS_LOOKUP", separator
);
593 if (access_flags
& NFSV3ACCESS_MODIFY
) {
594 ND_PRINT("%cNFS_ACCESS_MODIFY", separator
);
597 if (access_flags
& NFSV3ACCESS_EXTEND
) {
598 ND_PRINT("%cNFS_ACCESS_EXTEND", separator
);
601 if (access_flags
& NFSV3ACCESS_DELETE
) {
602 ND_PRINT("%cNFS_ACCESS_DELETE", separator
);
605 if (access_flags
& NFSV3ACCESS_EXECUTE
)
606 ND_PRINT("%cNFS_ACCESS_EXECUTE", separator
);
613 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
614 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
617 ND_PRINT(" %u bytes @ %" PRIu64
,
618 EXTRACT_BE_U_4(dp
+ 2),
622 ND_PRINT(" %u bytes @ %u",
623 EXTRACT_BE_U_4(dp
+ 1),
631 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
632 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
635 ND_PRINT(" %u (%u) bytes @ %" PRIu64
,
636 EXTRACT_BE_U_4(dp
+ 4),
637 EXTRACT_BE_U_4(dp
+ 2),
639 if (ndo
->ndo_vflag
) {
641 tok2str(nfsv3_writemodes
,
642 NULL
, EXTRACT_BE_U_4(dp
+ 3)));
646 ND_PRINT(" %u (%u) bytes @ %u (%u)",
647 EXTRACT_BE_U_4(dp
+ 3),
648 EXTRACT_BE_U_4(dp
+ 2),
649 EXTRACT_BE_U_4(dp
+ 1),
656 case NFSPROC_SYMLINK
:
657 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
658 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
660 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
662 if (parsefn(ndo
, dp
) == NULL
)
664 if (v3
&& ndo
->ndo_vflag
)
665 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
671 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
672 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
674 type
= (nfs_type
) EXTRACT_BE_U_4(dp
);
676 if ((dp
= parse_sattr3(ndo
, dp
, &sa3
)) == NULL
)
678 ND_PRINT(" %s", tok2str(type2str
, "unk-ft %u", type
));
679 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
683 EXTRACT_BE_U_4(dp
+ 1));
687 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
693 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
694 (dp
= parsefhn(ndo
, dp
, v3
)) != NULL
) {
696 if (parsefhn(ndo
, dp
, v3
) != NULL
)
702 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
703 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
705 if (parsefhn(ndo
, dp
, v3
) != NULL
)
710 case NFSPROC_READDIR
:
711 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
712 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
716 * We shouldn't really try to interpret the
717 * offset cookie here.
719 ND_PRINT(" %u bytes @ %" PRId64
,
720 EXTRACT_BE_U_4(dp
+ 4),
722 if (ndo
->ndo_vflag
) {
724 * This displays the 8 bytes
725 * of the verifier in order,
726 * from the low-order byte
727 * to the high-order byte.
729 ND_PRINT(" verf %08x%08x",
730 EXTRACT_BE_U_4(dp
+ 2),
731 EXTRACT_BE_U_4(dp
+ 3));
736 * Print the offset as signed, since -1 is
737 * common, but offsets > 2^31 aren't.
739 ND_PRINT(" %u bytes @ %u",
740 EXTRACT_BE_U_4(dp
+ 1),
747 case NFSPROC_READDIRPLUS
:
748 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
749 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
752 * We don't try to interpret the offset
755 ND_PRINT(" %u bytes @ %" PRId64
,
756 EXTRACT_BE_U_4(dp
+ 4),
758 if (ndo
->ndo_vflag
) {
761 * This displays the 8 bytes
762 * of the verifier in order,
763 * from the low-order byte
764 * to the high-order byte.
766 ND_PRINT(" max %u verf %08x%08x",
767 EXTRACT_BE_U_4(dp
+ 5),
768 EXTRACT_BE_U_4(dp
+ 2),
769 EXTRACT_BE_U_4(dp
+ 3));
776 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
777 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
779 ND_PRINT(" %u bytes @ %" PRIu64
,
780 EXTRACT_BE_U_4(dp
+ 2),
792 ND_PRINT("%s", tstr
);
796 * Print out an NFS file handle.
797 * We assume packet was not truncated before the end of the
798 * file handle pointed to by dp.
800 * Note: new version (using portable file-handle parser) doesn't produce
801 * generation number. It probably could be made to do that, with some
802 * additional hacking on the parser code.
805 nfs_printfh(netdissect_options
*ndo
,
806 const uint32_t *dp
, const u_int len
)
810 const char *sfsname
= NULL
;
813 if (ndo
->ndo_uflag
) {
815 char const *sep
= "";
818 for (i
=0; i
<len
; i
++) {
820 * This displays 4 bytes in big-endian byte
821 * order. That's as good a choice as little-
822 * endian, as there's no guarantee that the
823 * server is big-endian or little-endian or
824 * that the file handle contains 4-byte
825 * integral fields, and is better than "the
826 * byte order of the host running tcpdump", as
827 * the latter means that different hosts
828 * running tcpdump may show the same file
829 * handle in different ways.
831 ND_PRINT("%s%x", sep
, EXTRACT_BE_U_4(dp
+ i
));
838 Parse_fh((const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
841 /* file system ID is ASCII, not numeric, for this server OS */
842 char temp
[NFSX_V3FHMAX
+1];
845 /* Make sure string is null-terminated */
847 if (stringlen
> NFSX_V3FHMAX
)
848 stringlen
= NFSX_V3FHMAX
;
849 strncpy(temp
, sfsname
, stringlen
);
850 temp
[stringlen
] = '\0';
851 /* Remove trailing spaces */
852 spacep
= strchr(temp
, ' ');
856 ND_PRINT(" fh %s/", temp
);
858 ND_PRINT(" fh %u,%u/",
859 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
);
862 if(fsid
.Fsid_dev
.Minor
== 257)
863 /* Print the undecoded handle */
864 ND_PRINT("%s", fsid
.Opaque_Handle
);
866 ND_PRINT("%ld", (long) ino
);
870 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
871 * us to match up replies with requests and thus to know how to parse
875 struct xid_map_entry
{
876 uint32_t xid
; /* transaction ID (net order) */
877 int ipver
; /* IP version (4 or 6) */
878 struct in6_addr client
; /* client IP address (net order) */
879 struct in6_addr server
; /* server IP address (net order) */
880 uint32_t proc
; /* call proc number (host order) */
881 uint32_t vers
; /* program version (host order) */
885 * Map entries are kept in an array that we manage as a ring;
886 * new entries are always added at the tail of the ring. Initially,
887 * all the entries are zero and hence don't match anything.
890 #define XIDMAPSIZE 64
892 static struct xid_map_entry xid_map
[XIDMAPSIZE
];
894 static int xid_map_next
= 0;
895 static int xid_map_hint
= 0;
898 xid_map_enter(netdissect_options
*ndo
,
899 const struct sunrpc_msg
*rp
, const u_char
*bp
)
901 const struct ip
*ip
= NULL
;
902 const struct ip6_hdr
*ip6
= NULL
;
903 struct xid_map_entry
*xmep
;
905 if (!ND_TTEST_4(rp
->rm_call
.cb_proc
))
907 switch (IP_V((const struct ip
*)bp
)) {
909 ip
= (const struct ip
*)bp
;
912 ip6
= (const struct ip6_hdr
*)bp
;
918 xmep
= &xid_map
[xid_map_next
];
920 if (++xid_map_next
>= XIDMAPSIZE
)
923 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
926 UNALIGNED_MEMCPY(&xmep
->client
, ip
->ip_src
,
928 UNALIGNED_MEMCPY(&xmep
->server
, ip
->ip_dst
,
933 UNALIGNED_MEMCPY(&xmep
->client
, ip6
->ip6_src
,
934 sizeof(ip6
->ip6_src
));
935 UNALIGNED_MEMCPY(&xmep
->server
, ip6
->ip6_dst
,
936 sizeof(ip6
->ip6_dst
));
938 xmep
->proc
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_proc
);
939 xmep
->vers
= EXTRACT_BE_U_4(&rp
->rm_call
.cb_vers
);
944 * Returns 0 and puts NFSPROC_xxx in proc return and
945 * version in vers return, or returns -1 on failure
948 xid_map_find(const struct sunrpc_msg
*rp
, const u_char
*bp
, uint32_t *proc
,
952 struct xid_map_entry
*xmep
;
954 const struct ip
*ip
= (const struct ip
*)bp
;
955 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
958 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
959 /* Start searching from where we last left off */
964 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
966 switch (xmep
->ipver
) {
968 if (UNALIGNED_MEMCMP(ip
->ip_src
, &xmep
->server
,
969 sizeof(ip
->ip_src
)) != 0 ||
970 UNALIGNED_MEMCMP(ip
->ip_dst
, &xmep
->client
,
971 sizeof(ip
->ip_dst
)) != 0) {
976 if (UNALIGNED_MEMCMP(ip6
->ip6_src
, &xmep
->server
,
977 sizeof(ip6
->ip6_src
)) != 0 ||
978 UNALIGNED_MEMCMP(ip6
->ip6_dst
, &xmep
->client
,
979 sizeof(ip6
->ip6_dst
)) != 0) {
995 if (++i
>= XIDMAPSIZE
)
997 } while (i
!= xid_map_hint
);
1004 * Routines for parsing reply packets
1008 * Return a pointer to the beginning of the actual results.
1009 * If the packet was truncated, return 0.
1011 static const uint32_t *
1012 parserep(netdissect_options
*ndo
,
1013 const struct sunrpc_msg
*rp
, u_int length
)
1017 enum sunrpc_accept_stat astat
;
1021 * Here we find the address of the ar_verf credentials.
1022 * Originally, this calculation was
1023 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
1024 * On the wire, the rp_acpt field starts immediately after
1025 * the (32 bit) rp_stat field. However, rp_acpt (which is a
1026 * "struct accepted_reply") contains a "struct opaque_auth",
1027 * whose internal representation contains a pointer, so on a
1028 * 64-bit machine the compiler inserts 32 bits of padding
1029 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
1030 * the internal representation to parse the on-the-wire
1031 * representation. Instead, we skip past the rp_stat field,
1032 * which is an "enum" and so occupies one 32-bit word.
1034 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
1035 ND_TCHECK_4(dp
+ 1);
1036 len
= EXTRACT_BE_U_4(dp
+ 1);
1040 * skip past the ar_verf credentials.
1042 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1045 * now we can check the ar_stat field
1048 astat
= (enum sunrpc_accept_stat
) EXTRACT_BE_U_4(dp
);
1049 if (astat
!= SUNRPC_SUCCESS
) {
1050 ND_PRINT(" %s", tok2str(sunrpc_str
, "ar_stat %u", astat
));
1051 nfserr
= 1; /* suppress trunc string */
1054 /* successful return */
1055 ND_TCHECK_LEN(dp
, sizeof(astat
));
1056 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1061 static const uint32_t *
1062 parsestatus(netdissect_options
*ndo
,
1063 const uint32_t *dp
, u_int
*er
)
1069 errnum
= EXTRACT_BE_U_4(dp
);
1073 if (!ndo
->ndo_qflag
)
1074 ND_PRINT(" ERROR: %s",
1075 tok2str(status2str
, "unk %u", errnum
));
1083 static const uint32_t *
1084 parsefattr(netdissect_options
*ndo
,
1085 const uint32_t *dp
, int verbose
, int v3
)
1087 const struct nfs_fattr
*fap
;
1089 fap
= (const struct nfs_fattr
*)dp
;
1090 ND_TCHECK_4(&fap
->fa_gid
);
1093 * XXX - UIDs and GIDs are unsigned in NFS and in
1094 * at least some UN*Xes, but we'll show them as
1095 * signed because -2 has traditionally been the
1096 * UID for "nobody", rather than 4294967294.
1098 ND_PRINT(" %s %o ids %d/%d",
1099 tok2str(type2str
, "unk-ft %u ",
1100 EXTRACT_BE_U_4(&fap
->fa_type
)),
1101 EXTRACT_BE_U_4(&fap
->fa_mode
),
1102 EXTRACT_BE_S_4(&fap
->fa_uid
),
1103 EXTRACT_BE_S_4(&fap
->fa_gid
));
1105 ND_TCHECK_8(&fap
->fa3_size
);
1106 ND_PRINT(" sz %" PRIu64
,
1107 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_size
));
1109 ND_TCHECK_4(&fap
->fa2_size
);
1110 ND_PRINT(" sz %u", EXTRACT_BE_U_4(&fap
->fa2_size
));
1113 /* print lots more stuff */
1116 ND_TCHECK_8(&fap
->fa3_ctime
);
1117 ND_PRINT(" nlink %u rdev %u/%u",
1118 EXTRACT_BE_U_4(&fap
->fa_nlink
),
1119 EXTRACT_BE_U_4(&fap
->fa3_rdev
.specdata1
),
1120 EXTRACT_BE_U_4(&fap
->fa3_rdev
.specdata2
));
1121 ND_PRINT(" fsid %" PRIx64
,
1122 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_fsid
));
1123 ND_PRINT(" fileid %" PRIx64
,
1124 EXTRACT_BE_U_8((const uint32_t *)&fap
->fa3_fileid
));
1125 ND_PRINT(" a/m/ctime %u.%06u",
1126 EXTRACT_BE_U_4(&fap
->fa3_atime
.nfsv3_sec
),
1127 EXTRACT_BE_U_4(&fap
->fa3_atime
.nfsv3_nsec
));
1128 ND_PRINT(" %u.%06u",
1129 EXTRACT_BE_U_4(&fap
->fa3_mtime
.nfsv3_sec
),
1130 EXTRACT_BE_U_4(&fap
->fa3_mtime
.nfsv3_nsec
));
1131 ND_PRINT(" %u.%06u",
1132 EXTRACT_BE_U_4(&fap
->fa3_ctime
.nfsv3_sec
),
1133 EXTRACT_BE_U_4(&fap
->fa3_ctime
.nfsv3_nsec
));
1135 ND_TCHECK_8(&fap
->fa2_ctime
);
1136 ND_PRINT(" nlink %u rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1137 EXTRACT_BE_U_4(&fap
->fa_nlink
),
1138 EXTRACT_BE_U_4(&fap
->fa2_rdev
),
1139 EXTRACT_BE_U_4(&fap
->fa2_fsid
),
1140 EXTRACT_BE_U_4(&fap
->fa2_fileid
));
1141 ND_PRINT(" %u.%06u",
1142 EXTRACT_BE_U_4(&fap
->fa2_atime
.nfsv2_sec
),
1143 EXTRACT_BE_U_4(&fap
->fa2_atime
.nfsv2_usec
));
1144 ND_PRINT(" %u.%06u",
1145 EXTRACT_BE_U_4(&fap
->fa2_mtime
.nfsv2_sec
),
1146 EXTRACT_BE_U_4(&fap
->fa2_mtime
.nfsv2_usec
));
1147 ND_PRINT(" %u.%06u",
1148 EXTRACT_BE_U_4(&fap
->fa2_ctime
.nfsv2_sec
),
1149 EXTRACT_BE_U_4(&fap
->fa2_ctime
.nfsv2_usec
));
1152 return ((const uint32_t *)((const unsigned char *)dp
+
1153 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1159 parseattrstat(netdissect_options
*ndo
,
1160 const uint32_t *dp
, int verbose
, int v3
)
1164 dp
= parsestatus(ndo
, dp
, &er
);
1170 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1174 parsediropres(netdissect_options
*ndo
,
1179 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1184 dp
= parsefh(ndo
, dp
, 0);
1188 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1192 parselinkres(netdissect_options
*ndo
,
1193 const uint32_t *dp
, int v3
)
1197 dp
= parsestatus(ndo
, dp
, &er
);
1202 if (v3
&& !(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1205 return (parsefn(ndo
, dp
) != NULL
);
1209 parsestatfs(netdissect_options
*ndo
,
1210 const uint32_t *dp
, int v3
)
1212 const struct nfs_statfs
*sfsp
;
1215 dp
= parsestatus(ndo
, dp
, &er
);
1227 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1231 ND_TCHECK_LEN(dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1233 sfsp
= (const struct nfs_statfs
*)dp
;
1236 ND_PRINT(" tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1237 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_tbytes
),
1238 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_fbytes
),
1239 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_abytes
));
1240 if (ndo
->ndo_vflag
) {
1241 ND_PRINT(" tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1242 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_tfiles
),
1243 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_ffiles
),
1244 EXTRACT_BE_U_8((const uint32_t *)&sfsp
->sf_afiles
),
1245 EXTRACT_BE_U_4(&sfsp
->sf_invarsec
));
1248 ND_PRINT(" tsize %u bsize %u blocks %u bfree %u bavail %u",
1249 EXTRACT_BE_U_4(&sfsp
->sf_tsize
),
1250 EXTRACT_BE_U_4(&sfsp
->sf_bsize
),
1251 EXTRACT_BE_U_4(&sfsp
->sf_blocks
),
1252 EXTRACT_BE_U_4(&sfsp
->sf_bfree
),
1253 EXTRACT_BE_U_4(&sfsp
->sf_bavail
));
1262 parserddires(netdissect_options
*ndo
,
1267 dp
= parsestatus(ndo
, dp
, &er
);
1275 ND_TCHECK_4(dp
+ 2);
1276 ND_PRINT(" offset 0x%x size %u ",
1277 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1278 if (EXTRACT_BE_U_4(dp
+ 2) != 0)
1286 static const uint32_t *
1287 parse_wcc_attr(netdissect_options
*ndo
,
1290 /* Our caller has already checked this */
1291 ND_PRINT(" sz %" PRIu64
, EXTRACT_BE_U_8(dp
));
1292 ND_PRINT(" mtime %u.%06u ctime %u.%06u",
1293 EXTRACT_BE_U_4(dp
+ 2), EXTRACT_BE_U_4(dp
+ 3),
1294 EXTRACT_BE_U_4(dp
+ 4), EXTRACT_BE_U_4(dp
+ 5));
1299 * Pre operation attributes. Print only if vflag > 1.
1301 static const uint32_t *
1302 parse_pre_op_attr(netdissect_options
*ndo
,
1303 const uint32_t *dp
, int verbose
)
1306 if (!EXTRACT_BE_U_4(dp
))
1309 ND_TCHECK_LEN(dp
, 24);
1311 return parse_wcc_attr(ndo
, dp
);
1313 /* If not verbose enough, just skip over wcc_attr */
1321 * Post operation attributes are printed if vflag >= 1
1323 static const uint32_t *
1324 parse_post_op_attr(netdissect_options
*ndo
,
1325 const uint32_t *dp
, int verbose
)
1328 if (!EXTRACT_BE_U_4(dp
))
1332 return parsefattr(ndo
, dp
, verbose
, 1);
1334 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1339 static const uint32_t *
1340 parse_wcc_data(netdissect_options
*ndo
,
1341 const uint32_t *dp
, int verbose
)
1345 if (!(dp
= parse_pre_op_attr(ndo
, dp
, verbose
)))
1350 return parse_post_op_attr(ndo
, dp
, verbose
);
1353 static const uint32_t *
1354 parsecreateopres(netdissect_options
*ndo
,
1355 const uint32_t *dp
, int verbose
)
1359 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1362 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1365 if (!EXTRACT_BE_U_4(dp
))
1368 if (!(dp
= parsefh(ndo
, dp
, 1)))
1371 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1373 if (ndo
->ndo_vflag
> 1) {
1374 ND_PRINT(" dir attr:");
1375 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1385 parsewccres(netdissect_options
*ndo
,
1386 const uint32_t *dp
, int verbose
)
1390 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1392 return parse_wcc_data(ndo
, dp
, verbose
) != NULL
;
1395 static const uint32_t *
1396 parsev3rddirres(netdissect_options
*ndo
,
1397 const uint32_t *dp
, int verbose
)
1401 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1405 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1409 if (ndo
->ndo_vflag
) {
1410 ND_TCHECK_4(dp
+ 1);
1412 * This displays the 8 bytes of the verifier in order,
1413 * from the low-order byte to the high-order byte.
1415 ND_PRINT(" verf %08x%08x",
1416 EXTRACT_BE_U_4(dp
), EXTRACT_BE_U_4(dp
+ 1));
1425 parsefsinfo(netdissect_options
*ndo
,
1428 const struct nfsv3_fsinfo
*sfp
;
1431 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1435 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1440 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1441 ND_TCHECK_SIZE(sfp
);
1442 ND_PRINT(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1443 EXTRACT_BE_U_4(&sfp
->fs_rtmax
),
1444 EXTRACT_BE_U_4(&sfp
->fs_rtpref
),
1445 EXTRACT_BE_U_4(&sfp
->fs_wtmax
),
1446 EXTRACT_BE_U_4(&sfp
->fs_wtpref
),
1447 EXTRACT_BE_U_4(&sfp
->fs_dtpref
));
1448 if (ndo
->ndo_vflag
) {
1449 ND_PRINT(" rtmult %u wtmult %u maxfsz %" PRIu64
,
1450 EXTRACT_BE_U_4(&sfp
->fs_rtmult
),
1451 EXTRACT_BE_U_4(&sfp
->fs_wtmult
),
1452 EXTRACT_BE_U_8((const uint32_t *)&sfp
->fs_maxfilesize
));
1453 ND_PRINT(" delta %u.%06u ",
1454 EXTRACT_BE_U_4(&sfp
->fs_timedelta
.nfsv3_sec
),
1455 EXTRACT_BE_U_4(&sfp
->fs_timedelta
.nfsv3_nsec
));
1463 parsepathconf(netdissect_options
*ndo
,
1467 const struct nfsv3_pathconf
*spp
;
1469 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1473 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1478 spp
= (const struct nfsv3_pathconf
*)dp
;
1479 ND_TCHECK_SIZE(spp
);
1481 ND_PRINT(" linkmax %u namemax %u %s %s %s %s",
1482 EXTRACT_BE_U_4(&spp
->pc_linkmax
),
1483 EXTRACT_BE_U_4(&spp
->pc_namemax
),
1484 EXTRACT_BE_U_4(&spp
->pc_notrunc
) ? "notrunc" : "",
1485 EXTRACT_BE_U_4(&spp
->pc_chownrestricted
) ? "chownres" : "",
1486 EXTRACT_BE_U_4(&spp
->pc_caseinsensitive
) ? "igncase" : "",
1487 EXTRACT_BE_U_4(&spp
->pc_casepreserving
) ? "keepcase" : "");
1494 interp_reply(netdissect_options
*ndo
,
1495 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
, int length
)
1501 v3
= (vers
== NFS_VER3
);
1503 if (!v3
&& proc
< NFS_NPROCS
)
1504 proc
= nfsv3_procid
[proc
];
1506 ND_PRINT(" %s", tok2str(nfsproc_str
, "proc-%u", proc
));
1509 case NFSPROC_GETATTR
:
1510 dp
= parserep(ndo
, rp
, length
);
1511 if (dp
!= NULL
&& parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
) != 0)
1515 case NFSPROC_SETATTR
:
1516 if (!(dp
= parserep(ndo
, rp
, length
)))
1519 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1522 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0) != 0)
1527 case NFSPROC_LOOKUP
:
1528 if (!(dp
= parserep(ndo
, rp
, length
)))
1531 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1534 if (ndo
->ndo_vflag
> 1) {
1535 ND_PRINT(" post dattr:");
1536 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1539 if (!(dp
= parsefh(ndo
, dp
, v3
)))
1541 if ((dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)) &&
1542 ndo
->ndo_vflag
> 1) {
1543 ND_PRINT(" post dattr:");
1544 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1550 if (parsediropres(ndo
, dp
) != 0)
1555 case NFSPROC_ACCESS
:
1556 if (!(dp
= parserep(ndo
, rp
, length
)))
1558 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1562 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1566 ND_PRINT(" c %04x", EXTRACT_BE_U_4(dp
));
1570 case NFSPROC_READLINK
:
1571 dp
= parserep(ndo
, rp
, length
);
1572 if (dp
!= NULL
&& parselinkres(ndo
, dp
, v3
) != 0)
1577 if (!(dp
= parserep(ndo
, rp
, length
)))
1580 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1582 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1586 if (ndo
->ndo_vflag
) {
1587 ND_TCHECK_4(dp
+ 1);
1588 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1589 if (EXTRACT_BE_U_4(dp
+ 1))
1594 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0) != 0)
1600 if (!(dp
= parserep(ndo
, rp
, length
)))
1603 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1605 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1609 if (ndo
->ndo_vflag
) {
1611 ND_PRINT(" %u bytes", EXTRACT_BE_U_4(dp
));
1612 if (ndo
->ndo_vflag
> 1) {
1613 ND_TCHECK_4(dp
+ 1);
1615 tok2str(nfsv3_writemodes
,
1616 NULL
, EXTRACT_BE_U_4(dp
+ 1)));
1621 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
) != 0)
1626 case NFSPROC_CREATE
:
1628 if (!(dp
= parserep(ndo
, rp
, length
)))
1631 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1634 if (parsediropres(ndo
, dp
) != 0)
1639 case NFSPROC_SYMLINK
:
1640 if (!(dp
= parserep(ndo
, rp
, length
)))
1643 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1646 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1652 if (!(dp
= parserep(ndo
, rp
, length
)))
1654 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != NULL
)
1658 case NFSPROC_REMOVE
:
1660 if (!(dp
= parserep(ndo
, rp
, length
)))
1663 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1666 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1671 case NFSPROC_RENAME
:
1672 if (!(dp
= parserep(ndo
, rp
, length
)))
1675 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1677 if (ndo
->ndo_vflag
) {
1679 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1682 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1687 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1693 if (!(dp
= parserep(ndo
, rp
, length
)))
1696 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1698 if (ndo
->ndo_vflag
) {
1699 ND_PRINT(" file POST:");
1700 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1703 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1708 if (parsestatus(ndo
, dp
, &er
) != NULL
)
1713 case NFSPROC_READDIR
:
1714 if (!(dp
= parserep(ndo
, rp
, length
)))
1717 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1720 if (parserddires(ndo
, dp
) != 0)
1725 case NFSPROC_READDIRPLUS
:
1726 if (!(dp
= parserep(ndo
, rp
, length
)))
1728 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1732 case NFSPROC_FSSTAT
:
1733 dp
= parserep(ndo
, rp
, length
);
1734 if (dp
!= NULL
&& parsestatfs(ndo
, dp
, v3
) != 0)
1738 case NFSPROC_FSINFO
:
1739 dp
= parserep(ndo
, rp
, length
);
1740 if (dp
!= NULL
&& parsefsinfo(ndo
, dp
) != 0)
1744 case NFSPROC_PATHCONF
:
1745 dp
= parserep(ndo
, rp
, length
);
1746 if (dp
!= NULL
&& parsepathconf(ndo
, dp
) != 0)
1750 case NFSPROC_COMMIT
:
1751 dp
= parserep(ndo
, rp
, length
);
1752 if (dp
!= NULL
&& parsewccres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1761 ND_PRINT("%s", tstr
);