1 /* op.c - relay backend operations */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2003-2004 The OpenLDAP Foundation.
5 * Portions Copyright 2004 Pierangelo Masarati.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
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>.
17 * This work was initially developed by Pierangelo Masarati for inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/socket.h>
29 #include "back-relay.h"
32 relay_back_op_bind( struct slap_op *op, struct slap_rep *rs )
34 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
37 if ( ri->ri_bd->be_bind ) {
38 BackendDB *be = op->o_bd;
41 rc = ( ri->ri_bd->be_bind )( op, rs );
49 relay_back_op_unbind( struct slap_op *op, struct slap_rep *rs )
51 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
54 if ( ri->ri_bd->be_unbind ) {
55 BackendDB *be = op->o_bd;
58 rc = ( ri->ri_bd->be_unbind )( op, rs );
67 relay_back_op_search( struct slap_op *op, struct slap_rep *rs )
69 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
72 if ( ri->ri_bd->be_search ) {
73 BackendDB *be = op->o_bd;
76 rc = ( ri->ri_bd->be_search )( op, rs );
85 relay_back_op_compare( struct slap_op *op, struct slap_rep *rs )
87 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
90 if ( ri->ri_bd->be_compare ) {
91 BackendDB *be = op->o_bd;
94 rc = ( ri->ri_bd->be_compare )( op, rs );
103 relay_back_op_modify( struct slap_op *op, struct slap_rep *rs )
105 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
108 if ( ri->ri_bd->be_modify ) {
109 BackendDB *be = op->o_bd;
111 op->o_bd = ri->ri_bd;
112 rc = ( ri->ri_bd->be_modify )( op, rs );
121 relay_back_op_modrdn( struct slap_op *op, struct slap_rep *rs )
123 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
126 if ( ri->ri_bd->be_modrdn ) {
127 BackendDB *be = op->o_bd;
129 op->o_bd = ri->ri_bd;
130 rc = ( ri->ri_bd->be_modrdn )( op, rs );
139 relay_back_op_add( struct slap_op *op, struct slap_rep *rs )
141 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
144 if ( ri->ri_bd->be_add ) {
145 BackendDB *be = op->o_bd;
147 op->o_bd = ri->ri_bd;
148 rc = ( ri->ri_bd->be_add )( op, rs );
157 relay_back_op_delete( struct slap_op *op, struct slap_rep *rs )
159 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
162 if ( ri->ri_bd->be_delete ) {
163 BackendDB *be = op->o_bd;
165 op->o_bd = ri->ri_bd;
166 rc = ( ri->ri_bd->be_delete )( op, rs );
175 relay_back_op_abandon( struct slap_op *op, struct slap_rep *rs )
177 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
180 if ( ri->ri_bd->be_abandon ) {
181 BackendDB *be = op->o_bd;
183 op->o_bd = ri->ri_bd;
184 rc = ( ri->ri_bd->be_abandon )( op, rs );
193 relay_back_op_cancel( struct slap_op *op, struct slap_rep *rs )
195 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
198 if ( ri->ri_bd->be_cancel ) {
199 BackendDB *be = op->o_bd;
201 op->o_bd = ri->ri_bd;
202 rc = ( ri->ri_bd->be_cancel )( op, rs );
211 relay_back_op_extended( struct slap_op *op, struct slap_rep *rs )
213 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
216 if ( ri->ri_bd->be_extended ) {
217 BackendDB *be = op->o_bd;
219 op->o_bd = ri->ri_bd;
220 rc = ( ri->ri_bd->be_extended )( op, rs );
229 relay_back_entry_release_rw( struct slap_op *op, Entry *e, int rw )
231 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
234 if ( ri->ri_bd->be_release ) {
235 BackendDB *be = op->o_bd;
237 op->o_bd = ri->ri_bd;
238 rc = ( ri->ri_bd->be_release )( op, e, rw );
247 relay_back_entry_get_rw( struct slap_op *op, struct berval *ndn,
248 ObjectClass *oc, AttributeDescription *at, int rw, Entry **e )
250 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
253 if ( ri->ri_bd->be_fetch ) {
254 BackendDB *be = op->o_bd;
256 op->o_bd = ri->ri_bd;
257 rc = ( ri->ri_bd->be_fetch )( op, ndn, oc, at, rw, e );
265 int relay_back_chk_referrals( struct slap_op *op, struct slap_rep *rs )
267 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
270 if ( ri->ri_bd->be_chk_referrals ) {
271 BackendDB *be = op->o_bd;
273 op->o_bd = ri->ri_bd;
274 rc = ( ri->ri_bd->be_chk_referrals )( op, rs );
282 int relay_back_operational( struct slap_op *op, struct slap_rep *rs, int opattrs, Attribute **ap )
284 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
287 if ( ri->ri_bd->be_operational ) {
288 BackendDB *be = op->o_bd;
290 op->o_bd = ri->ri_bd;
291 rc = ( ri->ri_bd->be_operational )( op, rs, opattrs, ap );
299 int relay_back_has_subordinates( struct slap_op *op, Entry *e, int *hasSubs )
301 relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
304 if ( ri->ri_bd->be_has_subordinates ) {
305 BackendDB *be = op->o_bd;
307 op->o_bd = ri->ri_bd;
308 rc = ( ri->ri_bd->be_has_subordinates )( op, e, hasSubs );
317 relay_back_connection_init( BackendDB *bd, struct slap_conn *c )
319 relay_back_info *ri = (relay_back_info *)bd->be_private;
321 if ( ri->ri_bd->be_connection_init ) {
322 return ( ri->ri_bd->be_connection_init )( ri->ri_bd, c );
330 relay_back_connection_destroy( BackendDB *bd, struct slap_conn *c )
332 relay_back_info *ri = (relay_back_info *)bd->be_private;
334 if ( ri->ri_bd->be_connection_destroy ) {
335 return ( ri->ri_bd->be_connection_destroy )( ri->ri_bd, c );