]> git.sur5r.net Git - openldap/blob - servers/slapd/back-relay/op.c
add back-relay (doesn't work yet)
[openldap] / servers / slapd / back-relay / op.c
1 /* op.c - relay backend operations */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2003-2004 The OpenLDAP Foundation.
5  * Portions Copyright 2004 Pierangelo Masarati.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by Pierangelo Masarati for inclusion
18  * in OpenLDAP Software.
19  */
20
21 #include "portable.h"
22
23 #include <stdio.h>
24
25 #include <ac/string.h>
26 #include <ac/socket.h>
27
28 #include "slap.h"
29 #include "back-relay.h"
30
31 int
32 relay_back_op_bind( struct slap_op *op, struct slap_rep *rs )
33 {
34         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
35         int                     rc = 1;
36
37         if ( ri->ri_bd->be_bind ) {
38                 BackendDB       *be = op->o_bd;
39
40                 op->o_bd = ri->ri_bd;
41                 rc = ( ri->ri_bd->be_bind )( op, rs );
42                 op->o_bd = be;
43         }
44
45         return rc;
46 }
47
48 int
49 relay_back_op_unbind( struct slap_op *op, struct slap_rep *rs )
50 {
51         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
52         int                     rc = 1;
53
54         if ( ri->ri_bd->be_unbind ) {
55                 BackendDB       *be = op->o_bd;
56
57                 op->o_bd = ri->ri_bd;
58                 rc = ( ri->ri_bd->be_unbind )( op, rs );
59                 op->o_bd = be;
60         }
61
62         return rc;
63
64 }
65
66 int
67 relay_back_op_search( struct slap_op *op, struct slap_rep *rs )
68 {
69         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
70         int                     rc = 1;
71
72         if ( ri->ri_bd->be_search ) {
73                 BackendDB       *be = op->o_bd;
74
75                 op->o_bd = ri->ri_bd;
76                 rc = ( ri->ri_bd->be_search )( op, rs );
77                 op->o_bd = be;
78         }
79
80         return rc;
81
82 }
83
84 int
85 relay_back_op_compare( struct slap_op *op, struct slap_rep *rs )
86 {
87         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
88         int                     rc = 1;
89
90         if ( ri->ri_bd->be_compare ) {
91                 BackendDB       *be = op->o_bd;
92
93                 op->o_bd = ri->ri_bd;
94                 rc = ( ri->ri_bd->be_compare )( op, rs );
95                 op->o_bd = be;
96         }
97
98         return rc;
99
100 }
101
102 int
103 relay_back_op_modify( struct slap_op *op, struct slap_rep *rs )
104 {
105         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
106         int                     rc = 1;
107
108         if ( ri->ri_bd->be_modify ) {
109                 BackendDB       *be = op->o_bd;
110
111                 op->o_bd = ri->ri_bd;
112                 rc = ( ri->ri_bd->be_modify )( op, rs );
113                 op->o_bd = be;
114         }
115
116         return rc;
117
118 }
119
120 int
121 relay_back_op_modrdn( struct slap_op *op, struct slap_rep *rs )
122 {
123         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
124         int                     rc = 1;
125
126         if ( ri->ri_bd->be_modrdn ) {
127                 BackendDB       *be = op->o_bd;
128
129                 op->o_bd = ri->ri_bd;
130                 rc = ( ri->ri_bd->be_modrdn )( op, rs );
131                 op->o_bd = be;
132         }
133
134         return rc;
135
136 }
137
138 int
139 relay_back_op_add( struct slap_op *op, struct slap_rep *rs )
140 {
141         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
142         int                     rc = 1;
143
144         if ( ri->ri_bd->be_add ) {
145                 BackendDB       *be = op->o_bd;
146
147                 op->o_bd = ri->ri_bd;
148                 rc = ( ri->ri_bd->be_add )( op, rs );
149                 op->o_bd = be;
150         }
151
152         return rc;
153
154 }
155
156 int
157 relay_back_op_delete( struct slap_op *op, struct slap_rep *rs )
158 {
159         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
160         int                     rc = 1;
161
162         if ( ri->ri_bd->be_delete ) {
163                 BackendDB       *be = op->o_bd;
164
165                 op->o_bd = ri->ri_bd;
166                 rc = ( ri->ri_bd->be_delete )( op, rs );
167                 op->o_bd = be;
168         }
169
170         return rc;
171
172 }
173
174 int
175 relay_back_op_abandon( struct slap_op *op, struct slap_rep *rs )
176 {
177         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
178         int                     rc = 1;
179
180         if ( ri->ri_bd->be_abandon ) {
181                 BackendDB       *be = op->o_bd;
182
183                 op->o_bd = ri->ri_bd;
184                 rc = ( ri->ri_bd->be_abandon )( op, rs );
185                 op->o_bd = be;
186         }
187
188         return rc;
189
190 }
191
192 int
193 relay_back_op_cancel( struct slap_op *op, struct slap_rep *rs )
194 {
195         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
196         int                     rc = 1;
197
198         if ( ri->ri_bd->be_cancel ) {
199                 BackendDB       *be = op->o_bd;
200
201                 op->o_bd = ri->ri_bd;
202                 rc = ( ri->ri_bd->be_cancel )( op, rs );
203                 op->o_bd = be;
204         }
205
206         return rc;
207
208 }
209
210 int
211 relay_back_op_extended( struct slap_op *op, struct slap_rep *rs )
212 {
213         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
214         int                     rc = 1;
215
216         if ( ri->ri_bd->be_extended ) {
217                 BackendDB       *be = op->o_bd;
218
219                 op->o_bd = ri->ri_bd;
220                 rc = ( ri->ri_bd->be_extended )( op, rs );
221                 op->o_bd = be;
222         }
223
224         return rc;
225
226 }
227
228 int
229 relay_back_entry_release_rw( struct slap_op *op, Entry *e, int rw )
230 {
231         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
232         int                     rc = 1;
233
234         if ( ri->ri_bd->be_release ) {
235                 BackendDB       *be = op->o_bd;
236
237                 op->o_bd = ri->ri_bd;
238                 rc = ( ri->ri_bd->be_release )( op, e, rw );
239                 op->o_bd = be;
240         }
241
242         return rc;
243
244 }
245
246 int
247 relay_back_entry_get_rw( struct slap_op *op, struct berval *ndn,
248         ObjectClass *oc, AttributeDescription *at, int rw, Entry **e )
249 {
250         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
251         int                     rc = 1;
252
253         if ( ri->ri_bd->be_fetch ) {
254                 BackendDB       *be = op->o_bd;
255
256                 op->o_bd = ri->ri_bd;
257                 rc = ( ri->ri_bd->be_fetch )( op, ndn, oc, at, rw, e );
258                 op->o_bd = be;
259         }
260
261         return rc;
262
263 }
264
265 int relay_back_chk_referrals( struct slap_op *op, struct slap_rep *rs )
266 {
267         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
268         int                     rc = 1;
269
270         if ( ri->ri_bd->be_chk_referrals ) {
271                 BackendDB       *be = op->o_bd;
272
273                 op->o_bd = ri->ri_bd;
274                 rc = ( ri->ri_bd->be_chk_referrals )( op, rs );
275                 op->o_bd = be;
276         }
277
278         return rc;
279
280 }
281
282 int relay_back_operational( struct slap_op *op, struct slap_rep *rs, int opattrs, Attribute **ap )
283 {
284         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
285         int                     rc = 1;
286
287         if ( ri->ri_bd->be_operational ) {
288                 BackendDB       *be = op->o_bd;
289
290                 op->o_bd = ri->ri_bd;
291                 rc = ( ri->ri_bd->be_operational )( op, rs, opattrs, ap );
292                 op->o_bd = be;
293         }
294
295         return rc;
296
297 }
298
299 int relay_back_has_subordinates( struct slap_op *op, Entry *e, int *hasSubs )
300 {
301         relay_back_info         *ri = (relay_back_info *)op->o_bd->be_private;
302         int                     rc = 1;
303
304         if ( ri->ri_bd->be_has_subordinates ) {
305                 BackendDB       *be = op->o_bd;
306
307                 op->o_bd = ri->ri_bd;
308                 rc = ( ri->ri_bd->be_has_subordinates )( op, e, hasSubs );
309                 op->o_bd = be;
310         }
311
312         return rc;
313
314 }
315
316 int
317 relay_back_connection_init( BackendDB *bd, struct slap_conn *c )
318 {
319         relay_back_info         *ri = (relay_back_info *)bd->be_private;
320
321         if ( ri->ri_bd->be_connection_init ) {
322                 return ( ri->ri_bd->be_connection_init )( ri->ri_bd, c );
323         }
324
325         return 1;
326
327 }
328
329 int
330 relay_back_connection_destroy( BackendDB *bd, struct slap_conn *c )
331 {
332         relay_back_info         *ri = (relay_back_info *)bd->be_private;
333
334         if ( ri->ri_bd->be_connection_destroy ) {
335                 return ( ri->ri_bd->be_connection_destroy )( ri->ri_bd, c );
336         }
337
338         return 1;
339
340 }
341