]> git.sur5r.net Git - openldap/blob - servers/slapd/back-meta/back-meta.h
Fix prev commit
[openldap] / servers / slapd / back-meta / back-meta.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1999-2004 The OpenLDAP Foundation.
5  * Portions Copyright 2001-2003 Pierangelo Masarati.
6  * Portions Copyright 1999-2003 Howard Chu.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in the file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was initially developed by the Howard Chu for inclusion
19  * in OpenLDAP Software and subsequently enhanced by Pierangelo
20  * Masarati.
21  */
22
23 #ifndef SLAPD_LDAP_H
24 #error "include servers/slapd/back-ldap/back-ldap.h before this file!"
25 #endif /* SLAPD_LDAP_H */
26
27 #ifndef SLAPD_META_H
28 #define SLAPD_META_H
29
30 #include "external.h"
31
32 /* String rewrite library */
33 #include "rewrite.h"
34 LDAP_BEGIN_DECL
35
36 struct slap_conn;
37 struct slap_op;
38
39 struct metasingleconn {
40         int                     candidate;
41 #define META_NOT_CANDIDATE      0
42 #define META_CANDIDATE          1
43 #define META_LAST_CONN          -1
44         
45         LDAP                    *ld;
46         struct berval           bound_dn;
47         struct berval           cred;
48         int                     bound;
49 #define META_UNBOUND            0
50 #define META_BOUND              1
51 #define META_ANONYMOUS          2
52 };
53
54 #define META_LAST(lsc)          ((lsc)->candidate == META_LAST_CONN)
55
56 struct metaconn {
57         struct slap_conn        *conn;
58         struct rewrite_info     *rwinfo;
59         
60         /*
61          * means that the connection is bound; 
62          * of course only one target actually is ...
63          */
64         int             bound_target;
65 #define META_BOUND_NONE         -1
66 #define META_BOUND_ALL          -2
67         /* supersedes the connection stuff */
68         struct metasingleconn *conns;
69 };
70
71 struct metatarget {
72         char                    *uri;
73         struct berval           psuffix;        /* pretty suffix */
74         struct berval           suffix;         /* normalized suffix */
75         struct berval           binddn;
76         struct berval           bindpw;
77
78         struct berval           pseudorootdn;
79         struct berval           pseudorootpw;
80
81 #if 0
82         struct rewrite_info     *rwinfo;
83
84         struct ldapmap          oc_map;
85         struct ldapmap          at_map;
86 #endif
87         struct ldaprwmap        rwmap;
88 };
89
90 struct metadncache {
91         ldap_pvt_thread_mutex_t mutex;
92         Avlnode                 *tree;
93
94 #define META_DNCACHE_DISABLED   0
95 #define META_DNCACHE_FOREVER    -1
96         long int                ttl;  /* seconds; 0: no cache, -1: no expiry */
97 };
98
99 struct metainfo {
100         int                     ntargets;
101         int                     defaulttarget;
102         int                     network_timeout;
103 #define META_DEFAULT_TARGET_NONE        -1
104         struct metatarget       **targets;
105
106         struct rewrite_info     *rwinfo;
107         Backend                 *glue_be; 
108
109         struct metadncache      cache;
110         
111         ldap_pvt_thread_mutex_t conn_mutex;
112         Avlnode                 *conntree;
113
114         int                     savecred;
115 };
116
117 #define META_OP_ALLOW_MULTIPLE          0x00
118 #define META_OP_REQUIRE_SINGLE          0x01
119 #define META_OP_REQUIRE_ALL             0x02
120 extern struct metaconn *
121 meta_back_getconn(
122                 Operation               *op,
123                 SlapReply               *rs,
124                 int                     op_type,
125                 struct berval           *dn,
126                 int                     *candidate
127 );
128
129 extern int
130 meta_back_dobind(
131                 struct metaconn         *lc,
132                 Operation               *op
133 );
134
135 extern int
136 meta_back_is_valid(
137                 struct metaconn         *lc, 
138                 int                     candidate 
139 );
140
141 extern int
142 meta_back_op_result(
143                 struct metaconn         *lc,
144                 Operation               *op,
145                 SlapReply               *rs
146 );
147
148 extern int
149 back_meta_LTX_init_module(
150                 int                     argc,
151                 char                    *argv[]
152 );
153
154 extern int
155 meta_back_conn_cmp(
156                 const void              *c1,
157                 const void              *c2
158 );
159
160 extern int
161 meta_back_conn_dup(
162                 void                    *c1,
163                 void                    *c2
164 );
165
166 /*
167  * Candidate stuff
168  */
169 extern int
170 meta_back_is_candidate(
171                 struct berval           *nsuffix,
172                 struct berval           *ndn
173 );
174
175 extern int
176 meta_back_count_candidates(
177                 struct metainfo         *li,
178                 struct berval           *ndn
179 );
180
181 extern int
182 meta_back_is_candidate_unique(
183                 struct metainfo         *li,
184                 struct berval           *ndn
185 );
186
187 extern int
188 meta_back_select_unique_candidate(
189                 struct metainfo         *li,
190                 struct berval           *ndn
191 );
192
193 extern int
194 meta_clear_unused_candidates(
195                 struct metainfo         *li,
196                 struct metaconn         *lc,
197                 int                     candidate,
198                 int                     reallyclean
199 );
200
201 extern int
202 meta_clear_one_candidate(
203                 struct metasingleconn   *lc,
204                 int                     reallyclean
205 );
206
207 /*
208  * Dn cache stuff (experimental)
209  */
210 extern int
211 meta_dncache_cmp(
212                 const void              *c1,
213                 const void              *c2
214 );
215
216 extern int
217 meta_dncache_dup(
218                 void                    *c1,
219                 void                    *c2
220 );
221
222 extern int
223 meta_dncache_get_target(
224                 struct metadncache      *cache,
225                 struct berval           *ndn
226 );
227
228 extern int
229 meta_dncache_update_entry(
230                 struct metadncache      *cache,
231                 struct berval           *ndn,
232                 int                     target
233 );
234
235 extern int
236 meta_dncache_delete_entry(
237                 struct metadncache      *cache,
238                 struct berval           *ndn
239 );
240
241 extern void
242 meta_dncache_free(
243                 void *entry
244 );
245
246 LDAP_END_DECL
247
248 #endif /* SLAPD_META_H */
249