]>
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"
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 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((ndo
, "%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_32BITS(dp
);
239 if (sa3
->sa_modeset
) {
241 sa3
->sa_mode
= EXTRACT_32BITS(dp
);
246 sa3
->sa_uidset
= EXTRACT_32BITS(dp
);
248 if (sa3
->sa_uidset
) {
250 sa3
->sa_uid
= EXTRACT_32BITS(dp
);
255 sa3
->sa_gidset
= EXTRACT_32BITS(dp
);
257 if (sa3
->sa_gidset
) {
259 sa3
->sa_gid
= EXTRACT_32BITS(dp
);
264 sa3
->sa_sizeset
= EXTRACT_32BITS(dp
);
266 if (sa3
->sa_sizeset
) {
268 sa3
->sa_size
= EXTRACT_32BITS(dp
);
273 sa3
->sa_atimetype
= EXTRACT_32BITS(dp
);
275 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
) {
277 sa3
->sa_atime
.nfsv3_sec
= EXTRACT_32BITS(dp
);
279 sa3
->sa_atime
.nfsv3_nsec
= EXTRACT_32BITS(dp
);
284 sa3
->sa_mtimetype
= EXTRACT_32BITS(dp
);
286 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
) {
288 sa3
->sa_mtime
.nfsv3_sec
= EXTRACT_32BITS(dp
);
290 sa3
->sa_mtime
.nfsv3_nsec
= EXTRACT_32BITS(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((ndo
, " mode %o", sa3
->sa_mode
));
308 ND_PRINT((ndo
, " uid %u", sa3
->sa_uid
));
310 ND_PRINT((ndo
, " gid %u", sa3
->sa_gid
));
312 if (sa3
->sa_atimetype
== NFSV3SATTRTIME_TOCLIENT
)
313 ND_PRINT((ndo
, " atime %u.%06u", sa3
->sa_atime
.nfsv3_sec
,
314 sa3
->sa_atime
.nfsv3_nsec
));
315 if (sa3
->sa_mtimetype
== NFSV3SATTRTIME_TOCLIENT
)
316 ND_PRINT((ndo
, " mtime %u.%06u", sa3
->sa_mtime
.nfsv3_sec
,
317 sa3
->sa_mtime
.nfsv3_nsec
));
322 nfsreply_print(netdissect_options
*ndo
,
323 register const u_char
*bp
, u_int length
,
324 register const u_char
*bp2
)
326 register const struct sunrpc_msg
*rp
;
327 char srcid
[20], dstid
[20]; /*fits 32bit*/
329 nfserr
= 0; /* assume no error */
330 rp
= (const struct sunrpc_msg
*)bp
;
332 ND_TCHECK(rp
->rm_xid
);
333 if (!ndo
->ndo_nflag
) {
334 strlcpy(srcid
, "nfs", sizeof(srcid
));
335 snprintf(dstid
, sizeof(dstid
), "%u",
336 EXTRACT_32BITS(&rp
->rm_xid
));
338 snprintf(srcid
, sizeof(srcid
), "%u", NFS_PORT
);
339 snprintf(dstid
, sizeof(dstid
), "%u",
340 EXTRACT_32BITS(&rp
->rm_xid
));
342 print_nfsaddr(ndo
, bp2
, srcid
, dstid
);
344 nfsreply_print_noaddr(ndo
, bp
, length
, bp2
);
349 ND_PRINT((ndo
, "%s", tstr
));
353 nfsreply_print_noaddr(netdissect_options
*ndo
,
354 register const u_char
*bp
, u_int length
,
355 register const u_char
*bp2
)
357 register 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 nfserr
= 0; /* assume no error */
365 rp
= (const struct sunrpc_msg
*)bp
;
367 ND_TCHECK(rp
->rm_reply
.rp_stat
);
368 reply_stat
= EXTRACT_32BITS(&rp
->rm_reply
.rp_stat
);
369 switch (reply_stat
) {
371 case SUNRPC_MSG_ACCEPTED
:
372 ND_PRINT((ndo
, "reply ok %u", length
));
373 if (xid_map_find(rp
, bp2
, &proc
, &vers
) >= 0)
374 interp_reply(ndo
, rp
, proc
, vers
, length
);
377 case SUNRPC_MSG_DENIED
:
378 ND_PRINT((ndo
, "reply ERR %u: ", length
));
379 ND_TCHECK(rp
->rm_reply
.rp_reject
.rj_stat
);
380 rstat
= EXTRACT_32BITS(&rp
->rm_reply
.rp_reject
.rj_stat
);
383 case SUNRPC_RPC_MISMATCH
:
384 ND_TCHECK(rp
->rm_reply
.rp_reject
.rj_vers
.high
);
385 rlow
= EXTRACT_32BITS(&rp
->rm_reply
.rp_reject
.rj_vers
.low
);
386 rhigh
= EXTRACT_32BITS(&rp
->rm_reply
.rp_reject
.rj_vers
.high
);
387 ND_PRINT((ndo
, "RPC Version mismatch (%u-%u)", rlow
, rhigh
));
390 case SUNRPC_AUTH_ERROR
:
391 ND_TCHECK(rp
->rm_reply
.rp_reject
.rj_why
);
392 rwhy
= EXTRACT_32BITS(&rp
->rm_reply
.rp_reject
.rj_why
);
393 ND_PRINT((ndo
, "Auth %s", tok2str(sunrpc_auth_str
, "Invalid failure code %u", rwhy
)));
397 ND_PRINT((ndo
, "Unknown reason for rejecting rpc message %u", (unsigned int)rstat
));
403 ND_PRINT((ndo
, "reply Unknown rpc response code=%u %u", reply_stat
, length
));
410 ND_PRINT((ndo
, "%s", tstr
));
414 * Return a pointer to the first file handle in the packet.
415 * If the packet was truncated, return 0.
417 static const uint32_t *
418 parsereq(netdissect_options
*ndo
,
419 register const struct sunrpc_msg
*rp
, register u_int length
)
421 register const uint32_t *dp
;
425 * find the start of the req data (if we captured it)
427 dp
= (const uint32_t *)&rp
->rm_call
.cb_cred
;
429 len
= EXTRACT_32BITS(&dp
[1]);
431 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
433 len
= EXTRACT_32BITS(&dp
[1]);
435 dp
+= (len
+ (2 * sizeof(*dp
) + 3)) / sizeof(*dp
);
436 ND_TCHECK2(dp
[0], 0);
445 * Print out an NFS file handle and return a pointer to following word.
446 * If packet was truncated, return 0.
448 static const uint32_t *
449 parsefh(netdissect_options
*ndo
,
450 register const uint32_t *dp
, int v3
)
456 len
= EXTRACT_32BITS(dp
) / 4;
461 if (ND_TTEST2(*dp
, len
* sizeof(*dp
))) {
462 nfs_printfh(ndo
, dp
, len
);
470 * Print out a file name and return pointer to 32-bit word past it.
471 * If packet was truncated, return 0.
473 static const uint32_t *
474 parsefn(netdissect_options
*ndo
,
475 register const uint32_t *dp
)
477 register uint32_t len
;
478 register const u_char
*cp
;
480 /* Bail if we don't have the string length */
483 /* Fetch string length; convert to host order */
487 ND_TCHECK2(*dp
, ((len
+ 3) & ~3));
489 cp
= (const u_char
*)dp
;
490 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
491 dp
+= ((len
+ 3) & ~3) / sizeof(*dp
);
492 ND_PRINT((ndo
, "\""));
493 if (fn_printn(ndo
, cp
, len
, ndo
->ndo_snapend
)) {
494 ND_PRINT((ndo
, "\""));
497 ND_PRINT((ndo
, "\""));
505 * Print out file handle and file name.
506 * Return pointer to 32-bit word past file name.
507 * If packet was truncated (or there was some other error), return 0.
509 static const uint32_t *
510 parsefhn(netdissect_options
*ndo
,
511 register const uint32_t *dp
, int v3
)
513 dp
= parsefh(ndo
, dp
, v3
);
516 ND_PRINT((ndo
, " "));
517 return (parsefn(ndo
, dp
));
521 nfsreq_print_noaddr(netdissect_options
*ndo
,
522 register const u_char
*bp
, u_int length
,
523 register const u_char
*bp2
)
525 register const struct sunrpc_msg
*rp
;
526 register const uint32_t *dp
;
530 uint32_t access_flags
;
531 struct nfsv3_sattr sa3
;
533 ND_PRINT((ndo
, "%d", length
));
534 nfserr
= 0; /* assume no error */
535 rp
= (const struct sunrpc_msg
*)bp
;
537 if (!xid_map_enter(ndo
, rp
, bp2
)) /* record proc number for later on */
540 v3
= (EXTRACT_32BITS(&rp
->rm_call
.cb_vers
) == NFS_VER3
);
541 proc
= EXTRACT_32BITS(&rp
->rm_call
.cb_proc
);
543 if (!v3
&& proc
< NFS_NPROCS
)
544 proc
= nfsv3_procid
[proc
];
546 ND_PRINT((ndo
, " %s", tok2str(nfsproc_str
, "proc-%u", proc
)));
549 case NFSPROC_GETATTR
:
550 case NFSPROC_SETATTR
:
551 case NFSPROC_READLINK
:
554 case NFSPROC_PATHCONF
:
555 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
556 parsefh(ndo
, dp
, v3
) != NULL
)
565 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
566 parsefhn(ndo
, dp
, v3
) != NULL
)
571 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
572 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
574 access_flags
= EXTRACT_32BITS(&dp
[0]);
575 if (access_flags
& ~NFSV3ACCESS_FULL
) {
576 /* NFSV3ACCESS definitions aren't up to date */
577 ND_PRINT((ndo
, " %04x", access_flags
));
578 } else if ((access_flags
& NFSV3ACCESS_FULL
) == NFSV3ACCESS_FULL
) {
579 ND_PRINT((ndo
, " NFS_ACCESS_FULL"));
581 char separator
= ' ';
582 if (access_flags
& NFSV3ACCESS_READ
) {
583 ND_PRINT((ndo
, " NFS_ACCESS_READ"));
586 if (access_flags
& NFSV3ACCESS_LOOKUP
) {
587 ND_PRINT((ndo
, "%cNFS_ACCESS_LOOKUP", separator
));
590 if (access_flags
& NFSV3ACCESS_MODIFY
) {
591 ND_PRINT((ndo
, "%cNFS_ACCESS_MODIFY", separator
));
594 if (access_flags
& NFSV3ACCESS_EXTEND
) {
595 ND_PRINT((ndo
, "%cNFS_ACCESS_EXTEND", separator
));
598 if (access_flags
& NFSV3ACCESS_DELETE
) {
599 ND_PRINT((ndo
, "%cNFS_ACCESS_DELETE", separator
));
602 if (access_flags
& NFSV3ACCESS_EXECUTE
)
603 ND_PRINT((ndo
, "%cNFS_ACCESS_EXECUTE", separator
));
610 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
611 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
614 ND_PRINT((ndo
, " %u bytes @ %" PRIu64
,
615 EXTRACT_32BITS(&dp
[2]),
616 EXTRACT_64BITS(&dp
[0])));
619 ND_PRINT((ndo
, " %u bytes @ %u",
620 EXTRACT_32BITS(&dp
[1]),
621 EXTRACT_32BITS(&dp
[0])));
628 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
629 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
632 ND_PRINT((ndo
, " %u (%u) bytes @ %" PRIu64
,
633 EXTRACT_32BITS(&dp
[4]),
634 EXTRACT_32BITS(&dp
[2]),
635 EXTRACT_64BITS(&dp
[0])));
636 if (ndo
->ndo_vflag
) {
639 ND_PRINT((ndo
, " <%s>",
640 tok2str(nfsv3_writemodes
,
641 NULL
, EXTRACT_32BITS(dp
))));
645 ND_PRINT((ndo
, " %u (%u) bytes @ %u (%u)",
646 EXTRACT_32BITS(&dp
[3]),
647 EXTRACT_32BITS(&dp
[2]),
648 EXTRACT_32BITS(&dp
[1]),
649 EXTRACT_32BITS(&dp
[0])));
655 case NFSPROC_SYMLINK
:
656 if ((dp
= parsereq(ndo
, rp
, length
)) != 0 &&
657 (dp
= parsefhn(ndo
, dp
, v3
)) != 0) {
658 ND_PRINT((ndo
, " ->"));
659 if (v3
&& (dp
= parse_sattr3(ndo
, dp
, &sa3
)) == 0)
661 if (parsefn(ndo
, dp
) == 0)
663 if (v3
&& ndo
->ndo_vflag
)
664 print_sattr3(ndo
, &sa3
, ndo
->ndo_vflag
);
670 if ((dp
= parsereq(ndo
, rp
, length
)) != 0 &&
671 (dp
= parsefhn(ndo
, dp
, v3
)) != 0) {
673 type
= (nfs_type
)EXTRACT_32BITS(dp
);
675 if ((dp
= parse_sattr3(ndo
, dp
, &sa3
)) == 0)
677 ND_PRINT((ndo
, " %s", tok2str(type2str
, "unk-ft %d", type
)));
678 if (ndo
->ndo_vflag
&& (type
== NFCHR
|| type
== NFBLK
)) {
680 ND_PRINT((ndo
, " %u/%u",
681 EXTRACT_32BITS(&dp
[0]),
682 EXTRACT_32BITS(&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
) {
694 ND_PRINT((ndo
, " ->"));
695 if (parsefhn(ndo
, dp
, v3
) != NULL
)
701 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
702 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
703 ND_PRINT((ndo
, " ->"));
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((ndo
, " %u bytes @ %" PRId64
,
719 EXTRACT_32BITS(&dp
[4]),
720 EXTRACT_64BITS(&dp
[0])));
722 ND_PRINT((ndo
, " verf %08x%08x", dp
[2], dp
[3]));
726 * Print the offset as signed, since -1 is
727 * common, but offsets > 2^31 aren't.
729 ND_PRINT((ndo
, " %u bytes @ %d",
730 EXTRACT_32BITS(&dp
[1]),
731 EXTRACT_32BITS(&dp
[0])));
737 case NFSPROC_READDIRPLUS
:
738 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
739 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
742 * We don't try to interpret the offset
745 ND_PRINT((ndo
, " %u bytes @ %" PRId64
,
746 EXTRACT_32BITS(&dp
[4]),
747 EXTRACT_64BITS(&dp
[0])));
748 if (ndo
->ndo_vflag
) {
750 ND_PRINT((ndo
, " max %u verf %08x%08x",
751 EXTRACT_32BITS(&dp
[5]), dp
[2], dp
[3]));
758 if ((dp
= parsereq(ndo
, rp
, length
)) != NULL
&&
759 (dp
= parsefh(ndo
, dp
, v3
)) != NULL
) {
761 ND_PRINT((ndo
, " %u bytes @ %" PRIu64
,
762 EXTRACT_32BITS(&dp
[2]),
763 EXTRACT_64BITS(&dp
[0])));
774 ND_PRINT((ndo
, "%s", tstr
));
778 * Print out an NFS file handle.
779 * We assume packet was not truncated before the end of the
780 * file handle pointed to by dp.
782 * Note: new version (using portable file-handle parser) doesn't produce
783 * generation number. It probably could be made to do that, with some
784 * additional hacking on the parser code.
787 nfs_printfh(netdissect_options
*ndo
,
788 register const uint32_t *dp
, const u_int len
)
792 const char *sfsname
= NULL
;
795 if (ndo
->ndo_uflag
) {
797 char const *sep
= "";
799 ND_PRINT((ndo
, " fh["));
800 for (i
=0; i
<len
; i
++) {
801 ND_PRINT((ndo
, "%s%x", sep
, dp
[i
]));
804 ND_PRINT((ndo
, "]"));
808 Parse_fh((const u_char
*)dp
, len
, &fsid
, &ino
, NULL
, &sfsname
, 0);
811 /* file system ID is ASCII, not numeric, for this server OS */
812 static char temp
[NFSX_V3FHMAX
+1];
814 /* Make sure string is null-terminated */
815 strncpy(temp
, sfsname
, NFSX_V3FHMAX
);
816 temp
[sizeof(temp
) - 1] = '\0';
817 /* Remove trailing spaces */
818 spacep
= strchr(temp
, ' ');
822 ND_PRINT((ndo
, " fh %s/", temp
));
824 ND_PRINT((ndo
, " fh %d,%d/",
825 fsid
.Fsid_dev
.Major
, fsid
.Fsid_dev
.Minor
));
828 if(fsid
.Fsid_dev
.Minor
== 257)
829 /* Print the undecoded handle */
830 ND_PRINT((ndo
, "%s", fsid
.Opaque_Handle
));
832 ND_PRINT((ndo
, "%ld", (long) ino
));
836 * Maintain a small cache of recent client.XID.server/proc pairs, to allow
837 * us to match up replies with requests and thus to know how to parse
841 struct xid_map_entry
{
842 uint32_t xid
; /* transaction ID (net order) */
843 int ipver
; /* IP version (4 or 6) */
844 struct in6_addr client
; /* client IP address (net order) */
845 struct in6_addr server
; /* server IP address (net order) */
846 uint32_t proc
; /* call proc number (host order) */
847 uint32_t vers
; /* program version (host order) */
851 * Map entries are kept in an array that we manage as a ring;
852 * new entries are always added at the tail of the ring. Initially,
853 * all the entries are zero and hence don't match anything.
856 #define XIDMAPSIZE 64
858 struct xid_map_entry xid_map
[XIDMAPSIZE
];
860 int xid_map_next
= 0;
861 int xid_map_hint
= 0;
864 xid_map_enter(netdissect_options
*ndo
,
865 const struct sunrpc_msg
*rp
, const u_char
*bp
)
867 const struct ip
*ip
= NULL
;
868 const struct ip6_hdr
*ip6
= NULL
;
869 struct xid_map_entry
*xmep
;
871 if (!ND_TTEST(rp
->rm_call
.cb_vers
))
873 switch (IP_V((const struct ip
*)bp
)) {
875 ip
= (const struct ip
*)bp
;
878 ip6
= (const struct ip6_hdr
*)bp
;
884 xmep
= &xid_map
[xid_map_next
];
886 if (++xid_map_next
>= XIDMAPSIZE
)
889 UNALIGNED_MEMCPY(&xmep
->xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
892 UNALIGNED_MEMCPY(&xmep
->client
, &ip
->ip_src
, sizeof(ip
->ip_src
));
893 UNALIGNED_MEMCPY(&xmep
->server
, &ip
->ip_dst
, sizeof(ip
->ip_dst
));
897 UNALIGNED_MEMCPY(&xmep
->client
, &ip6
->ip6_src
, sizeof(ip6
->ip6_src
));
898 UNALIGNED_MEMCPY(&xmep
->server
, &ip6
->ip6_dst
, sizeof(ip6
->ip6_dst
));
900 xmep
->proc
= EXTRACT_32BITS(&rp
->rm_call
.cb_proc
);
901 xmep
->vers
= EXTRACT_32BITS(&rp
->rm_call
.cb_vers
);
906 * Returns 0 and puts NFSPROC_xxx in proc return and
907 * version in vers return, or returns -1 on failure
910 xid_map_find(const struct sunrpc_msg
*rp
, const u_char
*bp
, uint32_t *proc
,
914 struct xid_map_entry
*xmep
;
916 const struct ip
*ip
= (const struct ip
*)bp
;
917 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
920 UNALIGNED_MEMCPY(&xid
, &rp
->rm_xid
, sizeof(xmep
->xid
));
921 /* Start searching from where we last left off */
926 if (xmep
->ipver
!= IP_V(ip
) || xmep
->xid
!= xid
)
928 switch (xmep
->ipver
) {
930 if (UNALIGNED_MEMCMP(&ip
->ip_src
, &xmep
->server
,
931 sizeof(ip
->ip_src
)) != 0 ||
932 UNALIGNED_MEMCMP(&ip
->ip_dst
, &xmep
->client
,
933 sizeof(ip
->ip_dst
)) != 0) {
938 if (UNALIGNED_MEMCMP(&ip6
->ip6_src
, &xmep
->server
,
939 sizeof(ip6
->ip6_src
)) != 0 ||
940 UNALIGNED_MEMCMP(&ip6
->ip6_dst
, &xmep
->client
,
941 sizeof(ip6
->ip6_dst
)) != 0) {
957 if (++i
>= XIDMAPSIZE
)
959 } while (i
!= xid_map_hint
);
966 * Routines for parsing reply packets
970 * Return a pointer to the beginning of the actual results.
971 * If the packet was truncated, return 0.
973 static const uint32_t *
974 parserep(netdissect_options
*ndo
,
975 register const struct sunrpc_msg
*rp
, register u_int length
)
977 register const uint32_t *dp
;
979 enum sunrpc_accept_stat astat
;
983 * Here we find the address of the ar_verf credentials.
984 * Originally, this calculation was
985 * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
986 * On the wire, the rp_acpt field starts immediately after
987 * the (32 bit) rp_stat field. However, rp_acpt (which is a
988 * "struct accepted_reply") contains a "struct opaque_auth",
989 * whose internal representation contains a pointer, so on a
990 * 64-bit machine the compiler inserts 32 bits of padding
991 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use
992 * the internal representation to parse the on-the-wire
993 * representation. Instead, we skip past the rp_stat field,
994 * which is an "enum" and so occupies one 32-bit word.
996 dp
= ((const uint32_t *)&rp
->rm_reply
) + 1;
998 len
= EXTRACT_32BITS(&dp
[1]);
1002 * skip past the ar_verf credentials.
1004 dp
+= (len
+ (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
1005 ND_TCHECK2(dp
[0], 0);
1008 * now we can check the ar_stat field
1010 astat
= (enum sunrpc_accept_stat
) EXTRACT_32BITS(dp
);
1011 if (astat
!= SUNRPC_SUCCESS
) {
1012 ND_PRINT((ndo
, " %s", tok2str(sunrpc_str
, "ar_stat %d", astat
)));
1013 nfserr
= 1; /* suppress trunc string */
1016 /* successful return */
1017 ND_TCHECK2(*dp
, sizeof(astat
));
1018 return ((const uint32_t *) (sizeof(astat
) + ((const char *)dp
)));
1023 static const uint32_t *
1024 parsestatus(netdissect_options
*ndo
,
1025 const uint32_t *dp
, int *er
)
1031 errnum
= EXTRACT_32BITS(&dp
[0]);
1035 if (!ndo
->ndo_qflag
)
1036 ND_PRINT((ndo
, " ERROR: %s",
1037 tok2str(status2str
, "unk %d", errnum
)));
1045 static const uint32_t *
1046 parsefattr(netdissect_options
*ndo
,
1047 const uint32_t *dp
, int verbose
, int v3
)
1049 const struct nfs_fattr
*fap
;
1051 fap
= (const struct nfs_fattr
*)dp
;
1052 ND_TCHECK(fap
->fa_gid
);
1054 ND_PRINT((ndo
, " %s %o ids %d/%d",
1055 tok2str(type2str
, "unk-ft %d ",
1056 EXTRACT_32BITS(&fap
->fa_type
)),
1057 EXTRACT_32BITS(&fap
->fa_mode
),
1058 EXTRACT_32BITS(&fap
->fa_uid
),
1059 EXTRACT_32BITS(&fap
->fa_gid
)));
1061 ND_TCHECK(fap
->fa3_size
);
1062 ND_PRINT((ndo
, " sz %" PRIu64
,
1063 EXTRACT_64BITS((const uint32_t *)&fap
->fa3_size
)));
1065 ND_TCHECK(fap
->fa2_size
);
1066 ND_PRINT((ndo
, " sz %d", EXTRACT_32BITS(&fap
->fa2_size
)));
1069 /* print lots more stuff */
1072 ND_TCHECK(fap
->fa3_ctime
);
1073 ND_PRINT((ndo
, " nlink %d rdev %d/%d",
1074 EXTRACT_32BITS(&fap
->fa_nlink
),
1075 EXTRACT_32BITS(&fap
->fa3_rdev
.specdata1
),
1076 EXTRACT_32BITS(&fap
->fa3_rdev
.specdata2
)));
1077 ND_PRINT((ndo
, " fsid %" PRIx64
,
1078 EXTRACT_64BITS((const uint32_t *)&fap
->fa3_fsid
)));
1079 ND_PRINT((ndo
, " fileid %" PRIx64
,
1080 EXTRACT_64BITS((const uint32_t *)&fap
->fa3_fileid
)));
1081 ND_PRINT((ndo
, " a/m/ctime %u.%06u",
1082 EXTRACT_32BITS(&fap
->fa3_atime
.nfsv3_sec
),
1083 EXTRACT_32BITS(&fap
->fa3_atime
.nfsv3_nsec
)));
1084 ND_PRINT((ndo
, " %u.%06u",
1085 EXTRACT_32BITS(&fap
->fa3_mtime
.nfsv3_sec
),
1086 EXTRACT_32BITS(&fap
->fa3_mtime
.nfsv3_nsec
)));
1087 ND_PRINT((ndo
, " %u.%06u",
1088 EXTRACT_32BITS(&fap
->fa3_ctime
.nfsv3_sec
),
1089 EXTRACT_32BITS(&fap
->fa3_ctime
.nfsv3_nsec
)));
1091 ND_TCHECK(fap
->fa2_ctime
);
1092 ND_PRINT((ndo
, " nlink %d rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
1093 EXTRACT_32BITS(&fap
->fa_nlink
),
1094 EXTRACT_32BITS(&fap
->fa2_rdev
),
1095 EXTRACT_32BITS(&fap
->fa2_fsid
),
1096 EXTRACT_32BITS(&fap
->fa2_fileid
)));
1097 ND_PRINT((ndo
, " %u.%06u",
1098 EXTRACT_32BITS(&fap
->fa2_atime
.nfsv2_sec
),
1099 EXTRACT_32BITS(&fap
->fa2_atime
.nfsv2_usec
)));
1100 ND_PRINT((ndo
, " %u.%06u",
1101 EXTRACT_32BITS(&fap
->fa2_mtime
.nfsv2_sec
),
1102 EXTRACT_32BITS(&fap
->fa2_mtime
.nfsv2_usec
)));
1103 ND_PRINT((ndo
, " %u.%06u",
1104 EXTRACT_32BITS(&fap
->fa2_ctime
.nfsv2_sec
),
1105 EXTRACT_32BITS(&fap
->fa2_ctime
.nfsv2_usec
)));
1108 return ((const uint32_t *)((const unsigned char *)dp
+
1109 (v3
? NFSX_V3FATTR
: NFSX_V2FATTR
)));
1115 parseattrstat(netdissect_options
*ndo
,
1116 const uint32_t *dp
, int verbose
, int v3
)
1120 dp
= parsestatus(ndo
, dp
, &er
);
1126 return (parsefattr(ndo
, dp
, verbose
, v3
) != NULL
);
1130 parsediropres(netdissect_options
*ndo
,
1135 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1140 dp
= parsefh(ndo
, dp
, 0);
1144 return (parsefattr(ndo
, dp
, ndo
->ndo_vflag
, 0) != NULL
);
1148 parselinkres(netdissect_options
*ndo
,
1149 const uint32_t *dp
, int v3
)
1153 dp
= parsestatus(ndo
, dp
, &er
);
1158 if (v3
&& !(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1160 ND_PRINT((ndo
, " "));
1161 return (parsefn(ndo
, dp
) != NULL
);
1165 parsestatfs(netdissect_options
*ndo
,
1166 const uint32_t *dp
, int v3
)
1168 const struct nfs_statfs
*sfsp
;
1171 dp
= parsestatus(ndo
, dp
, &er
);
1182 ND_PRINT((ndo
, " POST:"));
1183 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1187 ND_TCHECK2(*dp
, (v3
? NFSX_V3STATFS
: NFSX_V2STATFS
));
1189 sfsp
= (const struct nfs_statfs
*)dp
;
1192 ND_PRINT((ndo
, " tbytes %" PRIu64
" fbytes %" PRIu64
" abytes %" PRIu64
,
1193 EXTRACT_64BITS((const uint32_t *)&sfsp
->sf_tbytes
),
1194 EXTRACT_64BITS((const uint32_t *)&sfsp
->sf_fbytes
),
1195 EXTRACT_64BITS((const uint32_t *)&sfsp
->sf_abytes
)));
1196 if (ndo
->ndo_vflag
) {
1197 ND_PRINT((ndo
, " tfiles %" PRIu64
" ffiles %" PRIu64
" afiles %" PRIu64
" invar %u",
1198 EXTRACT_64BITS((const uint32_t *)&sfsp
->sf_tfiles
),
1199 EXTRACT_64BITS((const uint32_t *)&sfsp
->sf_ffiles
),
1200 EXTRACT_64BITS((const uint32_t *)&sfsp
->sf_afiles
),
1201 EXTRACT_32BITS(&sfsp
->sf_invarsec
)));
1204 ND_PRINT((ndo
, " tsize %d bsize %d blocks %d bfree %d bavail %d",
1205 EXTRACT_32BITS(&sfsp
->sf_tsize
),
1206 EXTRACT_32BITS(&sfsp
->sf_bsize
),
1207 EXTRACT_32BITS(&sfsp
->sf_blocks
),
1208 EXTRACT_32BITS(&sfsp
->sf_bfree
),
1209 EXTRACT_32BITS(&sfsp
->sf_bavail
)));
1218 parserddires(netdissect_options
*ndo
,
1223 dp
= parsestatus(ndo
, dp
, &er
);
1232 ND_PRINT((ndo
, " offset 0x%x size %d ",
1233 EXTRACT_32BITS(&dp
[0]), EXTRACT_32BITS(&dp
[1])));
1235 ND_PRINT((ndo
, " eof"));
1242 static const uint32_t *
1243 parse_wcc_attr(netdissect_options
*ndo
,
1246 ND_PRINT((ndo
, " sz %" PRIu64
, EXTRACT_64BITS(&dp
[0])));
1247 ND_PRINT((ndo
, " mtime %u.%06u ctime %u.%06u",
1248 EXTRACT_32BITS(&dp
[2]), EXTRACT_32BITS(&dp
[3]),
1249 EXTRACT_32BITS(&dp
[4]), EXTRACT_32BITS(&dp
[5])));
1254 * Pre operation attributes. Print only if vflag > 1.
1256 static const uint32_t *
1257 parse_pre_op_attr(netdissect_options
*ndo
,
1258 const uint32_t *dp
, int verbose
)
1261 if (!EXTRACT_32BITS(&dp
[0]))
1264 ND_TCHECK2(*dp
, 24);
1266 return parse_wcc_attr(ndo
, dp
);
1268 /* If not verbose enough, just skip over wcc_attr */
1276 * Post operation attributes are printed if vflag >= 1
1278 static const uint32_t *
1279 parse_post_op_attr(netdissect_options
*ndo
,
1280 const uint32_t *dp
, int verbose
)
1283 if (!EXTRACT_32BITS(&dp
[0]))
1287 return parsefattr(ndo
, dp
, verbose
, 1);
1289 return (dp
+ (NFSX_V3FATTR
/ sizeof (uint32_t)));
1294 static const uint32_t *
1295 parse_wcc_data(netdissect_options
*ndo
,
1296 const uint32_t *dp
, int verbose
)
1299 ND_PRINT((ndo
, " PRE:"));
1300 if (!(dp
= parse_pre_op_attr(ndo
, dp
, verbose
)))
1304 ND_PRINT((ndo
, " POST:"));
1305 return parse_post_op_attr(ndo
, dp
, verbose
);
1308 static const uint32_t *
1309 parsecreateopres(netdissect_options
*ndo
,
1310 const uint32_t *dp
, int verbose
)
1314 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1317 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1320 if (!EXTRACT_32BITS(&dp
[0]))
1323 if (!(dp
= parsefh(ndo
, dp
, 1)))
1326 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1328 if (ndo
->ndo_vflag
> 1) {
1329 ND_PRINT((ndo
, " dir attr:"));
1330 dp
= parse_wcc_data(ndo
, dp
, verbose
);
1340 parsewccres(netdissect_options
*ndo
,
1341 const uint32_t *dp
, int verbose
)
1345 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1347 return parse_wcc_data(ndo
, dp
, verbose
) != 0;
1350 static const uint32_t *
1351 parsev3rddirres(netdissect_options
*ndo
,
1352 const uint32_t *dp
, int verbose
)
1356 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1359 ND_PRINT((ndo
, " POST:"));
1360 if (!(dp
= parse_post_op_attr(ndo
, dp
, verbose
)))
1364 if (ndo
->ndo_vflag
) {
1366 ND_PRINT((ndo
, " verf %08x%08x", dp
[0], dp
[1]));
1375 parsefsinfo(netdissect_options
*ndo
,
1378 const struct nfsv3_fsinfo
*sfp
;
1381 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1384 ND_PRINT((ndo
, " POST:"));
1385 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1390 sfp
= (const struct nfsv3_fsinfo
*)dp
;
1392 ND_PRINT((ndo
, " rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
1393 EXTRACT_32BITS(&sfp
->fs_rtmax
),
1394 EXTRACT_32BITS(&sfp
->fs_rtpref
),
1395 EXTRACT_32BITS(&sfp
->fs_wtmax
),
1396 EXTRACT_32BITS(&sfp
->fs_wtpref
),
1397 EXTRACT_32BITS(&sfp
->fs_dtpref
)));
1398 if (ndo
->ndo_vflag
) {
1399 ND_PRINT((ndo
, " rtmult %u wtmult %u maxfsz %" PRIu64
,
1400 EXTRACT_32BITS(&sfp
->fs_rtmult
),
1401 EXTRACT_32BITS(&sfp
->fs_wtmult
),
1402 EXTRACT_64BITS((const uint32_t *)&sfp
->fs_maxfilesize
)));
1403 ND_PRINT((ndo
, " delta %u.%06u ",
1404 EXTRACT_32BITS(&sfp
->fs_timedelta
.nfsv3_sec
),
1405 EXTRACT_32BITS(&sfp
->fs_timedelta
.nfsv3_nsec
)));
1413 parsepathconf(netdissect_options
*ndo
,
1417 const struct nfsv3_pathconf
*spp
;
1419 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1422 ND_PRINT((ndo
, " POST:"));
1423 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1428 spp
= (const struct nfsv3_pathconf
*)dp
;
1431 ND_PRINT((ndo
, " linkmax %u namemax %u %s %s %s %s",
1432 EXTRACT_32BITS(&spp
->pc_linkmax
),
1433 EXTRACT_32BITS(&spp
->pc_namemax
),
1434 EXTRACT_32BITS(&spp
->pc_notrunc
) ? "notrunc" : "",
1435 EXTRACT_32BITS(&spp
->pc_chownrestricted
) ? "chownres" : "",
1436 EXTRACT_32BITS(&spp
->pc_caseinsensitive
) ? "igncase" : "",
1437 EXTRACT_32BITS(&spp
->pc_casepreserving
) ? "keepcase" : ""));
1444 interp_reply(netdissect_options
*ndo
,
1445 const struct sunrpc_msg
*rp
, uint32_t proc
, uint32_t vers
, int length
)
1447 register const uint32_t *dp
;
1451 v3
= (vers
== NFS_VER3
);
1453 if (!v3
&& proc
< NFS_NPROCS
)
1454 proc
= nfsv3_procid
[proc
];
1456 ND_PRINT((ndo
, " %s", tok2str(nfsproc_str
, "proc-%u", proc
)));
1459 case NFSPROC_GETATTR
:
1460 dp
= parserep(ndo
, rp
, length
);
1461 if (dp
!= NULL
&& parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, v3
) != 0)
1465 case NFSPROC_SETATTR
:
1466 if (!(dp
= parserep(ndo
, rp
, length
)))
1469 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1472 if (parseattrstat(ndo
, dp
, !ndo
->ndo_qflag
, 0) != 0)
1477 case NFSPROC_LOOKUP
:
1478 if (!(dp
= parserep(ndo
, rp
, length
)))
1481 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1484 if (ndo
->ndo_vflag
> 1) {
1485 ND_PRINT((ndo
, " post dattr:"));
1486 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1489 if (!(dp
= parsefh(ndo
, dp
, v3
)))
1491 if ((dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)) &&
1492 ndo
->ndo_vflag
> 1) {
1493 ND_PRINT((ndo
, " post dattr:"));
1494 dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
);
1500 if (parsediropres(ndo
, dp
) != 0)
1505 case NFSPROC_ACCESS
:
1506 if (!(dp
= parserep(ndo
, rp
, length
)))
1508 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1511 ND_PRINT((ndo
, " attr:"));
1512 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1515 ND_PRINT((ndo
, " c %04x", EXTRACT_32BITS(&dp
[0])));
1518 case NFSPROC_READLINK
:
1519 dp
= parserep(ndo
, rp
, length
);
1520 if (dp
!= NULL
&& parselinkres(ndo
, dp
, v3
) != 0)
1525 if (!(dp
= parserep(ndo
, rp
, length
)))
1528 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1530 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1534 if (ndo
->ndo_vflag
) {
1536 ND_PRINT((ndo
, " %u bytes", EXTRACT_32BITS(&dp
[0])));
1537 if (EXTRACT_32BITS(&dp
[1]))
1538 ND_PRINT((ndo
, " EOF"));
1542 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, 0) != 0)
1548 if (!(dp
= parserep(ndo
, rp
, length
)))
1551 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1553 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1557 if (ndo
->ndo_vflag
) {
1559 ND_PRINT((ndo
, " %u bytes", EXTRACT_32BITS(&dp
[0])));
1560 if (ndo
->ndo_vflag
> 1) {
1562 ND_PRINT((ndo
, " <%s>",
1563 tok2str(nfsv3_writemodes
,
1564 NULL
, EXTRACT_32BITS(&dp
[1]))));
1569 if (parseattrstat(ndo
, dp
, ndo
->ndo_vflag
, v3
) != 0)
1574 case NFSPROC_CREATE
:
1576 if (!(dp
= parserep(ndo
, rp
, length
)))
1579 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1582 if (parsediropres(ndo
, dp
) != 0)
1587 case NFSPROC_SYMLINK
:
1588 if (!(dp
= parserep(ndo
, rp
, length
)))
1591 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1594 if (parsestatus(ndo
, dp
, &er
) != 0)
1600 if (!(dp
= parserep(ndo
, rp
, length
)))
1602 if (parsecreateopres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1606 case NFSPROC_REMOVE
:
1608 if (!(dp
= parserep(ndo
, rp
, length
)))
1611 if (parsewccres(ndo
, dp
, ndo
->ndo_vflag
))
1614 if (parsestatus(ndo
, dp
, &er
) != 0)
1619 case NFSPROC_RENAME
:
1620 if (!(dp
= parserep(ndo
, rp
, length
)))
1623 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1625 if (ndo
->ndo_vflag
) {
1626 ND_PRINT((ndo
, " from:"));
1627 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1629 ND_PRINT((ndo
, " to:"));
1630 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1635 if (parsestatus(ndo
, dp
, &er
) != 0)
1641 if (!(dp
= parserep(ndo
, rp
, length
)))
1644 if (!(dp
= parsestatus(ndo
, dp
, &er
)))
1646 if (ndo
->ndo_vflag
) {
1647 ND_PRINT((ndo
, " file POST:"));
1648 if (!(dp
= parse_post_op_attr(ndo
, dp
, ndo
->ndo_vflag
)))
1650 ND_PRINT((ndo
, " dir:"));
1651 if (!(dp
= parse_wcc_data(ndo
, dp
, ndo
->ndo_vflag
)))
1656 if (parsestatus(ndo
, dp
, &er
) != 0)
1661 case NFSPROC_READDIR
:
1662 if (!(dp
= parserep(ndo
, rp
, length
)))
1665 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1668 if (parserddires(ndo
, dp
) != 0)
1673 case NFSPROC_READDIRPLUS
:
1674 if (!(dp
= parserep(ndo
, rp
, length
)))
1676 if (parsev3rddirres(ndo
, dp
, ndo
->ndo_vflag
))
1680 case NFSPROC_FSSTAT
:
1681 dp
= parserep(ndo
, rp
, length
);
1682 if (dp
!= NULL
&& parsestatfs(ndo
, dp
, v3
) != 0)
1686 case NFSPROC_FSINFO
:
1687 dp
= parserep(ndo
, rp
, length
);
1688 if (dp
!= NULL
&& parsefsinfo(ndo
, dp
) != 0)
1692 case NFSPROC_PATHCONF
:
1693 dp
= parserep(ndo
, rp
, length
);
1694 if (dp
!= NULL
&& parsepathconf(ndo
, dp
) != 0)
1698 case NFSPROC_COMMIT
:
1699 dp
= parserep(ndo
, rp
, length
);
1700 if (dp
!= NULL
&& parsewccres(ndo
, dp
, ndo
->ndo_vflag
) != 0)
1709 ND_PRINT((ndo
, "%s", tstr
));