Back to index

openldap  2.4.31
Classes | Defines | Typedefs | Functions | Variables
op.c File Reference
#include "portable.h"
#include <stdio.h>
#include "slap.h"
#include "back-relay.h"

Go to the source code of this file.

Classes

struct  relay_fail_modes_s
struct  relay_callback

Defines

#define RB_ERR_MASK   0x0000FFFFU /* bitmask for default return value */
#define RB_BDERR   0x80000000U /* use .rf_bd's default return value */
#define RB_OPERR   0x40000000U /* set rs->sr_err = .rf_op return value */
#define RB_REF   0x20000000U /* use default_referral if available */
#define RB_SEND   0x10000000U /* send result; RB_??ERR is also set */
#define RB_SENDREF   0/*unused*/ /* like RB_SEND when referral found */
#define RB_NO_BIND   (RB_OPERR | LDAP_INVALID_CREDENTIALS)
#define RB_NOT_SUPP   (RB_OPERR | LDAP_UNWILLING_TO_PERFORM)
#define RB_NO_OBJ   (RB_REF | LDAP_NO_SUCH_OBJECT)
#define RB_CHK_REF   (RB_REF | RB_SENDREF | LDAP_SUCCESS)
#define RB_OP(b, o)   { (b) | RB_BD2ERR(b), (o) | RB_BD2ERR(b) }
#define RB_BD2ERR(b)   ((b) ? RB_BDERR : 0)
#define relay_back_add_cb(rcb, op)
#define relay_back_remove_cb(rcb, op)
#define RELAY_WRAP_OP(op, bd, which, act)
#define RELAY_DEFOP(func, which)

Typedefs

typedef struct relay_callback relay_callback

Functions

static int relay_back_cleanup_cb (Operation *op, SlapReply *rs)
static int relay_back_response_cb (Operation *op, SlapReply *rs)
static BackendDBrelay_back_select_backend (Operation *op, SlapReply *rs, int which)
static int relay_back_op (Operation *op, SlapReply *rs, int which)
int relay_back_op_bind (Operation *op, SlapReply *rs)
int relay_back_entry_release_rw (Operation *op, Entry *e, int rw)
int relay_back_entry_get_rw (Operation *op, struct berval *ndn, ObjectClass *oc, AttributeDescription *at, int rw, Entry **e)
int relay_back_has_subordinates (Operation *op, Entry *e, int *hasSubs)

Variables

static struct relay_fail_modes_s relay_fail_modes [relay_op_last]

Class Documentation

struct relay_fail_modes_s

Definition at line 30 of file op.c.

Class Members
slap_mask_t rf_bd
slap_mask_t rf_op
struct relay_callback

Definition at line 73 of file op.c.

Collaboration diagram for relay_callback:
Class Members
BackendDB * rcb_bd
slap_callback rcb_sc

Define Documentation

#define RB_BD2ERR (   b)    ((b) ? RB_BDERR : 0)
#define RB_BDERR   0x80000000U /* use .rf_bd's default return value */

Definition at line 33 of file op.c.

Definition at line 41 of file op.c.

#define RB_ERR_MASK   0x0000FFFFU /* bitmask for default return value */

Definition at line 32 of file op.c.

Definition at line 38 of file op.c.

Definition at line 40 of file op.c.

Definition at line 39 of file op.c.

#define RB_OP (   b,
 
)    { (b) | RB_BD2ERR(b), (o) | RB_BD2ERR(b) }
#define RB_OPERR   0x40000000U /* set rs->sr_err = .rf_op return value */

Definition at line 34 of file op.c.

#define RB_REF   0x20000000U /* use default_referral if available */

Definition at line 35 of file op.c.

#define RB_SEND   0x10000000U /* send result; RB_??ERR is also set */

Definition at line 36 of file op.c.

#define RB_SENDREF   0/*unused*/ /* like RB_SEND when referral found */

Definition at line 37 of file op.c.

