]> git.sur5r.net Git - openldap/blob - servers/slapd/back-meta/back-meta.h
463fc5a7c138b55f4cc5fab58ecb9e4124a4e2ff
[openldap] / servers / slapd / back-meta / back-meta.h
1 /*
2  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  *
5  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
6  *
7  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
8  *
9  * This work has been developed to fulfill the requirements
10  * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated
11  * to the OpenLDAP Foundation in the hope that it may be useful
12  * to the Open Source community, but WITHOUT ANY WARRANTY.
13  *
14  * Permission is granted to anyone to use this software for any purpose
15  * on any computer system, and to alter it and redistribute it, subject
16  * to the following restrictions:
17  *
18  * 1. The author and SysNet s.n.c. are not responsible for the consequences
19  *    of use of this software, no matter how awful, even if they arise from 
20  *    flaws in it.
21  *
22  * 2. The origin of this software must not be misrepresented, either by
23  *    explicit claim or by omission.  Since few users ever read sources,
24  *    credits should appear in the documentation.
25  *
26  * 3. Altered versions must be plainly marked as such, and must not be
27  *    misrepresented as being the original software.  Since few users
28  *    ever read sources, credits should appear in the documentation.
29  *    SysNet s.n.c. cannot be responsible for the consequences of the
30  *    alterations.
31  *                         
32  * 4. This notice may not be removed or altered.
33  *
34  *
35  * This software is based on the backend back-ldap, implemented
36  * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence
37  * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other
38  * contributors. The contribution of the original software to the present
39  * implementation is acknowledged in this copyright statement.
40  *
41  * A special acknowledgement goes to Howard for the overall architecture
42  * (and for borrowing large pieces of code), and to Mark, who implemented
43  * from scratch the attribute/objectclass mapping.
44  *
45  * The original copyright statement follows.
46  *
47  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
48  *
49  * Permission is granted to anyone to use this software for any purpose
50  * on any computer system, and to alter it and redistribute it, subject
51  * to the following restrictions:
52  *
53  * 1. The author is not responsible for the consequences of use of this
54  *    software, no matter how awful, even if they arise from flaws in it.
55  *
56  * 2. The origin of this software must not be misrepresented, either by
57  *    explicit claim or by omission.  Since few users ever read sources,
58  *    credits should appear in the documentation.
59  *
60  * 3. Altered versions must be plainly marked as such, and must not be
61  *    misrepresented as being the original software.  Since few users
62  *    ever read sources, credits should appear in the
63  *    documentation.
64  *
65  * 4. This notice may not be removed or altered.
66  *                
67  */ 
68
69 #ifndef SLAPD_LDAP_H
70 #error "include servers/slapd/back-ldap/back-ldap.h before this file!"
71 #endif /* SLAPD_LDAP_H */
72
73 #ifndef SLAPD_META_H
74 #define SLAPD_META_H
75
76 #include "external.h"
77
78 /* String rewrite library */
79 #include "rewrite.h"
80 #include "cache.h"
81 LDAP_BEGIN_DECL
82
83 struct slap_conn;
84 struct slap_op;
85
86 struct metasingleconn {
87         int                     candidate;
88 #define META_NOT_CANDIDATE      0
89 #define META_CANDIDATE          1
90 #define META_LAST_CONN          -1
91         
92         LDAP                    *ld;
93         struct berval           bound_dn;
94         struct berval           cred;
95         int                     bound;
96 #define META_UNBOUND            0
97 #define META_BOUND              1
98 #define META_ANONYMOUS          2
99 };
100
101 #define META_LAST(lsc)          ((lsc)->candidate == META_LAST_CONN)
102
103 struct metaconn {
104         struct slap_conn        *conn;
105         struct rewrite_info     *rwinfo;
106         
107         /*
108          * means that the connection is bound; 
109          * of course only one target actually is ...
110          */
111         int             bound_target;
112 #define META_BOUND_NONE         -1
113 #define META_BOUND_ALL          -2
114         /* supersedes the connection stuff */
115         struct metasingleconn *conns;
116 };
117
118 struct metatarget {
119         char                    *uri;
120         struct berval           psuffix;        /* pretty suffix */
121         struct berval           suffix;         /* normalized suffix */
122         struct berval           binddn;
123         struct berval           bindpw;
124
125         struct berval           pseudorootdn;
126         struct berval           pseudorootpw;
127
128 #if 0
129         struct rewrite_info     *rwinfo;
130
131         struct ldapmap          oc_map;
132         struct ldapmap          at_map;
133 #endif
134         struct ldaprwmap        rwmap;
135 };
136
137 struct metadncache {
138         ldap_pvt_thread_mutex_t mutex;
139         Avlnode                 *tree;
140
141 #define META_DNCACHE_DISABLED   0
142 #define META_DNCACHE_FOREVER    -1
143         long int                ttl;  /* seconds; 0: no cache, -1: no expiry */
144 };
145
146 struct metainfo {
147         int                     ntargets;
148         int                     defaulttarget;
149 #define META_DEFAULT_TARGET_NONE        -1
150         struct metatarget       **targets;
151
152 #ifdef LDAP_CACHING 
153         struct rewrite_info     *rwinfo;
154         cache_manager           *cm; 
155         Backend                 *glue_be; 
156 #endif /* LDAP_CACHING */
157
158         struct metadncache      cache;
159         
160         ldap_pvt_thread_mutex_t conn_mutex;
161         Avlnode                 *conntree;
162
163         int                     savecred;
164 };
165
166 #define META_OP_ALLOW_MULTIPLE          0x00
167 #define META_OP_REQUIRE_SINGLE          0x01
168 #define META_OP_REQUIRE_ALL             0x02
169 extern struct metaconn *
170 meta_back_getconn(
171                 Operation               *op,
172                 SlapReply               *rs,
173                 int                     op_type,
174                 struct berval           *dn,
175                 int                     *candidate
176 );
177
178 extern int
179 meta_back_dobind(
180                 struct metaconn         *lc,
181                 Operation               *op
182 );
183
184 extern int
185 meta_back_is_valid(
186                 struct metaconn         *lc, 
187                 int                     candidate 
188 );
189
190 extern int
191 meta_back_op_result(
192                 struct metaconn         *lc,
193                 Operation               *op,
194                 SlapReply               *rs
195 );
196
197 extern int
198 back_meta_LTX_init_module(
199                 int                     argc,
200                 char                    *argv[]
201 );
202
203 extern int
204 meta_back_conn_cmp(
205                 const void              *c1,
206                 const void              *c2
207 );
208
209 extern int
210 meta_back_conn_dup(
211                 void                    *c1,
212                 void                    *c2
213 );
214
215 /*
216  * Candidate stuff
217  */
218 extern int
219 meta_back_is_candidate(
220                 struct berval           *nsuffix,
221                 struct berval           *ndn
222 );
223
224 extern int
225 meta_back_count_candidates(
226                 struct metainfo         *li,
227                 struct berval           *ndn
228 );
229
230 extern int
231 meta_back_is_candidate_unique(
232                 struct metainfo         *li,
233                 struct berval           *ndn
234 );
235
236 extern int
237 meta_back_select_unique_candidate(
238                 struct metainfo         *li,
239                 struct berval           *ndn
240 );
241
242 extern int
243 meta_clear_unused_candidates(
244                 struct metainfo         *li,
245                 struct metaconn         *lc,
246                 int                     candidate,
247                 int                     reallyclean
248 );
249
250 extern int
251 meta_clear_one_candidate(
252                 struct metasingleconn   *lc,
253                 int                     reallyclean
254 );
255
256 /*
257  * Dn cache stuff (experimental)
258  */
259 extern int
260 meta_dncache_cmp(
261                 const void              *c1,
262                 const void              *c2
263 );
264
265 extern int
266 meta_dncache_dup(
267                 void                    *c1,
268                 void                    *c2
269 );
270
271 extern int
272 meta_dncache_get_target(
273                 struct metadncache      *cache,
274                 struct berval           *ndn
275 );
276
277 extern int
278 meta_dncache_update_entry(
279                 struct metadncache      *cache,
280                 struct berval           *ndn,
281                 int                     target
282 );
283
284 extern int
285 meta_dncache_delete_entry(
286                 struct metadncache      *cache,
287                 struct berval           *ndn
288 );
289
290 extern void
291 meta_dncache_free(
292                 void *entry
293 );
294
295 LDAP_END_DECL
296
297 #endif /* SLAPD_META_H */
298