print-nfs.c (39300) | print-nfs.c (75118) |
---|---|
1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 * The Regents of the University of California. All rights reserved. 4 * 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 16 * written permission. 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. | 1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 * The Regents of the University of California. All rights reserved. 4 * 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 16 * written permission. 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. |
20 * 21 * $FreeBSD: head/contrib/tcpdump/print-nfs.c 75118 2001-04-03 07:50:46Z fenner $ |
|
20 */ 21 22#ifndef lint 23static const char rcsid[] = | 22 */ 23 24#ifndef lint 25static const char rcsid[] = |
24 "@(#) $Header: print-nfs.c,v 1.65 97/08/17 13:24:22 leres Exp $ (LBL)"; | 26 "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.87 2000/10/07 05:53:12 itojun Exp $ (LBL)"; |
25#endif 26 | 27#endif 28 |
29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 |
|
27#include <sys/param.h> 28#include <sys/time.h> 29#include <sys/socket.h> 30 | 33#include <sys/param.h> 34#include <sys/time.h> 35#include <sys/socket.h> 36 |
31#include <net/if.h> | 37struct mbuf; 38struct rtentry; |
32 33#include <netinet/in.h> | 39 40#include <netinet/in.h> |
34#include <net/ethernet.h> 35#include <netinet/in_systm.h> 36#include <netinet/ip.h> 37#include <netinet/ip_var.h> | |
38 39#include <rpc/rpc.h> 40 41#include <ctype.h> 42#include <pcap.h> 43#include <stdio.h> 44#include <string.h> 45 46#include "interface.h" 47#include "addrtoname.h" | 41 42#include <rpc/rpc.h> 43 44#include <ctype.h> 45#include <pcap.h> 46#include <stdio.h> 47#include <string.h> 48 49#include "interface.h" 50#include "addrtoname.h" |
48#include "extract.h" /* must come after interface.h */ | |
49 50#include "nfs.h" 51#include "nfsfh.h" 52 | 51 52#include "nfs.h" 53#include "nfsfh.h" 54 |
53static void nfs_printfh(const u_int32_t *, const int); 54static void xid_map_enter(const struct rpc_msg *, const struct ip *); 55static int32_t xid_map_find(const struct rpc_msg *, const struct ip *, u_int32_t *, 56 u_int32_t *); | 55#include "ip.h" 56#ifdef INET6 57#include "ip6.h" 58#endif 59 60static void nfs_printfh(const u_int32_t *, const u_int); 61static void xid_map_enter(const struct rpc_msg *, const u_char *); 62static int32_t xid_map_find(const struct rpc_msg *, const u_char *, 63 u_int32_t *, u_int32_t *); |
57static void interp_reply(const struct rpc_msg *, u_int32_t, u_int32_t, int); 58static const u_int32_t *parse_post_op_attr(const u_int32_t *, int); | 64static void interp_reply(const struct rpc_msg *, u_int32_t, u_int32_t, int); 65static const u_int32_t *parse_post_op_attr(const u_int32_t *, int); |
66static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose); 67static int print_int64(const u_int32_t *dp, int how); 68static void print_nfsaddr(const u_char *, const char *, const char *); |
|
59 | 69 |
60static int nfserr; /* true if we error rather than trunc */ 61 | |
62/* 63 * Mapping of old NFS Version 2 RPC numbers to generic numbers. 64 */ 65u_int32_t nfsv3_procid[NFS_NPROCS] = { 66 NFSPROC_NULL, 67 NFSPROC_GETATTR, 68 NFSPROC_SETATTR, 69 NFSPROC_NOOP, --- 16 unchanged lines hidden (view full) --- 86 NFSPROC_NOOP, 87 NFSPROC_NOOP, 88 NFSPROC_NOOP, 89 NFSPROC_NOOP, 90 NFSPROC_NOOP, 91 NFSPROC_NOOP 92}; 93 | 70/* 71 * Mapping of old NFS Version 2 RPC numbers to generic numbers. 72 */ 73u_int32_t nfsv3_procid[NFS_NPROCS] = { 74 NFSPROC_NULL, 75 NFSPROC_GETATTR, 76 NFSPROC_SETATTR, 77 NFSPROC_NOOP, --- 16 unchanged lines hidden (view full) --- 94 NFSPROC_NOOP, 95 NFSPROC_NOOP, 96 NFSPROC_NOOP, 97 NFSPROC_NOOP, 98 NFSPROC_NOOP, 99 NFSPROC_NOOP 100}; 101 |
94const char *nfsv3_writemodes[NFSV3WRITE_NMODES] = { 95 "unstable", 96 "datasync", 97 "filesync" | 102/* 103 * NFS V2 and V3 status values. 104 * 105 * Some of these come from the RFCs for NFS V2 and V3, with the message 106 * strings taken from the FreeBSD C library "errlst.c". 107 * 108 * Others are errors that are not in the RFC but that I suspect some 109 * NFS servers could return; the values are FreeBSD errno values, as 110 * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS 111 * was primarily BSD-derived. 112 */ 113static struct tok status2str[] = { 114 { 1, "Operation not permitted" }, /* EPERM */ 115 { 2, "No such file or directory" }, /* ENOENT */ 116 { 5, "Input/output error" }, /* EIO */ 117 { 6, "Device not configured" }, /* ENXIO */ 118 { 11, "Resource deadlock avoided" }, /* EDEADLK */ 119 { 12, "Cannot allocate memory" }, /* ENOMEM */ 120 { 13, "Permission denied" }, /* EACCES */ 121 { 17, "File exists" }, /* EEXIST */ 122 { 18, "Cross-device link" }, /* EXDEV */ 123 { 19, "Operation not supported by device" }, /* ENODEV */ 124 { 20, "Not a directory" }, /* ENOTDIR */ 125 { 21, "Is a directory" }, /* EISDIR */ 126 { 22, "Invalid argument" }, /* EINVAL */ 127 { 26, "Text file busy" }, /* ETXTBSY */ 128 { 27, "File too large" }, /* EFBIG */ 129 { 28, "No space left on device" }, /* ENOSPC */ 130 { 30, "Read-only file system" }, /* EROFS */ 131 { 31, "Too many links" }, /* EMLINK */ 132 { 45, "Operation not supported" }, /* EOPNOTSUPP */ 133 { 62, "Too many levels of symbolic links" }, /* ELOOP */ 134 { 63, "File name too long" }, /* ENAMETOOLONG */ 135 { 66, "Directory not empty" }, /* ENOTEMPTY */ 136 { 69, "Disc quota exceeded" }, /* EDQUOT */ 137 { 70, "Stale NFS file handle" }, /* ESTALE */ 138 { 71, "Too many levels of remote in path" }, /* EREMOTE */ 139 { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */ 140 { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */ 141 { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */ 142 { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */ 143 { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */ 144 { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */ 145 { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */ 146 { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */ 147 { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */ 148 { 0, NULL } |
98}; 99 | 149}; 150 |
151static struct tok nfsv3_writemodes[] = { 152 { 0, "unstable" }, 153 { 1, "datasync" }, 154 { 2, "filesync" }, 155 { 0, NULL } 156}; 157 |
|
100static struct tok type2str[] = { 101 { NFNON, "NON" }, 102 { NFREG, "REG" }, 103 { NFDIR, "DIR" }, 104 { NFBLK, "BLK" }, 105 { NFCHR, "CHR" }, 106 { NFLNK, "LNK" }, 107 { NFFIFO, "FIFO" }, --- 8 unchanged lines hidden (view full) --- 116 * Assume that a system that has INT64_FORMAT defined, has a 64-bit 117 * integer datatype and can print it. 118 */ 119 120#define UNSIGNED 0 121#define SIGNED 1 122#define HEX 2 123 | 158static struct tok type2str[] = { 159 { NFNON, "NON" }, 160 { NFREG, "REG" }, 161 { NFDIR, "DIR" }, 162 { NFBLK, "BLK" }, 163 { NFCHR, "CHR" }, 164 { NFLNK, "LNK" }, 165 { NFFIFO, "FIFO" }, --- 8 unchanged lines hidden (view full) --- 174 * Assume that a system that has INT64_FORMAT defined, has a 64-bit 175 * integer datatype and can print it. 176 */ 177 178#define UNSIGNED 0 179#define SIGNED 1 180#define HEX 2 181 |
124#define INT64_FORMAT "%qd" 125#define U_INT64_FORMAT "%qu" 126#define HEX_INT64_FORMAT "%qx" 127 128int print_int64(const u_int32_t *dp, int how) | 182static int print_int64(const u_int32_t *dp, int how) |
129{ 130#ifdef INT64_FORMAT 131 u_int64_t res; 132 133 res = ((u_int64_t)ntohl(dp[0]) << 32) | (u_int64_t)ntohl(dp[1]); 134 switch (how) { 135 case SIGNED: 136 printf(INT64_FORMAT, res); 137 break; 138 case UNSIGNED: 139 printf(U_INT64_FORMAT, res); 140 break; 141 case HEX: 142 printf(HEX_INT64_FORMAT, res); 143 break; 144 default: 145 return (0); 146 } 147#else | 183{ 184#ifdef INT64_FORMAT 185 u_int64_t res; 186 187 res = ((u_int64_t)ntohl(dp[0]) << 32) | (u_int64_t)ntohl(dp[1]); 188 switch (how) { 189 case SIGNED: 190 printf(INT64_FORMAT, res); 191 break; 192 case UNSIGNED: 193 printf(U_INT64_FORMAT, res); 194 break; 195 case HEX: 196 printf(HEX_INT64_FORMAT, res); 197 break; 198 default: 199 return (0); 200 } 201#else |
148 /* 149 * XXX - throw upper 32 bits away. 150 * Could also go for hex: printf("0x%x%x", dp[0], dp[1]); 151 */ 152 if (how == SIGNED) 153 printf("%ld", (int)dp[1]); 154 else 155 printf("%lu", (unsigned int)dp[1]); | 202 switch (how) { 203 case SIGNED: 204 case UNSIGNED: 205 case HEX: 206 printf("0x%x%08x", (u_int32_t)ntohl(dp[0]), 207 (u_int32_t)ntohl(dp[1])); 208 break; 209 default: 210 return (0); 211 } |
156#endif 157 return 1; 158} 159 | 212#endif 213 return 1; 214} 215 |
216static void 217print_nfsaddr(const u_char *bp, const char *s, const char *d) 218{ 219 struct ip *ip; 220#ifdef INET6 221 struct ip6_hdr *ip6; 222 char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN]; 223#else 224#ifndef INET_ADDRSTRLEN 225#define INET_ADDRSTRLEN 16 226#endif 227 char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN]; 228#endif 229 230 srcaddr[0] = dstaddr[0] = '\0'; 231 switch (IP_V((struct ip *)bp)) { 232 case 4: 233 ip = (struct ip *)bp; 234 strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr)); 235 strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr)); 236 break; 237#ifdef INET6 238 case 6: 239 ip6 = (struct ip6_hdr *)bp; 240 strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src), 241 sizeof(srcaddr)); 242 strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst), 243 sizeof(dstaddr)); 244 break; 245#endif 246 default: 247 strlcpy(srcaddr, "?", sizeof(srcaddr)); 248 strlcpy(dstaddr, "?", sizeof(dstaddr)); 249 break; 250 } 251 252 (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d); 253} 254 |
|
160static const u_int32_t * 161parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3) 162{ | 255static const u_int32_t * 256parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3) 257{ |
163 register const u_int32_t *ep = (u_int32_t *)snapend; 164 165 if (dp + 1 > ep) 166 return (NULL); | 258 TCHECK(dp[0]); |
167 if ((sa3->sa_modeset = ntohl(*dp++))) { | 259 if ((sa3->sa_modeset = ntohl(*dp++))) { |
168 if (dp + 1 > ep) 169 return (NULL); | 260 TCHECK(dp[0]); |
170 sa3->sa_mode = ntohl(*dp++); 171 } 172 | 261 sa3->sa_mode = ntohl(*dp++); 262 } 263 |
173 if (dp + 1 > ep) 174 return (NULL); | 264 TCHECK(dp[0]); |
175 if ((sa3->sa_uidset = ntohl(*dp++))) { | 265 if ((sa3->sa_uidset = ntohl(*dp++))) { |
176 if (dp + 1 > ep) 177 return (NULL); | 266 TCHECK(dp[0]); |
178 sa3->sa_uid = ntohl(*dp++); 179 } 180 | 267 sa3->sa_uid = ntohl(*dp++); 268 } 269 |
181 if (dp + 1 > ep) 182 return (NULL); | 270 TCHECK(dp[0]); |
183 if ((sa3->sa_gidset = ntohl(*dp++))) { | 271 if ((sa3->sa_gidset = ntohl(*dp++))) { |
184 if (dp + 1 > ep) 185 return (NULL); | 272 TCHECK(dp[0]); |
186 sa3->sa_gid = ntohl(*dp++); 187 } 188 | 273 sa3->sa_gid = ntohl(*dp++); 274 } 275 |
189 if (dp + 1 > ep) 190 return (NULL); | 276 TCHECK(dp[0]); |
191 if ((sa3->sa_sizeset = ntohl(*dp++))) { | 277 if ((sa3->sa_sizeset = ntohl(*dp++))) { |
192 if (dp + 1 > ep) 193 return (NULL); | 278 TCHECK(dp[0]); |
194 sa3->sa_size = ntohl(*dp++); 195 } 196 | 279 sa3->sa_size = ntohl(*dp++); 280 } 281 |
197 if (dp + 1 > ep) 198 return (NULL); | 282 TCHECK(dp[0]); |
199 if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { | 283 if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { |
200 if (dp + 2 > ep) 201 return (NULL); | 284 TCHECK(dp[1]); |
202 sa3->sa_atime.nfsv3_sec = ntohl(*dp++); 203 sa3->sa_atime.nfsv3_nsec = ntohl(*dp++); 204 } 205 | 285 sa3->sa_atime.nfsv3_sec = ntohl(*dp++); 286 sa3->sa_atime.nfsv3_nsec = ntohl(*dp++); 287 } 288 |
206 if (dp + 1 > ep) 207 return (NULL); | 289 TCHECK(dp[0]); |
208 if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { | 290 if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { |
209 if (dp + 2 > ep) 210 return (NULL); | 291 TCHECK(dp[1]); |
211 sa3->sa_mtime.nfsv3_sec = ntohl(*dp++); 212 sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++); 213 } 214 215 return dp; | 292 sa3->sa_mtime.nfsv3_sec = ntohl(*dp++); 293 sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++); 294 } 295 296 return dp; |
297trunc: 298 return NULL; |
|
216} 217 | 299} 300 |
218void | 301static int nfserr; /* true if we error rather than trunc */ 302 303static void |
219print_sattr3(const struct nfsv3_sattr *sa3, int verbose) 220{ 221 if (sa3->sa_modeset) 222 printf(" mode %o", sa3->sa_mode); 223 if (sa3->sa_uidset) 224 printf(" uid %u", sa3->sa_uid); 225 if (sa3->sa_gidset) 226 printf(" gid %u", sa3->sa_gid); --- 7 unchanged lines hidden (view full) --- 234 } 235} 236 237void 238nfsreply_print(register const u_char *bp, u_int length, 239 register const u_char *bp2) 240{ 241 register const struct rpc_msg *rp; | 304print_sattr3(const struct nfsv3_sattr *sa3, int verbose) 305{ 306 if (sa3->sa_modeset) 307 printf(" mode %o", sa3->sa_mode); 308 if (sa3->sa_uidset) 309 printf(" uid %u", sa3->sa_uid); 310 if (sa3->sa_gidset) 311 printf(" gid %u", sa3->sa_gid); --- 7 unchanged lines hidden (view full) --- 319 } 320} 321 322void 323nfsreply_print(register const u_char *bp, u_int length, 324 register const u_char *bp2) 325{ 326 register const struct rpc_msg *rp; |
242 register const struct ip *ip; | |
243 u_int32_t proc, vers; | 327 u_int32_t proc, vers; |
328 char srcid[20], dstid[20]; /*fits 32bit*/ |
|
244 245 nfserr = 0; /* assume no error */ 246 rp = (const struct rpc_msg *)bp; | 329 330 nfserr = 0; /* assume no error */ 331 rp = (const struct rpc_msg *)bp; |
247 ip = (const struct ip *)bp2; | |
248 | 332 |
249 if (!nflag) 250 (void)printf("%s.nfs > %s.%u: reply %s %d", 251 ipaddr_string(&ip->ip_src), 252 ipaddr_string(&ip->ip_dst), 253 (u_int32_t)ntohl(rp->rm_xid), 254 ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED? 255 "ok":"ERR", | 333 if (!nflag) { 334 strlcpy(srcid, "nfs", sizeof(srcid)); 335 snprintf(dstid, sizeof(dstid), "%u", 336 (u_int32_t)ntohl(rp->rm_xid)); 337 } else { 338 snprintf(srcid, sizeof(srcid), "%u", NFS_PORT); 339 snprintf(dstid, sizeof(dstid), "%u", 340 (u_int32_t)ntohl(rp->rm_xid)); 341 } 342 print_nfsaddr(bp2, srcid, dstid); 343 (void)printf("reply %s %d", 344 ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED? 345 "ok":"ERR", |
256 length); | 346 length); |
257 else 258 (void)printf("%s.%u > %s.%u: reply %s %d", 259 ipaddr_string(&ip->ip_src), 260 NFS_PORT, 261 ipaddr_string(&ip->ip_dst), 262 (u_int32_t)ntohl(rp->rm_xid), 263 ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED? 264 "ok":"ERR", 265 length); | |
266 | 347 |
267 if (xid_map_find(rp, ip, &proc, &vers) >= 0) | 348 if (xid_map_find(rp, bp2, &proc, &vers) >= 0) |
268 interp_reply(rp, proc, vers, length); 269} 270 271/* 272 * Return a pointer to the first file handle in the packet. | 349 interp_reply(rp, proc, vers, length); 350} 351 352/* 353 * Return a pointer to the first file handle in the packet. |
273 * If the packet was truncated, return NULL. | 354 * If the packet was truncated, return 0. |
274 */ 275static const u_int32_t * | 355 */ 356static const u_int32_t * |
276parsereq(register const struct rpc_msg *rp, register int length) | 357parsereq(register const struct rpc_msg *rp, register u_int length) |
277{ 278 register const u_int32_t *dp; 279 register u_int len; 280 281 /* 282 * find the start of the req data (if we captured it) 283 */ 284 dp = (u_int32_t *)&rp->rm_call.cb_cred; --- 10 unchanged lines hidden (view full) --- 295 } 296 } 297trunc: 298 return (NULL); 299} 300 301/* 302 * Print out an NFS file handle and return a pointer to following word. | 358{ 359 register const u_int32_t *dp; 360 register u_int len; 361 362 /* 363 * find the start of the req data (if we captured it) 364 */ 365 dp = (u_int32_t *)&rp->rm_call.cb_cred; --- 10 unchanged lines hidden (view full) --- 376 } 377 } 378trunc: 379 return (NULL); 380} 381 382/* 383 * Print out an NFS file handle and return a pointer to following word. |
303 * If packet was truncated, return NULL. | 384 * If packet was truncated, return 0. |
304 */ 305static const u_int32_t * 306parsefh(register const u_int32_t *dp, int v3) 307{ 308 int len; 309 310 if (v3) { 311 TCHECK(dp[0]); --- 7 unchanged lines hidden (view full) --- 319 return (dp + len); 320 } 321trunc: 322 return (NULL); 323} 324 325/* 326 * Print out a file name and return pointer to 32-bit word past it. | 385 */ 386static const u_int32_t * 387parsefh(register const u_int32_t *dp, int v3) 388{ 389 int len; 390 391 if (v3) { 392 TCHECK(dp[0]); --- 7 unchanged lines hidden (view full) --- 400 return (dp + len); 401 } 402trunc: 403 return (NULL); 404} 405 406/* 407 * Print out a file name and return pointer to 32-bit word past it. |
327 * If packet was truncated, return NULL. | 408 * If packet was truncated, return 0. |
328 */ 329static const u_int32_t * 330parsefn(register const u_int32_t *dp) 331{ 332 register u_int32_t len; 333 register const u_char *cp; 334 335 /* Bail if we don't have the string length */ | 409 */ 410static const u_int32_t * 411parsefn(register const u_int32_t *dp) 412{ 413 register u_int32_t len; 414 register const u_char *cp; 415 416 /* Bail if we don't have the string length */ |
336 if ((u_char *)dp > snapend - sizeof(*dp)) 337 return (NULL); | 417 TCHECK(*dp); |
338 339 /* Fetch string length; convert to host order */ 340 len = *dp++; 341 NTOHL(len); 342 | 418 419 /* Fetch string length; convert to host order */ 420 len = *dp++; 421 NTOHL(len); 422 |
423 TCHECK2(*dp, ((len + 3) & ~3)); 424 |
|
343 cp = (u_char *)dp; 344 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */ 345 dp += ((len + 3) & ~3) / sizeof(*dp); | 425 cp = (u_char *)dp; 426 /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */ 427 dp += ((len + 3) & ~3) / sizeof(*dp); |
346 if ((u_char *)dp > snapend) 347 return (NULL); | |
348 /* XXX seems like we should be checking the length */ 349 putchar('"'); 350 (void) fn_printn(cp, len, NULL); 351 putchar('"'); 352 353 return (dp); | 428 /* XXX seems like we should be checking the length */ 429 putchar('"'); 430 (void) fn_printn(cp, len, NULL); 431 putchar('"'); 432 433 return (dp); |
434trunc: 435 return NULL; |
|
354} 355 356/* 357 * Print out file handle and file name. 358 * Return pointer to 32-bit word past file name. | 436} 437 438/* 439 * Print out file handle and file name. 440 * Return pointer to 32-bit word past file name. |
359 * If packet was truncated (or there was some other error), return NULL. | 441 * If packet was truncated (or there was some other error), return 0. |
360 */ 361static const u_int32_t * 362parsefhn(register const u_int32_t *dp, int v3) 363{ 364 dp = parsefh(dp, v3); 365 if (dp == NULL) 366 return (NULL); 367 putchar(' '); 368 return (parsefn(dp)); 369} 370 371void 372nfsreq_print(register const u_char *bp, u_int length, 373 register const u_char *bp2) 374{ 375 register const struct rpc_msg *rp; | 442 */ 443static const u_int32_t * 444parsefhn(register const u_int32_t *dp, int v3) 445{ 446 dp = parsefh(dp, v3); 447 if (dp == NULL) 448 return (NULL); 449 putchar(' '); 450 return (parsefn(dp)); 451} 452 453void 454nfsreq_print(register const u_char *bp, u_int length, 455 register const u_char *bp2) 456{ 457 register const struct rpc_msg *rp; |
376 register const struct ip *ip; | |
377 register const u_int32_t *dp; | 458 register const u_int32_t *dp; |
378 nfstype type; 379 int proc, v3; | 459 nfs_type type; 460 int v3; 461 u_int32_t proc; |
380 struct nfsv3_sattr sa3; | 462 struct nfsv3_sattr sa3; |
463 char srcid[20], dstid[20]; /*fits 32bit*/ |
|
381 382 nfserr = 0; /* assume no error */ 383 rp = (const struct rpc_msg *)bp; | 464 465 nfserr = 0; /* assume no error */ 466 rp = (const struct rpc_msg *)bp; |
384 ip = (const struct ip *)bp2; 385 if (!nflag) 386 (void)printf("%s.%u > %s.nfs: %d", 387 ipaddr_string(&ip->ip_src), 388 (u_int32_t)ntohl(rp->rm_xid), 389 ipaddr_string(&ip->ip_dst), 390 length); 391 else 392 (void)printf("%s.%u > %s.%u: %d", 393 ipaddr_string(&ip->ip_src), 394 (u_int32_t)ntohl(rp->rm_xid), 395 ipaddr_string(&ip->ip_dst), 396 NFS_PORT, 397 length); | 467 if (!nflag) { 468 snprintf(srcid, sizeof(srcid), "%u", 469 (u_int32_t)ntohl(rp->rm_xid)); 470 strlcpy(dstid, "nfs", sizeof(dstid)); 471 } else { 472 snprintf(srcid, sizeof(srcid), "%u", 473 (u_int32_t)ntohl(rp->rm_xid)); 474 snprintf(dstid, sizeof(dstid), "%u", NFS_PORT); 475 } 476 print_nfsaddr(bp2, srcid, dstid); 477 (void)printf("%d", length); |
398 | 478 |
399 xid_map_enter(rp, ip); /* record proc number for later on */ | 479 xid_map_enter(rp, bp2); /* record proc number for later on */ |
400 401 v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3); 402 proc = ntohl(rp->rm_call.cb_proc); 403 404 if (!v3 && proc < NFS_NPROCS) 405 proc = nfsv3_procid[proc]; 406 407 switch (proc) { 408 case NFSPROC_NOOP: 409 printf(" nop"); 410 return; 411 case NFSPROC_NULL: 412 printf(" null"); 413 return; 414 415 case NFSPROC_GETATTR: 416 printf(" getattr"); | 480 481 v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3); 482 proc = ntohl(rp->rm_call.cb_proc); 483 484 if (!v3 && proc < NFS_NPROCS) 485 proc = nfsv3_procid[proc]; 486 487 switch (proc) { 488 case NFSPROC_NOOP: 489 printf(" nop"); 490 return; 491 case NFSPROC_NULL: 492 printf(" null"); 493 return; 494 495 case NFSPROC_GETATTR: 496 printf(" getattr"); |
417 if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) | 497 if ((dp = parsereq(rp, length)) != NULL && 498 parsefh(dp, v3) != NULL) |
418 return; 419 break; 420 421 case NFSPROC_SETATTR: 422 printf(" setattr"); | 499 return; 500 break; 501 502 case NFSPROC_SETATTR: 503 printf(" setattr"); |
423 if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) | 504 if ((dp = parsereq(rp, length)) != NULL && 505 parsefh(dp, v3) != NULL) |
424 return; 425 break; 426 427 case NFSPROC_LOOKUP: 428 printf(" lookup"); | 506 return; 507 break; 508 509 case NFSPROC_LOOKUP: 510 printf(" lookup"); |
429 if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) | 511 if ((dp = parsereq(rp, length)) != NULL && 512 parsefhn(dp, v3) != NULL) |
430 return; 431 break; 432 433 case NFSPROC_ACCESS: 434 printf(" access"); 435 if ((dp = parsereq(rp, length)) != NULL && 436 (dp = parsefh(dp, v3)) != NULL) { | 513 return; 514 break; 515 516 case NFSPROC_ACCESS: 517 printf(" access"); 518 if ((dp = parsereq(rp, length)) != NULL && 519 (dp = parsefh(dp, v3)) != NULL) { |
437 TCHECK(*dp); 438 printf(" %04lx", ntohl(dp[0])); | 520 TCHECK(dp[0]); 521 printf(" %04x", (u_int32_t)ntohl(dp[0])); |
439 return; 440 } 441 break; 442 443 case NFSPROC_READLINK: 444 printf(" readlink"); | 522 return; 523 } 524 break; 525 526 case NFSPROC_READLINK: 527 printf(" readlink"); |
445 if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) | 528 if ((dp = parsereq(rp, length)) != NULL && 529 parsefh(dp, v3) != NULL) |
446 return; 447 break; 448 449 case NFSPROC_READ: 450 printf(" read"); 451 if ((dp = parsereq(rp, length)) != NULL && 452 (dp = parsefh(dp, v3)) != NULL) { 453 if (v3) { | 530 return; 531 break; 532 533 case NFSPROC_READ: 534 printf(" read"); 535 if ((dp = parsereq(rp, length)) != NULL && 536 (dp = parsefh(dp, v3)) != NULL) { 537 if (v3) { |
454 TCHECK2(*dp, 3 * sizeof(*dp)); 455 printf(" %lu bytes @ ", ntohl(dp[2])); | 538 TCHECK(dp[2]); 539 printf(" %u bytes @ ", 540 (u_int32_t) ntohl(dp[2])); |
456 print_int64(dp, UNSIGNED); 457 } else { | 541 print_int64(dp, UNSIGNED); 542 } else { |
458 TCHECK2(*dp, 2 * sizeof(*dp)); 459 printf(" %lu bytes @ %lu", 460 ntohl(dp[1]), ntohl(dp[0])); | 543 TCHECK(dp[1]); 544 printf(" %u bytes @ %u", 545 (u_int32_t)ntohl(dp[1]), 546 (u_int32_t)ntohl(dp[0])); |
461 } 462 return; 463 } 464 break; 465 466 case NFSPROC_WRITE: 467 printf(" write"); 468 if ((dp = parsereq(rp, length)) != NULL && 469 (dp = parsefh(dp, v3)) != NULL) { 470 if (v3) { | 547 } 548 return; 549 } 550 break; 551 552 case NFSPROC_WRITE: 553 printf(" write"); 554 if ((dp = parsereq(rp, length)) != NULL && 555 (dp = parsefh(dp, v3)) != NULL) { 556 if (v3) { |
471 TCHECK2(*dp, 3 * sizeof(*dp)); 472 printf(" %lu bytes @ ", ntohl(dp[4])); | 557 TCHECK(dp[4]); 558 printf(" %u bytes @ ", 559 (u_int32_t) ntohl(dp[4])); |
473 print_int64(dp, UNSIGNED); 474 if (vflag) { 475 dp += 3; | 560 print_int64(dp, UNSIGNED); 561 if (vflag) { 562 dp += 3; |
476 TCHECK2(*dp, sizeof(*dp)); | 563 TCHECK(dp[0]); |
477 printf(" <%s>", | 564 printf(" <%s>", |
478 nfsv3_writemodes[ntohl(*dp)]); | 565 tok2str(nfsv3_writemodes, 566 NULL, ntohl(*dp))); |
479 } 480 } else { | 567 } 568 } else { |
481 TCHECK2(*dp, 4 * sizeof(*dp)); 482 printf(" %lu (%lu) bytes @ %lu (%lu)", 483 ntohl(dp[3]), ntohl(dp[2]), 484 ntohl(dp[1]), ntohl(dp[0])); | 569 TCHECK(dp[3]); 570 printf(" %u (%u) bytes @ %u (%u)", 571 (u_int32_t)ntohl(dp[3]), 572 (u_int32_t)ntohl(dp[2]), 573 (u_int32_t)ntohl(dp[1]), 574 (u_int32_t)ntohl(dp[0])); |
485 } 486 return; 487 } 488 break; 489 490 case NFSPROC_CREATE: 491 printf(" create"); | 575 } 576 return; 577 } 578 break; 579 580 case NFSPROC_CREATE: 581 printf(" create"); |
492 if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) | 582 if ((dp = parsereq(rp, length)) != NULL && 583 parsefhn(dp, v3) != NULL) |
493 return; 494 break; 495 496 case NFSPROC_MKDIR: 497 printf(" mkdir"); | 584 return; 585 break; 586 587 case NFSPROC_MKDIR: 588 printf(" mkdir"); |
498 if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) | 589 if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) |
499 return; 500 break; 501 502 case NFSPROC_SYMLINK: 503 printf(" symlink"); | 590 return; 591 break; 592 593 case NFSPROC_SYMLINK: 594 printf(" symlink"); |
504 if ((dp = parsereq(rp, length)) != NULL && 505 (dp = parsefhn(dp, v3)) != NULL) { 506 fputs(" -> ", stdout); 507 if (v3 && (dp = parse_sattr3(dp, &sa3)) == NULL) | 595 if ((dp = parsereq(rp, length)) != 0 && 596 (dp = parsefhn(dp, v3)) != 0) { 597 fputs(" ->", stdout); 598 if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0) |
508 break; | 599 break; |
509 if (parsefn(dp) == NULL) | 600 if (parsefn(dp) == 0) |
510 break; 511 if (v3 && vflag) 512 print_sattr3(&sa3, vflag); 513 return; 514 } 515 break; 516 517 case NFSPROC_MKNOD: 518 printf(" mknod"); | 601 break; 602 if (v3 && vflag) 603 print_sattr3(&sa3, vflag); 604 return; 605 } 606 break; 607 608 case NFSPROC_MKNOD: 609 printf(" mknod"); |
519 if ((dp = parsereq(rp, length)) != NULL && 520 (dp = parsefhn(dp, v3)) != NULL) { 521 if (dp + 1 > (u_int32_t *)snapend) | 610 if ((dp = parsereq(rp, length)) != 0 && 611 (dp = parsefhn(dp, v3)) != 0) { 612 TCHECK(*dp); 613 type = (nfs_type)ntohl(*dp++); 614 if ((dp = parse_sattr3(dp, &sa3)) == 0) |
522 break; | 615 break; |
523 type = (nfstype)ntohl(*dp++); 524 if ((dp = parse_sattr3(dp, &sa3)) == NULL) 525 break; | |
526 printf(" %s", tok2str(type2str, "unk-ft %d", type)); 527 if (vflag && (type == NFCHR || type == NFBLK)) { | 616 printf(" %s", tok2str(type2str, "unk-ft %d", type)); 617 if (vflag && (type == NFCHR || type == NFBLK)) { |
528 if (dp + 2 > (u_int32_t *)snapend) 529 break; 530 printf(" %lu/%lu", ntohl(dp[0]), ntohl(dp[1])); | 618 TCHECK(dp[1]); 619 printf(" %u/%u", 620 (u_int32_t)ntohl(dp[0]), 621 (u_int32_t)ntohl(dp[1])); |
531 dp += 2; 532 } 533 if (vflag) 534 print_sattr3(&sa3, vflag); 535 return; 536 } 537 break; 538 539 case NFSPROC_REMOVE: 540 printf(" remove"); | 622 dp += 2; 623 } 624 if (vflag) 625 print_sattr3(&sa3, vflag); 626 return; 627 } 628 break; 629 630 case NFSPROC_REMOVE: 631 printf(" remove"); |
541 if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) | 632 if ((dp = parsereq(rp, length)) != NULL && 633 parsefhn(dp, v3) != NULL) |
542 return; 543 break; 544 545 case NFSPROC_RMDIR: 546 printf(" rmdir"); | 634 return; 635 break; 636 637 case NFSPROC_RMDIR: 638 printf(" rmdir"); |
547 if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) | 639 if ((dp = parsereq(rp, length)) != NULL && 640 parsefhn(dp, v3) != NULL) |
548 return; 549 break; 550 551 case NFSPROC_RENAME: 552 printf(" rename"); 553 if ((dp = parsereq(rp, length)) != NULL && 554 (dp = parsefhn(dp, v3)) != NULL) { 555 fputs(" ->", stdout); --- 12 unchanged lines hidden (view full) --- 568 } 569 break; 570 571 case NFSPROC_READDIR: 572 printf(" readdir"); 573 if ((dp = parsereq(rp, length)) != NULL && 574 (dp = parsefh(dp, v3)) != NULL) { 575 if (v3) { | 641 return; 642 break; 643 644 case NFSPROC_RENAME: 645 printf(" rename"); 646 if ((dp = parsereq(rp, length)) != NULL && 647 (dp = parsefhn(dp, v3)) != NULL) { 648 fputs(" ->", stdout); --- 12 unchanged lines hidden (view full) --- 661 } 662 break; 663 664 case NFSPROC_READDIR: 665 printf(" readdir"); 666 if ((dp = parsereq(rp, length)) != NULL && 667 (dp = parsefh(dp, v3)) != NULL) { 668 if (v3) { |
576 TCHECK2(*dp, 20); | 669 TCHECK(dp[4]); |
577 /* 578 * We shouldn't really try to interpret the 579 * offset cookie here. 580 */ | 670 /* 671 * We shouldn't really try to interpret the 672 * offset cookie here. 673 */ |
581 printf(" %lu bytes @ ", ntohl(dp[4])); | 674 printf(" %u bytes @ ", 675 (u_int32_t) ntohl(dp[4])); |
582 print_int64(dp, SIGNED); 583 if (vflag) 584 printf(" verf %08x%08x", dp[2], 585 dp[3]); 586 } else { | 676 print_int64(dp, SIGNED); 677 if (vflag) 678 printf(" verf %08x%08x", dp[2], 679 dp[3]); 680 } else { |
587 TCHECK2(*dp, 2 * sizeof(*dp)); | 681 TCHECK(dp[1]); |
588 /* 589 * Print the offset as signed, since -1 is 590 * common, but offsets > 2^31 aren't. 591 */ | 682 /* 683 * Print the offset as signed, since -1 is 684 * common, but offsets > 2^31 aren't. 685 */ |
592 printf(" %lu bytes @ %ld", ntohl(dp[1]), 593 ntohl(dp[0])); | 686 printf(" %u bytes @ %d", 687 (u_int32_t)ntohl(dp[1]), 688 (u_int32_t)ntohl(dp[0])); |
594 } 595 return; 596 } 597 break; 598 599 case NFSPROC_READDIRPLUS: 600 printf(" readdirplus"); 601 if ((dp = parsereq(rp, length)) != NULL && 602 (dp = parsefh(dp, v3)) != NULL) { | 689 } 690 return; 691 } 692 break; 693 694 case NFSPROC_READDIRPLUS: 695 printf(" readdirplus"); 696 if ((dp = parsereq(rp, length)) != NULL && 697 (dp = parsefh(dp, v3)) != NULL) { |
603 TCHECK2(*dp, 20); | 698 TCHECK(dp[4]); |
604 /* 605 * We don't try to interpret the offset 606 * cookie here. 607 */ | 699 /* 700 * We don't try to interpret the offset 701 * cookie here. 702 */ |
608 printf(" %lu bytes @ ", ntohl(dp[4])); | 703 printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4])); |
609 print_int64(dp, SIGNED); 610 if (vflag) | 704 print_int64(dp, SIGNED); 705 if (vflag) |
611 printf(" max %lu verf %08x%08x", 612 ntohl(dp[5]), dp[2], dp[3]); | 706 printf(" max %u verf %08x%08x", 707 (u_int32_t) ntohl(dp[5]), dp[2], dp[3]); |
613 return; 614 } 615 break; 616 617 case NFSPROC_FSSTAT: 618 printf(" fsstat"); | 708 return; 709 } 710 break; 711 712 case NFSPROC_FSSTAT: 713 printf(" fsstat"); |
619 if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) | 714 if ((dp = parsereq(rp, length)) != NULL && 715 parsefh(dp, v3) != NULL) |
620 return; 621 break; 622 623 case NFSPROC_FSINFO: 624 printf(" fsinfo"); 625 break; 626 627 case NFSPROC_PATHCONF: 628 printf(" pathconf"); 629 break; 630 631 case NFSPROC_COMMIT: 632 printf(" commit"); 633 if ((dp = parsereq(rp, length)) != NULL && 634 (dp = parsefh(dp, v3)) != NULL) { | 716 return; 717 break; 718 719 case NFSPROC_FSINFO: 720 printf(" fsinfo"); 721 break; 722 723 case NFSPROC_PATHCONF: 724 printf(" pathconf"); 725 break; 726 727 case NFSPROC_COMMIT: 728 printf(" commit"); 729 if ((dp = parsereq(rp, length)) != NULL && 730 (dp = parsefh(dp, v3)) != NULL) { |
635 printf(" %lu bytes @ ", ntohl(dp[2])); | 731 printf(" %u bytes @ ", (u_int32_t) ntohl(dp[2])); |
636 print_int64(dp, UNSIGNED); 637 return; 638 } 639 break; 640 641 default: | 732 print_int64(dp, UNSIGNED); 733 return; 734 } 735 break; 736 737 default: |
642 printf(" proc-%lu", ntohl(rp->rm_call.cb_proc)); | 738 printf(" proc-%u", (u_int32_t)ntohl(rp->rm_call.cb_proc)); |
643 return; 644 } | 739 return; 740 } |
741 |
|
645trunc: 646 if (!nfserr) 647 fputs(" [|nfs]", stdout); 648} 649 650/* 651 * Print out an NFS file handle. 652 * We assume packet was not truncated before the end of the 653 * file handle pointed to by dp. 654 * 655 * Note: new version (using portable file-handle parser) doesn't produce 656 * generation number. It probably could be made to do that, with some 657 * additional hacking on the parser code. 658 */ 659static void | 742trunc: 743 if (!nfserr) 744 fputs(" [|nfs]", stdout); 745} 746 747/* 748 * Print out an NFS file handle. 749 * We assume packet was not truncated before the end of the 750 * file handle pointed to by dp. 751 * 752 * Note: new version (using portable file-handle parser) doesn't produce 753 * generation number. It probably could be made to do that, with some 754 * additional hacking on the parser code. 755 */ 756static void |
660nfs_printfh(register const u_int32_t *dp, const int len) | 757nfs_printfh(register const u_int32_t *dp, const u_int len) |
661{ 662 my_fsid fsid; 663 ino_t ino; 664 char *sfsname = NULL; 665 | 758{ 759 my_fsid fsid; 760 ino_t ino; 761 char *sfsname = NULL; 762 |
666 Parse_fh((caddr_t *)dp, len, &fsid, &ino, NULL, &sfsname, 0); | 763 Parse_fh((caddr_t*)dp, len, &fsid, &ino, NULL, &sfsname, 0); |
667 668 if (sfsname) { 669 /* file system ID is ASCII, not numeric, for this server OS */ 670 static char temp[NFSX_V3FHMAX+1]; 671 672 /* Make sure string is null-terminated */ 673 strncpy(temp, sfsname, NFSX_V3FHMAX); | 764 765 if (sfsname) { 766 /* file system ID is ASCII, not numeric, for this server OS */ 767 static char temp[NFSX_V3FHMAX+1]; 768 769 /* Make sure string is null-terminated */ 770 strncpy(temp, sfsname, NFSX_V3FHMAX); |
771 temp[sizeof(temp) - 1] = '\0'; |
|
674 /* Remove trailing spaces */ 675 sfsname = strchr(temp, ' '); 676 if (sfsname) 677 *sfsname = 0; 678 | 772 /* Remove trailing spaces */ 773 sfsname = strchr(temp, ' '); 774 if (sfsname) 775 *sfsname = 0; 776 |
679 (void)printf(" fh %s/%u", temp, (u_int32_t)ino); | 777 (void)printf(" fh %s/", temp); |
680 } else { | 778 } else { |
681 (void)printf(" fh %u,%u/%u", 682 fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor, (u_int32_t)ino); | 779 (void)printf(" fh %d,%d/", 780 fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor); |
683 } | 781 } |
782 783 if(fsid.Fsid_dev.Minor == 257 && uflag) 784 /* Print the undecoded handle */ 785 (void)printf("%s", fsid.Opaque_Handle); 786 else 787 (void)printf("%ld", (long) ino); |
|
684} 685 686/* 687 * Maintain a small cache of recent client.XID.server/proc pairs, to allow 688 * us to match up replies with requests and thus to know how to parse 689 * the reply. 690 */ 691 692struct xid_map_entry { | 788} 789 790/* 791 * Maintain a small cache of recent client.XID.server/proc pairs, to allow 792 * us to match up replies with requests and thus to know how to parse 793 * the reply. 794 */ 795 796struct xid_map_entry { |
693 u_int32_t xid; /* transaction ID (net order) */ | 797 u_int32_t xid; /* transaction ID (net order) */ 798 int ipver; /* IP version (4 or 6) */ 799#ifdef INET6 800 struct in6_addr client; /* client IP address (net order) */ 801 struct in6_addr server; /* server IP address (net order) */ 802#else |
694 struct in_addr client; /* client IP address (net order) */ 695 struct in_addr server; /* server IP address (net order) */ | 803 struct in_addr client; /* client IP address (net order) */ 804 struct in_addr server; /* server IP address (net order) */ |
696 u_int32_t proc; /* call proc number (host order) */ 697 u_int32_t vers; /* program version (host order) */ | 805#endif 806 u_int32_t proc; /* call proc number (host order) */ 807 u_int32_t vers; /* program version (host order) */ |
698}; 699 700/* 701 * Map entries are kept in an array that we manage as a ring; 702 * new entries are always added at the tail of the ring. Initially, 703 * all the entries are zero and hence don't match anything. 704 */ 705 706#define XIDMAPSIZE 64 707 708struct xid_map_entry xid_map[XIDMAPSIZE]; 709 710int xid_map_next = 0; 711int xid_map_hint = 0; 712 713static void | 808}; 809 810/* 811 * Map entries are kept in an array that we manage as a ring; 812 * new entries are always added at the tail of the ring. Initially, 813 * all the entries are zero and hence don't match anything. 814 */ 815 816#define XIDMAPSIZE 64 817 818struct xid_map_entry xid_map[XIDMAPSIZE]; 819 820int xid_map_next = 0; 821int xid_map_hint = 0; 822 823static void |
714xid_map_enter(const struct rpc_msg *rp, const struct ip *ip) | 824xid_map_enter(const struct rpc_msg *rp, const u_char *bp) |
715{ | 825{ |
826 struct ip *ip = NULL; 827#ifdef INET6 828 struct ip6_hdr *ip6 = NULL; 829#endif |
|
716 struct xid_map_entry *xmep; 717 | 830 struct xid_map_entry *xmep; 831 |
832 switch (IP_V((struct ip *)bp)) { 833 case 4: 834 ip = (struct ip *)bp; 835 break; 836#ifdef INET6 837 case 6: 838 ip6 = (struct ip6_hdr *)bp; 839 break; 840#endif 841 default: 842 return; 843 } 844 |
|
718 xmep = &xid_map[xid_map_next]; 719 720 if (++xid_map_next >= XIDMAPSIZE) 721 xid_map_next = 0; 722 723 xmep->xid = rp->rm_xid; | 845 xmep = &xid_map[xid_map_next]; 846 847 if (++xid_map_next >= XIDMAPSIZE) 848 xid_map_next = 0; 849 850 xmep->xid = rp->rm_xid; |
724 xmep->client = ip->ip_src; 725 xmep->server = ip->ip_dst; | 851 if (ip) { 852 xmep->ipver = 4; 853 memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src)); 854 memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst)); 855 } 856#ifdef INET6 857 else if (ip6) { 858 xmep->ipver = 6; 859 memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src)); 860 memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); 861 } 862#endif |
726 xmep->proc = ntohl(rp->rm_call.cb_proc); 727 xmep->vers = ntohl(rp->rm_call.cb_vers); 728} 729 730/* 731 * Returns 0 and puts NFSPROC_xxx in proc return and 732 * version in vers return, or returns -1 on failure 733 */ 734static int | 863 xmep->proc = ntohl(rp->rm_call.cb_proc); 864 xmep->vers = ntohl(rp->rm_call.cb_vers); 865} 866 867/* 868 * Returns 0 and puts NFSPROC_xxx in proc return and 869 * version in vers return, or returns -1 on failure 870 */ 871static int |
735xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc, | 872xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc, |
736 u_int32_t *vers) 737{ 738 int i; 739 struct xid_map_entry *xmep; 740 u_int32_t xid = rp->rm_xid; | 873 u_int32_t *vers) 874{ 875 int i; 876 struct xid_map_entry *xmep; 877 u_int32_t xid = rp->rm_xid; |
741 u_int32_t clip = ip->ip_dst.s_addr; 742 u_int32_t sip = ip->ip_src.s_addr; | 878 struct ip *ip = (struct ip *)bp; 879#ifdef INET6 880 struct ip6_hdr *ip6 = (struct ip6_hdr *)bp; 881#endif 882 int cmp; |
743 744 /* Start searching from where we last left off */ | 883 884 /* Start searching from where we last left off */ |
745 i = xid_map_hint; | 885 i = xid_map_hint; |
746 do { 747 xmep = &xid_map[i]; | 886 do { 887 xmep = &xid_map[i]; |
748 if (xmep->xid == xid && xmep->client.s_addr == clip && 749 xmep->server.s_addr == sip) { | 888 cmp = 1; 889 if (xmep->ipver != IP_V(ip) || xmep->xid != xid) 890 goto nextitem; 891 switch (xmep->ipver) { 892 case 4: 893 if (memcmp(&ip->ip_src, &xmep->server, 894 sizeof(ip->ip_src)) != 0 || 895 memcmp(&ip->ip_dst, &xmep->client, 896 sizeof(ip->ip_dst)) != 0) { 897 cmp = 0; 898 } 899 break; 900#ifdef INET6 901 case 6: 902 if (memcmp(&ip6->ip6_src, &xmep->server, 903 sizeof(ip6->ip6_src)) != 0 || 904 memcmp(&ip6->ip6_dst, &xmep->client, 905 sizeof(ip6->ip6_dst)) != 0) { 906 cmp = 0; 907 } 908 break; 909#endif 910 default: 911 cmp = 0; 912 break; 913 } 914 if (cmp) { |
750 /* match */ 751 xid_map_hint = i; 752 *proc = xmep->proc; 753 *vers = xmep->vers; 754 return 0; 755 } | 915 /* match */ 916 xid_map_hint = i; 917 *proc = xmep->proc; 918 *vers = xmep->vers; 919 return 0; 920 } |
921 nextitem: |
|
756 if (++i >= XIDMAPSIZE) 757 i = 0; 758 } while (i != xid_map_hint); 759 760 /* search failed */ | 922 if (++i >= XIDMAPSIZE) 923 i = 0; 924 } while (i != xid_map_hint); 925 926 /* search failed */ |
761 return (0); | 927 return (-1); |
762} 763 764/* 765 * Routines for parsing reply packets 766 */ 767 768/* 769 * Return a pointer to the beginning of the actual results. | 928} 929 930/* 931 * Routines for parsing reply packets 932 */ 933 934/* 935 * Return a pointer to the beginning of the actual results. |
770 * If the packet was truncated, return NULL. | 936 * If the packet was truncated, return 0. |
771 */ 772static const u_int32_t * | 937 */ 938static const u_int32_t * |
773parserep(register const struct rpc_msg *rp, register int length) | 939parserep(register const struct rpc_msg *rp, register u_int length) |
774{ 775 register const u_int32_t *dp; | 940{ 941 register const u_int32_t *dp; |
776 int len; | 942 u_int len; |
777 enum accept_stat astat; 778 779 /* 780 * Portability note: 781 * Here we find the address of the ar_verf credentials. 782 * Originally, this calculation was 783 * dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf 784 * On the wire, the rp_acpt field starts immediately after 785 * the (32 bit) rp_stat field. However, rp_acpt (which is a 786 * "struct accepted_reply") contains a "struct opaque_auth", 787 * whose internal representation contains a pointer, so on a 788 * 64-bit machine the compiler inserts 32 bits of padding 789 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use 790 * the internal representation to parse the on-the-wire 791 * representation. Instead, we skip past the rp_stat field, 792 * which is an "enum" and so occupies one 32-bit word. 793 */ 794 dp = ((const u_int32_t *)&rp->rm_reply) + 1; | 943 enum accept_stat astat; 944 945 /* 946 * Portability note: 947 * Here we find the address of the ar_verf credentials. 948 * Originally, this calculation was 949 * dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf 950 * On the wire, the rp_acpt field starts immediately after 951 * the (32 bit) rp_stat field. However, rp_acpt (which is a 952 * "struct accepted_reply") contains a "struct opaque_auth", 953 * whose internal representation contains a pointer, so on a 954 * 64-bit machine the compiler inserts 32 bits of padding 955 * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use 956 * the internal representation to parse the on-the-wire 957 * representation. Instead, we skip past the rp_stat field, 958 * which is an "enum" and so occupies one 32-bit word. 959 */ 960 dp = ((const u_int32_t *)&rp->rm_reply) + 1; |
795 TCHECK2(dp[0], 1); | 961 TCHECK(dp[1]); |
796 len = ntohl(dp[1]); 797 if (len >= length) 798 return (NULL); 799 /* 800 * skip past the ar_verf credentials. 801 */ 802 dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t); 803 TCHECK2(dp[0], 0); --- 33 unchanged lines hidden (view full) --- 837 return (NULL); 838 839 default: 840 printf(" ar_stat %d", astat); 841 nfserr = 1; /* suppress trunc string */ 842 return (NULL); 843 } 844 /* successful return */ | 962 len = ntohl(dp[1]); 963 if (len >= length) 964 return (NULL); 965 /* 966 * skip past the ar_verf credentials. 967 */ 968 dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t); 969 TCHECK2(dp[0], 0); --- 33 unchanged lines hidden (view full) --- 1003 return (NULL); 1004 1005 default: 1006 printf(" ar_stat %d", astat); 1007 nfserr = 1; /* suppress trunc string */ 1008 return (NULL); 1009 } 1010 /* successful return */ |
845 if ((sizeof(astat) + ((u_char *)dp)) < snapend) 846 return ((u_int32_t *) (sizeof(astat) + ((char *)dp))); 847 | 1011 TCHECK2(*dp, sizeof(astat)); 1012 return ((u_int32_t *) (sizeof(astat) + ((char *)dp))); |
848trunc: | 1013trunc: |
849 return (NULL); | 1014 return (0); |
850} 851 | 1015} 1016 |
852 | |
853static const u_int32_t * 854parsestatus(const u_int32_t *dp, int *er) 855{ | 1017static const u_int32_t * 1018parsestatus(const u_int32_t *dp, int *er) 1019{ |
856 register int errnum; | 1020 int errnum; |
857 858 TCHECK(dp[0]); | 1021 1022 TCHECK(dp[0]); |
1023 |
|
859 errnum = ntohl(dp[0]); 860 if (er) 861 *er = errnum; 862 if (errnum != 0) { 863 if (!qflag) | 1024 errnum = ntohl(dp[0]); 1025 if (er) 1026 *er = errnum; 1027 if (errnum != 0) { 1028 if (!qflag) |
864 printf(" ERROR: %s", pcap_strerror(errnum)); | 1029 printf(" ERROR: %s", 1030 tok2str(status2str, "unk %d", errnum)); |
865 nfserr = 1; 866 return (NULL); 867 } 868 return (dp + 1); 869trunc: | 1031 nfserr = 1; 1032 return (NULL); 1033 } 1034 return (dp + 1); 1035trunc: |
870 return (NULL); | 1036 return NULL; |
871} 872 873static const u_int32_t * 874parsefattr(const u_int32_t *dp, int verbose, int v3) 875{ 876 const struct nfs_fattr *fap; 877 878 fap = (const struct nfs_fattr *)dp; 879 TCHECK(fap->fa_gid); 880 if (verbose) { | 1037} 1038 1039static const u_int32_t * 1040parsefattr(const u_int32_t *dp, int verbose, int v3) 1041{ 1042 const struct nfs_fattr *fap; 1043 1044 fap = (const struct nfs_fattr *)dp; 1045 TCHECK(fap->fa_gid); 1046 if (verbose) { |
881 printf(" %s %lo ids %ld/%ld", 882 tok2str(type2str, "unk-ft %d ", ntohl(fap->fa_type)), 883 ntohl(fap->fa_mode), ntohl(fap->fa_uid), 884 ntohl(fap->fa_gid)); | 1047 printf(" %s %o ids %d/%d", 1048 tok2str(type2str, "unk-ft %d ", 1049 (u_int32_t)ntohl(fap->fa_type)), 1050 (u_int32_t)ntohl(fap->fa_mode), 1051 (u_int32_t)ntohl(fap->fa_uid), 1052 (u_int32_t) ntohl(fap->fa_gid)); |
885 if (v3) { 886 TCHECK(fap->fa3_size); 887 printf(" sz "); 888 print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED); 889 putchar(' '); 890 } else { 891 TCHECK(fap->fa2_size); | 1053 if (v3) { 1054 TCHECK(fap->fa3_size); 1055 printf(" sz "); 1056 print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED); 1057 putchar(' '); 1058 } else { 1059 TCHECK(fap->fa2_size); |
892 printf(" sz %ld ", ntohl(fap->fa2_size)); | 1060 printf(" sz %d ", (u_int32_t) ntohl(fap->fa2_size)); |
893 } 894 } 895 /* print lots more stuff */ 896 if (verbose > 1) { 897 if (v3) { 898 TCHECK(fap->fa3_ctime); | 1061 } 1062 } 1063 /* print lots more stuff */ 1064 if (verbose > 1) { 1065 if (v3) { 1066 TCHECK(fap->fa3_ctime); |
899 printf("nlink %ld rdev %ld/%ld ", 900 ntohl(fap->fa_nlink), 901 ntohl(fap->fa3_rdev.specdata1), 902 ntohl(fap->fa3_rdev.specdata2)); | 1067 printf("nlink %d rdev %d/%d ", 1068 (u_int32_t)ntohl(fap->fa_nlink), 1069 (u_int32_t) ntohl(fap->fa3_rdev.specdata1), 1070 (u_int32_t) ntohl(fap->fa3_rdev.specdata2)); |
903 printf("fsid "); 904 print_int64((u_int32_t *)&fap->fa2_fsid, HEX); 905 printf(" nodeid "); 906 print_int64((u_int32_t *)&fap->fa2_fileid, HEX); | 1071 printf("fsid "); 1072 print_int64((u_int32_t *)&fap->fa2_fsid, HEX); 1073 printf(" nodeid "); 1074 print_int64((u_int32_t *)&fap->fa2_fileid, HEX); |
907 printf(" a/m/ctime %lu.%06lu ", 908 ntohl(fap->fa3_atime.nfsv3_sec), 909 ntohl(fap->fa3_atime.nfsv3_nsec)); 910 printf("%lu.%06lu ", 911 ntohl(fap->fa3_mtime.nfsv3_sec), 912 ntohl(fap->fa3_mtime.nfsv3_nsec)); 913 printf("%lu.%06lu ", 914 ntohl(fap->fa3_ctime.nfsv3_sec), 915 ntohl(fap->fa3_ctime.nfsv3_nsec)); | 1075 printf(" a/m/ctime %u.%06u ", 1076 (u_int32_t) ntohl(fap->fa3_atime.nfsv3_sec), 1077 (u_int32_t) ntohl(fap->fa3_atime.nfsv3_nsec)); 1078 printf("%u.%06u ", 1079 (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_sec), 1080 (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_nsec)); 1081 printf("%u.%06u ", 1082 (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_sec), 1083 (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_nsec)); |
916 } else { 917 TCHECK(fap->fa2_ctime); | 1084 } else { 1085 TCHECK(fap->fa2_ctime); |
918 printf("nlink %ld rdev %lx fsid %lx nodeid %lx a/m/ctime ", 919 ntohl(fap->fa_nlink), ntohl(fap->fa2_rdev), 920 ntohl(fap->fa2_fsid), ntohl(fap->fa2_fileid)); 921 printf("%lu.%06lu ", 922 ntohl(fap->fa2_atime.nfsv2_sec), 923 ntohl(fap->fa2_atime.nfsv2_usec)); 924 printf("%lu.%06lu ", 925 ntohl(fap->fa2_mtime.nfsv2_sec), 926 ntohl(fap->fa2_mtime.nfsv2_usec)); 927 printf("%lu.%06lu ", 928 ntohl(fap->fa2_ctime.nfsv2_sec), 929 ntohl(fap->fa2_ctime.nfsv2_usec)); | 1086 printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ", 1087 (u_int32_t) ntohl(fap->fa_nlink), 1088 (u_int32_t) ntohl(fap->fa2_rdev), 1089 (u_int32_t) ntohl(fap->fa2_fsid), 1090 (u_int32_t) ntohl(fap->fa2_fileid)); 1091 printf("%u.%06u ", 1092 (u_int32_t) ntohl(fap->fa2_atime.nfsv2_sec), 1093 (u_int32_t) ntohl(fap->fa2_atime.nfsv2_usec)); 1094 printf("%u.%06u ", 1095 (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_sec), 1096 (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_usec)); 1097 printf("%u.%06u ", 1098 (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_sec), 1099 (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_usec)); |
930 } 931 } 932 return ((const u_int32_t *)((unsigned char *)dp + 933 (v3 ? NFSX_V3FATTR : NFSX_V2FATTR))); 934trunc: 935 return (NULL); 936} 937 --- 9 unchanged lines hidden (view full) --- 947 return (parsefattr(dp, verbose, v3) != NULL); 948} 949 950static int 951parsediropres(const u_int32_t *dp) 952{ 953 int er; 954 | 1100 } 1101 } 1102 return ((const u_int32_t *)((unsigned char *)dp + 1103 (v3 ? NFSX_V3FATTR : NFSX_V2FATTR))); 1104trunc: 1105 return (NULL); 1106} 1107 --- 9 unchanged lines hidden (view full) --- 1117 return (parsefattr(dp, verbose, v3) != NULL); 1118} 1119 1120static int 1121parsediropres(const u_int32_t *dp) 1122{ 1123 int er; 1124 |
955 dp = parsestatus(dp, &er); 956 if (dp == NULL || er) | 1125 if (!(dp = parsestatus(dp, &er)) || er) |
957 return (0); 958 959 dp = parsefh(dp, 0); 960 if (dp == NULL) 961 return (0); 962 963 return (parsefattr(dp, vflag, 0) != NULL); 964} 965 966static int 967parselinkres(const u_int32_t *dp, int v3) 968{ 969 int er; 970 971 dp = parsestatus(dp, &er); 972 if (dp == NULL || er) 973 return(0); | 1126 return (0); 1127 1128 dp = parsefh(dp, 0); 1129 if (dp == NULL) 1130 return (0); 1131 1132 return (parsefattr(dp, vflag, 0) != NULL); 1133} 1134 1135static int 1136parselinkres(const u_int32_t *dp, int v3) 1137{ 1138 int er; 1139 1140 dp = parsestatus(dp, &er); 1141 if (dp == NULL || er) 1142 return(0); |
974 975 if (v3 && ((dp = parse_post_op_attr(dp, vflag)) != NULL)) | 1143 if (v3 && !(dp = parse_post_op_attr(dp, vflag))) |
976 return (0); | 1144 return (0); |
977 | |
978 putchar(' '); 979 return (parsefn(dp) != NULL); 980} 981 982static int 983parsestatfs(const u_int32_t *dp, int v3) 984{ 985 const struct nfs_statfs *sfsp; 986 int er; 987 988 dp = parsestatus(dp, &er); 989 if (dp == NULL || (!v3 && er)) | 1145 putchar(' '); 1146 return (parsefn(dp) != NULL); 1147} 1148 1149static int 1150parsestatfs(const u_int32_t *dp, int v3) 1151{ 1152 const struct nfs_statfs *sfsp; 1153 int er; 1154 1155 dp = parsestatus(dp, &er); 1156 if (dp == NULL || (!v3 && er)) |
990 return(0); | 1157 return (0); |
991 992 if (qflag) 993 return(1); 994 995 if (v3) { 996 if (vflag) 997 printf(" POST:"); | 1158 1159 if (qflag) 1160 return(1); 1161 1162 if (v3) { 1163 if (vflag) 1164 printf(" POST:"); |
998 if ((dp = parse_post_op_attr(dp, vflag)) == NULL) | 1165 if (!(dp = parse_post_op_attr(dp, vflag))) |
999 return (0); 1000 } 1001 1002 TCHECK2(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS)); 1003 1004 sfsp = (const struct nfs_statfs *)dp; 1005 1006 if (v3) { --- 5 unchanged lines hidden (view full) --- 1012 print_int64((u_int32_t *)&sfsp->sf_abytes, UNSIGNED); 1013 if (vflag) { 1014 printf(" tfiles "); 1015 print_int64((u_int32_t *)&sfsp->sf_tfiles, UNSIGNED); 1016 printf(" ffiles "); 1017 print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED); 1018 printf(" afiles "); 1019 print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED); | 1166 return (0); 1167 } 1168 1169 TCHECK2(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS)); 1170 1171 sfsp = (const struct nfs_statfs *)dp; 1172 1173 if (v3) { --- 5 unchanged lines hidden (view full) --- 1179 print_int64((u_int32_t *)&sfsp->sf_abytes, UNSIGNED); 1180 if (vflag) { 1181 printf(" tfiles "); 1182 print_int64((u_int32_t *)&sfsp->sf_tfiles, UNSIGNED); 1183 printf(" ffiles "); 1184 print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED); 1185 printf(" afiles "); 1186 print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED); |
1020 printf(" invar %lu", ntohl(sfsp->sf_invarsec)); | 1187 printf(" invar %u", 1188 (u_int32_t) ntohl(sfsp->sf_invarsec)); |
1021 } 1022 } else { | 1189 } 1190 } else { |
1023 printf(" tsize %ld bsize %ld blocks %ld bfree %ld bavail %ld", 1024 ntohl(sfsp->sf_tsize), ntohl(sfsp->sf_bsize), 1025 ntohl(sfsp->sf_blocks), ntohl(sfsp->sf_bfree), 1026 ntohl(sfsp->sf_bavail)); | 1191 printf(" tsize %d bsize %d blocks %d bfree %d bavail %d", 1192 (u_int32_t)ntohl(sfsp->sf_tsize), 1193 (u_int32_t)ntohl(sfsp->sf_bsize), 1194 (u_int32_t)ntohl(sfsp->sf_blocks), 1195 (u_int32_t)ntohl(sfsp->sf_bfree), 1196 (u_int32_t)ntohl(sfsp->sf_bavail)); |
1027 } 1028 1029 return (1); 1030trunc: 1031 return (0); 1032} 1033 1034static int 1035parserddires(const u_int32_t *dp) 1036{ 1037 int er; 1038 1039 dp = parsestatus(dp, &er); | 1197 } 1198 1199 return (1); 1200trunc: 1201 return (0); 1202} 1203 1204static int 1205parserddires(const u_int32_t *dp) 1206{ 1207 int er; 1208 1209 dp = parsestatus(dp, &er); |
1040 if (dp == NULL || er) | 1210 if (dp == 0 || er) |
1041 return (0); 1042 if (qflag) 1043 return (1); 1044 1045 TCHECK(dp[2]); | 1211 return (0); 1212 if (qflag) 1213 return (1); 1214 1215 TCHECK(dp[2]); |
1046 printf(" offset %lx size %ld ", ntohl(dp[0]), ntohl(dp[1])); | 1216 printf(" offset %x size %d ", 1217 (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1])); |
1047 if (dp[2] != 0) | 1218 if (dp[2] != 0) |
1048 printf("eof"); | 1219 printf(" eof"); |
1049 1050 return (1); 1051trunc: 1052 return (0); 1053} 1054 1055static const u_int32_t * 1056parse_wcc_attr(const u_int32_t *dp) 1057{ 1058 printf(" sz "); 1059 print_int64(dp, UNSIGNED); | 1220 1221 return (1); 1222trunc: 1223 return (0); 1224} 1225 1226static const u_int32_t * 1227parse_wcc_attr(const u_int32_t *dp) 1228{ 1229 printf(" sz "); 1230 print_int64(dp, UNSIGNED); |
1060 printf(" mtime %lu.%06lu ctime %lu.%06lu", ntohl(dp[2]), ntohl(dp[3]), 1061 ntohl(dp[4]), ntohl(dp[5])); | 1231 printf(" mtime %u.%06u ctime %u.%06u", 1232 (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[3]), 1233 (u_int32_t)ntohl(dp[4]), (u_int32_t)ntohl(dp[5])); |
1062 return (dp + 6); 1063} 1064 1065/* 1066 * Pre operation attributes. Print only if vflag > 1. 1067 */ 1068static const u_int32_t * 1069parse_pre_op_attr(const u_int32_t *dp, int verbose) --- 31 unchanged lines hidden (view full) --- 1101 return (NULL); 1102} 1103 1104static const u_int32_t * 1105parse_wcc_data(const u_int32_t *dp, int verbose) 1106{ 1107 if (verbose > 1) 1108 printf(" PRE:"); | 1234 return (dp + 6); 1235} 1236 1237/* 1238 * Pre operation attributes. Print only if vflag > 1. 1239 */ 1240static const u_int32_t * 1241parse_pre_op_attr(const u_int32_t *dp, int verbose) --- 31 unchanged lines hidden (view full) --- 1273 return (NULL); 1274} 1275 1276static const u_int32_t * 1277parse_wcc_data(const u_int32_t *dp, int verbose) 1278{ 1279 if (verbose > 1) 1280 printf(" PRE:"); |
1109 if ((dp = parse_pre_op_attr(dp, verbose)) == NULL) 1110 return (NULL); | 1281 if (!(dp = parse_pre_op_attr(dp, verbose))) 1282 return (0); |
1111 1112 if (verbose) 1113 printf(" POST:"); 1114 return parse_post_op_attr(dp, verbose); 1115} 1116 1117static const u_int32_t * 1118parsecreateopres(const u_int32_t *dp, int verbose) 1119{ 1120 int er; 1121 | 1283 1284 if (verbose) 1285 printf(" POST:"); 1286 return parse_post_op_attr(dp, verbose); 1287} 1288 1289static const u_int32_t * 1290parsecreateopres(const u_int32_t *dp, int verbose) 1291{ 1292 int er; 1293 |
1122 if ((dp = parsestatus(dp, &er)) == NULL) 1123 return (NULL); | 1294 if (!(dp = parsestatus(dp, &er))) 1295 return (0); |
1124 if (er) 1125 dp = parse_wcc_data(dp, verbose); 1126 else { 1127 TCHECK(dp[0]); 1128 if (!ntohl(dp[0])) 1129 return (dp + 1); 1130 dp++; | 1296 if (er) 1297 dp = parse_wcc_data(dp, verbose); 1298 else { 1299 TCHECK(dp[0]); 1300 if (!ntohl(dp[0])) 1301 return (dp + 1); 1302 dp++; |
1131 if ((dp = parsefh(dp, 1)) == NULL) 1132 return (NULL); | 1303 if (!(dp = parsefh(dp, 1))) 1304 return (0); |
1133 if (verbose) { | 1305 if (verbose) { |
1134 if ((dp = parse_post_op_attr(dp, verbose)) == NULL) 1135 return (NULL); | 1306 if (!(dp = parse_post_op_attr(dp, verbose))) 1307 return (0); |
1136 if (vflag > 1) { 1137 printf("dir attr:"); 1138 dp = parse_wcc_data(dp, verbose); 1139 } 1140 } 1141 } 1142 return (dp); 1143trunc: 1144 return (NULL); 1145} 1146 1147static int 1148parsewccres(const u_int32_t *dp, int verbose) 1149{ 1150 int er; 1151 | 1308 if (vflag > 1) { 1309 printf("dir attr:"); 1310 dp = parse_wcc_data(dp, verbose); 1311 } 1312 } 1313 } 1314 return (dp); 1315trunc: 1316 return (NULL); 1317} 1318 1319static int 1320parsewccres(const u_int32_t *dp, int verbose) 1321{ 1322 int er; 1323 |
1152 if ((dp = parsestatus(dp, &er)) == NULL) | 1324 if (!(dp = parsestatus(dp, &er))) |
1153 return (0); | 1325 return (0); |
1154 return parse_wcc_data(dp, verbose) != NULL; | 1326 return parse_wcc_data(dp, verbose) != 0; |
1155} 1156 1157static const u_int32_t * 1158parsev3rddirres(const u_int32_t *dp, int verbose) 1159{ 1160 int er; 1161 | 1327} 1328 1329static const u_int32_t * 1330parsev3rddirres(const u_int32_t *dp, int verbose) 1331{ 1332 int er; 1333 |
1162 if ((dp = parsestatus(dp, &er)) == NULL) 1163 return (NULL); | 1334 if (!(dp = parsestatus(dp, &er))) 1335 return (0); |
1164 if (vflag) 1165 printf(" POST:"); | 1336 if (vflag) 1337 printf(" POST:"); |
1166 if ((dp = parse_post_op_attr(dp, verbose)) == NULL) 1167 return (NULL); | 1338 if (!(dp = parse_post_op_attr(dp, verbose))) 1339 return (0); |
1168 if (er) 1169 return dp; 1170 if (vflag) { 1171 TCHECK(dp[1]); 1172 printf(" verf %08x%08x", dp[0], dp[1]); 1173 dp += 2; 1174 } 1175 return dp; 1176trunc: 1177 return (NULL); 1178} 1179 1180static int 1181parsefsinfo(const u_int32_t *dp) 1182{ 1183 struct nfsv3_fsinfo *sfp; 1184 int er; 1185 | 1340 if (er) 1341 return dp; 1342 if (vflag) { 1343 TCHECK(dp[1]); 1344 printf(" verf %08x%08x", dp[0], dp[1]); 1345 dp += 2; 1346 } 1347 return dp; 1348trunc: 1349 return (NULL); 1350} 1351 1352static int 1353parsefsinfo(const u_int32_t *dp) 1354{ 1355 struct nfsv3_fsinfo *sfp; 1356 int er; 1357 |
1186 if ((dp = parsestatus(dp, &er)) == NULL) | 1358 if (!(dp = parsestatus(dp, &er))) |
1187 return (0); 1188 if (vflag) 1189 printf(" POST:"); | 1359 return (0); 1360 if (vflag) 1361 printf(" POST:"); |
1190 if ((dp = parse_post_op_attr(dp, vflag)) == NULL) | 1362 if (!(dp = parse_post_op_attr(dp, vflag))) |
1191 return (0); 1192 if (er) 1193 return (1); 1194 1195 sfp = (struct nfsv3_fsinfo *)dp; 1196 TCHECK(*sfp); | 1363 return (0); 1364 if (er) 1365 return (1); 1366 1367 sfp = (struct nfsv3_fsinfo *)dp; 1368 TCHECK(*sfp); |
1197 printf(" rtmax %lu rtpref %lu wtmax %lu wtpref %lu dtpref %lu", 1198 ntohl(sfp->fs_rtmax), ntohl(sfp->fs_rtpref), 1199 ntohl(sfp->fs_wtmax), ntohl(sfp->fs_wtpref), 1200 ntohl(sfp->fs_dtpref)); | 1369 printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u", 1370 (u_int32_t) ntohl(sfp->fs_rtmax), 1371 (u_int32_t) ntohl(sfp->fs_rtpref), 1372 (u_int32_t) ntohl(sfp->fs_wtmax), 1373 (u_int32_t) ntohl(sfp->fs_wtpref), 1374 (u_int32_t) ntohl(sfp->fs_dtpref)); |
1201 if (vflag) { | 1375 if (vflag) { |
1202 printf(" rtmult %lu wtmult %lu maxfsz ", 1203 ntohl(sfp->fs_rtmult), ntohl(sfp->fs_wtmult)); | 1376 printf(" rtmult %u wtmult %u maxfsz ", 1377 (u_int32_t) ntohl(sfp->fs_rtmult), 1378 (u_int32_t) ntohl(sfp->fs_wtmult)); |
1204 print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED); | 1379 print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED); |
1205 printf(" delta %lu.%06lu ", ntohl(sfp->fs_timedelta.nfsv3_sec), 1206 ntohl(sfp->fs_timedelta.nfsv3_nsec)); | 1380 printf(" delta %u.%06u ", 1381 (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec), 1382 (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec)); |
1207 } | 1383 } |
1208 return (1); 1209trunc: | |
1210 return (0); | 1384 return (0); |
1385trunc: 1386 return (1); |
|
1211} 1212 1213static int 1214parsepathconf(const u_int32_t *dp) 1215{ 1216 int er; 1217 struct nfsv3_pathconf *spp; 1218 | 1387} 1388 1389static int 1390parsepathconf(const u_int32_t *dp) 1391{ 1392 int er; 1393 struct nfsv3_pathconf *spp; 1394 |
1219 if ((dp = parsestatus(dp, &er)) == NULL) | 1395 if (!(dp = parsestatus(dp, &er))) |
1220 return (0); 1221 if (vflag) 1222 printf(" POST:"); | 1396 return (0); 1397 if (vflag) 1398 printf(" POST:"); |
1223 if ((dp = parse_post_op_attr(dp, vflag)) == NULL) | 1399 if (!(dp = parse_post_op_attr(dp, vflag))) |
1224 return (0); 1225 if (er) 1226 return (1); 1227 1228 spp = (struct nfsv3_pathconf *)dp; 1229 TCHECK(*spp); 1230 | 1400 return (0); 1401 if (er) 1402 return (1); 1403 1404 spp = (struct nfsv3_pathconf *)dp; 1405 TCHECK(*spp); 1406 |
1231 printf(" linkmax %lu namemax %lu %s %s %s %s", 1232 ntohl(spp->pc_linkmax), 1233 ntohl(spp->pc_namemax), | 1407 printf(" linkmax %u namemax %u %s %s %s %s", 1408 (u_int32_t) ntohl(spp->pc_linkmax), 1409 (u_int32_t) ntohl(spp->pc_namemax), |
1234 ntohl(spp->pc_notrunc) ? "notrunc" : "", 1235 ntohl(spp->pc_chownrestricted) ? "chownres" : "", 1236 ntohl(spp->pc_caseinsensitive) ? "igncase" : "", 1237 ntohl(spp->pc_casepreserving) ? "keepcase" : ""); | 1410 ntohl(spp->pc_notrunc) ? "notrunc" : "", 1411 ntohl(spp->pc_chownrestricted) ? "chownres" : "", 1412 ntohl(spp->pc_caseinsensitive) ? "igncase" : "", 1413 ntohl(spp->pc_casepreserving) ? "keepcase" : ""); |
1238 return (1); 1239trunc: | |
1240 return (0); | 1414 return (0); |
1415trunc: 1416 return (1); |
|
1241} | 1417} |
1242 | 1418 |
1243static void 1244interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int length) 1245{ 1246 register const u_int32_t *dp; 1247 register int v3; | 1419static void 1420interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int length) 1421{ 1422 register const u_int32_t *dp; 1423 register int v3; |
1248 | |
1249 int er; 1250 1251 v3 = (vers == NFS_VER3); 1252 1253 if (!v3 && proc < NFS_NPROCS) 1254 proc = nfsv3_procid[proc]; 1255 1256 switch (proc) { --- 10 unchanged lines hidden (view full) --- 1267 printf(" getattr"); 1268 dp = parserep(rp, length); 1269 if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0) 1270 return; 1271 break; 1272 1273 case NFSPROC_SETATTR: 1274 printf(" setattr"); | 1424 int er; 1425 1426 v3 = (vers == NFS_VER3); 1427 1428 if (!v3 && proc < NFS_NPROCS) 1429 proc = nfsv3_procid[proc]; 1430 1431 switch (proc) { --- 10 unchanged lines hidden (view full) --- 1442 printf(" getattr"); 1443 dp = parserep(rp, length); 1444 if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0) 1445 return; 1446 break; 1447 1448 case NFSPROC_SETATTR: 1449 printf(" setattr"); |
1275 if ((dp = parserep(rp, length)) == NULL) | 1450 if (!(dp = parserep(rp, length))) |
1276 return; 1277 if (v3) { | 1451 return; 1452 if (v3) { |
1278 if (parsewccres(dp, vflag) != 0) | 1453 if (parsewccres(dp, vflag)) |
1279 return; 1280 } else { 1281 if (parseattrstat(dp, !qflag, 0) != 0) 1282 return; 1283 } 1284 break; 1285 1286 case NFSPROC_LOOKUP: 1287 printf(" lookup"); | 1454 return; 1455 } else { 1456 if (parseattrstat(dp, !qflag, 0) != 0) 1457 return; 1458 } 1459 break; 1460 1461 case NFSPROC_LOOKUP: 1462 printf(" lookup"); |
1288 if ((dp = parserep(rp, length)) == NULL) | 1463 if (!(dp = parserep(rp, length))) |
1289 break; 1290 if (v3) { | 1464 break; 1465 if (v3) { |
1291 if ((dp = parsestatus(dp, &er)) == NULL) | 1466 if (!(dp = parsestatus(dp, &er))) |
1292 break; 1293 if (er) { 1294 if (vflag > 1) { 1295 printf(" post dattr:"); 1296 dp = parse_post_op_attr(dp, vflag); 1297 } 1298 } else { | 1467 break; 1468 if (er) { 1469 if (vflag > 1) { 1470 printf(" post dattr:"); 1471 dp = parse_post_op_attr(dp, vflag); 1472 } 1473 } else { |
1299 if ((dp = parsefh(dp, v3)) == NULL) | 1474 if (!(dp = parsefh(dp, v3))) |
1300 break; | 1475 break; |
1301 if (((dp = parse_post_op_attr(dp, vflag)) != NULL) && 1302 (vflag > 1)) { | 1476 if ((dp = parse_post_op_attr(dp, vflag)) && 1477 vflag > 1) { |
1303 printf(" post dattr:"); 1304 dp = parse_post_op_attr(dp, vflag); 1305 } 1306 } | 1478 printf(" post dattr:"); 1479 dp = parse_post_op_attr(dp, vflag); 1480 } 1481 } |
1307 if (dp != NULL) | 1482 if (dp) |
1308 return; 1309 } else { 1310 if (parsediropres(dp) != 0) 1311 return; 1312 } 1313 break; 1314 1315 case NFSPROC_ACCESS: 1316 printf(" access"); 1317 dp = parserep(rp, length); | 1483 return; 1484 } else { 1485 if (parsediropres(dp) != 0) 1486 return; 1487 } 1488 break; 1489 1490 case NFSPROC_ACCESS: 1491 printf(" access"); 1492 dp = parserep(rp, length); |
1318 if ((dp = parsestatus(dp, &er)) == NULL) | 1493 if (!(dp = parsestatus(dp, &er))) |
1319 break; 1320 if (vflag) 1321 printf(" attr:"); | 1494 break; 1495 if (vflag) 1496 printf(" attr:"); |
1322 if ((dp = parse_post_op_attr(dp, vflag)) == NULL) | 1497 if (!(dp = parse_post_op_attr(dp, vflag))) |
1323 break; 1324 if (!er) | 1498 break; 1499 if (!er) |
1325 printf(" c %04lx", ntohl(dp[0])); | 1500 printf(" c %04x", (u_int32_t)ntohl(dp[0])); |
1326 return; 1327 1328 case NFSPROC_READLINK: 1329 printf(" readlink"); 1330 dp = parserep(rp, length); 1331 if (dp != NULL && parselinkres(dp, v3) != 0) 1332 return; 1333 break; 1334 1335 case NFSPROC_READ: 1336 printf(" read"); | 1501 return; 1502 1503 case NFSPROC_READLINK: 1504 printf(" readlink"); 1505 dp = parserep(rp, length); 1506 if (dp != NULL && parselinkres(dp, v3) != 0) 1507 return; 1508 break; 1509 1510 case NFSPROC_READ: 1511 printf(" read"); |
1337 if ((dp = parserep(rp, length)) == NULL) | 1512 if (!(dp = parserep(rp, length))) |
1338 break; 1339 if (v3) { | 1513 break; 1514 if (v3) { |
1340 if ((dp = parsestatus(dp, &er)) == NULL) | 1515 if (!(dp = parsestatus(dp, &er))) |
1341 break; | 1516 break; |
1342 if ((dp = parse_post_op_attr(dp, vflag)) == NULL) | 1517 if (!(dp = parse_post_op_attr(dp, vflag))) |
1343 break; 1344 if (er) 1345 return; 1346 if (vflag) { | 1518 break; 1519 if (er) 1520 return; 1521 if (vflag) { |
1347 TCHECK2(*dp, 8); 1348 printf("%lu bytes", ntohl(dp[0])); | 1522 TCHECK(dp[1]); 1523 printf("%u bytes", (u_int32_t) ntohl(dp[0])); |
1349 if (ntohl(dp[1])) 1350 printf(" EOF"); 1351 } 1352 return; 1353 } else { 1354 if (parseattrstat(dp, vflag, 0) != 0) 1355 return; 1356 } 1357 break; 1358 1359 case NFSPROC_WRITE: 1360 printf(" write"); | 1524 if (ntohl(dp[1])) 1525 printf(" EOF"); 1526 } 1527 return; 1528 } else { 1529 if (parseattrstat(dp, vflag, 0) != 0) 1530 return; 1531 } 1532 break; 1533 1534 case NFSPROC_WRITE: 1535 printf(" write"); |
1361 if ((dp = parserep(rp, length)) == NULL) | 1536 if (!(dp = parserep(rp, length))) |
1362 break; 1363 if (v3) { | 1537 break; 1538 if (v3) { |
1364 if ((dp = parsestatus(dp, &er)) == NULL) | 1539 if (!(dp = parsestatus(dp, &er))) |
1365 break; | 1540 break; |
1366 if ((dp = parse_wcc_data(dp, vflag)) == NULL) | 1541 if (!(dp = parse_wcc_data(dp, vflag))) |
1367 break; 1368 if (er) 1369 return; 1370 if (vflag) { | 1542 break; 1543 if (er) 1544 return; 1545 if (vflag) { |
1371 TCHECK2(*dp, 4); 1372 printf("%lu bytes", ntohl(dp[0])); | 1546 TCHECK(dp[0]); 1547 printf("%u bytes", (u_int32_t) ntohl(dp[0])); |
1373 if (vflag > 1) { | 1548 if (vflag > 1) { |
1374 TCHECK2(*dp, 4); | 1549 TCHECK(dp[1]); |
1375 printf(" <%s>", | 1550 printf(" <%s>", |
1376 nfsv3_writemodes[ntohl(dp[1])]); | 1551 tok2str(nfsv3_writemodes, 1552 NULL, ntohl(dp[1]))); |
1377 } 1378 return; 1379 } 1380 } else { 1381 if (parseattrstat(dp, vflag, v3) != 0) 1382 return; 1383 } 1384 break; 1385 1386 case NFSPROC_CREATE: 1387 printf(" create"); | 1553 } 1554 return; 1555 } 1556 } else { 1557 if (parseattrstat(dp, vflag, v3) != 0) 1558 return; 1559 } 1560 break; 1561 1562 case NFSPROC_CREATE: 1563 printf(" create"); |
1388 if ((dp = parserep(rp, length)) == NULL) | 1564 if (!(dp = parserep(rp, length))) |
1389 break; 1390 if (v3) { | 1565 break; 1566 if (v3) { |
1391 if (parsecreateopres(dp, vflag) != NULL) | 1567 if (parsecreateopres(dp, vflag) != 0) |
1392 return; 1393 } else { 1394 if (parsediropres(dp) != 0) 1395 return; 1396 } 1397 break; 1398 1399 case NFSPROC_MKDIR: 1400 printf(" mkdir"); | 1568 return; 1569 } else { 1570 if (parsediropres(dp) != 0) 1571 return; 1572 } 1573 break; 1574 1575 case NFSPROC_MKDIR: 1576 printf(" mkdir"); |
1401 if ((dp = parserep(rp, length)) == NULL) | 1577 if (!(dp = parserep(rp, length))) |
1402 break; 1403 if (v3) { | 1578 break; 1579 if (v3) { |
1404 if (parsecreateopres(dp, vflag) != NULL) | 1580 if (parsecreateopres(dp, vflag) != 0) |
1405 return; 1406 } else { 1407 if (parsediropres(dp) != 0) 1408 return; 1409 } 1410 break; 1411 1412 case NFSPROC_SYMLINK: 1413 printf(" symlink"); | 1581 return; 1582 } else { 1583 if (parsediropres(dp) != 0) 1584 return; 1585 } 1586 break; 1587 1588 case NFSPROC_SYMLINK: 1589 printf(" symlink"); |
1414 if ((dp = parserep(rp, length)) == NULL) | 1590 if (!(dp = parserep(rp, length))) |
1415 break; 1416 if (v3) { | 1591 break; 1592 if (v3) { |
1417 if (parsecreateopres(dp, vflag) != NULL) | 1593 if (parsecreateopres(dp, vflag) != 0) |
1418 return; 1419 } else { | 1594 return; 1595 } else { |
1420 if (parsestatus(dp, &er) != NULL) | 1596 if (parsestatus(dp, &er) != 0) |
1421 return; 1422 } 1423 break; 1424 1425 case NFSPROC_MKNOD: 1426 printf(" mknod"); | 1597 return; 1598 } 1599 break; 1600 1601 case NFSPROC_MKNOD: 1602 printf(" mknod"); |
1427 if ((dp = parserep(rp, length)) == NULL) | 1603 if (!(dp = parserep(rp, length))) |
1428 break; | 1604 break; |
1429 if (parsecreateopres(dp, vflag) != NULL) | 1605 if (parsecreateopres(dp, vflag) != 0) |
1430 return; 1431 break; 1432 1433 case NFSPROC_REMOVE: 1434 printf(" remove"); | 1606 return; 1607 break; 1608 1609 case NFSPROC_REMOVE: 1610 printf(" remove"); |
1435 if ((dp = parserep(rp, length)) == NULL) | 1611 if (!(dp = parserep(rp, length))) |
1436 break; 1437 if (v3) { | 1612 break; 1613 if (v3) { |
1438 if (parsewccres(dp, vflag) != 0) | 1614 if (parsewccres(dp, vflag)) |
1439 return; 1440 } else { | 1615 return; 1616 } else { |
1441 if (parsestatus(dp, &er) != NULL) | 1617 if (parsestatus(dp, &er) != 0) |
1442 return; 1443 } 1444 break; 1445 1446 case NFSPROC_RMDIR: 1447 printf(" rmdir"); | 1618 return; 1619 } 1620 break; 1621 1622 case NFSPROC_RMDIR: 1623 printf(" rmdir"); |
1448 if ((dp = parserep(rp, length)) == NULL) | 1624 if (!(dp = parserep(rp, length))) |
1449 break; 1450 if (v3) { | 1625 break; 1626 if (v3) { |
1451 if (parsewccres(dp, vflag) != 0) | 1627 if (parsewccres(dp, vflag)) |
1452 return; 1453 } else { | 1628 return; 1629 } else { |
1454 if (parsestatus(dp, &er) != NULL) | 1630 if (parsestatus(dp, &er) != 0) |
1455 return; 1456 } 1457 break; 1458 1459 case NFSPROC_RENAME: 1460 printf(" rename"); | 1631 return; 1632 } 1633 break; 1634 1635 case NFSPROC_RENAME: 1636 printf(" rename"); |
1461 if ((dp = parserep(rp, length)) == NULL) | 1637 if (!(dp = parserep(rp, length))) |
1462 break; 1463 if (v3) { | 1638 break; 1639 if (v3) { |
1464 if ((dp = parsestatus(dp, &er)) == NULL) | 1640 if (!(dp = parsestatus(dp, &er))) |
1465 break; 1466 if (vflag) { 1467 printf(" from:"); | 1641 break; 1642 if (vflag) { 1643 printf(" from:"); |
1468 if ((dp = parse_wcc_data(dp, vflag)) == NULL) | 1644 if (!(dp = parse_wcc_data(dp, vflag))) |
1469 break; 1470 printf(" to:"); | 1645 break; 1646 printf(" to:"); |
1471 if ((dp = parse_wcc_data(dp, vflag)) == NULL) | 1647 if (!(dp = parse_wcc_data(dp, vflag))) |
1472 break; 1473 } 1474 return; 1475 } else { | 1648 break; 1649 } 1650 return; 1651 } else { |
1476 if (parsestatus(dp, &er) != NULL) | 1652 if (parsestatus(dp, &er) != 0) |
1477 return; 1478 } 1479 break; 1480 1481 case NFSPROC_LINK: 1482 printf(" link"); | 1653 return; 1654 } 1655 break; 1656 1657 case NFSPROC_LINK: 1658 printf(" link"); |
1483 if ((dp = parserep(rp, length)) == NULL) | 1659 if (!(dp = parserep(rp, length))) |
1484 break; 1485 if (v3) { | 1660 break; 1661 if (v3) { |
1486 if ((dp = parsestatus(dp, &er)) == NULL) | 1662 if (!(dp = parsestatus(dp, &er))) |
1487 break; 1488 if (vflag) { 1489 printf(" file POST:"); | 1663 break; 1664 if (vflag) { 1665 printf(" file POST:"); |
1490 if ((dp = parse_post_op_attr(dp, vflag)) == NULL) | 1666 if (!(dp = parse_post_op_attr(dp, vflag))) |
1491 break; 1492 printf(" dir:"); | 1667 break; 1668 printf(" dir:"); |
1493 if ((dp = parse_wcc_data(dp, vflag)) == NULL) | 1669 if (!(dp = parse_wcc_data(dp, vflag))) |
1494 break; 1495 return; 1496 } 1497 } else { | 1670 break; 1671 return; 1672 } 1673 } else { |
1498 if (parsestatus(dp, &er) != NULL) | 1674 if (parsestatus(dp, &er) != 0) |
1499 return; 1500 } 1501 break; 1502 1503 case NFSPROC_READDIR: 1504 printf(" readdir"); | 1675 return; 1676 } 1677 break; 1678 1679 case NFSPROC_READDIR: 1680 printf(" readdir"); |
1505 if ((dp = parserep(rp, length)) == NULL) | 1681 if (!(dp = parserep(rp, length))) |
1506 break; 1507 if (v3) { | 1682 break; 1683 if (v3) { |
1508 if (parsev3rddirres(dp, vflag) != NULL) | 1684 if (parsev3rddirres(dp, vflag)) |
1509 return; 1510 } else { 1511 if (parserddires(dp) != 0) 1512 return; 1513 } 1514 break; 1515 1516 case NFSPROC_READDIRPLUS: 1517 printf(" readdirplus"); | 1685 return; 1686 } else { 1687 if (parserddires(dp) != 0) 1688 return; 1689 } 1690 break; 1691 1692 case NFSPROC_READDIRPLUS: 1693 printf(" readdirplus"); |
1518 if ((dp = parserep(rp, length)) == NULL) | 1694 if (!(dp = parserep(rp, length))) |
1519 break; | 1695 break; |
1520 if (parsev3rddirres(dp, vflag) != NULL) | 1696 if (parsev3rddirres(dp, vflag)) |
1521 return; 1522 break; 1523 1524 case NFSPROC_FSSTAT: 1525 printf(" fsstat"); 1526 dp = parserep(rp, length); | 1697 return; 1698 break; 1699 1700 case NFSPROC_FSSTAT: 1701 printf(" fsstat"); 1702 dp = parserep(rp, length); |
1527 if (dp != NULL && parsestatfs(dp, v3) != NULL) | 1703 if (dp != NULL && parsestatfs(dp, v3) != 0) |
1528 return; 1529 break; 1530 1531 case NFSPROC_FSINFO: 1532 printf(" fsinfo"); 1533 dp = parserep(rp, length); | 1704 return; 1705 break; 1706 1707 case NFSPROC_FSINFO: 1708 printf(" fsinfo"); 1709 dp = parserep(rp, length); |
1534 if (dp != NULL && parsefsinfo(dp) != NULL) | 1710 if (dp != NULL && parsefsinfo(dp) != 0) |
1535 return; 1536 break; 1537 1538 case NFSPROC_PATHCONF: 1539 printf(" pathconf"); 1540 dp = parserep(rp, length); 1541 if (dp != NULL && parsepathconf(dp) != 0) 1542 return; --- 5 unchanged lines hidden (view full) --- 1548 if (dp != NULL && parsewccres(dp, vflag) != 0) 1549 return; 1550 break; 1551 1552 default: 1553 printf(" proc-%u", proc); 1554 return; 1555 } | 1711 return; 1712 break; 1713 1714 case NFSPROC_PATHCONF: 1715 printf(" pathconf"); 1716 dp = parserep(rp, length); 1717 if (dp != NULL && parsepathconf(dp) != 0) 1718 return; --- 5 unchanged lines hidden (view full) --- 1724 if (dp != NULL && parsewccres(dp, vflag) != 0) 1725 return; 1726 break; 1727 1728 default: 1729 printf(" proc-%u", proc); 1730 return; 1731 } |
1556 | |
1557trunc: 1558 if (!nfserr) 1559 fputs(" [|nfs]", stdout); 1560} | 1732trunc: 1733 if (!nfserr) 1734 fputs(" [|nfs]", stdout); 1735} |