#define relay_back_add_cb (   rcb,
  op 
)
Value:
{                           \
              (rcb)->rcb_sc.sc_next = (op)->o_callback; \
              (rcb)->rcb_sc.sc_response = relay_back_response_cb; \
              (rcb)->rcb_sc.sc_cleanup = 0;                    \
              (rcb)->rcb_sc.sc_private = (op)->o_bd;           \
              (op)->o_callback = (slap_callback *) (rcb);      \
}

Definition at line 96 of file op.c.

#define relay_back_remove_cb (   rcb,
  op 
)
Value:
{                    \
		slap_callback      **sc = &(op)->o_callback;   \
              for ( ;; sc = &(*sc)->sc_next )                  \
                     if ( *sc == (slap_callback *) (rcb) ) {   \
                            *sc = (*sc)->sc_next; break;       \
                     } else if ( *sc == NULL ) break;   \
}

Definition at line 104 of file op.c.

#define RELAY_DEFOP (   func,
  which 
)
Value:
int func( Operation *op, SlapReply *rs ) \
       { return relay_back_op( op, rs, which ); }

Definition at line 246 of file op.c.

#define RELAY_WRAP_OP (   op,
  bd,
  which,
  act 
)
Value:
{ \
	OpExtraDB wrap_oex; \
	BackendDB *const wrap_bd = (op)->o_bd; \
       wrap_oex.oe_db = wrap_bd; \
       wrap_oex.oe.oe_key = (char *) wrap_bd->be_private + (which); \
       LDAP_SLIST_INSERT_HEAD( &(op)->o_extra, &wrap_oex.oe, oe_next ); \
       (op)->o_bd = (bd); \
       act; \
       (op)->o_bd = wrap_bd; \
       LDAP_SLIST_REMOVE( &(op)->o_extra, &wrap_oex.oe, OpExtra, oe_next ); \
}

Definition at line 176 of file op.c.


Typedef Documentation


Function Documentation

static int relay_back_cleanup_cb ( Operation op,
SlapReply rs 
) [static]

Definition at line 79 of file op.c.

{
       op->o_bd = ((relay_callback *) op->o_callback)->rcb_bd;
       return SLAP_CB_CONTINUE;
}

Here is the caller graph for this function:

int relay_back_entry_get_rw ( Operation op,
struct berval ndn,
ObjectClass oc,
AttributeDescription at,
int  rw,
Entry **  e 
)

Definition at line 284 of file op.c.

{
       BackendDB            *bd;
       int                  rc = LDAP_NO_SUCH_OBJECT;

       bd = relay_back_select_backend( op, NULL, relay_op_entry_get );
       if ( bd && bd->be_fetch ) {
              RELAY_WRAP_OP( op, bd, relay_op_entry_get, {
                     rc = bd->be_fetch( op, ndn, oc, at, rw, e );
              });
       }

       return rc;
}

Here is the call graph for this function:

int relay_back_entry_release_rw ( Operation op,
Entry e,
int  rw 
)

Definition at line 265 of file op.c.

{
       BackendDB            *bd;
       int                  rc = LDAP_UNWILLING_TO_PERFORM;

       bd = relay_back_select_backend( op, NULL, relay_op_entry_release );
       if ( bd && bd->be_release ) {
              RELAY_WRAP_OP( op, bd, relay_op_entry_release, {
                     rc = bd->be_release( op, e, rw );
              });
       } else if ( e->e_private == NULL ) {
              entry_free( e );
              rc = LDAP_SUCCESS;
       }

       return rc;
}

Here is the call graph for this function:

int relay_back_has_subordinates ( Operation op,
Entry e,
int hasSubs 
)

Definition at line 312 of file op.c.

{
       BackendDB            *bd;
       int                  rc = LDAP_OTHER;

       bd = relay_back_select_backend( op, NULL, relay_op_has_subordinates );
       if ( bd && bd->be_has_subordinates ) {
              RELAY_WRAP_OP( op, bd, relay_op_has_subordinates, {
                     rc = bd->be_has_subordinates( op, e, hasSubs );
              });
       }

       return rc;
}

