xref: /freebsd/sys/fs/nfs/rpcv2.h (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Rick Macklem at The University of Guelph.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36 
37 #ifndef _NFS_RPCV2_H_
38 #define	_NFS_RPCV2_H_
39 
40 /*
41  * Definitions for Sun RPC Version 2, from
42  * "RPC: Remote Procedure Call Protocol Specification" RFC1057
43  */
44 
45 /* Version # */
46 #define	RPC_VER2		2
47 
48 /* Authentication flavours */
49 #define	RPCAUTH_NULL			0
50 #define	RPCAUTH_UNIX			1
51 #define	RPCAUTH_SHORT			2
52 #define	RPCAUTH_KERB4			4
53 #define	RPCAUTH_GSS			6
54 #define	RPCAUTH_GSSKRB5			390003
55 #define	RPCAUTH_GSSKRB5INTEGRITY	390004
56 #define	RPCAUTH_GSSKRB5PRIVACY		390005
57 
58 #define	RPCAUTH_MAXSIZ		400
59 #define	RPCVERF_MAXSIZ	12	/* For Kerb, can actually be 400 */
60 
61 /*
62  * RPCAUTH_UNIX defs.
63  */
64 #define	RPCAUTHUNIX_MINSIZ	(5 * NFSX_UNSIGNED)
65 #define	RPCAUTH_UNIXGIDS 16
66 
67 /*
68  * RPCAUTH_GSS defs.
69  */
70 #define	RPCAUTHGSS_VERS1	1
71 
72 #define	RPCAUTHGSS_DATA		0
73 #define	RPCAUTHGSS_INIT		1
74 #define	RPCAUTHGSS_CONTINIT	2
75 #define	RPCAUTHGSS_DESTROY	3
76 
77 #define	RPCAUTHGSS_SVCNONE	1
78 #define	RPCAUTHGSS_SVCINTEGRITY	2
79 #define	RPCAUTHGSS_SVCPRIVACY	3
80 
81 #define	RPCAUTHGSS_MAXSEQ	0x80000000
82 
83 #define	RPCAUTHGSS_WINDOW	64	/* # of bits in u_int64_t */
84 #define	RPCAUTHGSS_SEQWINDOW	(RPCAUTHGSS_WINDOW + 1)
85 
86 #define	RPCAUTHGSS_MIC		1
87 #define	RPCAUTHGSS_WRAP		2
88 
89 /*
90  * Qop values for the types of security services.
91  */
92 #define	GSS_KERBV_QOP		0
93 
94 /*
95  * Sizes of GSS stuff.
96  */
97 #define	RPCGSS_KEYSIZ		8
98 
99 #define	GSSX_AUTHHEAD	(5 * NFSX_UNSIGNED)
100 #define	GSSX_MYHANDLE	(sizeof (long) + sizeof (u_int64_t))
101 #define	GSSX_RPCHEADER	(13 * NFSX_UNSIGNED + GSSX_MYHANDLE)
102 #define	GSSX_MINWRAP	(2 * NFSX_UNSIGNED)
103 #define	GSSX_KERBVTOKEN	24
104 #define	GSSX_LOCALHANDLE (sizeof (void *))
105 
106 /*
107  * Stuff for the gssd.
108  */
109 #define	RPCPROG_GSSD		0x20101010
110 #define	RPCGSSD_VERS		1
111 #define	RPCGSSD_INIT		1
112 #define	RPCGSSD_CONTINIT	2
113 #define	RPCGSSD_CONTINITDESTROY	3
114 #define	RPCGSSD_CLINIT		4
115 #define	RPCGSSD_CLINITUID	5
116 #define	RPCGSSD_CLCONT		6
117 #define	RPCGSSD_CLCONTUID	7
118 #define	RPCGSSD_CLINITNAME	8
119 #define	RPCGSSD_CLCONTNAME	9
120 
121 /*
122  * Stuff for the nfsuserd
123  */
124 #define	RPCPROG_NFSUSERD	0x21010101
125 #define	RPCNFSUSERD_VERS	1
126 #define	RPCNFSUSERD_GETUID	1
127 #define	RPCNFSUSERD_GETGID	2
128 #define	RPCNFSUSERD_GETUSER	3
129 #define	RPCNFSUSERD_GETGROUP	4
130 
131 /*
132  * Some major status codes.
133  */
134 #if !defined(_GSSAPI_H_) && !defined(GSSAPI_H_) && !defined(_GSSAPI_GSSAPI_H_) && !defined(_RPCSEC_GSS_H)
135 #define	 GSS_S_COMPLETE                  0x00000000
136 #define	 GSS_S_CONTINUE_NEEDED           0x00000001
137 #define	 GSS_S_DUPLICATE_TOKEN           0x00000002
138 #define	 GSS_S_OLD_TOKEN                 0x00000004
139 #define	 GSS_S_UNSEQ_TOKEN               0x00000008
140 #define	 GSS_S_GAP_TOKEN                 0x00000010
141 #define	 GSS_S_BAD_MECH                  0x00010000
142 #define	 GSS_S_BAD_NAME                  0x00020000
143 #define	 GSS_S_BAD_NAMETYPE              0x00030000
144 #define	 GSS_S_BAD_BINDINGS              0x00040000
145 #define	 GSS_S_BAD_STATUS                0x00050000
146 #define	 GSS_S_BAD_MIC                   0x00060000
147 #define	 GSS_S_BAD_SIG                   0x00060000
148 #define	 GSS_S_NO_CRED                   0x00070000
149 #define	 GSS_S_NO_CONTEXT                0x00080000
150 #define	 GSS_S_DEFECTIVE_TOKEN           0x00090000
151 #define	 GSS_S_DEFECTIVE_CREDENTIAL      0x000a0000
152 #define	 GSS_S_CREDENTIALS_EXPIRED       0x000b0000
153 #define	 GSS_S_CONTEXT_EXPIRED           0x000c0000
154 #define	 GSS_S_FAILURE                   0x000d0000
155 #define	 GSS_S_BAD_QOP                   0x000e0000
156 #define	 GSS_S_UNAUTHORIZED              0x000f0000
157 #define	 GSS_S_UNAVAILABLE               0x00100000
158 #define	 GSS_S_DUPLICATE_ELEMENT         0x00110000
159 #define	 GSS_S_NAME_NOT_MN               0x00120000
160 #define	 GSS_S_CALL_INACCESSIBLE_READ    0x01000000
161 #define	 GSS_S_CALL_INACCESSIBLE_WRITE   0x02000000
162 #define	 GSS_S_CALL_BAD_STRUCTURE        0x03000000
163 #endif	/* _GSSAPI_H_ */
164 
165 /* Rpc Constants */
166 #define	RPC_CALL	0
167 #define	RPC_REPLY	1
168 #define	RPC_MSGACCEPTED	0
169 #define	RPC_MSGDENIED	1
170 #define	RPC_PROGUNAVAIL	1
171 #define	RPC_PROGMISMATCH	2
172 #define	RPC_PROCUNAVAIL	3
173 #define	RPC_GARBAGE	4		/* I like this one */
174 #define	RPC_MISMATCH	0
175 #define	RPC_AUTHERR	1
176 
177 /* Authentication failures */
178 #define	AUTH_BADCRED	1
179 #define	AUTH_REJECTCRED	2
180 #define	AUTH_BADVERF	3
181 #define	AUTH_REJECTVERF	4
182 #define	AUTH_TOOWEAK	5		/* Give em wheaties */
183 #define	AUTH_PROBCRED	13
184 #define	AUTH_CTXCRED	14
185 
186 /* Sizes of rpc header parts */
187 #define	RPC_SIZ		24
188 #define	RPC_REPLYSIZ	28
189 
190 /* RPC Prog definitions */
191 #define	RPCPROG_MNT	100005
192 #define	RPCMNT_VER1	1
193 #define	RPCMNT_VER3	3
194 #define	RPCMNT_MOUNT	1
195 #define	RPCMNT_DUMP	2
196 #define	RPCMNT_UMOUNT	3
197 #define	RPCMNT_UMNTALL	4
198 #define	RPCMNT_EXPORT	5
199 #define	RPCMNT_NAMELEN	255
200 #define	RPCMNT_PATHLEN	1024
201 #define	RPCPROG_NFS	100003
202 
203 /* Structs for common parts of the rpc's */
204 struct rpcv2_time {
205 	u_int32_t rpc_sec;
206 	u_int32_t rpc_usec;
207 };
208 
209 #endif	/* _NFS_RPCV2_H_ */
210