xref: /titanic_44/usr/src/lib/libidmap/common/idmap_impl.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
1c5c4113dSnw141292 /*
2c5c4113dSnw141292  * CDDL HEADER START
3c5c4113dSnw141292  *
4c5c4113dSnw141292  * The contents of this file are subject to the terms of the
5c5c4113dSnw141292  * Common Development and Distribution License (the "License").
6c5c4113dSnw141292  * You may not use this file except in compliance with the License.
7c5c4113dSnw141292  *
8c5c4113dSnw141292  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c5c4113dSnw141292  * or http://www.opensolaris.org/os/licensing.
10c5c4113dSnw141292  * See the License for the specific language governing permissions
11c5c4113dSnw141292  * and limitations under the License.
12c5c4113dSnw141292  *
13c5c4113dSnw141292  * When distributing Covered Code, include this CDDL HEADER in each
14c5c4113dSnw141292  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c5c4113dSnw141292  * If applicable, add the following below this CDDL HEADER, with the
16c5c4113dSnw141292  * fields enclosed by brackets "[]" replaced with your own identifying
17c5c4113dSnw141292  * information: Portions Copyright [yyyy] [name of copyright owner]
18c5c4113dSnw141292  *
19c5c4113dSnw141292  * CDDL HEADER END
20c5c4113dSnw141292  */
21c5c4113dSnw141292 /*
22c5866007SKeyur Desai  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23c5c4113dSnw141292  */
24c5c4113dSnw141292 
25c5c4113dSnw141292 /*
26c5c4113dSnw141292  * Private Header for Identity Mapping
27c5c4113dSnw141292  */
28c5c4113dSnw141292 
29c5c4113dSnw141292 #ifndef _IDMAP_IMPL_H
30c5c4113dSnw141292 #define	_IDMAP_IMPL_H
31c5c4113dSnw141292 
32c5c4113dSnw141292 
33479ac375Sdm199847 #include <rpc/xdr.h>
34479ac375Sdm199847 #include <libscf.h>
35479ac375Sdm199847 #include <resolv.h>
36479ac375Sdm199847 
379b214d32SJordan Brown #include <rpcsvc/idmap_prot.h>
38c5c4113dSnw141292 #include "idmap_priv.h"
397a8a68f5SJulian Pullen 
40479ac375Sdm199847 
41c5c4113dSnw141292 
42c5c4113dSnw141292 #ifdef __cplusplus
43c5c4113dSnw141292 extern "C" {
44c5c4113dSnw141292 #endif
45c5c4113dSnw141292 
46c5c4113dSnw141292 struct idmap_udt_handle {
47c5c4113dSnw141292 	idmap_update_batch	batch;
48c5c4113dSnw141292 	uint64_t		next;
498e228215Sdm199847 	int64_t			error_index;
508e228215Sdm199847 	idmap_stat		commit_stat;
518e228215Sdm199847 	idmap_namerule		error_rule;
528e228215Sdm199847 	idmap_namerule		conflict_rule;
53c5c4113dSnw141292 };
54c5c4113dSnw141292 
55651c0131Sbaban #define	_IDMAP_RESET_UDT_HANDLE(uh) \
56651c0131Sbaban 	(void) xdr_free(xdr_idmap_update_batch, (caddr_t)&uh->batch);\
578e228215Sdm199847 	uh->next = 0;\
588e228215Sdm199847 	uh->error_index = -1;\
598e228215Sdm199847 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->error_rule);\
608e228215Sdm199847 	(void) xdr_free(xdr_idmap_namerule, (caddr_t)&uh->conflict_rule);
61651c0131Sbaban 
62c5c4113dSnw141292 typedef struct idmap_get_res {
63c5c4113dSnw141292 	idmap_id_type	idtype;
64c5c4113dSnw141292 	uid_t		*uid;
65c5c4113dSnw141292 	gid_t		*gid;
66c5c4113dSnw141292 	int		*is_user;
67c5c4113dSnw141292 	char		**sidprefix;
68c5c4113dSnw141292 	idmap_rid_t	*rid;
69c5c4113dSnw141292 	idmap_stat	*stat;
7048258c6bSjp151216 	idmap_info	*info;
713ee87bcaSJulian Pullen 	int		cache_res;
72c5c4113dSnw141292 } idmap_get_res_t;
73c5c4113dSnw141292 
74c5c4113dSnw141292 struct idmap_get_handle {
75c5c4113dSnw141292 	idmap_mapping_batch	batch;
76c5c4113dSnw141292 	idmap_get_res_t		*retlist;
77c5c4113dSnw141292 	uint64_t		next;
78c5c4113dSnw141292 };
79c5c4113dSnw141292 
80651c0131Sbaban #define	_IDMAP_RESET_GET_HANDLE(gh) \
81651c0131Sbaban 	(void) xdr_free(xdr_idmap_mapping_batch, (caddr_t)&gh->batch);\
82651c0131Sbaban 	if (gh->retlist) \
83651c0131Sbaban 		free(gh->retlist);\
84651c0131Sbaban 	gh->retlist = NULL;\
85651c0131Sbaban 	gh->next = 0;
86651c0131Sbaban 
87c5c4113dSnw141292 struct idmap_iter {
88c5c4113dSnw141292 	int			type;
89c5c4113dSnw141292 	uint64_t		limit;
90c5c4113dSnw141292 	void			*arg;
91c5c4113dSnw141292 	idmap_retcode		retcode;
92c5c4113dSnw141292 	uint64_t		lastrowid;
93c5c4113dSnw141292 	uint64_t		next;
94c5c4113dSnw141292 	void			*retlist;
95c5c4113dSnw141292 };
96c5c4113dSnw141292 
97c5c4113dSnw141292 typedef struct stat_table {
98c5c4113dSnw141292 	idmap_retcode	retcode;
99c5c4113dSnw141292 	const char	*msg;
100c5c4113dSnw141292 	int		errnum;
101c5c4113dSnw141292 } stat_table_t;
102c5c4113dSnw141292 
103c5c4113dSnw141292 typedef idmap_retcode	_idmap_stat;
104c5c4113dSnw141292 
105*1fdeec65Sjoyce mcintosh extern idmap_stat	_idmap_clnt_call(const rpcproc_t,
106*1fdeec65Sjoyce mcintosh 				const xdrproc_t, const caddr_t,
107*1fdeec65Sjoyce mcintosh 				const xdrproc_t, caddr_t out,
108*1fdeec65Sjoyce mcintosh 				const struct timeval);
109*1fdeec65Sjoyce mcintosh 
110651c0131Sbaban extern idmap_retcode	_udt_extend_batch(idmap_udt_handle_t *);
111c5c4113dSnw141292 extern idmap_retcode	_get_ids_extend_batch(idmap_get_handle_t *);
112c5c4113dSnw141292 extern idmap_stat	_iter_get_next_list(int, idmap_iter_t *, void *,
113c5c4113dSnw141292 				uchar_t **, size_t, xdrproc_t, xdrproc_t);
114c5c4113dSnw141292 
115c5866007SKeyur Desai extern idmap_logger_t logger;
116479ac375Sdm199847 
117c5c4113dSnw141292 #ifdef __cplusplus
118c5c4113dSnw141292 }
119c5c4113dSnw141292 #endif
120c5c4113dSnw141292 
121c5c4113dSnw141292 #endif /* _IDMAP_IMPL_H */
122