xref: /titanic_44/usr/src/lib/libidmap/common/idmap_impl.h (revision ac88567a7a5bb7f01cf22cf366bc9d6203e24d7a)
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 /*
26  * Private Header for Identity Mapping
27  */
28 
29 #ifndef _IDMAP_IMPL_H
30 #define	_IDMAP_IMPL_H
31 
32 
33 #include <rpc/xdr.h>
34 #include <libscf.h>
35 #include <resolv.h>
36 
37 #include <rpcsvc/idmap_prot.h>
38 #include "idmap_priv.h"
39 
40 
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #define	_IDMAP_HANDLE_RPC_DOORS		1
47 
48 #define	_IDMAP_GET_CLIENT_HANDLE(h, clnt) \
49 		if (h == NULL) \
50 			return (IDMAP_ERR_CLIENT_HANDLE);\
51 		if (h->type != _IDMAP_HANDLE_RPC_DOORS) \
52 			return (IDMAP_ERR_NOTSUPPORTED);\
53 		clnt = (CLIENT *)h->privhandle;\
54 		if (clnt == NULL)\
55 			return (IDMAP_ERR_RPC_HANDLE);
56 
57 struct idmap_handle {
58 	int	type;
59 	void	*privhandle;
60 	/* locks */
61 };
62 
63 struct idmap_udt_handle {
64 	struct idmap_handle	*ih;
65 	idmap_update_batch	batch;
66 	uint64_t		next;
67 	int64_t			error_index;
68 	idmap_stat		commit_stat;
69 	idmap_namerule		error_rule;
70 	idmap_namerule		conflict_rule;
71 };
72 
73 #define	_IDMAP_RESET_UDT_HANDLE(uh) \
74 	(void) xdr_free(xdr_idmap_update_batch, (caddr_t)&uh->batch);\
75 	uh->next = 0;\
76 	uh->error_index = -1;\
77 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->error_rule);\
78 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->conflict_rule);
79 
80 typedef struct idmap_get_res {
81 	idmap_id_type	idtype;
82 	uid_t		*uid;
83 	gid_t		*gid;
84 	int		*is_user;
85 	char		**sidprefix;
86 	idmap_rid_t	*rid;
87 	idmap_stat	*stat;
88 	idmap_info	*info;
89 	int		cache_res;
90 } idmap_get_res_t;
91 
92 struct idmap_get_handle {
93 	struct idmap_handle	*ih;
94 	idmap_mapping_batch	batch;
95 	idmap_get_res_t		*retlist;
96 	uint64_t		next;
97 };
98 
99 #define	_IDMAP_RESET_GET_HANDLE(gh) \
100 	(void) xdr_free(xdr_idmap_mapping_batch, (caddr_t)&gh->batch);\
101 	if (gh->retlist) \
102 		free(gh->retlist);\
103 	gh->retlist = NULL;\
104 	gh->next = 0;
105 
106 struct idmap_iter {
107 	struct idmap_handle	*ih;
108 	int			type;
109 	uint64_t		limit;
110 	void			*arg;
111 	idmap_retcode		retcode;
112 	uint64_t		lastrowid;
113 	uint64_t		next;
114 	void			*retlist;
115 };
116 
117 typedef struct stat_table {
118 	idmap_retcode	retcode;
119 	const char	*msg;
120 	int		errnum;
121 } stat_table_t;
122 
123 typedef idmap_retcode	_idmap_stat;
124 
125 extern idmap_retcode	_udt_extend_batch(idmap_udt_handle_t *);
126 extern idmap_retcode	_get_ids_extend_batch(idmap_get_handle_t *);
127 extern idmap_stat	_iter_get_next_list(int, idmap_iter_t *, void *,
128 				uchar_t **, size_t, xdrproc_t, xdrproc_t);
129 extern idmap_stat	_idmap_rpc2stat(CLIENT *);
130 
131 extern idmap_logger_t logger;
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* _IDMAP_IMPL_H */
138