]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slap.h
NVALUES: fix a couple of value_find_ex() calls
[openldap] / servers / slapd / slap.h
index 0a63c1f969380d935c10cdcf5532289d3c9b8dfd..9e747fa5a383c921fb9f941057625a1c47e6eb1d 100644 (file)
 #include "ldap_pvt_thread.h"
 #include "ldap_queue.h"
 
+#ifdef LDAP_DEVEL
+/* #define SLAP_NVALUES 1 */
 #define SLAP_EXTENDED_SCHEMA 1
+#endif
 
 LDAP_BEGIN_DECL
 /*
@@ -72,7 +75,7 @@ LDAP_BEGIN_DECL
 
 #define MAXREMATCHES (100)
 
-#define SLAP_MAX_WORKER_THREADS                (32)
+#define SLAP_MAX_WORKER_THREADS                (16)
 
 #define SLAP_SB_MAX_INCOMING_DEFAULT ((1<<18) - 1)
 #define SLAP_SB_MAX_INCOMING_AUTH ((1<<24) - 1)
@@ -313,7 +316,9 @@ typedef struct slap_syntax {
 #define SLAP_SYNTAX_HIDE       0x8000U /* hide (do not publish) */
 
        slap_syntax_validate_func       *ssyn_validate;
+#ifndef SLAP_NVALUES
        slap_syntax_transform_func      *ssyn_normalize;
+#endif
        slap_syntax_transform_func      *ssyn_pretty;
 
 #ifdef SLAPD_BINARY_CONVERSION