Here is the call graph for this function:

static int relay_back_op ( Operation op,
SlapReply rs,
int  which 
) [static]

Definition at line 194 of file op.c.

{
       BackendDB     *bd;
       BI_op_bind    *func;
       slap_mask_t   fail_mode = relay_fail_modes[which].rf_op;
       int           rc = ( fail_mode & RB_ERR_MASK );

       bd = relay_back_select_backend( op, rs, which );
       if ( bd == NULL ) {
              if ( fail_mode & RB_BDERR )
                     return rs->sr_err;   /* sr_err was set above */

       } else if ( (func = (&bd->be_bind)[which]) != 0 ) {
              relay_callback       rcb;

              relay_back_add_cb( &rcb, op );
              RELAY_WRAP_OP( op, bd, which, {
                     rc = func( op, rs );
              });
              relay_back_remove_cb( &rcb, op );

       } else if ( fail_mode & RB_OPERR ) {
              rs->sr_err = rc;
              if ( rc == LDAP_UNWILLING_TO_PERFORM ) {
                     rs->sr_text = "operation not supported within naming context";
              }

              if ( fail_mode & RB_SEND ) {
                     send_ldap_result( op, rs );
              }
       }

       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int relay_back_op_bind ( Operation op,
SlapReply rs 
)

Definition at line 231 of file op.c.

{
       /* allow rootdn as a means to auth without the need to actually
        * contact the proxied DSA */
       switch ( be_rootdn_bind( op, rs ) ) {
       case SLAP_CB_CONTINUE:
              break;

       default:
              return rs->sr_err;
       }

       return relay_back_op( op, rs, op_bind );
}

Here is the call graph for this function:

static int relay_back_response_cb ( Operation op,
SlapReply rs 
) [static]

Definition at line 86 of file op.c.

Here is the call graph for this function:

static BackendDB* relay_back_select_backend ( Operation op,
SlapReply rs,
int  which 
) [static]

Definition at line 117 of file op.c.

{
       OpExtra              *oex;
       char          *key = (char *) op->o_bd->be_private;
       BackendDB     *bd  = ((relay_back_info *) key)->ri_bd;
       slap_mask_t   fail_mode = relay_fail_modes[which].rf_bd;
       int           useDN = 0, rc = ( fail_mode & RB_ERR_MASK );

       if ( bd == NULL && !BER_BVISNULL( &op->o_req_ndn ) ) {
              useDN = 1;
              bd = select_backend( &op->o_req_ndn, 1 );
       }

       if ( bd != NULL ) {
              key += which; /* <relay, op type> key from RELAY_WRAP_OP() */
              LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) {
                     if ( oex->oe_key == key )
                            break;
              }
              if ( oex == NULL ) {
                     return bd;
              }

              Debug( LDAP_DEBUG_ANY,
                     "%s: back-relay for DN=\"%s\" would call self.\n",
                     op->o_log_prefix, op->o_req_dn.bv_val, 0 );

       } else if ( useDN && ( fail_mode & RB_REF ) && default_referral ) {
              rc = LDAP_REFERRAL;

              /* if we set sr_err to LDAP_REFERRAL, we must provide one */
              rs->sr_ref = referral_rewrite(
                     default_referral, NULL, &op->o_req_dn,
                     op->o_tag == LDAP_REQ_SEARCH ?
                     op->ors_scope : LDAP_SCOPE_DEFAULT );
              if ( rs->sr_ref != NULL ) {
                     rs->sr_flags |= REP_REF_MUSTBEFREED;
              } else {
                     rs->sr_ref = default_referral;
              }

              if ( fail_mode & RB_SENDREF )
                     fail_mode = (RB_BDERR | RB_SEND);
       }

       if ( fail_mode & RB_BDERR ) {
              rs->sr_err = rc;
              if ( fail_mode & RB_SEND ) {
                     send_ldap_result( op, rs );
              }
       }

       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation