xref: /onnv-gate/usr/src/uts/common/nfs/nfsid_map.h (revision 11291:80bdcd03e626)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*11291SRobert.Thurlow@Sun.COM  * Common Development and Distribution License (the "License").
6*11291SRobert.Thurlow@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*11291SRobert.Thurlow@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _NFSID_MAP_H
270Sstevel@tonic-gate #define	_NFSID_MAP_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifndef _KERNEL
300Sstevel@tonic-gate #include <stddef.h>
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate #include <sys/sysmacros.h>
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * NFSv4 id mapping daemon
370Sstevel@tonic-gate  *
380Sstevel@tonic-gate  * This daemon is used by the kernel to map strings in the form
390Sstevel@tonic-gate  * "user@dns_domain" from an integer form or vice-versa.  The daemon
400Sstevel@tonic-gate  * uses the system configured name services for the mapping.
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  * The status results determines if a mapping was successful.
430Sstevel@tonic-gate  *
440Sstevel@tonic-gate  * The mapping is cached in the kernel, so that expensive upcalls are
450Sstevel@tonic-gate  * reduced to a minimum.
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #ifdef	__cplusplus
490Sstevel@tonic-gate extern "C" {
500Sstevel@tonic-gate #endif
510Sstevel@tonic-gate 
520Sstevel@tonic-gate /*
530Sstevel@tonic-gate  * mapid commands
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate #define	NFSMAPID_STR_UID	1
560Sstevel@tonic-gate #define	NFSMAPID_UID_STR	2
570Sstevel@tonic-gate #define	NFSMAPID_STR_GID	3
580Sstevel@tonic-gate #define	NFSMAPID_GID_STR	4
59*11291SRobert.Thurlow@Sun.COM #define	NFSMAPID_SRV_NETINFO	5
600Sstevel@tonic-gate 
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate  * We are passing in arguments in a variable length struct
630Sstevel@tonic-gate  * similar to a dirent_t. We break apart a utf8string into
640Sstevel@tonic-gate  * its components and allocate a struct long enough to hold
650Sstevel@tonic-gate  * the string and a NUL terminator.  The caller must ensure the
660Sstevel@tonic-gate  * terminator is set.
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate struct mapid_arg {
690Sstevel@tonic-gate 	uint_t	cmd;
700Sstevel@tonic-gate 	union {
710Sstevel@tonic-gate 		uid_t		uid;
720Sstevel@tonic-gate 		gid_t		gid;
730Sstevel@tonic-gate 		int		len;
740Sstevel@tonic-gate 	} u_arg;
750Sstevel@tonic-gate 	char str[1];
760Sstevel@tonic-gate };
770Sstevel@tonic-gate typedef struct mapid_arg mapid_arg_t;
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /*
800Sstevel@tonic-gate  * The actual required size of the args, rounded up to a 64 bit boundary
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate #define	MAPID_ARG_LEN(str_length)	\
830Sstevel@tonic-gate 	((offsetof(mapid_arg_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
860Sstevel@tonic-gate  * Return status codes
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate #define	NFSMAPID_OK		0
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * numeric string is mapped to its literal number
920Sstevel@tonic-gate  */
930Sstevel@tonic-gate #define	NFSMAPID_NUMSTR		1
940Sstevel@tonic-gate 
950Sstevel@tonic-gate /*
960Sstevel@tonic-gate  * Value cannot be mapped, badly formed string
970Sstevel@tonic-gate  */
980Sstevel@tonic-gate #define	NFSMAPID_UNMAPPABLE	2
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  * Caller provided invalid arguments
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate #define	NFSMAPID_INVALID	3
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate /*
1060Sstevel@tonic-gate  * Internal error in daemon e.g. out of memory, can't return result
1070Sstevel@tonic-gate  */
1080Sstevel@tonic-gate #define	NFSMAPID_INTERNAL	4
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /*
1110Sstevel@tonic-gate  * Incorrect domain used
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate #define	NFSMAPID_BADDOMAIN	5
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate /*
1160Sstevel@tonic-gate  * Out of range uid/gid
1170Sstevel@tonic-gate  */
1180Sstevel@tonic-gate #define	NFSMAPID_BADID		6
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * User or group cannot be found in nameservice
1220Sstevel@tonic-gate  */
1230Sstevel@tonic-gate #define	NFSMAPID_NOTFOUND	7
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate /*
1260Sstevel@tonic-gate  * Similar to the arguments, the result is variable length.
1270Sstevel@tonic-gate  * The returner must ensure the string terminator is set.
1280Sstevel@tonic-gate  */
1290Sstevel@tonic-gate struct mapid_res {
1300Sstevel@tonic-gate 	uint_t	status;
1310Sstevel@tonic-gate 	union {
1320Sstevel@tonic-gate 		uid_t		uid;
1330Sstevel@tonic-gate 		gid_t		gid;
1340Sstevel@tonic-gate 		int		len;
1350Sstevel@tonic-gate 	} u_res;
1360Sstevel@tonic-gate 	char str[1];
1370Sstevel@tonic-gate };
1380Sstevel@tonic-gate typedef struct mapid_res mapid_res_t;
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate /*
1410Sstevel@tonic-gate  * The actual required size of the result, rounded up to a 64 bit boundary
1420Sstevel@tonic-gate  */
1430Sstevel@tonic-gate #define	MAPID_RES_LEN(str_length)	\
1440Sstevel@tonic-gate 	((offsetof(mapid_res_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
1450Sstevel@tonic-gate 
146*11291SRobert.Thurlow@Sun.COM /*
147*11291SRobert.Thurlow@Sun.COM  * Support for referral name resolution by the NFS client
148*11291SRobert.Thurlow@Sun.COM  */
149*11291SRobert.Thurlow@Sun.COM typedef struct refd_door_args {
150*11291SRobert.Thurlow@Sun.COM 	int		cmd;		/* NFS4_FS_LOCATIONS/NFS4_SRV_NETINFO */
151*11291SRobert.Thurlow@Sun.COM 	int		xdr_len;	/* Length of xdr Buffer */
152*11291SRobert.Thurlow@Sun.COM 	char		xdr_arg[1];	/* Buffer holding xdr encoded data */
153*11291SRobert.Thurlow@Sun.COM } refd_door_args_t;
154*11291SRobert.Thurlow@Sun.COM 
155*11291SRobert.Thurlow@Sun.COM typedef struct refd_door_res {
156*11291SRobert.Thurlow@Sun.COM 	int		res_status;
157*11291SRobert.Thurlow@Sun.COM 	int		xdr_len;
158*11291SRobert.Thurlow@Sun.COM 	char		xdr_res[1];
159*11291SRobert.Thurlow@Sun.COM } refd_door_res_t;
160*11291SRobert.Thurlow@Sun.COM 
161*11291SRobert.Thurlow@Sun.COM #ifdef _SYSCALL32
162*11291SRobert.Thurlow@Sun.COM typedef struct refd_door_args32 {
163*11291SRobert.Thurlow@Sun.COM 	int32_t		cmd;
164*11291SRobert.Thurlow@Sun.COM 	int32_t		xdr_len;
165*11291SRobert.Thurlow@Sun.COM 	char		xdr_arg[1];
166*11291SRobert.Thurlow@Sun.COM } refd_door_args32_t;
167*11291SRobert.Thurlow@Sun.COM 
168*11291SRobert.Thurlow@Sun.COM typedef struct 	refd_door_res32 {
169*11291SRobert.Thurlow@Sun.COM 	int32_t		res_status;
170*11291SRobert.Thurlow@Sun.COM 	int32_t		xdr_len;
171*11291SRobert.Thurlow@Sun.COM 	char		xdr_res[1];
172*11291SRobert.Thurlow@Sun.COM } refd_door_res32_t;
173*11291SRobert.Thurlow@Sun.COM #endif
174*11291SRobert.Thurlow@Sun.COM 
1750Sstevel@tonic-gate #ifdef	__cplusplus
1760Sstevel@tonic-gate }
1770Sstevel@tonic-gate #endif
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate #endif /* _NFSID_MAP_H */
180