xref: /titanic_44/usr/src/lib/libidmap/common/idmap_impl.h (revision 0cd13cbfb4270b840b4bd22ec5f673b2b6a2c02b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Private Header for Identity Mapping
28  */
29 
30 #ifndef _IDMAP_IMPL_H
31 #define	_IDMAP_IMPL_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include "idmap_prot.h"
36 #include "idmap_priv.h"
37 #include <rpc/xdr.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #define	_IDMAP_HANDLE_RPC_DOORS		1
44 
45 #define	_IDMAP_GET_CLIENT_HANDLE(h, clnt) \
46 		if (h == NULL) \
47 			return (IDMAP_ERR_CLIENT_HANDLE);\
48 		if (h->type != _IDMAP_HANDLE_RPC_DOORS) \
49 			return (IDMAP_ERR_NOTSUPPORTED);\
50 		clnt = (CLIENT *)h->privhandle;\
51 		if (clnt == NULL)\
52 			return (IDMAP_ERR_RPC_HANDLE);
53 
54 struct idmap_handle {
55 	int	type;
56 	void	*privhandle;
57 	/* locks */
58 };
59 
60 struct idmap_udt_handle {
61 	struct idmap_handle	*ih;
62 	idmap_update_batch	batch;
63 	uint64_t		next;
64 	int64_t			error_index;
65 	idmap_stat		commit_stat;
66 	idmap_namerule		error_rule;
67 	idmap_namerule		conflict_rule;
68 };
69 
70 #define	_IDMAP_RESET_UDT_HANDLE(uh) \
71 	(void) xdr_free(xdr_idmap_update_batch, (caddr_t)&uh->batch);\
72 	uh->next = 0;\
73 	uh->error_index = -1;\
74 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->error_rule);\
75 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->conflict_rule);
76 
77 typedef struct idmap_get_res {
78 	idmap_id_type	idtype;
79 	uid_t		*uid;
80 	gid_t		*gid;
81 	int		*is_user;
82 	char		**sidprefix;
83 	idmap_rid_t	*rid;
84 	idmap_stat	*stat;
85 	idmap_info	*info;
86 } idmap_get_res_t;
87 
88 struct idmap_get_handle {
89 	struct idmap_handle	*ih;
90 	idmap_mapping_batch	batch;
91 	idmap_get_res_t		*retlist;
92 	uint64_t		next;
93 };
94 
95 #define	_IDMAP_RESET_GET_HANDLE(gh) \
96 	(void) xdr_free(xdr_idmap_mapping_batch, (caddr_t)&gh->batch);\
97 	if (gh->retlist) \
98 		free(gh->retlist);\
99 	gh->retlist = NULL;\
100 	gh->next = 0;
101 
102 struct idmap_iter {
103 	struct idmap_handle	*ih;
104 	int			type;
105 	uint64_t		limit;
106 	void			*arg;
107 	idmap_retcode		retcode;
108 	uint64_t		lastrowid;
109 	uint64_t		next;
110 	void			*retlist;
111 };
112 
113 typedef struct stat_table {
114 	idmap_retcode	retcode;
115 	const char	*msg;
116 	int		errnum;
117 } stat_table_t;
118 
119 typedef idmap_retcode	_idmap_stat;
120 
121 extern idmap_retcode	_udt_extend_batch(idmap_udt_handle_t *);
122 extern idmap_retcode	_get_ids_extend_batch(idmap_get_handle_t *);
123 extern idmap_stat	_iter_get_next_list(int, idmap_iter_t *, void *,
124 				uchar_t **, size_t, xdrproc_t, xdrproc_t);
125 extern idmap_stat	_idmap_rpc2stat(CLIENT *);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* _IDMAP_IMPL_H */
132