xref: /titanic_51/usr/src/head/rpcsvc/nfs4_prot.x (revision 7fd791373689a6af05e27efec3b1ab556e02aa23)
1 /*
2  * This file was machine generated for [RFC7530].
3  *
4  * Last updated Tue Mar 10 11:51:21 PDT 2015.
5  */
6 
7 /*
8  * Copyright (c) 2015 IETF Trust and the persons identified
9  * as authors of the code.  All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with
12  * or without modification, are permitted provided that the
13  * following conditions are met:
14  *
15  * - Redistributions of source code must retain the above
16  *   copyright notice, this list of conditions and the
17  *   following disclaimer.
18  *
19  * - Redistributions in binary form must reproduce the above
20  *   copyright notice, this list of conditions and the
21  *   following disclaimer in the documentation and/or other
22  *   materials provided with the distribution.
23  *
24  * - Neither the name of Internet Society, IETF or IETF
25  *   Trust, nor the names of specific contributors, may be
26  *   used to endorse or promote products derived from this
27  *   software without specific prior written permission.
28  *
29  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
30  *   AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
31  *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
34  *   EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
35  *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36  *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37  *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38  *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41  *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42  *   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
43  *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  */
45 
46 /*
47  * This code was derived from RFC 7531.
48  */
49 
50 /*
51  *      nfs4_prot.x
52  *
53  */
54 
55 /*
56  * Basic typedefs for RFC 1832 data type definitions
57  */
58 /*
59  * typedef int          int32_t;
60  * typedef unsigned int uint32_t;
61  * typedef hyper                int64_t;
62  * typedef unsigned hyper       uint64_t;
63  */
64 
65 /*
66  * Sizes
67  */
68 const NFS4_FHSIZE               = 128;
69 const NFS4_VERIFIER_SIZE        = 8;
70 const NFS4_OTHER_SIZE           = 12;
71 const NFS4_OPAQUE_LIMIT         = 1024;
72 
73 const NFS4_INT64_MAX            = 0x7fffffffffffffff;
74 const NFS4_UINT64_MAX           = 0xffffffffffffffff;
75 const NFS4_INT32_MAX            = 0x7fffffff;
76 const NFS4_UINT32_MAX           = 0xffffffff;
77 
78 
79 /*
80  * File types
81  */
82 enum nfs_ftype4 {
83         NF4REG = 1,     /* Regular File */
84         NF4DIR = 2,     /* Directory */
85         NF4BLK = 3,     /* Special File - block device */
86         NF4CHR = 4,     /* Special File - character device */
87         NF4LNK = 5,     /* Symbolic Link */
88         NF4SOCK = 6,    /* Special File - socket */
89         NF4FIFO = 7,    /* Special File - fifo */
90         NF4ATTRDIR
91                 = 8,    /* Attribute Directory */
92         NF4NAMEDATTR
93                 = 9     /* Named Attribute */
94 };
95 
96 /*
97  * Error status
98  */
99 enum nfsstat4 {
100  NFS4_OK                = 0,    /* everything is okay       */
101  NFS4ERR_PERM           = 1,    /* caller not privileged    */
102  NFS4ERR_NOENT          = 2,    /* no such file/directory   */
103  NFS4ERR_IO             = 5,    /* hard I/O error           */
104  NFS4ERR_NXIO           = 6,    /* no such device           */
105  NFS4ERR_ACCESS         = 13,   /* access denied            */
106  NFS4ERR_EXIST          = 17,   /* file already exists      */
107  NFS4ERR_XDEV           = 18,   /* different file systems   */
108  /* Unused/reserved        19 */
109  NFS4ERR_NOTDIR         = 20,   /* should be a directory    */
110  NFS4ERR_ISDIR          = 21,   /* should not be directory  */
111  NFS4ERR_INVAL          = 22,   /* invalid argument         */
112  NFS4ERR_FBIG           = 27,   /* file exceeds server max  */
113  NFS4ERR_NOSPC          = 28,   /* no space on file system  */
114  NFS4ERR_ROFS           = 30,   /* read-only file system    */
115  NFS4ERR_MLINK          = 31,   /* too many hard links      */
116  NFS4ERR_NAMETOOLONG    = 63,   /* name exceeds server max  */
117  NFS4ERR_NOTEMPTY       = 66,   /* directory not empty      */
118  NFS4ERR_DQUOT          = 69,   /* hard quota limit reached */
119  NFS4ERR_STALE          = 70,   /* file no longer exists    */
120  NFS4ERR_BADHANDLE      = 10001,/* Illegal filehandle       */
121  NFS4ERR_BAD_COOKIE     = 10003,/* READDIR cookie is stale  */
122  NFS4ERR_NOTSUPP        = 10004,/* operation not supported  */
123  NFS4ERR_TOOSMALL       = 10005,/* response limit exceeded  */
124  NFS4ERR_SERVERFAULT    = 10006,/* undefined server error   */
125  NFS4ERR_BADTYPE        = 10007,/* type invalid for CREATE  */
126  NFS4ERR_DELAY          = 10008,/* file "busy" - retry      */
127  NFS4ERR_SAME           = 10009,/* nverify says attrs same  */
128  NFS4ERR_DENIED         = 10010,/* lock unavailable         */
129  NFS4ERR_EXPIRED        = 10011,/* lock lease expired       */
130  NFS4ERR_LOCKED         = 10012,/* I/O failed due to lock   */
131  NFS4ERR_GRACE          = 10013,/* in grace period          */
132  NFS4ERR_FHEXPIRED      = 10014,/* filehandle expired       */
133  NFS4ERR_SHARE_DENIED   = 10015,/* share reserve denied     */
134  NFS4ERR_WRONGSEC       = 10016,/* wrong security flavor    */
135  NFS4ERR_CLID_INUSE     = 10017,/* clientid in use          */
136  NFS4ERR_RESOURCE       = 10018,/* resource exhaustion      */
137  NFS4ERR_MOVED          = 10019,/* file system relocated    */
138  NFS4ERR_NOFILEHANDLE   = 10020,/* current FH is not set    */
139  NFS4ERR_MINOR_VERS_MISMATCH = 10021,/* minor vers not supp */
140  NFS4ERR_STALE_CLIENTID = 10022,/* server has rebooted      */
141  NFS4ERR_STALE_STATEID  = 10023,/* server has rebooted      */
142  NFS4ERR_OLD_STATEID    = 10024,/* state is out of sync     */
143  NFS4ERR_BAD_STATEID    = 10025,/* incorrect stateid        */
144  NFS4ERR_BAD_SEQID      = 10026,/* request is out of seq.   */
145  NFS4ERR_NOT_SAME       = 10027,/* verify - attrs not same  */
146  NFS4ERR_LOCK_RANGE     = 10028,/* lock range not supported */
147  NFS4ERR_SYMLINK        = 10029,/* should be file/directory */
148  NFS4ERR_RESTOREFH      = 10030,/* no saved filehandle      */
149  NFS4ERR_LEASE_MOVED    = 10031,/* some file system moved   */
150  NFS4ERR_ATTRNOTSUPP    = 10032,/* recommended attr not sup */
151  NFS4ERR_NO_GRACE       = 10033,/* reclaim outside of grace */
152  NFS4ERR_RECLAIM_BAD    = 10034,/* reclaim error at server  */
153  NFS4ERR_RECLAIM_CONFLICT = 10035,/* conflict on reclaim    */
154  NFS4ERR_BADXDR         = 10036,/* XDR decode failed        */
155  NFS4ERR_LOCKS_HELD     = 10037,/* file locks held at CLOSE */
156  NFS4ERR_OPENMODE       = 10038,/* conflict in OPEN and I/O */
157  NFS4ERR_BADOWNER       = 10039,/* owner translation bad    */
158  NFS4ERR_BADCHAR        = 10040,/* UTF-8 char not supported */
159  NFS4ERR_BADNAME        = 10041,/* name not supported       */
160  NFS4ERR_BAD_RANGE      = 10042,/* lock range not supported */
161  NFS4ERR_LOCK_NOTSUPP   = 10043,/* no atomic up/downgrade   */
162  NFS4ERR_OP_ILLEGAL     = 10044,/* undefined operation      */
163  NFS4ERR_DEADLOCK       = 10045,/* file locking deadlock    */
164  NFS4ERR_FILE_OPEN      = 10046,/* open file blocks op.     */
165  NFS4ERR_ADMIN_REVOKED  = 10047,/* lock-owner state revoked */
166  NFS4ERR_CB_PATH_DOWN   = 10048 /* callback path down       */
167 };
168 
169 /*
170  * Basic data types
171  */
172 typedef opaque  attrlist4<>;
173 typedef uint32_t        bitmap4<>;
174 typedef uint64_t        changeid4;
175 typedef uint64_t        clientid4;
176 typedef uint32_t        count4;
177 typedef uint64_t        length4;
178 typedef uint32_t        mode4;
179 typedef uint64_t        nfs_cookie4;
180 typedef opaque  nfs_fh4<NFS4_FHSIZE>;
181 typedef uint32_t        nfs_lease4;
182 typedef uint64_t        offset4;
183 typedef uint32_t        qop4;
184 typedef opaque  sec_oid4<>;
185 typedef uint32_t        seqid4;
186 typedef opaque  utf8string<>;
187 typedef utf8string      utf8str_cis;
188 typedef utf8string      utf8str_cs;
189 typedef utf8string      utf8str_mixed;
190 typedef utf8str_cs      component4;
191 typedef opaque  linktext4<>;
192 typedef utf8string      ascii_REQUIRED4;
193 typedef component4      pathname4<>;
194 typedef uint64_t        nfs_lockid4;
195 typedef opaque  verifier4[NFS4_VERIFIER_SIZE];
196 
197 
198 /*
199  * Timeval
200  */
201 struct nfstime4 {
202         int64_t         seconds;
203         uint32_t        nseconds;
204 };
205 
206 enum time_how4 {
207         SET_TO_SERVER_TIME4 = 0,
208         SET_TO_CLIENT_TIME4 = 1
209 };
210 
211 union settime4 switch (time_how4 set_it) {
212  case SET_TO_CLIENT_TIME4:
213          nfstime4       time;
214  default:
215          void;
216 };
217 
218 
219 /*
220  * File attribute definitions
221  */
222 
223 /*
224  * FSID structure for major/minor
225  */
226 struct fsid4 {
227         uint64_t        major;
228         uint64_t        minor;
229 };
230 
231 
232 /*
233  * File system locations attribute for relocation/migration
234  */
235 struct fs_location4 {
236         utf8str_cis     server<>;
237         pathname4       rootpath;
238 };
239 
240 struct fs_locations4 {
241         pathname4       fs_root;
242         fs_location4    locations<>;
243 };
244 
245 
246 /*
247  * Various Access Control Entry definitions
248  */
249 
250 /*
251  * Mask that indicates which Access Control Entries
252  * are supported.  Values for the fattr4_aclsupport attribute.
253  */
254 const ACL4_SUPPORT_ALLOW_ACL    = 0x00000001;
255 const ACL4_SUPPORT_DENY_ACL     = 0x00000002;
256 const ACL4_SUPPORT_AUDIT_ACL    = 0x00000004;
257 const ACL4_SUPPORT_ALARM_ACL    = 0x00000008;
258 
259 
260 typedef uint32_t        acetype4;
261 
262 
263 /*
264  * acetype4 values; others can be added as needed.
265  */
266 const ACE4_ACCESS_ALLOWED_ACE_TYPE      = 0x00000000;
267 const ACE4_ACCESS_DENIED_ACE_TYPE       = 0x00000001;
268 const ACE4_SYSTEM_AUDIT_ACE_TYPE        = 0x00000002;
269 const ACE4_SYSTEM_ALARM_ACE_TYPE        = 0x00000003;
270 
271 
272 
273 /*
274  * ACE flag
275  */
276 typedef uint32_t        aceflag4;
277 
278 
279 /*
280  * ACE flag values
281  */
282 const ACE4_FILE_INHERIT_ACE             = 0x00000001;
283 const ACE4_DIRECTORY_INHERIT_ACE        = 0x00000002;
284 const ACE4_NO_PROPAGATE_INHERIT_ACE     = 0x00000004;
285 const ACE4_INHERIT_ONLY_ACE             = 0x00000008;
286 const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG   = 0x00000010;
287 const ACE4_FAILED_ACCESS_ACE_FLAG       = 0x00000020;
288 const ACE4_IDENTIFIER_GROUP             = 0x00000040;
289 
290 
291 
292 /*
293  * ACE mask
294  */
295 typedef uint32_t        acemask4;
296 
297 
298 /*
299  * ACE mask values
300  */
301 const ACE4_READ_DATA            = 0x00000001;
302 const ACE4_LIST_DIRECTORY       = 0x00000001;
303 const ACE4_WRITE_DATA           = 0x00000002;
304 const ACE4_ADD_FILE             = 0x00000002;
305 const ACE4_APPEND_DATA          = 0x00000004;
306 const ACE4_ADD_SUBDIRECTORY     = 0x00000004;
307 const ACE4_READ_NAMED_ATTRS     = 0x00000008;
308 const ACE4_WRITE_NAMED_ATTRS    = 0x00000010;
309 const ACE4_EXECUTE              = 0x00000020;
310 const ACE4_DELETE_CHILD         = 0x00000040;
311 const ACE4_READ_ATTRIBUTES      = 0x00000080;
312 const ACE4_WRITE_ATTRIBUTES     = 0x00000100;
313 
314 const ACE4_DELETE               = 0x00010000;
315 const ACE4_READ_ACL             = 0x00020000;
316 const ACE4_WRITE_ACL            = 0x00040000;
317 const ACE4_WRITE_OWNER          = 0x00080000;
318 const ACE4_SYNCHRONIZE          = 0x00100000;
319 
320 
321 /*
322  * ACE4_GENERIC_READ - defined as a combination of
323  *      ACE4_READ_ACL |
324  *      ACE4_READ_DATA |
325  *      ACE4_READ_ATTRIBUTES |
326  *      ACE4_SYNCHRONIZE
327  */
328 
329 const ACE4_GENERIC_READ = 0x00120081;
330 
331 /*
332  * ACE4_GENERIC_WRITE - defined as a combination of
333  *      ACE4_READ_ACL |
334  *      ACE4_WRITE_DATA |
335  *      ACE4_WRITE_ATTRIBUTES |
336  *      ACE4_WRITE_ACL |
337  *      ACE4_APPEND_DATA |
338  *      ACE4_SYNCHRONIZE
339  */
340 const ACE4_GENERIC_WRITE = 0x00160106;
341 
342 
343 /*
344  * ACE4_GENERIC_EXECUTE - defined as a combination of
345  *      ACE4_READ_ACL
346  *      ACE4_READ_ATTRIBUTES
347  *      ACE4_EXECUTE
348  *      ACE4_SYNCHRONIZE
349  */
350 const ACE4_GENERIC_EXECUTE = 0x001200A0;
351 
352 
353 /*
354  * Access Control Entry definition
355  */
356 struct nfsace4 {
357         acetype4                type;
358         aceflag4                flag;
359         acemask4                access_mask;
360         utf8str_mixed           who;
361 };
362 
363 
364 /*
365  * Field definitions for the fattr4_mode attribute
366  */
367 const MODE4_SUID = 0x800;  /* set user id on execution */
368 const MODE4_SGID = 0x400;  /* set group id on execution */
369 const MODE4_SVTX = 0x200;  /* save text even after use */
370 const MODE4_RUSR = 0x100;  /* read permission: owner */
371 const MODE4_WUSR = 0x080;  /* write permission: owner */
372 const MODE4_XUSR = 0x040;  /* execute permission: owner */
373 const MODE4_RGRP = 0x020;  /* read permission: group */
374 const MODE4_WGRP = 0x010;  /* write permission: group */
375 const MODE4_XGRP = 0x008;  /* execute permission: group */
376 const MODE4_ROTH = 0x004;  /* read permission: other */
377 const MODE4_WOTH = 0x002;  /* write permission: other */
378 const MODE4_XOTH = 0x001;  /* execute permission: other */
379 
380 
381 /*
382  * Special data/attribute associated with
383  * file types NF4BLK and NF4CHR.
384  */
385 struct specdata4 {
386  uint32_t specdata1; /* major device number */
387  uint32_t specdata2; /* minor device number */
388 };
389 
390 
391 /*
392  * Values for fattr4_fh_expire_type
393  */
394 const FH4_PERSISTENT          = 0x00000000;
395 const FH4_NOEXPIRE_WITH_OPEN  = 0x00000001;
396 const FH4_VOLATILE_ANY        = 0x00000002;
397 const FH4_VOL_MIGRATION       = 0x00000004;
398 const FH4_VOL_RENAME          = 0x00000008;
399 
400 
401 typedef bitmap4                 fattr4_supported_attrs;
402 typedef nfs_ftype4              fattr4_type;
403 typedef uint32_t                fattr4_fh_expire_type;
404 typedef changeid4               fattr4_change;
405 typedef uint64_t                fattr4_size;
406 typedef bool                    fattr4_link_support;
407 typedef bool                    fattr4_symlink_support;
408 typedef bool                    fattr4_named_attr;
409 typedef fsid4                   fattr4_fsid;
410 typedef bool                    fattr4_unique_handles;
411 typedef nfs_lease4              fattr4_lease_time;
412 typedef nfsstat4                fattr4_rdattr_error;
413 
414 typedef nfsace4                 fattr4_acl<>;
415 typedef uint32_t                fattr4_aclsupport;
416 typedef bool                    fattr4_archive;
417 typedef bool                    fattr4_cansettime;
418 typedef bool                    fattr4_case_insensitive;
419 typedef bool                    fattr4_case_preserving;
420 typedef bool                    fattr4_chown_restricted;
421 typedef uint64_t                fattr4_fileid;
422 typedef uint64_t                fattr4_files_avail;
423 typedef nfs_fh4                 fattr4_filehandle;
424 typedef uint64_t                fattr4_files_free;
425 typedef uint64_t                fattr4_files_total;
426 typedef fs_locations4           fattr4_fs_locations;
427 typedef bool                    fattr4_hidden;
428 typedef bool                    fattr4_homogeneous;
429 typedef uint64_t                fattr4_maxfilesize;
430 typedef uint32_t                fattr4_maxlink;
431 typedef uint32_t                fattr4_maxname;
432 typedef uint64_t                fattr4_maxread;
433 typedef uint64_t                fattr4_maxwrite;
434 typedef ascii_REQUIRED4         fattr4_mimetype;
435 typedef mode4                   fattr4_mode;
436 typedef uint64_t                fattr4_mounted_on_fileid;
437 typedef bool                    fattr4_no_trunc;
438 typedef uint32_t                fattr4_numlinks;
439 typedef utf8str_mixed           fattr4_owner;
440 typedef utf8str_mixed           fattr4_owner_group;
441 typedef uint64_t                fattr4_quota_avail_hard;
442 typedef uint64_t                fattr4_quota_avail_soft;
443 typedef uint64_t                fattr4_quota_used;
444 typedef specdata4               fattr4_rawdev;
445 typedef uint64_t                fattr4_space_avail;
446 typedef uint64_t                fattr4_space_free;
447 typedef uint64_t                fattr4_space_total;
448 typedef uint64_t                fattr4_space_used;
449 typedef bool                    fattr4_system;
450 typedef nfstime4                fattr4_time_access;
451 typedef settime4                fattr4_time_access_set;
452 typedef nfstime4                fattr4_time_backup;
453 typedef nfstime4                fattr4_time_create;
454 typedef nfstime4                fattr4_time_delta;
455 typedef nfstime4                fattr4_time_metadata;
456 typedef nfstime4                fattr4_time_modify;
457 typedef settime4                fattr4_time_modify_set;
458 
459 
460 /*
461  * Mandatory attributes
462  */
463 const FATTR4_SUPPORTED_ATTRS    = 0;
464 const FATTR4_TYPE               = 1;
465 const FATTR4_FH_EXPIRE_TYPE     = 2;
466 const FATTR4_CHANGE             = 3;
467 const FATTR4_SIZE               = 4;
468 const FATTR4_LINK_SUPPORT       = 5;
469 const FATTR4_SYMLINK_SUPPORT    = 6;
470 const FATTR4_NAMED_ATTR         = 7;
471 const FATTR4_FSID               = 8;
472 const FATTR4_UNIQUE_HANDLES     = 9;
473 const FATTR4_LEASE_TIME         = 10;
474 const FATTR4_RDATTR_ERROR       = 11;
475 const FATTR4_FILEHANDLE         = 19;
476 
477 /*
478  * Recommended attributes
479  */
480 const FATTR4_ACL                = 12;
481 const FATTR4_ACLSUPPORT         = 13;
482 const FATTR4_ARCHIVE            = 14;
483 const FATTR4_CANSETTIME         = 15;
484 const FATTR4_CASE_INSENSITIVE   = 16;
485 const FATTR4_CASE_PRESERVING    = 17;
486 const FATTR4_CHOWN_RESTRICTED   = 18;
487 const FATTR4_FILEID             = 20;
488 const FATTR4_FILES_AVAIL        = 21;
489 const FATTR4_FILES_FREE         = 22;
490 const FATTR4_FILES_TOTAL        = 23;
491 const FATTR4_FS_LOCATIONS       = 24;
492 const FATTR4_HIDDEN             = 25;
493 const FATTR4_HOMOGENEOUS        = 26;
494 const FATTR4_MAXFILESIZE        = 27;
495 const FATTR4_MAXLINK            = 28;
496 const FATTR4_MAXNAME            = 29;
497 const FATTR4_MAXREAD            = 30;
498 const FATTR4_MAXWRITE           = 31;
499 const FATTR4_MIMETYPE           = 32;
500 const FATTR4_MODE               = 33;
501 const FATTR4_NO_TRUNC           = 34;
502 const FATTR4_NUMLINKS           = 35;
503 const FATTR4_OWNER              = 36;
504 const FATTR4_OWNER_GROUP        = 37;
505 const FATTR4_QUOTA_AVAIL_HARD   = 38;
506 const FATTR4_QUOTA_AVAIL_SOFT   = 39;
507 const FATTR4_QUOTA_USED         = 40;
508 const FATTR4_RAWDEV             = 41;
509 const FATTR4_SPACE_AVAIL        = 42;
510 const FATTR4_SPACE_FREE         = 43;
511 const FATTR4_SPACE_TOTAL        = 44;
512 const FATTR4_SPACE_USED         = 45;
513 const FATTR4_SYSTEM             = 46;
514 const FATTR4_TIME_ACCESS        = 47;
515 const FATTR4_TIME_ACCESS_SET    = 48;
516 const FATTR4_TIME_BACKUP        = 49;
517 const FATTR4_TIME_CREATE        = 50;
518 const FATTR4_TIME_DELTA         = 51;
519 const FATTR4_TIME_METADATA      = 52;
520 const FATTR4_TIME_MODIFY        = 53;
521 const FATTR4_TIME_MODIFY_SET    = 54;
522 const FATTR4_MOUNTED_ON_FILEID  = 55;
523 
524 /*
525  * File attribute container
526  */
527 struct fattr4 {
528         bitmap4         attrmask;
529         attrlist4       attr_vals;
530 };
531 
532 
533 /*
534  * Change info for the client
535  */
536 struct change_info4 {
537         bool            atomic;
538         changeid4       before;
539         changeid4       after;
540 };
541 
542 
543 struct clientaddr4 {
544         /* see struct rpcb in RFC 1833 */
545         string r_netid<>;       /* network id */
546         string r_addr<>;        /* universal address */
547 };
548 
549 
550 /*
551  * Callback program info as provided by the client
552  */
553 struct cb_client4 {
554         unsigned int    cb_program;
555         clientaddr4     cb_location;
556 };
557 
558 
559 /*
560  * Stateid
561  */
562 struct stateid4 {
563         uint32_t        seqid;
564         opaque          other[NFS4_OTHER_SIZE];
565 };
566 
567 /*
568  * Client ID
569  */
570 struct nfs_client_id4 {
571         verifier4       verifier;
572         opaque          id<NFS4_OPAQUE_LIMIT>;
573 };
574 
575 
576 struct open_owner4 {
577         clientid4       clientid;
578         opaque          owner<NFS4_OPAQUE_LIMIT>;
579 };
580 
581 
582 struct lock_owner4 {
583         clientid4       clientid;
584         opaque          owner<NFS4_OPAQUE_LIMIT>;
585 };
586 
587 
588 enum nfs_lock_type4 {
589         READ_LT         = 1,
590         WRITE_LT        = 2,
591         READW_LT        = 3,    /* blocking read */
592         WRITEW_LT       = 4     /* blocking write */
593 };
594 
595 
596 const ACCESS4_READ      = 0x00000001;
597 const ACCESS4_LOOKUP    = 0x00000002;
598 const ACCESS4_MODIFY    = 0x00000004;
599 const ACCESS4_EXTEND    = 0x00000008;
600 const ACCESS4_DELETE    = 0x00000010;
601 const ACCESS4_EXECUTE   = 0x00000020;
602 
603 struct ACCESS4args {
604         /* CURRENT_FH: object */
605         uint32_t        access;
606 };
607 
608 struct ACCESS4resok {
609         uint32_t        supported;
610         uint32_t        access;
611 };
612 
613 union ACCESS4res switch (nfsstat4 status) {
614  case NFS4_OK:
615          ACCESS4resok   resok4;
616  default:
617          void;
618 };
619 
620 struct CLOSE4args {
621         /* CURRENT_FH: object */
622         seqid4          seqid;
623         stateid4        open_stateid;
624 };
625 
626 union CLOSE4res switch (nfsstat4 status) {
627  case NFS4_OK:
628          stateid4       open_stateid;
629  default:
630          void;
631 };
632 
633 struct COMMIT4args {
634         /* CURRENT_FH: file */
635         offset4         offset;
636         count4          count;
637 };
638 
639 struct COMMIT4resok {
640         verifier4       writeverf;
641 };
642 
643 union COMMIT4res switch (nfsstat4 status) {
644  case NFS4_OK:
645          COMMIT4resok   resok4;
646  default:
647          void;
648 };
649 
650 union createtype4 switch (nfs_ftype4 type) {
651  case NF4LNK:
652          linktext4 linkdata;
653  case NF4BLK:
654  case NF4CHR:
655          specdata4 devdata;
656  case NF4SOCK:
657  case NF4FIFO:
658  case NF4DIR:
659          void;
660  default:
661          void;  /* server should return NFS4ERR_BADTYPE */
662 };
663 
664 struct CREATE4args {
665         /* CURRENT_FH: directory for creation */
666         createtype4     objtype;
667         component4      objname;
668         fattr4          createattrs;
669 };
670 
671 struct CREATE4resok {
672         change_info4    cinfo;
673         bitmap4         attrset;        /* attributes set */
674 };
675 
676 union CREATE4res switch (nfsstat4 status) {
677  case NFS4_OK:
678          CREATE4resok resok4;
679  default:
680          void;
681 };
682 
683 struct DELEGPURGE4args {
684         clientid4       clientid;
685 };
686 
687 struct DELEGPURGE4res {
688         nfsstat4        status;
689 };
690 
691 struct DELEGRETURN4args {
692         /* CURRENT_FH: delegated file */
693         stateid4        deleg_stateid;
694 };
695 
696 struct DELEGRETURN4res {
697         nfsstat4        status;
698 };
699 
700 struct GETATTR4args {
701         /* CURRENT_FH: directory or file */
702         bitmap4         attr_request;
703 };
704 
705 struct GETATTR4resok {
706         fattr4          obj_attributes;
707 };
708 
709 union GETATTR4res switch (nfsstat4 status) {
710  case NFS4_OK:
711          GETATTR4resok  resok4;
712  default:
713          void;
714 };
715 
716 struct GETFH4resok {
717         nfs_fh4         object;
718 };
719 
720 union GETFH4res switch (nfsstat4 status) {
721  case NFS4_OK:
722          GETFH4resok     resok4;
723  default:
724          void;
725 };
726 
727 struct LINK4args {
728         /* SAVED_FH: source object */
729         /* CURRENT_FH: target directory */
730         component4      newname;
731 };
732 
733 struct LINK4resok {
734         change_info4    cinfo;
735 };
736 
737 union LINK4res switch (nfsstat4 status) {
738  case NFS4_OK:
739          LINK4resok resok4;
740  default:
741          void;
742 };
743 
744 /*
745  * For LOCK, transition from open_owner to new lock_owner
746  */
747 struct open_to_lock_owner4 {
748         seqid4          open_seqid;
749         stateid4        open_stateid;
750         seqid4          lock_seqid;
751         lock_owner4     lock_owner;
752 };
753 
754 /*
755  * For LOCK, existing lock_owner continues to request file locks
756  */
757 struct exist_lock_owner4 {
758         stateid4        lock_stateid;
759         seqid4          lock_seqid;
760 };
761 
762 union locker4 switch (bool new_lock_owner) {
763  case TRUE:
764         open_to_lock_owner4     open_owner;
765  case FALSE:
766         exist_lock_owner4       lock_owner;
767 };
768 
769 /*
770  * LOCK/LOCKT/LOCKU: Record lock management
771  */
772 struct LOCK4args {
773         /* CURRENT_FH: file */
774         nfs_lock_type4  locktype;
775         bool            reclaim;
776         offset4         offset;
777         length4         length;
778         locker4         locker;
779 };
780 
781 struct LOCK4denied {
782         offset4         offset;
783         length4         length;
784         nfs_lock_type4  locktype;
785         lock_owner4     owner;
786 };
787 
788 struct LOCK4resok {
789         stateid4        lock_stateid;
790 };
791 
792 union LOCK4res switch (nfsstat4 status) {
793  case NFS4_OK:
794          LOCK4resok     resok4;
795  case NFS4ERR_DENIED:
796          LOCK4denied    denied;
797  default:
798          void;
799 };
800 
801 struct LOCKT4args {
802         /* CURRENT_FH: file */
803         nfs_lock_type4  locktype;
804         offset4         offset;
805         length4         length;
806         lock_owner4     owner;
807 };
808 
809 union LOCKT4res switch (nfsstat4 status) {
810  case NFS4ERR_DENIED:
811          LOCK4denied    denied;
812  case NFS4_OK:
813          void;
814  default:
815          void;
816 };
817 
818 struct LOCKU4args {
819         /* CURRENT_FH: file */
820         nfs_lock_type4  locktype;
821         seqid4          seqid;
822         stateid4        lock_stateid;
823         offset4         offset;
824         length4         length;
825 };
826 
827 union LOCKU4res switch (nfsstat4 status) {
828  case NFS4_OK:
829          stateid4       lock_stateid;
830  default:
831          void;
832 };
833 
834 struct LOOKUP4args {
835         /* CURRENT_FH: directory */
836         component4      objname;
837 };
838 
839 struct LOOKUP4res {
840         /* CURRENT_FH: object */
841         nfsstat4        status;
842 };
843 
844 struct LOOKUPP4res {
845         /* CURRENT_FH: directory */
846         nfsstat4        status;
847 };
848 
849 struct NVERIFY4args {
850         /* CURRENT_FH: object */
851         fattr4          obj_attributes;
852 };
853 
854 struct NVERIFY4res {
855         nfsstat4        status;
856 };
857 
858 const OPEN4_SHARE_ACCESS_READ   = 0x00000001;
859 const OPEN4_SHARE_ACCESS_WRITE  = 0x00000002;
860 const OPEN4_SHARE_ACCESS_BOTH   = 0x00000003;
861 
862 const OPEN4_SHARE_DENY_NONE     = 0x00000000;
863 const OPEN4_SHARE_DENY_READ     = 0x00000001;
864 const OPEN4_SHARE_DENY_WRITE    = 0x00000002;
865 const OPEN4_SHARE_DENY_BOTH     = 0x00000003;
866 /*
867  * Various definitions for OPEN
868  */
869 enum createmode4 {
870         UNCHECKED4      = 0,
871         GUARDED4        = 1,
872         EXCLUSIVE4      = 2
873 };
874 
875 union createhow4 switch (createmode4 mode) {
876  case UNCHECKED4:
877  case GUARDED4:
878          fattr4         createattrs;
879  case EXCLUSIVE4:
880          verifier4      createverf;
881 };
882 
883 enum opentype4 {
884         OPEN4_NOCREATE  = 0,
885         OPEN4_CREATE    = 1
886 };
887 
888 union openflag4 switch (opentype4 opentype) {
889  case OPEN4_CREATE:
890          createhow4     how;
891  default:
892          void;
893 };
894 
895 /* Next definitions used for OPEN delegation */
896 enum limit_by4 {
897         NFS_LIMIT_SIZE          = 1,
898         NFS_LIMIT_BLOCKS        = 2
899         /* others as needed */
900 };
901 
902 struct nfs_modified_limit4 {
903         uint32_t        num_blocks;
904         uint32_t        bytes_per_block;
905 };
906 
907 union nfs_space_limit4 switch (limit_by4 limitby) {
908  /* limit specified as file size */
909  case NFS_LIMIT_SIZE:
910          uint64_t               filesize;
911  /* limit specified by number of blocks */
912  case NFS_LIMIT_BLOCKS:
913          nfs_modified_limit4    mod_blocks;
914 } ;
915 
916 enum open_delegation_type4 {
917         OPEN_DELEGATE_NONE      = 0,
918         OPEN_DELEGATE_READ      = 1,
919         OPEN_DELEGATE_WRITE     = 2
920 };
921 
922 enum open_claim_type4 {
923         CLAIM_NULL              = 0,
924         CLAIM_PREVIOUS          = 1,
925         CLAIM_DELEGATE_CUR      = 2,
926         CLAIM_DELEGATE_PREV     = 3
927 };
928 
929 struct open_claim_delegate_cur4 {
930         stateid4        delegate_stateid;
931         component4      file;
932 };
933 
934 union open_claim4 switch (open_claim_type4 claim) {
935  /*
936   * No special rights to file.
937   * Ordinary OPEN of the specified file.
938   */
939  case CLAIM_NULL:
940         /* CURRENT_FH: directory */
941         component4      file;
942  /*
943   * Right to the file established by an
944   * open previous to server reboot.  File
945   * identified by filehandle obtained at
946   * that time rather than by name.
947   */
948  case CLAIM_PREVIOUS:
949         /* CURRENT_FH: file being reclaimed */
950         open_delegation_type4   delegate_type;
951 
952  /*
953   * Right to file based on a delegation
954   * granted by the server.  File is
955   * specified by name.
956   */
957  case CLAIM_DELEGATE_CUR:
958         /* CURRENT_FH: directory */
959         open_claim_delegate_cur4        delegate_cur_info;
960 
961  /*
962   * Right to file based on a delegation
963   * granted to a previous boot instance
964   * of the client.  File is specified by name.
965   */
966  case CLAIM_DELEGATE_PREV:
967         /* CURRENT_FH: directory */
968         component4      file_delegate_prev;
969 };
970 
971 /*
972  * OPEN: Open a file, potentially receiving an open delegation
973  */
974 struct OPEN4args {
975         seqid4          seqid;
976         uint32_t        share_access;
977         uint32_t        share_deny;
978         open_owner4     owner;
979         openflag4       openhow;
980         open_claim4     claim;
981 };
982 
983 struct open_read_delegation4 {
984  stateid4 stateid;    /* Stateid for delegation */
985  bool     recall;     /* Pre-recalled flag for
986                          delegations obtained
987                          by reclaim (CLAIM_PREVIOUS). */
988 
989  nfsace4 permissions; /* Defines users who don't
990                          need an ACCESS call to
991                          open for read. */
992 };
993 
994 struct open_write_delegation4 {
995  stateid4 stateid;      /* Stateid for delegation */
996  bool     recall;       /* Pre-recalled flag for
997                            delegations obtained
998                            by reclaim
999                            (CLAIM_PREVIOUS). */
1000 
1001  nfs_space_limit4
1002            space_limit; /* Defines condition that
1003                            the client must check to
1004                            determine whether the
1005                            file needs to be flushed
1006                            to the server on close. */
1007 
1008  nfsace4   permissions; /* Defines users who don't
1009                            need an ACCESS call as
1010                            part of a delegated
1011                            open. */
1012 };
1013 
1014 union open_delegation4
1015 switch (open_delegation_type4 delegation_type) {
1016         case OPEN_DELEGATE_NONE:
1017                 void;
1018         case OPEN_DELEGATE_READ:
1019                 open_read_delegation4 read;
1020         case OPEN_DELEGATE_WRITE:
1021                 open_write_delegation4 write;
1022 };
1023 
1024 /*
1025  * Result flags
1026  */
1027 
1028 /* Client must confirm open */
1029 const OPEN4_RESULT_CONFIRM      = 0x00000002;
1030 /* Type of file locking behavior at the server */
1031 const OPEN4_RESULT_LOCKTYPE_POSIX = 0x00000004;
1032 
1033 struct OPEN4resok {
1034  stateid4          stateid;     /* Stateid for open */
1035  change_info4      cinfo;       /* Directory change info */
1036  uint32_t          rflags;      /* Result flags */
1037  bitmap4           attrset;     /* attribute set for create */
1038  open_delegation4  delegation;  /* Info on any open
1039                                    delegation */
1040 };
1041 
1042 union OPEN4res switch (nfsstat4 status) {
1043  case NFS4_OK:
1044          /* CURRENT_FH: opened file */
1045          OPEN4resok      resok4;
1046  default:
1047          void;
1048 };
1049 
1050 struct OPENATTR4args {
1051         /* CURRENT_FH: object */
1052         bool    createdir;
1053 };
1054 
1055 struct OPENATTR4res {
1056         /* CURRENT_FH: named attr directory */
1057         nfsstat4        status;
1058 };
1059 
1060 struct OPEN_CONFIRM4args {
1061         /* CURRENT_FH: opened file */
1062         stateid4        open_stateid;
1063         seqid4          seqid;
1064 };
1065 
1066 struct OPEN_CONFIRM4resok {
1067         stateid4        open_stateid;
1068 };
1069 
1070 union OPEN_CONFIRM4res switch (nfsstat4 status) {
1071  case NFS4_OK:
1072          OPEN_CONFIRM4resok     resok4;
1073  default:
1074          void;
1075 };
1076 
1077 struct OPEN_DOWNGRADE4args {
1078         /* CURRENT_FH: opened file */
1079         stateid4        open_stateid;
1080         seqid4          seqid;
1081         uint32_t        share_access;
1082         uint32_t        share_deny;
1083 };
1084 
1085 struct OPEN_DOWNGRADE4resok {
1086         stateid4        open_stateid;
1087 };
1088 
1089 union OPEN_DOWNGRADE4res switch (nfsstat4 status) {
1090  case NFS4_OK:
1091          OPEN_DOWNGRADE4resok    resok4;
1092  default:
1093          void;
1094 };
1095 
1096 struct PUTFH4args {
1097         nfs_fh4         object;
1098 };
1099 
1100 struct PUTFH4res {
1101         /* CURRENT_FH: */
1102         nfsstat4        status;
1103 };
1104 
1105 struct PUTPUBFH4res {
1106         /* CURRENT_FH: public fh */
1107         nfsstat4        status;
1108 };
1109 
1110 struct PUTROOTFH4res {
1111         /* CURRENT_FH: root fh */
1112         nfsstat4        status;
1113 };
1114 
1115 struct READ4args {
1116         /* CURRENT_FH: file */
1117         stateid4        stateid;
1118         offset4         offset;
1119         count4          count;
1120 };
1121 
1122 struct READ4resok {
1123         bool            eof;
1124         opaque          data<>;
1125 };
1126 
1127 union READ4res switch (nfsstat4 status) {
1128  case NFS4_OK:
1129          READ4resok     resok4;
1130  default:
1131          void;
1132 };
1133 
1134 struct READDIR4args {
1135         /* CURRENT_FH: directory */
1136         nfs_cookie4     cookie;
1137         verifier4       cookieverf;
1138         count4          dircount;
1139         count4          maxcount;
1140         bitmap4         attr_request;
1141 };
1142 
1143 struct entry4 {
1144         nfs_cookie4     cookie;
1145         component4      name;
1146         fattr4          attrs;
1147         entry4          *nextentry;
1148 };
1149 
1150 struct dirlist4 {
1151         entry4          *entries;
1152         bool            eof;
1153 };
1154 
1155 struct READDIR4resok {
1156         verifier4       cookieverf;
1157         dirlist4        reply;
1158 };
1159 
1160 
1161 union READDIR4res switch (nfsstat4 status) {
1162  case NFS4_OK:
1163          READDIR4resok  resok4;
1164  default:
1165          void;
1166 };
1167 
1168 
1169 struct READLINK4resok {
1170         linktext4       link;
1171 };
1172 
1173 union READLINK4res switch (nfsstat4 status) {
1174  case NFS4_OK:
1175          READLINK4resok resok4;
1176  default:
1177          void;
1178 };
1179 
1180 struct REMOVE4args {
1181         /* CURRENT_FH: directory */
1182         component4      target;
1183 };
1184 
1185 struct REMOVE4resok {
1186         change_info4    cinfo;
1187 };
1188 
1189 union REMOVE4res switch (nfsstat4 status) {
1190  case NFS4_OK:
1191          REMOVE4resok   resok4;
1192  default:
1193          void;
1194 };
1195 
1196 struct RENAME4args {
1197         /* SAVED_FH: source directory */
1198         component4      oldname;
1199         /* CURRENT_FH: target directory */
1200         component4      newname;
1201 };
1202 
1203 struct RENAME4resok {
1204         change_info4    source_cinfo;
1205         change_info4    target_cinfo;
1206 };
1207 
1208 union RENAME4res switch (nfsstat4 status) {
1209  case NFS4_OK:
1210          RENAME4resok    resok4;
1211  default:
1212          void;
1213 };
1214 
1215 struct RENEW4args {
1216         clientid4       clientid;
1217 };
1218 
1219 struct RENEW4res {
1220         nfsstat4        status;
1221 };
1222 
1223 struct RESTOREFH4res {
1224         /* CURRENT_FH: value of saved fh */
1225         nfsstat4        status;
1226 };
1227 
1228 struct SAVEFH4res {
1229         /* SAVED_FH: value of current fh */
1230         nfsstat4        status;
1231 };
1232 
1233 struct SECINFO4args {
1234         /* CURRENT_FH: directory */
1235         component4      name;
1236 };
1237 
1238 /*
1239  * From RFC 2203
1240  */
1241 enum rpc_gss_svc_t {
1242         RPC_GSS_SVC_NONE        = 1,
1243         RPC_GSS_SVC_INTEGRITY   = 2,
1244         RPC_GSS_SVC_PRIVACY     = 3
1245 };
1246 
1247 struct rpcsec_gss_info {
1248         sec_oid4        oid;
1249         qop4            qop;
1250         rpc_gss_svc_t   service;
1251 };
1252 
1253 /* RPCSEC_GSS has a value of '6'.  See RFC 2203 */
1254 union secinfo4 switch (uint32_t flavor) {
1255  case RPCSEC_GSS:
1256          rpcsec_gss_info        flavor_info;
1257  default:
1258          void;
1259 };
1260 
1261 typedef secinfo4 SECINFO4resok<>;
1262 
1263 union SECINFO4res switch (nfsstat4 status) {
1264  case NFS4_OK:
1265          SECINFO4resok resok4;
1266  default:
1267          void;
1268 };
1269 
1270 struct SETATTR4args {
1271         /* CURRENT_FH: target object */
1272         stateid4        stateid;
1273         fattr4          obj_attributes;
1274 };
1275 
1276 struct SETATTR4res {
1277         nfsstat4        status;
1278         bitmap4         attrsset;
1279 };
1280 
1281 struct SETCLIENTID4args {
1282         nfs_client_id4  client;
1283         cb_client4      callback;
1284         uint32_t        callback_ident;
1285 };
1286 
1287 struct SETCLIENTID4resok {
1288         clientid4       clientid;
1289         verifier4       setclientid_confirm;
1290 };
1291 
1292 union SETCLIENTID4res switch (nfsstat4 status) {
1293  case NFS4_OK:
1294          SETCLIENTID4resok      resok4;
1295  case NFS4ERR_CLID_INUSE:
1296          clientaddr4    client_using;
1297  default:
1298          void;
1299 };
1300 
1301 struct SETCLIENTID_CONFIRM4args {
1302         clientid4       clientid;
1303         verifier4       setclientid_confirm;
1304 };
1305 
1306 struct SETCLIENTID_CONFIRM4res {
1307         nfsstat4        status;
1308 };
1309 
1310 struct VERIFY4args {
1311         /* CURRENT_FH: object */
1312         fattr4          obj_attributes;
1313 };
1314 
1315 struct VERIFY4res {
1316         nfsstat4        status;
1317 };
1318 
1319 enum stable_how4 {
1320         UNSTABLE4       = 0,
1321         DATA_SYNC4      = 1,
1322         FILE_SYNC4      = 2
1323 };
1324 
1325 struct WRITE4args {
1326         /* CURRENT_FH: file */
1327         stateid4        stateid;
1328         offset4         offset;
1329         stable_how4     stable;
1330         opaque          data<>;
1331 };
1332 
1333 struct WRITE4resok {
1334         count4          count;
1335         stable_how4     committed;
1336         verifier4       writeverf;
1337 };
1338 
1339 union WRITE4res switch (nfsstat4 status) {
1340  case NFS4_OK:
1341          WRITE4resok    resok4;
1342  default:
1343          void;
1344 };
1345 
1346 struct RELEASE_LOCKOWNER4args {
1347         lock_owner4     lock_owner;
1348 };
1349 
1350 struct RELEASE_LOCKOWNER4res {
1351         nfsstat4        status;
1352 };
1353 
1354 struct ILLEGAL4res {
1355         nfsstat4        status;
1356 };
1357 
1358 /*
1359  * Operation arrays
1360  */
1361 
1362 enum nfs_opnum4 {
1363  OP_ACCESS              = 3,
1364  OP_CLOSE               = 4,
1365  OP_COMMIT              = 5,
1366  OP_CREATE              = 6,
1367  OP_DELEGPURGE          = 7,
1368  OP_DELEGRETURN         = 8,
1369  OP_GETATTR             = 9,
1370  OP_GETFH               = 10,
1371  OP_LINK                = 11,
1372  OP_LOCK                = 12,
1373  OP_LOCKT               = 13,
1374  OP_LOCKU               = 14,
1375  OP_LOOKUP              = 15,
1376  OP_LOOKUPP             = 16,
1377  OP_NVERIFY             = 17,
1378  OP_OPEN                = 18,
1379  OP_OPENATTR            = 19,
1380  OP_OPEN_CONFIRM        = 20,
1381  OP_OPEN_DOWNGRADE      = 21,
1382  OP_PUTFH               = 22,
1383  OP_PUTPUBFH            = 23,
1384  OP_PUTROOTFH           = 24,
1385  OP_READ                = 25,
1386  OP_READDIR             = 26,
1387  OP_READLINK            = 27,
1388  OP_REMOVE              = 28,
1389  OP_RENAME              = 29,
1390  OP_RENEW               = 30,
1391  OP_RESTOREFH           = 31,
1392  OP_SAVEFH              = 32,
1393  OP_SECINFO             = 33,
1394  OP_SETATTR             = 34,
1395  OP_SETCLIENTID         = 35,
1396  OP_SETCLIENTID_CONFIRM = 36,
1397  OP_VERIFY              = 37,
1398  OP_WRITE               = 38,
1399  OP_RELEASE_LOCKOWNER   = 39,
1400  OP_ILLEGAL             = 10044
1401 };
1402 
1403 union nfs_argop4 switch (nfs_opnum4 argop) {
1404  case OP_ACCESS:        ACCESS4args opaccess;
1405  case OP_CLOSE:         CLOSE4args opclose;
1406  case OP_COMMIT:        COMMIT4args opcommit;
1407  case OP_CREATE:        CREATE4args opcreate;
1408  case OP_DELEGPURGE:    DELEGPURGE4args opdelegpurge;
1409  case OP_DELEGRETURN:   DELEGRETURN4args opdelegreturn;
1410  case OP_GETATTR:       GETATTR4args opgetattr;
1411  case OP_GETFH:         void;
1412  case OP_LINK:          LINK4args oplink;
1413  case OP_LOCK:          LOCK4args oplock;
1414  case OP_LOCKT:         LOCKT4args oplockt;
1415  case OP_LOCKU:         LOCKU4args oplocku;
1416  case OP_LOOKUP:        LOOKUP4args oplookup;
1417  case OP_LOOKUPP:       void;
1418  case OP_NVERIFY:       NVERIFY4args opnverify;
1419  case OP_OPEN:          OPEN4args opopen;
1420  case OP_OPENATTR:      OPENATTR4args opopenattr;
1421  case OP_OPEN_CONFIRM:  OPEN_CONFIRM4args opopen_confirm;
1422  case OP_OPEN_DOWNGRADE:
1423                         OPEN_DOWNGRADE4args opopen_downgrade;
1424  case OP_PUTFH:         PUTFH4args opputfh;
1425  case OP_PUTPUBFH:      void;
1426  case OP_PUTROOTFH:     void;
1427  case OP_READ:          READ4args opread;
1428  case OP_READDIR:       READDIR4args opreaddir;
1429  case OP_READLINK:      void;
1430  case OP_REMOVE:        REMOVE4args opremove;
1431  case OP_RENAME:        RENAME4args oprename;
1432  case OP_RENEW:         RENEW4args oprenew;
1433  case OP_RESTOREFH:     void;
1434  case OP_SAVEFH:        void;
1435  case OP_SECINFO:       SECINFO4args opsecinfo;
1436  case OP_SETATTR:       SETATTR4args opsetattr;
1437  case OP_SETCLIENTID:   SETCLIENTID4args opsetclientid;
1438  case OP_SETCLIENTID_CONFIRM: SETCLIENTID_CONFIRM4args
1439                                 opsetclientid_confirm;
1440  case OP_VERIFY:        VERIFY4args opverify;
1441  case OP_WRITE:         WRITE4args opwrite;
1442  case OP_RELEASE_LOCKOWNER:
1443                         RELEASE_LOCKOWNER4args
1444                         oprelease_lockowner;
1445  case OP_ILLEGAL:       void;
1446 };
1447 
1448 union nfs_resop4 switch (nfs_opnum4 resop) {
1449  case OP_ACCESS:        ACCESS4res opaccess;
1450  case OP_CLOSE:         CLOSE4res opclose;
1451  case OP_COMMIT:        COMMIT4res opcommit;
1452  case OP_CREATE:        CREATE4res opcreate;
1453  case OP_DELEGPURGE:    DELEGPURGE4res opdelegpurge;
1454  case OP_DELEGRETURN:   DELEGRETURN4res opdelegreturn;
1455  case OP_GETATTR:       GETATTR4res opgetattr;
1456  case OP_GETFH:         GETFH4res opgetfh;
1457  case OP_LINK:          LINK4res oplink;
1458  case OP_LOCK:          LOCK4res oplock;
1459  case OP_LOCKT:         LOCKT4res oplockt;
1460  case OP_LOCKU:         LOCKU4res oplocku;
1461  case OP_LOOKUP:        LOOKUP4res oplookup;
1462  case OP_LOOKUPP:       LOOKUPP4res oplookupp;
1463  case OP_NVERIFY:       NVERIFY4res opnverify;
1464  case OP_OPEN:          OPEN4res opopen;
1465  case OP_OPENATTR:      OPENATTR4res opopenattr;
1466  case OP_OPEN_CONFIRM:  OPEN_CONFIRM4res opopen_confirm;
1467  case OP_OPEN_DOWNGRADE:
1468                         OPEN_DOWNGRADE4res
1469                                 opopen_downgrade;
1470  case OP_PUTFH:         PUTFH4res opputfh;
1471  case OP_PUTPUBFH:      PUTPUBFH4res opputpubfh;
1472  case OP_PUTROOTFH:     PUTROOTFH4res opputrootfh;
1473  case OP_READ:          READ4res opread;
1474  case OP_READDIR:       READDIR4res opreaddir;
1475  case OP_READLINK:      READLINK4res opreadlink;
1476  case OP_REMOVE:        REMOVE4res opremove;
1477  case OP_RENAME:        RENAME4res oprename;
1478  case OP_RENEW:         RENEW4res oprenew;
1479  case OP_RESTOREFH:     RESTOREFH4res oprestorefh;
1480  case OP_SAVEFH:        SAVEFH4res opsavefh;
1481  case OP_SECINFO:       SECINFO4res opsecinfo;
1482  case OP_SETATTR:       SETATTR4res opsetattr;
1483  case OP_SETCLIENTID:   SETCLIENTID4res opsetclientid;
1484  case OP_SETCLIENTID_CONFIRM:
1485                         SETCLIENTID_CONFIRM4res
1486                                 opsetclientid_confirm;
1487  case OP_VERIFY:        VERIFY4res opverify;
1488  case OP_WRITE:         WRITE4res opwrite;
1489  case OP_RELEASE_LOCKOWNER:
1490                         RELEASE_LOCKOWNER4res
1491                                 oprelease_lockowner;
1492  case OP_ILLEGAL:       ILLEGAL4res opillegal;
1493 };
1494 
1495 struct COMPOUND4args {
1496         utf8str_cs      tag;
1497         uint32_t        minorversion;
1498         nfs_argop4      argarray<>;
1499 };
1500 
1501 struct COMPOUND4res {
1502         nfsstat4        status;
1503         utf8str_cs      tag;
1504         nfs_resop4      resarray<>;
1505 };
1506 
1507 
1508 /*
1509  * Remote file service routines
1510  */
1511 program NFS4_PROGRAM {
1512         version NFS_V4 {
1513                 void
1514                         NFSPROC4_NULL(void) = 0;
1515 
1516                 COMPOUND4res
1517                         NFSPROC4_COMPOUND(COMPOUND4args) = 1;
1518 
1519         } = 4;
1520 } = 100003;
1521 
1522 /*
1523  * NFS4 callback procedure definitions and program
1524  */
1525 struct CB_GETATTR4args {
1526         nfs_fh4 fh;
1527         bitmap4 attr_request;
1528 };
1529 
1530 struct CB_GETATTR4resok {
1531         fattr4  obj_attributes;
1532 };
1533 
1534 union CB_GETATTR4res switch (nfsstat4 status) {
1535  case NFS4_OK:
1536          CB_GETATTR4resok       resok4;
1537  default:
1538          void;
1539 };
1540 
1541 struct CB_RECALL4args {
1542         stateid4        stateid;
1543         bool            truncate;
1544         nfs_fh4         fh;
1545 };
1546 
1547 struct CB_RECALL4res {
1548         nfsstat4        status;
1549 };
1550 
1551 /*
1552  * CB_ILLEGAL: Response for illegal operation numbers
1553  */
1554 struct CB_ILLEGAL4res {
1555         nfsstat4        status;
1556 };
1557 
1558 /*
1559  * Various definitions for CB_COMPOUND
1560  */
1561 enum nfs_cb_opnum4 {
1562         OP_CB_GETATTR           = 3,
1563         OP_CB_RECALL            = 4,
1564         OP_CB_ILLEGAL           = 10044
1565 };
1566 
1567 union nfs_cb_argop4 switch (unsigned argop) {
1568  case OP_CB_GETATTR:    CB_GETATTR4args opcbgetattr;
1569  case OP_CB_RECALL:     CB_RECALL4args opcbrecall;
1570  case OP_CB_ILLEGAL:    void;
1571 };
1572 
1573 union nfs_cb_resop4 switch (unsigned resop) {
1574  case OP_CB_GETATTR:    CB_GETATTR4res opcbgetattr;
1575  case OP_CB_RECALL:     CB_RECALL4res opcbrecall;
1576  case OP_CB_ILLEGAL:    CB_ILLEGAL4res opcbillegal;
1577 };
1578 
1579 
1580 struct CB_COMPOUND4args {
1581         utf8str_cs      tag;
1582         uint32_t        minorversion;
1583         uint32_t        callback_ident;
1584         nfs_cb_argop4   argarray<>;
1585 };
1586 
1587 struct CB_COMPOUND4res {
1588         nfsstat4        status;
1589         utf8str_cs      tag;
1590         nfs_cb_resop4   resarray<>;
1591 };
1592 
1593 
1594 
1595 /*
1596  * Program number is in the transient range, since the client
1597  * will assign the exact transient program number and provide
1598  * that to the server via the SETCLIENTID operation.
1599  */
1600 program NFS4_CALLBACK {
1601         version NFS_CB {
1602                 void
1603                         CB_NULL(void) = 0;
1604                 CB_COMPOUND4res
1605                         CB_COMPOUND(CB_COMPOUND4args) = 1;
1606         } = 1;
1607 } = 0x40000000;
1608