summaryrefslogtreecommitdiff
path: root/usr/src/lib/libidmap/common/idmap_impl.h
blob: bcae8b6d8df3fab142acfc8980ec82e31e846f69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 */

/*
 * Private Header for Identity Mapping
 */

#ifndef _IDMAP_IMPL_H
#define	_IDMAP_IMPL_H


#include <rpc/xdr.h>
#include <libscf.h>
#include <resolv.h>

#include <rpcsvc/idmap_prot.h>
#include "idmap_priv.h"



#ifdef __cplusplus
extern "C" {
#endif

struct idmap_udt_handle {
	idmap_update_batch	batch;
	uint64_t		next;
	int64_t			error_index;
	idmap_stat		commit_stat;
	idmap_namerule		error_rule;
	idmap_namerule		conflict_rule;
};

#define	_IDMAP_RESET_UDT_HANDLE(uh) \
	xdr_free(xdr_idmap_update_batch, (caddr_t)&uh->batch);\
	uh->next = 0;\
	uh->error_index = -1;\
	xdr_free(xdr_idmap_namerule, (caddr_t)&uh->error_rule);\
	xdr_free(xdr_idmap_namerule, (caddr_t)&uh->conflict_rule);

typedef struct idmap_get_res {
	idmap_id_type	idtype;
	uid_t		*uid;
	gid_t		*gid;
	int		*is_user;
	char		**sidprefix;
	idmap_rid_t	*rid;
	idmap_stat	*stat;
	idmap_info	*info;
	int		cache_res;
} idmap_get_res_t;

struct idmap_get_handle {
	idmap_mapping_batch	batch;
	idmap_get_res_t		*retlist;
	uint64_t		next;
};

#define	_IDMAP_RESET_GET_HANDLE(gh) \
	xdr_free(xdr_idmap_mapping_batch, (caddr_t)&gh->batch);\
	if (gh->retlist) \
		free(gh->retlist);\
	gh->retlist = NULL;\
	gh->next = 0;

struct idmap_iter {
	int			type;
	uint64_t		limit;
	void			*arg;
	idmap_retcode		retcode;
	uint64_t		lastrowid;
	uint64_t		next;
	void			*retlist;
};

typedef struct stat_table {
	idmap_retcode	retcode;
	const char	*msg;
	int		errnum;
} stat_table_t;

typedef idmap_retcode	_idmap_stat;

extern idmap_stat	_idmap_clnt_call(const rpcproc_t,
				const xdrproc_t, const caddr_t,
				const xdrproc_t, caddr_t out,
				const struct timeval);

extern idmap_retcode	_udt_extend_batch(idmap_udt_handle_t *);
extern idmap_retcode	_get_ids_extend_batch(idmap_get_handle_t *);
extern idmap_stat	_iter_get_next_list(int, idmap_iter_t *, void *,
				uchar_t **, size_t, xdrproc_t, xdrproc_t);

extern idmap_logger_t logger;

#ifdef __cplusplus
}
#endif

#endif /* _IDMAP_IMPL_H */