]> git.sur5r.net Git - openldap/blob - servers/slapd/back-meta/back-meta.h
use auth sockbuf max
[openldap] / servers / slapd / back-meta / back-meta.h
1 /*
2  * Copyright 1998-2002 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
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         int                     bound;
95 #define META_UNBOUND            0
96 #define META_BOUND              1
97 #define META_ANONYMOUS          2
98 };
99
100 #define META_LAST(lsc)          ((lsc)->candidate == META_LAST_CONN)
101
102 struct metaconn {
103         struct slap_conn        *conn;
104         struct rewrite_info     *rwinfo;
105         
106         /*
107          * means that the connection is bound; 
108          * of course only one target actually is ...
109          */
110         int             bound_target;
111 #define META_BOUND_NONE         -1
112 #define META_BOUND_ALL          -2
113         /* supersedes the connection stuff */
114         struct metasingleconn *conns;
115 };
116
117 struct metatarget {
118         char                    *uri;
119         struct berval           psuffix;        /* pretty suffix */
120         struct berval           suffix;         /* normalized suffix */
121         struct berval           binddn;
122         struct berval           bindpw;
123
124         struct berval           pseudorootdn;
125         struct berval           pseudorootpw;
126
127         struct rewrite_info     *rwinfo;
128
129         struct ldapmap          oc_map;
130         struct ldapmap          at_map;
131 };
132
133 struct metadncache {
134         ldap_pvt_thread_mutex_t mutex;
135         Avlnode                 *tree;
136
137 #define META_DNCACHE_DISABLED   0
138 #define META_DNCACHE_FOREVER    -1
139         long int                ttl;  /* seconds; 0: no cache, -1: no expiry */
140 };
141
142 struct metainfo {
143         int                     ntargets;
144         int                     defaulttarget;
145 #define META_DEFAULT_TARGET_NONE        -1
146         struct metatarget       **targets;
147
148         struct metadncache      cache;
149         
150         ldap_pvt_thread_mutex_t conn_mutex;
151         Avlnode                 *conntree;
152 };
153
154 #define META_OP_ALLOW_MULTIPLE          0x00
155 #define META_OP_REQUIRE_SINGLE          0x01
156 #define META_OP_REQUIRE_ALL             0x02
157 extern struct metaconn *
158 meta_back_getconn(
159                 struct                  metainfo *li,
160                 struct                  slap_conn *conn,
161                 struct                  slap_op *op,
162                 int                     op_type,
163                 struct berval           *dn,
164                 int                     *candidate
165 );
166
167 extern int
168 meta_back_dobind(
169                 struct metaconn         *lc,
170                 Operation               *op
171 );
172
173 extern int
174 meta_back_is_valid(
175                 struct metaconn         *lc, 
176                 int                     candidate 
177 );
178
179 extern int
180 meta_back_op_result(
181                 struct metaconn         *lc,
182                 Operation               *op
183 );
184
185 extern int
186 back_meta_LTX_init_module(
187                 int                     argc,
188                 char                    *argv[]
189 );
190
191 extern int
192 meta_back_conn_cmp(
193                 const void              *c1,
194                 const void              *c2
195 );
196
197 extern int
198 meta_back_conn_dup(
199                 void                    *c1,
200                 void                    *c2
201 );
202
203 /*
204  * Candidate stuff
205  */
206 extern int
207 meta_back_is_candidate(
208                 struct berval           *nsuffix,
209                 struct berval           *ndn
210 );
211
212 extern int
213 meta_back_count_candidates(
214                 struct metainfo         *li,
215                 struct berval           *ndn
216 );
217
218 extern int
219 meta_back_is_candidate_unique(
220                 struct metainfo         *li,
221                 struct berval           *ndn
222 );
223
224 extern int
225 meta_back_select_unique_candidate(
226                 struct metainfo         *li,
227                 struct berval           *ndn
228 );
229
230 extern int
231 meta_clear_unused_candidates(
232                 struct metainfo         *li,
233                 struct metaconn         *lc,
234                 int                     candidate,
235                 int                     reallyclean
236 );
237
238 extern int
239 meta_clear_one_candidate(
240                 struct metasingleconn   *lc,
241                 int                     reallyclean
242 );
243
244 /*
245  * Dn cache stuff (experimental)
246  */
247 extern int
248 meta_dncache_cmp(
249                 const void              *c1,
250                 const void              *c2
251 );
252
253 extern int
254 meta_dncache_dup(
255                 void                    *c1,
256                 void                    *c2
257 );
258
259 extern int
260 meta_dncache_get_target(
261                 struct metadncache      *cache,
262                 struct berval           *ndn
263 );
264
265 extern int
266 meta_dncache_update_entry(
267                 struct metadncache      *cache,
268                 struct berval           *ndn,
269                 int                     target
270 );
271
272 extern int
273 meta_dncache_delete_entry(
274                 struct metadncache      *cache,
275                 struct berval           *ndn
276 );
277
278 extern void
279 meta_dncache_free(
280                 void *entry
281 );
282
283 LDAP_END_DECL
284
285 #endif /* SLAPD_META_H */
286