@@ -335,7 +340,11 @@ typedef struct slap_syntax_defs_rec {
        char *sd_desc;
        int sd_flags;
        slap_syntax_validate_func *sd_validate;
+#ifdef SLAP_NVALUES
+       slap_syntax_transform_func *sd_normalizeXXX; /* to be deleted */
+#else
        slap_syntax_transform_func *sd_normalize;
+#endif
        slap_syntax_transform_func *sd_pretty;
 #ifdef SLAPD_BINARY_CONVERSION
        slap_syntax_transform_func *sd_ber2str;
@@ -407,46 +416,87 @@ typedef struct slap_matching_rule {
 
 #define SLAP_MR_HIDE                   0x8000U
 
-#define SLAP_MR_TYPE_MASK              0x0F00U
-#define SLAP_MR_SUBTYPE_MASK   0x00F0U
-#define SLAP_MR_USAGE                  0x000FU
+#define SLAP_MR_TYPE_MASK              0xF000U
+#define SLAP_MR_SUBTYPE_MASK   0x0F00U
+#define SLAP_MR_USAGE                  0x00FFU
 
 #define SLAP_MR_NONE                   0x0000U
-#define SLAP_MR_EQUALITY               0x0100U
-#define SLAP_MR_ORDERING               0x0200U
-#define SLAP_MR_SUBSTR                 0x0400U
-#define SLAP_MR_EXT                            0x0800U /* implicitly extensible */
+#define SLAP_MR_EQUALITY               0x1000U
+#define SLAP_MR_ORDERING               0x2000U
+#define SLAP_MR_SUBSTR                 0x4000U
+#define SLAP_MR_EXT                            0x8000U /* implicitly extensible */
+
+#define SLAP_MR_EQUALITY_APPROX        ( SLAP_MR_EQUALITY | 0x0100U )
 
-#define SLAP_MR_EQUALITY_APPROX        ( SLAP_MR_EQUALITY | 0x0010U )
-#define SLAP_MR_DN_FOLD                        0x0008U
+#define SLAP_MR_SUBSTR_INITIAL ( SLAP_MR_SUBSTR | 0x0100U )
+#define SLAP_MR_SUBSTR_ANY             ( SLAP_MR_SUBSTR | 0x0200U )
+#define SLAP_MR_SUBSTR_FINAL   ( SLAP_MR_SUBSTR | 0x0400U )
 
-#define SLAP_MR_SUBSTR_INITIAL ( SLAP_MR_SUBSTR | 0x0010U )
-#define SLAP_MR_SUBSTR_ANY             ( SLAP_MR_SUBSTR | 0x0020U )
-#define SLAP_MR_SUBSTR_FINAL   ( SLAP_MR_SUBSTR | 0x0040U )
+#ifndef SLAP_NVALUES
+#define SLAP_MR_DN_FOLD                        0x0080U
+#endif
 
+#ifndef SLAP_NVALUES
 /*
- * normally the provided value is expected to conform to
+ * normally the asserted value is expected to conform to
  * assertion syntax specified in the matching rule, however
  * at times (such as during individual value modification),
- * the provided value is expected to conform to the
+ * the asserted value is expected to conform to the
  * attribute's value syntax.
  */
-#define SLAP_MR_ASSERTION_SYNTAX_MATCH                 0x0000U
-#define SLAP_MR_VALUE_SYNTAX_MATCH                             0x0001U
-#define SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH   0x0003U
-#define SLAP_MR_VALUE_NORMALIZED_MATCH 0x0004U
+#define SLAP_MR_ASSERTION_SYNTAX_MATCH         0x0000U
+#define SLAP_MR_ATTRIBUTE_SYNTAX_MATCH         0x0001U
 
-#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
-       (!((usage) & SLAP_MR_VALUE_SYNTAX_MATCH))
-#define SLAP_IS_MR_VALUE_SYNTAX_MATCH( usage ) \
-       ((usage) & SLAP_MR_VALUE_SYNTAX_MATCH)
+/* For SLAP_MR_ATTRIBUTE_SYNTAX_MATCHes, this flag indicates
+ * that the asserted value of the attribute syntax has been
+ * converted to the assertion syntax.  (Not sure why we just
+ * don't clear the SLAP_MR_ATTRIBUTE_SYNTAX_MATCH flag instead.)
+ */
+#define SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH       0x0002U
+
+#else
+/*
+ * The asserted value, depending on the particular usage,
+ * is expected to conform to either the assertion syntax
+ * or the attribute syntax.   In some cases, the syntax of
+ * the value is known.  If so, these flags indicate which
+ * syntax the value is expected to conform to.  If not,
+ * neither of these flags is set (until the syntax of the
+ * provided value is determined).  If the value is of the
+ * attribute syntax, the flag is changed once a value of
+ * the assertion syntax is derived from the provided value.
+ */
+#define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX      0x0001U
+#define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX      0x0002U
+
+#define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \
+       ((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX )
+#define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \
+       ((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX )
+#endif
+
+/* either or both the asserted value or attribute value
+ * may be provided in normalized form
+ */
+#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH                0x0010U
+#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH       0x0020U
 
-#define SLAP_IS_MR_VALUE_SYNTAX_CONVERTED_MATCH( usage ) \
-       (((usage) & SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) \
-               == SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH)
-#define SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( usage ) \
-       (((usage) & SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) \
-               == SLAP_MR_VALUE_SYNTAX_MATCH)
+#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
+       (!((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_MATCH))
+#define SLAP_IS_MR_ATTRIBUTE_SYNTAX_MATCH( usage ) \
+       ((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_MATCH)
+
+#define SLAP_IS_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH( usage ) \
+       (((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH) \
+               == SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH)
+#define SLAP_IS_MR_ATTRIBUTE_SYNTAX_NONCONVERTED_MATCH( usage ) \
+       (((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH) \
+               == SLAP_MR_ATTRIBUTE_SYNTAX_MATCH)
+
+#define SLAP_IS_MR_ASSERTED_VALUE_NORMALIZED_MATCH( usage ) \
+       ((usage) & SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH )
+#define SLAP_IS_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH( usage ) \
+       ((usage) & SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH )
 
        Syntax                                  *smr_syntax;
        slap_mr_convert_func    *smr_convert;
@@ -500,6 +550,7 @@ typedef struct slap_mrule_defs_rec {
        slap_mr_indexer_func *          mrd_indexer;
        slap_mr_filter_func *           mrd_filter;
 
+       /* For equality rule, this may refer to an appropriate approximate rule */
        char *                                          mrd_associated;
 } slap_mrule_defs_rec;
 
@@ -679,6 +730,11 @@ struct slap_internal_schema {
        AttributeDescription *si_ad_entryCSN;
        AttributeDescription *si_ad_superiorUUID;
 
+#ifdef LDAP_CACHING
+       /* LDAP cache specific operational attribute */
+       AttributeDescription *si_ad_queryid;
+#endif /* LDAP_CACHING */
+
        /* root DSE attribute descriptions */
        AttributeDescription *si_ad_altServer;
        AttributeDescription *si_ad_namingContexts;
@@ -739,12 +795,17 @@ struct slap_internal_schema {
 
        /* Matching Rules */
        MatchingRule    *si_mr_distinguishedNameMatch;
+       MatchingRule    *si_mr_caseExactMatch;
+       MatchingRule    *si_mr_caseExactSubstringsMatch;
+       MatchingRule    *si_mr_caseExactIA5Match;
        MatchingRule    *si_mr_integerMatch;
+       MatchingRule    *si_mr_integerFirstComponentMatch;
 
        /* Syntaxes */
-       Syntax          *si_syn_octetString;
+       Syntax          *si_syn_directoryString;
        Syntax          *si_syn_distinguishedName;
        Syntax          *si_syn_integer;
+       Syntax          *si_syn_octetString;
 };
 
 typedef struct slap_attr_assertion {
@@ -880,8 +941,11 @@ typedef struct slap_valuesreturnfilter {
  */
 typedef struct slap_attr {
        AttributeDescription *a_desc;
-       BerVarray       a_vals;
-       struct slap_attr        *a_next;
+       BerVarray       a_vals;         /* preserved values */
+#ifdef SLAP_NVALUES
+       BerVarray       a_nvals;        /* normalized values */
+#endif
+       struct slap_attr *a_next;
        unsigned a_flags;
 #define SLAP_ATTR_IXADD                0x1U
 #define SLAP_ATTR_IXDEL                0x2U
@@ -929,7 +993,11 @@ typedef struct slap_mod {
        int sm_op;
        AttributeDescription *sm_desc;
        struct berval sm_type;
-       BerVarray sm_bvalues;
+       BerVarray sm_values;
+#define sm_bvalues sm_values
+#ifdef SLAP_NVALUES
+       BerVarray sm_nvalues;
+#endif
 } Modification;
 
 typedef struct slap_mod_list {
@@ -937,7 +1005,9 @@ typedef struct slap_mod_list {
 #define sml_op         sml_mod.sm_op
 #define sml_desc       sml_mod.sm_desc
 #define        sml_type        sml_mod.sm_type
-#define sml_bvalues    sml_mod.sm_bvalues
+#define sml_bvalues    sml_mod.sm_values
+#define sml_values     sml_mod.sm_values
+#define sml_nvalues    sml_mod.sm_nvalues
        struct slap_mod_list *sml_next;
 } Modifications;
 
@@ -947,7 +1017,7 @@ typedef struct slap_ldap_modlist {
 #define ml_op          ml_mod.mod_op
 #define ml_type                ml_mod.mod_type
 #define ml_values      ml_mod.mod_values
-#define ml_bvalues     ml_mod.mod_bvalues
+#define ml_bvalues     ml_mod.mod_values
 } LDAPModList;
 
 /*
@@ -1224,6 +1294,8 @@ struct slap_backend_db {
 #define                be_modify       bd_info->bi_op_modify
 #define                be_modrdn       bd_info->bi_op_modrdn
 #define                be_search       bd_info->bi_op_search
+#define                be_abandon      bd_info->bi_op_abandon
+#define                be_cancel       bd_info->bi_op_cancel
 
 #define                be_extended     bd_info->bi_extended
 
@@ -1267,6 +1339,10 @@ struct slap_backend_db {
 #define SLAP_BFLAG_DYNAMIC             0x2000U
        slap_mask_t     be_flags;
 #define SLAP_LASTMOD(be)       (!((be)->be_flags & SLAP_BFLAG_NOLASTMOD))
+#define        SLAP_GLUE_INSTANCE(be)  ((be)->be_flags & SLAP_BFLAG_GLUE_INSTANCE)
+#define        SLAP_GLUE_SUBORDINATE(be) \
+       ((be)->be_flags & SLAP_BFLAG_GLUE_SUBORDINATE)
+#define        SLAP_GLUE_LINKED(be)    ((be)->be_flags & SLAP_BFLAG_GLUE_LINKED)
 #define SLAP_ALIASES(be)       ((be)->be_flags & SLAP_BFLAG_ALIASES)
 #define SLAP_REFERRALS(be)     ((be)->be_flags & SLAP_BFLAG_REFERRALS)
 #define SLAP_SUBENTRIES(be)    ((be)->be_flags & SLAP_BFLAG_SUBENTRIES)
@@ -1322,7 +1398,6 @@ struct slap_backend_db {
        /* these should be renamed from be_ to bd_ */
        BerVarray       be_suffix;      /* the DN suffixes of data in this backend */
        BerVarray       be_nsuffix;     /* the normalized DN suffixes in this backend */
-       BerVarray       be_suffixAlias; /* pairs of DN suffix aliases and deref values */
        struct berval be_schemadn;      /* per-backend subschema subentry DN */
        struct berval be_schemandn;     /* normalized subschema DN */
        struct berval be_rootdn;        /* the magic "root" name (DN) for this db */
@@ -1365,6 +1440,54 @@ typedef int (BI_db_open) LDAP_P((Backend *bd));
 typedef int (BI_db_close) LDAP_P((Backend *bd));
 typedef int (BI_db_destroy) LDAP_P((Backend *bd));
 
+#ifdef SLAP_OP_BLOCKS
+typedef struct req_bind_s {
+       int rb_method;
+       struct berval rb_cred;
+       struct berval rb_edn;
+} req_bind_s;
+
+typedef struct req_search_s {
+       int rs_scope;
+       int rs_deref;
+       int rs_slimit;
+       int rs_tlimit;
+       int rs_attrsonly;
+       AttributeName *rs_attrs;
+       Filter *rs_f;
+       struct berval rs_filterstr;
+} req_search_s;
+
+typedef struct req_compare_s {
+       AttributeAssertion *rs_ava;
+} req_compare_s;
+
+typedef struct req_modrdn_s {
+       struct berval rs_newrdn;
+       struct berval rs_nnewrdn;
+       struct berval rs_newSup;
+       struct berval rs_nnewSup;
+       int rs_deleteoldrdn;
+} req_modrdn_s;
+
+typedef struct req_add_s {
+       Entry *rs_e;
+} req_add_s;
+
+typedef struct req_abandon_s {
+       ber_int_t rs_msgid;
+} req_abandon_s;
+
+typedef struct req_extended_s {
+       struct berval rs_reqoid;
+       char *rs_rspoid;
+       struct berval *rs_rspdata;
+       LDAPControl **rs_rspctrls;
+       const char *rs_text;
+       BerVarray rs_refs;
+} req_extended_s;
+#endif /* SLAP_OP_BLOCKS */
+
 typedef int (BI_op_bind)  LDAP_P(( BackendDB *bd,
                struct slap_conn *c, struct slap_op *o,
                struct berval *dn, struct berval *ndn, int method,
@@ -1401,12 +1524,15 @@ typedef int (BI_op_delete) LDAP_P((BackendDB *bd,
 typedef int (BI_op_abandon) LDAP_P((BackendDB *bd,
                struct slap_conn *c, struct slap_op *o,
                ber_int_t msgid));
+typedef int (BI_op_cancel) LDAP_P((BackendDB *bd,
+               struct slap_conn *c, struct slap_op *o,
+               ber_int_t msgid));
 
 typedef int (BI_op_extended) LDAP_P((
        BackendDB               *be,
        struct slap_conn        *conn,
        struct slap_op          *op,
-       const char              *reqoid,
+       struct berval           *reqoid,
        struct berval * reqdata,
        char            **rspoid,
        struct berval ** rspdata,
@@ -1526,6 +1652,7 @@ struct slap_backend_info {
        BI_op_add       *bi_op_add;
        BI_op_delete    *bi_op_delete;
        BI_op_abandon   *bi_op_abandon;
+       BI_op_cancel    *bi_op_cancel;
 
        /* Extended Operations Helper */
        BI_op_extended  *bi_extended;
@@ -1652,13 +1779,41 @@ typedef struct slap_op {
        unsigned long o_opid;   /* id of this operation */
        unsigned long o_connid; /* id of conn initiating this op */
        struct slap_conn *o_conn;       /* connection spawning this op */
+#ifdef SLAP_OP_BLOCKS
+       BackendDB       *o_bd;  /* backend DB processing this op */
+#endif
 
        ber_int_t       o_msgid;        /* msgid of the request */
        ber_int_t       o_protocol;     /* version of the LDAP protocol used by client */
        ber_tag_t       o_tag;          /* tag of the request */
        time_t          o_time;         /* time op was initiated */
 
+#ifdef SLAP_OP_BLOCKS
+       struct berval   o_req_dn;       /* DN of target of request */
+       struct berval   o_req_ndn;
+
+       union o_req_u {
+               req_bind_s or_bind;
+               req_search_s or_search;
+               req_compare_s or_compare;
+               req_modrdn_s or_modrdn;
+               req_add_s or_add;
+               req_abandon_s or_abandon;
+               req_abandon_s or_cancel;
+               req_extended_s or_extended;
+       } o_request;
+
+/* short hands for union members */
+#define o_bind o_request.or_bind
+/* ... */
+
+/* short hands for inner request members */
+#define o_bind_edn o_bind.rb_edn
+/* ... */
+
+#else
        char *          o_extendedop;   /* extended operation OID */
+#endif
 
        ldap_pvt_thread_t       o_tid;  /* thread handling this op */
 
@@ -1670,6 +1825,7 @@ typedef struct slap_op {
 #define SLAP_CANCEL_DONE                               0x03
 
        char o_do_not_cache;    /* don't cache from this op */
+       char o_is_auth_check;   /* authorization in progress */
 
 #define SLAP_NO_CONTROL 0
 #define SLAP_NONCRITICAL_CONTROL 1
@@ -1737,9 +1893,6 @@ typedef struct slap_op {
        LDAP_LIST_ENTRY(slap_op) link;
 #endif
 
-#ifdef LDAP_CONNECTIONLESS
-       Sockaddr        o_peeraddr;     /* UDP peer address               */
-#endif
        AuthorizationInformation o_authz;
 
        BerElement      *o_ber;         /* ber of the request             */
@@ -1755,6 +1908,10 @@ typedef struct slap_op {
        LDAP_STAILQ_ENTRY(slap_op)      o_next; /* next operation in list         */
        ValuesReturnFilter *vrFilter; /* Structure represents ValuesReturnFilter */
 
+#ifdef LDAP_CACHING 
+       char            o_caching_on; 
+#endif /*LDAP_CACHING */ 
+
 #ifdef LDAP_SLAPI
        void    *o_pb;                  /* NS-SLAPI plugin */
 #endif
@@ -1965,14 +2122,6 @@ typedef struct slap_conn {
                        fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
        } while (0)
 #define StatslogTest( level ) (ldap_debug & (level))
-#elif defined(LDAP_SYSLOG)
-#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
-       do { \
-               if ( ldap_syslog & (level) ) \
-                       syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \
-                               (arg2), (arg3) ); \
-       } while (0)
-#define StatslogTest( level ) (ldap_syslog & (level))
 #else
 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
 #define StatslogTest( level ) (0)
@@ -2035,6 +2184,31 @@ enum {
 #define SLAP_SEARCH_MAX_CTRLS   10
 #endif
 
+#define SLAP_CTRL_FRONTEND                     0x80000000U
+#define SLAP_CTRL_FRONTEND_SEARCH      0x01000000U     /* for NOOP */
+
+#define SLAP_CTRL_OPFLAGS                      0x0000FFFFU
+#define SLAP_CTRL_ABANDON                      0x00000001U
+#define SLAP_CTRL_ADD                          0x00002002U
+#define SLAP_CTRL_BIND                         0x00000004U
+#define SLAP_CTRL_COMPARE                      0x00001008U
+#define SLAP_CTRL_DELETE                       0x00002010U
+#define SLAP_CTRL_MODIFY                       0x00002020U
+#define SLAP_CTRL_RENAME                       0x00002040U
+#define SLAP_CTRL_SEARCH                       0x00001080U
+#define SLAP_CTRL_UNBIND                       0x00000100U
+
+#define SLAP_CTRL_INTROGATE    (SLAP_CTRL_COMPARE|SLAP_CTRL_SEARCH)
+#define SLAP_CTRL_UPDATE \
+       (SLAP_CTRL_ADD|SLAP_CTRL_DELETE|SLAP_CTRL_MODIFY|SLAP_CTRL_RENAME)
+#define SLAP_CTRL_ACCESS       (SLAP_CTRL_INTROGATE|SLAP_CTRL_UPDATE)
+
+typedef int (SLAP_CTRL_PARSE_FN) LDAP_P((
+       Connection *conn,
+       Operation *op,
+       LDAPControl *ctrl,
+       const char **text ));
+
 LDAP_END_DECL
 
 #include "proto-slap.h"