xref: /titanic_44/usr/src/lib/libidmap/common/idmap_impl.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
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 struct idmap_udt_handle {
47 	idmap_update_batch	batch;
48 	uint64_t		next;
49 	int64_t			error_index;
50 	idmap_stat		commit_stat;
51 	idmap_namerule		error_rule;
52 	idmap_namerule		conflict_rule;
53 };
54 
55 #define	_IDMAP_RESET_UDT_HANDLE(uh) \
56 	(void) xdr_free(xdr_idmap_update_batch, (caddr_t)&uh->batch);\
57 	uh->next = 0;\
58 	uh->error_index = -1;\
59 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->error_rule);\
60 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->conflict_rule);
61 
62 typedef struct idmap_get_res {
63 	idmap_id_type	idtype;
64 	uid_t		*uid;
65 	gid_t		*gid;
66 	int		*is_user;
67 	char		**sidprefix;
68 	idmap_rid_t	*rid;
69 	idmap_stat	*stat;
70 	idmap_info	*info;
71 	int		cache_res;
72 } idmap_get_res_t;
73 
74 struct idmap_get_handle {
75 	idmap_mapping_batch	batch;
76 	idmap_get_res_t		*retlist;
77 	uint64_t		next;
78 };
79 
80 #define	_IDMAP_RESET_GET_HANDLE(gh) \
81 	(void) xdr_free(xdr_idmap_mapping_batch, (caddr_t)&gh->batch);\
82 	if (gh->retlist) \
83 		free(gh->retlist);\
84 	gh->retlist = NULL;\
85 	gh->next = 0;
86 
87 struct idmap_iter {
88 	int			type;
89 	uint64_t		limit;
90 	void			*arg;
91 	idmap_retcode		retcode;
92 	uint64_t		lastrowid;
93 	uint64_t		next;
94 	void			*retlist;
95 };
96 
97 typedef struct stat_table {
98 	idmap_retcode	retcode;
99 	const char	*msg;
100 	int		errnum;
101 } stat_table_t;
102 
103 typedef idmap_retcode	_idmap_stat;
104 
105 extern idmap_stat	_idmap_clnt_call(const rpcproc_t,
106 				const xdrproc_t, const caddr_t,
107 				const xdrproc_t, caddr_t out,
108 				const struct timeval);
109 
110 extern idmap_retcode	_udt_extend_batch(idmap_udt_handle_t *);
111 extern idmap_retcode	_get_ids_extend_batch(idmap_get_handle_t *);
112 extern idmap_stat	_iter_get_next_list(int, idmap_iter_t *, void *,
113 				uchar_t **, size_t, xdrproc_t, xdrproc_t);
114 
115 extern idmap_logger_t logger;
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif /* _IDMAP_IMPL_H */
122