xref: /titanic_41/usr/src/lib/libnisdb/nisdb_ldap.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #ifndef	_NISDB_LDAP_H
30 #define	_NISDB_LDAP_H
31 
32 #include <sys/time.h>
33 #include <thread.h>
34 #include <synch.h>
35 #include <pthread.h>
36 #include <rpcsvc/nis.h>
37 
38 #include "ldap_parse.h"
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /* Types supporting rpc.nisd configuration attributes */
45 
46 /* nisplusLDAPinitialUpdate */
47 typedef enum {
48 	ini_none,
49 	from_ldap,
50 	from_ldap_update_only,
51 	to_ldap,
52 	to_ldap_update_only
53 } __nis_initial_update_t;
54 
55 /* nisplusLDAPretrieveError */
56 typedef enum {
57 	use_cached,
58 	ret_retry,
59 	try_again,
60 	ret_unavail,
61 	no_such_name,
62 	fail
63 } __nis_retrieve_error_t;
64 
65 /* nisplusLDAPstoreError */
66 typedef enum {
67 	sto_retry,
68 	system_error,
69 	sto_unavail,
70 	sto_fail
71 } __nis_store_error_t;
72 
73 /* nisplusLDAPstoreErrorDisp */
74 typedef enum {
75 	std_delete_entry,
76 	abandon
77 } __nis_store_error_disp_t;
78 
79 /* nisplusLDAPrefreshError */
80 typedef enum {
81 	continue_using,
82 	ref_retry,
83 	continue_using_retry,
84 	cache_expired,
85 	tryagain
86 } __nis_refresh_error_t;
87 
88 /* nisplusLDAPthreadCreationError */
89 typedef enum {
90 	pass_error,
91 	cre_retry
92 } __nis_thread_creation_error_t;
93 
94 /* nisplusLDAPdumpError */
95 typedef enum {
96 	de_retry,
97 	rollback,
98 	rollback_retry
99 } __nis_dump_error_t;
100 
101 /* nisplusLDAPresyncService */
102 typedef enum {
103 	from_copy,
104 	directory_locked,
105 	from_live
106 } __nis_resync_service_t;
107 
108 /* nisplusLDAPupdateBatching */
109 typedef enum {
110 	accumulate,
111 	bounded_accumulate,
112 	upd_none
113 } __nis_update_batching_t;
114 
115 /* nisplusLDAPexclusiveWaitMode */
116 typedef enum {
117 	block,
118 	ewm_tryagain
119 } __nis_exclusive_wait_mode_t;
120 
121 /* nisplusLDAPmatchFetch */
122 typedef enum {
123 	no_match_only,
124 	mat_always,
125 	mat_never
126 } __nis_match_fetch_t;
127 
128 /* Keep track of desired number of attempts and timeout */
129 typedef struct {
130 	int		attempts;
131 	time_t		timeout;
132 } __nisdb_retry_t;
133 
134 /* Table mapping (and related) information */
135 typedef struct {
136 	time_t			initTtlLo;	/* Initial lo TTL for table */
137 	time_t			initTtlHi;	/* Initial hi TTL for table */
138 	time_t			ttl;		/* TTL for table entries */
139 	time_t			*expire;	/* Expire times for entries */
140 	time_t			enumExpire;	/* Enumeration expiration */
141 	bool_t			fromLDAP;	/* Get data from LDAP ? */
142 	bool_t			toLDAP;		/* Write data to LDAP ? */
143 	bool_t			isMaster;	/* Are we master for this ? */
144 	__nis_retrieve_error_t	retrieveError;
145 	__nisdb_retry_t		retrieveErrorRetry;
146 	__nis_store_error_t	storeError;
147 	__nisdb_retry_t		storeErrorRetry;
148 	__nis_store_error_disp_t
149 				storeErrorDisp;
150 	__nis_refresh_error_t	refreshError;
151 	__nisdb_retry_t		refreshErrorRetry;
152 	__nis_match_fetch_t	matchFetch;
153 	__nis_table_mapping_t	*tm;
154 	zotypes			objType;
155 	zotypes			expireType;
156 	char			*objName;
157 	bool_t			isDeferredTable;
158 	mutex_t			enumLock;
159 	pthread_t		enumTid;
160 	int			enumStat;
161 	int			enumDeferred;
162 	uint_t			enumEntries;
163 	ulong_t			enumTime;	/* Microseconds */
164 } __nisdb_table_mapping_t;
165 
166 /*
167  * Configuration data used by the rpc.nisd proper, but not in libnisdb.
168  */
169 typedef struct {
170 	__nis_initial_update_t		initialUpdate;
171 	__nis_thread_creation_error_t	threadCreationError;
172 	__nisdb_retry_t			threadCreationErrorTimeout;
173 	__nis_dump_error_t		dumpError;
174 	__nisdb_retry_t			dumpErrorTimeout;
175 	__nis_resync_service_t		resyncService;
176 	__nis_update_batching_t		updateBatching;
177 	__nisdb_retry_t			updateBatchingTimeout;
178 	__nis_exclusive_wait_mode_t	exclusiveWaitMode;
179 	int				numberOfServiceThreads;
180 	int				emulate_yp;
181 	int				maxRPCRecordSize;
182 } __nis_config_t;
183 
184 extern __nisdb_table_mapping_t	ldapDBTableMapping;
185 extern __nis_config_t		ldapConfig;
186 
187 #ifdef	__cplusplus
188 }
189 #endif	/* __cplusplus */
190 
191 #endif	/* _NISDB_LDAP_H */
192