]> git.sur5r.net Git - openldap/blob - servers/slapd/slap.h
Extend slapd schema structure definitions to reflect the new
[openldap] / servers / slapd / slap.h
1 /* slap.h - stand alone ldap server include file */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #ifndef _SLAP_H_
9 #define _SLAP_H_
10
11 #include "ldap_defaults.h"
12
13 #include <ac/stdlib.h>
14
15 #include <sys/types.h>
16 #include <ac/syslog.h>
17 #include <ac/regex.h>
18 #include <ac/socket.h>
19 #include <ac/time.h>
20 #include <ac/param.h>
21
22 #ifdef HAVE_CYRUS_SASL
23 #include <sasl.h>
24 #endif
25
26 #include "avl.h"
27
28 #ifndef ldap_debug
29 #define ldap_debug slap_debug
30 #endif
31
32
33 #include "ldap_log.h"
34
35 #include <ldap.h>
36 #include <ldap_schema.h>
37
38 #include "ldap_pvt_thread.h"
39 #include "ldif.h"
40
41 LDAP_BEGIN_DECL
42
43 #ifdef f_next
44 #undef f_next /* name conflict between sys/file.h on SCO and struct filter */
45 #endif
46
47 #define SERVICE_NAME  OPENLDAP_PACKAGE "-slapd"
48
49 /* LDAPMod.mod_op value ===> Must be kept in sync with ldap.h!
50  *
51  * This is a value used internally by the backends. It is needed to allow
52  * adding values that already exist without getting an error as required by
53  * modrdn when the new rdn was already an attribute value itself.
54  * JCG 05/1999 (gomez@engr.sgi.com)
55  */
56 #define SLAP_MOD_SOFTADD        0x1000
57
58 #define ON      1
59 #define OFF     (-1)
60 #define UNDEFINED 0
61
62 #define MAXREMATCHES 10
63
64 /* psuedo error code indicating disconnect */
65 #define SLAPD_DISCONNECT -1
66
67 /* psuedo error code indicating abandoned operation */
68 #define SLAPD_ABANDON -2
69
70
71 /* We assume "C" locale, that is US-ASCII */
72 #define ASCII_SPACE(c)  ( (c) == ' ' )
73 #define ASCII_LOWER(c)  ( (c) >= 'a' && (c) <= 'z' )
74 #define ASCII_UPPER(c)  ( (c) >= 'A' && (c) <= 'Z' )
75 #define ASCII_ALPHA(c)  ( ASCII_LOWER(c) || ASCII_UPPER(c) )
76 #define ASCII_DIGIT(c)  ( (c) >= '0' && (c) <= '9' )
77 #define ASCII_ALNUM(c)  ( ASCII_ALPHA(c) || ASCII_DIGIT(c) )
78
79 #define DN_SEPARATOR(c) ((c) == ',' || (c) == ';')
80 #define RDN_SEPARATOR(c)        ((c) == ',' || (c) == ';' || (c) == '+')
81 #define RDN_NEEDSESCAPE(c)      ((c) == '\\' || (c) == '"')
82
83 #define DESC_LEADCHAR(c)        ( ASCII_ALPHA(c) )
84 #define DESC_CHAR(c)    ( ASCII_ALNUM(c) || (c) == '-' )
85 #define OID_LEADCHAR(c) ( ASCII_DIGIT(c) )
86 #define OID_CHAR(c)     ( ASCII_DIGIT(c) || (c) == '.' )
87
88 #define ATTR_LEADCHAR(c)        ( DESC_LEADCHAR(c) || OID_LEADCHAR(c) )
89 #define ATTR_CHAR(c)    ( DESC_CHAR((c)) || (c) == '.' )
90
91 #define AD_LEADCHAR(c)  ( ATTR_CHAR(c) )
92 #define AD_CHAR(c)              ( ATTR_CHAR(c) || (c) == ';' )
93
94 #define SLAPD_ACI_DEFAULT_ATTR          "aci"
95
96 /* schema needed by slapd */
97 #define SLAPD_OID_DN_SYNTAX "1.3.6.1.4.1.1466.115.121.1.12"
98 #define SLAPD_OID_ACI_SYNTAX "1.3.6.1.4.1.4203.666.2.1" /* experimental */
99
100 LIBSLAPD_F (int) slap_debug;
101
102 /*
103  * Index types
104  */
105 #define SLAP_INDEX_PRESENCE      0x0001U
106 #define SLAP_INDEX_EQUALITY      0x0002U
107 #define SLAP_INDEX_APPROX        0x0004U
108 #define SLAP_INDEX_SUBSTR        0x0008U
109 #define SLAP_INDEX_EXTENDED              0x0010U
110 #define SLAP_INDEX_UNDEFINED     0x1000U
111 #define SLAP_INDEX_FROMINIT      0x8000U        /* psuedo type */
112
113 /*
114  * represents schema information for a database
115  */
116 #define SLAP_SCHERR_OUTOFMEM            1
117 #define SLAP_SCHERR_CLASS_NOT_FOUND     2
118 #define SLAP_SCHERR_ATTR_NOT_FOUND      3
119 #define SLAP_SCHERR_DUP_CLASS           4
120 #define SLAP_SCHERR_DUP_ATTR            5
121 #define SLAP_SCHERR_DUP_SYNTAX          6
122 #define SLAP_SCHERR_DUP_RULE            7
123 #define SLAP_SCHERR_NO_NAME             8
124 #define SLAP_SCHERR_ATTR_INCOMPLETE     9
125 #define SLAP_SCHERR_MR_NOT_FOUND        10
126 #define SLAP_SCHERR_SYN_NOT_FOUND       11
127 #define SLAP_SCHERR_MR_INCOMPLETE       12
128
129 typedef struct slap_oid_macro {
130         struct berval som_oid;
131         char **som_names;
132         struct slap_oid_macro *som_next;
133 } OidMacro;
134
135 /* forward declarations */
136 struct slap_syntax;
137 struct slap_matching_rule;
138
139 typedef int slap_syntax_validate_func LDAP_P((
140         struct slap_syntax *syntax,
141         struct berval * in));
142
143 typedef int slap_syntax_transform_func LDAP_P((
144         struct slap_syntax *syntax,
145         struct berval * in,
146         struct berval ** out));
147
148 typedef struct slap_syntax {
149         LDAP_SYNTAX                     ssyn_syn;
150 #define ssyn_oid                ssyn_syn.syn_oid
151 #define ssyn_desc               ssyn_syn.syn_desc
152 #define ssyn_extensions         ssyn_syn.syn_extensions
153
154         unsigned        ssyn_flags;
155
156 #define SLAP_SYNTAX_NONE        0x0U
157 #define SLAP_SYNTAX_BLOB        0x1U /* syntax treated as blob (audio) */
158 #define SLAP_SYNTAX_BINARY      0x2U /* binary transfer required (certificate) */
159 #define SLAP_SYNTAX_BER         0x4U /* stored using BER encoding (binary,certificate) */
160
161         slap_syntax_validate_func       *ssyn_validate;
162
163 #ifdef SLAPD_BINARY_CONVERSION
164         /* convert to and from binary */
165         slap_syntax_transform_func      *ssyn_ber2str;
166         slap_syntax_transform_func      *ssyn_str2ber;
167 #endif
168
169         struct slap_syntax              *ssyn_next;
170 } Syntax;
171
172 #define slap_syntax_is_flag(s,flag) ((int)((s)->ssyn_flags & (flag)) ? 1 : 0)
173 #define slap_syntax_is_blob(s)          slap_syntax_is_flag((s),SLAP_SYNTAX_BLOB)
174 #define slap_syntax_is_binary(s)        slap_syntax_is_flag((s),SLAP_SYNTAX_BINARY)
175 #define slap_syntax_is_ber(s)           slap_syntax_is_flag((s),SLAP_SYNTAX_BER)
176
177 /* XXX -> UCS-2 Converter */
178 typedef int slap_mr_convert_func LDAP_P((
179         struct berval * in,
180         struct berval ** out ));
181
182 /* Normalizer */
183 typedef int slap_mr_normalize_func LDAP_P((
184         unsigned use,
185         struct slap_syntax *syntax, /* NULL if in is asserted value */
186         struct slap_matching_rule *mr,
187         struct berval * in,
188         struct berval ** out ));
189
190 /* Match (compare) function */
191 typedef int slap_mr_match_func LDAP_P((
192         unsigned use,
193         struct slap_syntax *syntax,     /* syntax of stored value */
194         struct slap_matching_rule *mr,
195         struct berval * value,
196         void * assertValue ));
197
198 /* Index generation function */
199 typedef int slap_mr_indexer_func LDAP_P((
200         unsigned use,
201         struct slap_syntax *syntax,     /* syntax of stored value */
202         struct slap_matching_rule *mr,
203         struct berval **values,
204         struct berval **keys ));
205
206 struct slap_filter;     /* forward declaration */
207
208 /* Filter index function */
209 typedef int slap_mr_filter_func LDAP_P((
210         unsigned use,
211         struct slap_syntax *syntax,     /* syntax of stored value */
212         struct slap_matching_rule *mr,
213         struct slap_filter *filter,
214         struct berval **keys ));
215
216 typedef struct slap_matching_rule {
217         LDAP_MATCHING_RULE              smr_mrule;
218         unsigned                                smr_usage;
219
220 #define SLAP_MR_TYPE_MASK               0xFF00U
221 #define SLAP_MR_SUBTYPE_MASK    0x00FFU
222
223 #define SLAP_MR_NONE                    0x0000U
224 #define SLAP_MR_EQUALITY                0x0100U
225 #define SLAP_MR_ORDERING                0x0200U
226 #define SLAP_MR_SUBSTR                  0x0400U
227 #define SLAP_MR_EXT                             0x0800U
228
229 #define SLAP_MR_EQUALITY_APPROX ( SLAP_MR_EQUALITY | 0x0001U )
230
231 #define SLAP_MR_SUBSTR_INITIAL  ( SLAP_MR_SUBSTR | 0x0001U )
232 #define SLAP_MR_SUBSTR_ANY              ( SLAP_MR_SUBSTR | 0x0002U )
233 #define SLAP_MR_SUBSTR_FINAL    ( SLAP_MR_SUBSTR | 0x0004U )
234
235         Syntax                                  *smr_syntax;
236         slap_mr_convert_func    *smr_convert;
237         slap_mr_normalize_func  *smr_normalize;
238         slap_mr_match_func              *smr_match;
239         slap_mr_indexer_func    *smr_indexer;
240         slap_mr_filter_func             *smr_filter;
241         struct slap_matching_rule       *smr_next;
242 #define smr_oid                         smr_mrule.mr_oid
243 #define smr_names                       smr_mrule.mr_names
244 #define smr_desc                        smr_mrule.mr_desc
245 #define smr_obsolete            smr_mrule.mr_obsolete
246 #define smr_syntax_oid          smr_mrule.mr_syntax_oid
247 #define smr_extensions          smr_mrule.mr_extensions
248 } MatchingRule;
249
250 typedef struct slap_attribute_type {
251 #ifdef SLAPD_SCHEMA_NOT_COMPAT
252         char                                    *sat_cname;
253 #endif
254         LDAP_ATTRIBUTE_TYPE             sat_atype;
255         struct slap_attribute_type      *sat_sup;
256         struct slap_attribute_type      **sat_subtypes;
257         MatchingRule                    *sat_equality;
258         MatchingRule                    *sat_ordering;
259         MatchingRule                    *sat_substr;
260         Syntax                          *sat_syntax;
261 #ifndef SLAPD_SCHEMA_NOT_COMPAT
262         /* The next one is created to help in the transition */
263         int                             sat_syntax_compat;
264 #endif
265         struct slap_attribute_type      *sat_next;
266 #define sat_oid                 sat_atype.at_oid
267 #define sat_names               sat_atype.at_names
268 #define sat_desc                sat_atype.at_desc
269 #define sat_obsolete            sat_atype.at_obsolete
270 #define sat_sup_oid             sat_atype.at_sup_oid
271 #define sat_equality_oid        sat_atype.at_equality_oid
272 #define sat_ordering_oid        sat_atype.at_ordering_oid
273 #define sat_substr_oid          sat_atype.at_substr_oid
274 #define sat_syntax_oid          sat_atype.at_syntax_oid
275 #define sat_single_value        sat_atype.at_single_value
276 #define sat_collective          sat_atype.at_collective
277 #define sat_no_user_mod         sat_atype.at_no_user_mod
278 #define sat_usage               sat_atype.at_usage
279 #define sat_extensions          sat_atype.at_extensions
280 } AttributeType;
281
282 #define is_at_operational(at)   ((at)->sat_usage)
283 #define is_at_single_value(at)  ((at)->sat_single_value)
284 #define is_at_collective(at)    ((at)->sat_collective)
285 #define is_at_no_user_mod(at)   ((at)->sat_no_user_mod)
286
287 typedef struct slap_object_class {
288         LDAP_OBJECT_CLASS               soc_oclass;
289         struct slap_object_class        **soc_sups;
290         AttributeType                   **soc_required;
291         AttributeType                   **soc_allowed;
292         struct slap_object_class        *soc_next;
293 #define soc_oid                 soc_oclass.oc_oid
294 #define soc_names               soc_oclass.oc_names
295 #define soc_desc                soc_oclass.oc_desc
296 #define soc_obsolete            soc_oclass.oc_obsolete
297 #define soc_sup_oids            soc_oclass.oc_sup_oids
298 #define soc_kind                soc_oclass.oc_kind
299 #define soc_at_oids_must        soc_oclass.oc_at_oids_must
300 #define soc_at_oids_may         soc_oclass.oc_at_oids_may
301 #define soc_extensions          soc_oclass.oc_extensions
302 } ObjectClass;
303
304
305 #ifdef SLAPD_SCHEMA_NOT_COMPAT
306 /*
307  * represents a recognized attribute description ( type + options )
308  */
309 typedef struct slap_attr_desc {
310         struct berval *ad_cname;        /* canonical name */
311         AttributeType *ad_type;         /* NULL if unknown */
312         char *ad_lang;                          /* NULL if no language tags */
313         unsigned ad_flags;
314 #define SLAP_DESC_NONE          0x0U
315 #define SLAP_DESC_BINARY        0x1U
316 } AttributeDescription;
317
318 #define slap_ad_is_binary(ad)   ( (int)((ad)->ad_flags & SLAP_DESC_BINARY) ? 1 : 0 )
319
320 /*
321  * pointers to schema elements used internally
322  */
323 struct slap_internal_schema {
324         /* objectClass */
325         ObjectClass *si_oc_alias;
326         ObjectClass *si_oc_referral;
327
328         /* objectClass attribute */
329         AttributeDescription *si_ad_objectClass;
330
331         /* operational attributes */
332         AttributeDescription *si_ad_creatorsName;
333         AttributeDescription *si_ad_createTimestamp;
334         AttributeDescription *si_ad_modifiersName;
335         AttributeDescription *si_ad_modifyTimestamp;
336         AttributeDescription *si_ad_subschemaSubentry;
337
338         /* root DSE attributes */
339         AttributeDescription *si_ad_namingContexts;
340         AttributeDescription *si_ad_supportedControl;
341         AttributeDescription *si_ad_supportedExtension;
342         AttributeDescription *si_ad_supportedLDAPVersion;
343         AttributeDescription *si_ad_supportedSASLMechanisms;
344
345         /* subschema subentry attributes */
346         AttributeDescription *si_ad_objectClasses;
347         AttributeDescription *si_ad_attributeTypes;
348         AttributeDescription *si_ad_ldapSyntaxes;
349         AttributeDescription *si_ad_matchingRules;
350         AttributeDescription *si_ad_matchingRulesUse;
351
352         /* Aliases & Referrals */
353         AttributeDescription *si_ad_aliasedObjectName;
354         AttributeDescription *si_ad_ref;
355
356         /* ACL Internals */
357         AttributeDescription *si_ad_entry;
358         AttributeDescription *si_ad_children;
359
360         /* Other */
361         AttributeDescription *si_ad_userPassword;
362         AttributeDescription *si_ad_authPassword;
363 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
364         AttributeDescription *si_ad_krbName;
365 #endif
366 };
367
368 typedef struct slap_attr_assertion {
369         AttributeDescription    *aa_desc;
370         struct berval *aa_value;
371 } AttributeAssertion;
372
373 typedef struct slap_ss_assertion {
374         AttributeDescription    *sa_desc;
375         struct berval                   *sa_initial;
376         struct berval                   **sa_any;
377         struct berval                   *sa_final;
378 } SubstringAssertion;
379
380 typedef struct slap_mr_assertion {
381         char                                    *ma_rule;       /* optional */
382         AttributeDescription    *ma_desc;       /* optional */
383         int                                             ma_dnattrs; /* boolean */
384         struct berval                   *ma_value;      /* required */
385 } MatchingRuleAssertion;
386
387 #else
388
389 /*
390  * represents an attribute value assertion (i.e., attr;option=value)
391  */
392 typedef struct slap_ava {
393         char            *ava_type;      /* attribute description */
394         struct berval   ava_value;
395 } Ava;
396
397 /*
398  * represents an matching rule assertion
399  */
400 typedef struct slap_mra {
401         char    *mra_rule;      /* optional */
402         char    *mra_type;      /* attribute description -- optional */
403         int             mra_dnattrs;
404         struct berval   *mra_value;
405 } Mra;
406
407 #endif
408
409 /*
410  * represents a search filter
411  */
412
413 typedef struct slap_filter {
414         ber_tag_t       f_choice;       /* values taken from ldap.h, plus: */
415 #define SLAPD_FILTER_COMPUTED ((ber_tag_t) 0x01U)
416
417         union f_un_u {
418                 /* precomputed result */
419                 ber_int_t f_un_result;
420
421 #ifdef SLAPD_SCHEMA_NOT_COMPAT
422                 /* DN */
423                 char *f_un_dn;
424
425                 /* present */
426                 AttributeDescription *f_un_desc;
427
428                 /* simple value assertion */
429                 AttributeAssertion *f_un_ava;
430
431                 /* substring assertion */
432                 SubstringAssertion *f_un_ssa;
433
434                 /* matching rule assertion */
435                 MatchingRuleAssertion *f_un_mra;
436
437 #define f_dn                    f_un.f_un_dn
438 #define f_desc                  f_un.f_un_desc
439 #define f_ava                   f_un.f_un_ava
440 #define f_av_desc               f_un.f_un_ava->aa_desc
441 #define f_av_value              f_un.f_un_ava->aa_value
442 #define f_sub                   f_un.f_un_ssa
443 #define f_sub_desc              f_un.f_un_ssa->sa_desc
444 #define f_sub_initial   f_un.f_un_ssa->sa_initial
445 #define f_sub_any               f_un.f_un_ssa->sa_any
446 #define f_sub_final             f_un.f_un_ssa->sa_final
447 #define f_mra                   f_un.f_un_mra
448 #define f_mr_rule               f_un.f_un_mra->ma_rule
449 #define f_mr_desc               f_un.f_un_mra->ma_desc
450 #define f_mr_value              f_un.f_un_mra->ma_value
451 #define f_mr_dnaddrs    f_un.f_un_mra->ma_dnattrs
452 #else
453                 /* present */
454                 char            *f_un_type;
455
456                 /* equality, lessorequal, greaterorequal, approx */
457                 Ava             f_un_ava;
458
459                 /* extensible */
460                 Mra             f_un_fra;       
461
462                 /* substrings */
463                 struct sub {
464                         char    *f_un_sub_type;
465
466                         struct berval   *f_un_sub_initial;
467                         struct berval   **f_un_sub_any;
468                         struct berval   *f_un_sub_final;
469                 } f_un_sub;
470
471 #define f_dn            f_un.f_un_type  /* used for DN indices */
472 #define f_type          f_un.f_un_type
473 #define f_ava           f_un.f_un_ava
474 #define f_avtype        f_un.f_un_ava.ava_type
475 #define f_avvalue       f_un.f_un_ava.ava_value
476 #define f_mra           f_un.f_un_mra
477 #define f_mrtype        f_un.f_un_mra.mra_type
478 #define f_mrvalue       f_un.f_un_mra.mra_value
479 #define f_mrdnaddrs     f_un.f_un_mra.mra_dnattrs
480 #define f_sub           f_un.f_un_sub
481 #define f_sub_type      f_un.f_un_sub.f_un_sub_type
482 #define f_sub_initial   f_un.f_un_sub.f_un_sub_initial
483 #define f_sub_any       f_un.f_un_sub.f_un_sub_any
484 #define f_sub_final     f_un.f_un_sub.f_un_sub_final
485 #endif
486
487                 /* and, or, not */
488                 struct slap_filter *f_un_complex;
489         } f_un;
490
491 #define f_result        f_un.f_un_result
492 #define f_and           f_un.f_un_complex
493 #define f_or            f_un.f_un_complex
494 #define f_not           f_un.f_un_complex
495 #define f_list          f_un.f_un_complex
496
497         struct slap_filter      *f_next;
498 } Filter;
499
500 /* compare routines can return undefined */
501 #define SLAPD_COMPARE_UNDEFINED ((ber_tag_t) -1)
502
503 /*
504  * represents an attribute (description + values)
505  */
506 typedef struct slap_attr {
507 #ifdef SLAPD_SCHEMA_NOT_COMPAT
508         AttributeDescription *a_desc;
509 #else
510         char            *a_type;        /* description */
511         int             a_syntax;
512 #endif
513         struct berval   **a_vals;
514         struct slap_attr        *a_next;
515 } Attribute;
516
517 #ifndef SLAPD_SCHEMA_NOT_COMPAT
518 /*
519  * the attr_syntax() routine returns one of these values
520  * telling what kind of syntax an attribute supports.
521  */
522 #define SYNTAX_CIS      0x01    /* case insensitive string              */
523 #define SYNTAX_CES      0x02    /* case sensitive string                */
524 #define SYNTAX_BIN      0x04    /* binary data                          */
525 #define SYNTAX_TEL      0x08    /* telephone number string              */
526 #define SYNTAX_DN       0x10    /* dn string                            */
527 #endif
528
529 /*
530  * the id used in the indexes to refer to an entry
531  */
532 typedef unsigned long   ID;
533 #define NOID    ((ID)~0)
534
535 /*
536  * represents an entry in core
537  */
538 typedef struct slap_entry {
539         /*
540          * The ID field should only be changed before entry is
541          * inserted into a cache.  The ID value is backend
542          * specific.
543          */
544         ID              e_id;
545
546         char            *e_dn;          /* DN of this entry */
547         char            *e_ndn;         /* normalized DN of this entry */
548         Attribute       *e_attrs;       /* list of attributes + values */
549
550         /* for use by the backend for any purpose */
551         void*   e_private;
552 } Entry;
553
554 /*
555  * A list of LDAPMods
556  */
557 #ifdef SLAPD_SCHEMA_NOT_COMPAT
558 typedef struct slap_mod {
559         int sm_op;
560         AttributeDescription *sm_desc;
561         struct berval **sm_bvalues;
562 } Modification;
563 #else
564 #define Modification LDAPMod
565 #define sm_op mod_op
566 #define sm_desc mod_type
567 #define sm_bvalues mod_bvalues
568 #endif
569
570 typedef struct slap_mod_list {
571         Modification sml_mod;
572 #define sml_op          sml_mod.sm_op
573 #define sml_desc        sml_mod.sm_desc
574 #define sml_bvalues     sml_mod.sm_bvalues
575 #ifndef SLAPD_SCHEMA_NOT_COMPAT
576 #define sml_type        sml_mod.sm_desc
577 #endif
578         struct slap_mod_list *sml_next;
579 } Modifications;
580
581 #ifdef SLAPD_SCHEMA_NOT_COMPAT
582 typedef struct slap_ldap_modlist {
583         LDAPMod ml_mod;
584         struct slap_ldap_modlist *ml_next;
585 #define ml_op           ml_mod.mod_op
586 #define ml_type         ml_mod.mod_type
587 #define ml_values       ml_mod.mod_values
588 #define ml_bvalues      ml_mod.mod_bvalues
589 } LDAPModList;
590 #else
591 #define LDAPModList Modifications
592 #define ml_mod          sml_mod
593 #define ml_op           sml_mod.mod_op
594 #define ml_type         sml_mod.mod_type
595 #define ml_values       sml_mod.mod_values
596 #define ml_bvalues      sml_mod.mod_bvalues
597 #define ml_next         sml_next
598 #endif
599
600 /*
601  * represents an access control list
602  */
603
604 typedef enum slap_access_e {
605         ACL_INVALID_ACCESS = -1,
606         ACL_NONE = 0,
607         ACL_AUTH,
608         ACL_COMPARE,
609         ACL_SEARCH,
610         ACL_READ,
611         ACL_WRITE
612 } slap_access_t;
613
614 typedef enum slap_control_e {
615         ACL_INVALID_CONTROL     = 0,
616         ACL_STOP,
617         ACL_CONTINUE,
618         ACL_BREAK
619 } slap_control_t;
620
621 typedef unsigned long slap_access_mask_t;
622
623 /* the "by" part */
624 typedef struct slap_access {
625         slap_control_t a_type;
626
627 #define ACL_ACCESS2PRIV(access) (0x01U << (access))
628
629 #define ACL_PRIV_NONE                   ACL_ACCESS2PRIV( ACL_NONE )
630 #define ACL_PRIV_AUTH                   ACL_ACCESS2PRIV( ACL_AUTH )
631 #define ACL_PRIV_COMPARE                ACL_ACCESS2PRIV( ACL_COMPARE )
632 #define ACL_PRIV_SEARCH                 ACL_ACCESS2PRIV( ACL_SEARCH )
633 #define ACL_PRIV_READ                   ACL_ACCESS2PRIV( ACL_READ )
634 #define ACL_PRIV_WRITE                  ACL_ACCESS2PRIV( ACL_WRITE )
635
636 #define ACL_PRIV_MASK                   0x00ffUL
637
638 /* priv flags */
639 #define ACL_PRIV_LEVEL                  0x1000UL
640 #define ACL_PRIV_ADDITIVE               0x2000UL
641 #define ACL_PRIV_SUBSTRACTIVE   0x4000UL
642
643 /* invalid privs */
644 #define ACL_PRIV_INVALID                0x0UL
645
646 #define ACL_PRIV_ISSET(m,p)             (((m) & (p)) == (p))
647 #define ACL_PRIV_ASSIGN(m,p)    do { (m)  =  (p); } while(0)
648 #define ACL_PRIV_SET(m,p)               do { (m) |=  (p); } while(0)
649 #define ACL_PRIV_CLR(m,p)               do { (m) &= ~(p); } while(0)
650
651 #define ACL_INIT(m)                             ACL_PRIV_ASSIGN(m, ACL_PRIV_NONE)
652 #define ACL_INVALIDATE(m)               ACL_PRIV_ASSIGN(m, ACL_PRIV_INVALID)
653
654 #define ACL_GRANT(m,a)                  ACL_PRIV_ISSET((m),ACL_ACCESS2PRIV(a))
655
656 #define ACL_IS_INVALID(m)               ((m) == ACL_PRIV_INVALID)
657
658 #define ACL_IS_LEVEL(m)                 ACL_PRIV_ISSET((m),ACL_PRIV_LEVEL)
659 #define ACL_IS_ADDITIVE(m)              ACL_PRIV_ISSET((m),ACL_PRIV_ADDITIVE)
660 #define ACL_IS_SUBTRACTIVE(m)   ACL_PRIV_ISSET((m),ACL_PRIV_SUBSTRACTIVE)
661
662 #define ACL_LVL_NONE                    (ACL_PRIV_NONE|ACL_PRIV_LEVEL)
663 #define ACL_LVL_AUTH                    (ACL_PRIV_AUTH|ACL_LVL_NONE)
664 #define ACL_LVL_COMPARE                 (ACL_PRIV_COMPARE|ACL_LVL_AUTH)
665 #define ACL_LVL_SEARCH                  (ACL_PRIV_SEARCH|ACL_LVL_COMPARE)
666 #define ACL_LVL_READ                    (ACL_PRIV_READ|ACL_LVL_SEARCH)
667 #define ACL_LVL_WRITE                   (ACL_PRIV_WRITE|ACL_LVL_READ)
668
669 #define ACL_LVL(m,l)                    (((m)&ACL_PRIV_MASK) == ((l)&ACL_PRIV_MASK))
670 #define ACL_LVL_IS_NONE(m)              ACL_LVL((m),ACL_LVL_NONE)
671 #define ACL_LVL_IS_AUTH(m)              ACL_LVL((m),ACL_LVL_AUTH)
672 #define ACL_LVL_IS_COMPARE(m)   ACL_LVL((m),ACL_LVL_COMPARE)
673 #define ACL_LVL_IS_SEARCH(m)    ACL_LVL((m),ACL_LVL_SEARCH)
674 #define ACL_LVL_IS_READ(m)              ACL_LVL((m),ACL_LVL_READ)
675 #define ACL_LVL_IS_WRITE(m)             ACL_LVL((m),ACL_LVL_WRITE)
676
677 #define ACL_LVL_ASSIGN_NONE(m)          ACL_PRIV_ASSIGN((m),ACL_LVL_NONE)
678 #define ACL_LVL_ASSIGN_AUTH(m)          ACL_PRIV_ASSIGN((m),ACL_LVL_AUTH)
679 #define ACL_LVL_ASSIGN_COMPARE(m)       ACL_PRIV_ASSIGN((m),ACL_LVL_COMPARE)
680 #define ACL_LVL_ASSIGN_SEARCH(m)        ACL_PRIV_ASSIGN((m),ACL_LVL_SEARCH)
681 #define ACL_LVL_ASSIGN_READ(m)          ACL_PRIV_ASSIGN((m),ACL_LVL_READ)
682 #define ACL_LVL_ASSIGN_WRITE(m)         ACL_PRIV_ASSIGN((m),ACL_LVL_WRITE)
683
684         slap_access_mask_t      a_mask;
685
686         char            *a_dn_pat;
687 #ifdef SLAPD_SCHEMA_NOT_COMPAT
688         AttributeDescription    *a_dn_at;
689 #else
690         char            *a_dn_at;
691 #endif
692         int                     a_dn_self;
693
694         char            *a_peername_pat;
695         char            *a_sockname_pat;
696
697         char            *a_domain_pat;
698         char            *a_sockurl_pat;
699
700 #ifdef SLAPD_ACI_ENABLED
701 #ifdef SLAPD_SCHEMA_NOT_COMPAT
702         AttributeDescription    *a_aci_at;
703 #else
704         char            *a_aci_at;
705 #endif
706 #endif
707
708         /* ACL Groups */
709         char            *a_group_pat;
710         char            *a_group_oc;
711 #ifdef SLAPD_SCHEMA_NOT_COMPAT
712         AttributeDescription    *a_group_at;
713 #else
714         char            *a_group_at;
715 #endif
716
717         struct slap_access      *a_next;
718 } Access;
719
720 /* the "to" part */
721 typedef struct slap_acl {
722         /* "to" part: the entries this acl applies to */
723         Filter          *acl_filter;
724         regex_t         acl_dn_re;
725         char            *acl_dn_pat;
726         char            **acl_attrs;
727
728         /* "by" part: list of who has what access to the entries */
729         Access  *acl_access;
730
731         struct slap_acl *acl_next;
732 } AccessControl;
733
734 /*
735  * replog moddn param structure
736  */
737 struct replog_moddn {
738         char *newrdn;
739         int     deloldrdn;
740         char *newsup;
741 };
742
743 /*
744  * Backend-info
745  * represents a backend 
746  */
747
748 typedef struct slap_backend_info BackendInfo;   /* per backend type */
749 typedef struct slap_backend_db BackendDB;               /* per backend database */
750
751 LIBSLAPD_F (int) nBackendInfo;
752 LIBSLAPD_F (int) nBackendDB;
753 LIBSLAPD_F (BackendInfo *) backendInfo;
754 LIBSLAPD_F (BackendDB *) backendDB;
755
756 LIBSLAPD_F (int) slapMode;      
757 #define SLAP_UNDEFINED_MODE     0x0000
758 #define SLAP_SERVER_MODE        0x0001
759 #define SLAP_TOOL_MODE          0x0002
760 #define SLAP_MODE                       0x0003
761
762 #define SLAP_TRUNCATE_MODE      0x0100
763 #ifdef SLAPD_BDB2
764 #define SLAP_TIMED_MODE         0x1000
765 #endif
766
767 /* temporary aliases */
768 typedef BackendDB Backend;
769 #define nbackends nBackendDB
770 #define backends backendDB
771
772 struct slap_backend_db {
773         BackendInfo     *bd_info;       /* pointer to shared backend info */
774
775         /* BackendInfo accessors */
776 #define         be_config       bd_info->bi_db_config
777 #define         be_type         bd_info->bi_type
778
779 #define         be_bind         bd_info->bi_op_bind
780 #define         be_unbind       bd_info->bi_op_unbind
781 #define         be_add          bd_info->bi_op_add
782 #define         be_compare      bd_info->bi_op_compare
783 #define         be_delete       bd_info->bi_op_delete
784 #define         be_modify       bd_info->bi_op_modify
785 #define         be_modrdn       bd_info->bi_op_modrdn
786 #define         be_search       bd_info->bi_op_search
787
788 #define         be_extended     bd_info->bi_extended
789
790 #define         be_release      bd_info->bi_entry_release_rw
791 #define         be_group        bd_info->bi_acl_group
792
793 #define         be_controls     bd_info->bi_controls
794
795 #define         be_connection_init      bd_info->bi_connection_init
796 #define         be_connection_destroy   bd_info->bi_connection_destroy
797
798 #ifdef SLAPD_TOOLS
799 #define         be_entry_open bd_info->bi_tool_entry_open
800 #define         be_entry_close bd_info->bi_tool_entry_close
801 #define         be_entry_first bd_info->bi_tool_entry_first
802 #define         be_entry_next bd_info->bi_tool_entry_next
803 #define         be_entry_get bd_info->bi_tool_entry_get
804 #define         be_entry_put bd_info->bi_tool_entry_put
805 #define         be_index_attr bd_info->bi_tool_index_attr
806 #define         be_index_change bd_info->bi_tool_index_change
807 #define         be_sync bd_info->bi_tool_sync
808 #endif
809
810 #ifdef HAVE_CYRUS_SASL
811 #define         be_sasl_authorize bd_info->bi_sasl_authorize
812 #define         be_sasl_getsecret bd_info->bi_sasl_getsecret
813 #define         be_sasl_putsecret bd_info->bi_sasl_putsecret
814 #endif
815
816         /* these should be renamed from be_ to bd_ */
817         char    **be_suffix;    /* the DN suffixes of data in this backend */
818         char    **be_nsuffix;   /* the normalized DN suffixes in this backend */
819         char    **be_suffixAlias; /* pairs of DN suffix aliases and deref values */
820         char    *be_root_dn;    /* the magic "root" dn for this db      */
821         char    *be_root_ndn;   /* the magic "root" normalized dn for this db   */
822         struct berval be_root_pw;       /* the magic "root" password for this db        */
823         int     be_readonly;    /* 1 => db is in "read only" mode          */
824         unsigned int be_max_deref_depth;       /* limit for depth of an alias deref  */
825         int     be_sizelimit;   /* size limit for this backend             */
826         int     be_timelimit;   /* time limit for this backend             */
827         AccessControl *be_acl;  /* access control list for this backend    */
828         slap_access_t   be_dfltaccess;  /* access given if no acl matches          */
829         char    **be_replica;   /* replicas of this backend (in master)    */
830         char    *be_replogfile; /* replication log file (in master)        */
831         char    *be_update_ndn; /* allowed to make changes (in replicas) */
832         struct berval **be_update_refs; /* where to refer modifying clients to */
833         int     be_lastmod;     /* keep track of lastmodified{by,time}     */
834
835         char    *be_realm;
836
837         void    *be_private;    /* anything the backend database needs     */
838 };
839
840 struct slap_conn;
841 struct slap_op;
842
843 typedef int (*SLAP_EXTENDED_FN) LDAP_P((
844     Backend             *be,
845     struct slap_conn            *conn,
846     struct slap_op              *op,
847         const char              *reqoid,
848     struct berval * reqdata,
849         char            **rspoid,
850     struct berval ** rspdata,
851         LDAPControl *** rspctrls,
852         const char **   text,
853         struct berval *** refs ));
854
855 struct slap_backend_info {
856         char    *bi_type;       /* type of backend */
857
858         /*
859          * per backend type routines:
860          * bi_init: called to allocate a backend_info structure,
861          *              called once BEFORE configuration file is read.
862          *              bi_init() initializes this structure hence is
863          *              called directly from be_initialize()
864          * bi_config: called per 'backend' specific option
865          *              all such options must before any 'database' options
866          *              bi_config() is called only from read_config()
867          * bi_open: called to open each database, called
868          *              once AFTER configuration file is read but
869          *              BEFORE any bi_db_open() calls.
870          *              bi_open() is called from backend_startup()
871          * bi_close: called to close each database, called
872          *              once during shutdown after all bi_db_close calls.
873          *              bi_close() is called from backend_shutdown()
874          * bi_destroy: called to destroy each database, called
875          *              once during shutdown after all bi_db_destroy calls.
876          *              bi_destory() is called from backend_destroy()
877          */
878         int (*bi_init)  LDAP_P((BackendInfo *bi));
879         int     (*bi_config) LDAP_P((BackendInfo *bi,
880                 const char *fname, int lineno, int argc, char **argv ));
881         int (*bi_open) LDAP_P((BackendInfo *bi));
882         int (*bi_close) LDAP_P((BackendInfo *bi));
883         int (*bi_destroy) LDAP_P((BackendInfo *bi));
884
885         /*
886          * per database routines:
887          * bi_db_init: called to initialize each database,
888          *      called upon reading 'database <type>' 
889          *      called only from backend_db_init()
890          * bi_db_config: called to configure each database,
891          *  called per database to handle per database options
892          *      called only from read_config()
893          * bi_db_open: called to open each database
894          *      called once per database immediately AFTER bi_open()
895          *      calls but before daemon startup.
896          *  called only by backend_startup()
897          * bi_db_close: called to close each database
898          *      called once per database during shutdown but BEFORE
899          *  any bi_close call.
900          *  called only by backend_shutdown()
901          * bi_db_destroy: called to destroy each database
902          *  called once per database during shutdown AFTER all
903          *  bi_close calls but before bi_destory calls.
904          *  called only by backend_destory()
905          */
906         int (*bi_db_init) LDAP_P((Backend *bd));
907         int     (*bi_db_config) LDAP_P((Backend *bd,
908                 const char *fname, int lineno, int argc, char **argv ));
909         int (*bi_db_open) LDAP_P((Backend *bd));
910         int (*bi_db_close) LDAP_P((Backend *bd));
911         int (*bi_db_destroy) LDAP_P((Backend *db));
912
913         /* LDAP Operations Handling Routines */
914         int     (*bi_op_bind)  LDAP_P(( BackendDB *bd,
915                 struct slap_conn *c, struct slap_op *o,
916                 const char *dn, const char *ndn, int method,
917                 struct berval *cred, char** edn ));
918         int (*bi_op_unbind) LDAP_P((BackendDB *bd,
919                 struct slap_conn *c, struct slap_op *o ));
920         int     (*bi_op_search) LDAP_P((BackendDB *bd,
921                 struct slap_conn *c, struct slap_op *o,
922                 const char *base, const char *nbase,
923                 int scope, int deref,
924                 int slimit, int tlimit,
925                 Filter *f, const char *filterstr,
926                 char **attrs, int attrsonly));
927 #ifdef SLAPD_SCHEMA_NOT_COMPAT
928         int     (*bi_op_compare)LDAP_P((BackendDB *bd,
929                 struct slap_conn *c, struct slap_op *o,
930                 const char *dn, const char *ndn,
931                 AttributeAssertion *ava));
932 #else
933         int     (*bi_op_compare)LDAP_P((BackendDB *bd,
934                 struct slap_conn *c, struct slap_op *o,
935                 const char *dn, const char *ndn,
936                 Ava *ava));
937 #endif
938         int     (*bi_op_modify) LDAP_P((BackendDB *bd,
939                 struct slap_conn *c, struct slap_op *o,
940                 const char *dn, const char *ndn, Modifications *m));
941         int     (*bi_op_modrdn) LDAP_P((BackendDB *bd,
942                 struct slap_conn *c, struct slap_op *o,
943                 const char *dn, const char *ndn,
944                 const char *newrdn, int deleteoldrdn,
945                 const char *newSuperior));
946         int     (*bi_op_add)    LDAP_P((BackendDB *bd,
947                 struct slap_conn *c, struct slap_op *o,
948                 Entry *e));
949         int     (*bi_op_delete) LDAP_P((BackendDB *bd,
950                 struct slap_conn *c, struct slap_op *o,
951                 const char *dn, const char *ndn));
952         int     (*bi_op_abandon) LDAP_P((BackendDB *bd,
953                 struct slap_conn *c, struct slap_op *o,
954                 ber_int_t msgid));
955
956         /* Extended Operations Helper */
957         SLAP_EXTENDED_FN bi_extended;
958
959         /* Auxilary Functions */
960         int     (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
961
962 #ifdef SLAPD_SCHEMA_NOT_COMPAT
963         int     (*bi_acl_group)  LDAP_P((Backend *bd,
964                 Entry *e, const char *bdn, const char *edn,
965                 const char *objectclassValue,
966                 AttributeDescription *group_at ));
967 #else
968         int     (*bi_acl_group)  LDAP_P((Backend *bd,
969                 Entry *e, const char *bdn, const char *edn,
970                 const char *objectclassValue,
971                 const char *group_at ));
972 #endif
973
974         int     (*bi_connection_init) LDAP_P((BackendDB *bd,
975                 struct slap_conn *c));
976         int     (*bi_connection_destroy) LDAP_P((BackendDB *bd,
977                 struct slap_conn *c));
978
979         /* hooks for slap tools */
980         int (*bi_tool_entry_open) LDAP_P(( BackendDB *be, int mode ));
981         int (*bi_tool_entry_close) LDAP_P(( BackendDB *be ));
982         ID (*bi_tool_entry_first) LDAP_P(( BackendDB *be ));
983         ID (*bi_tool_entry_next) LDAP_P(( BackendDB *be ));
984         Entry* (*bi_tool_entry_get) LDAP_P(( BackendDB *be, ID id ));
985         ID (*bi_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e ));
986 #ifdef SLAPD_SCHEMA_NOT_COMPAT
987         int (*bi_tool_index_attr) LDAP_P(( BackendDB *be,
988                 AttributeDescription *desc ));
989         int (*bi_tool_index_change) LDAP_P(( BackendDB *be,
990                 AttributeDescription *desc,
991                 struct berval **bv, ID id, int op ));
992 #else
993         int (*bi_tool_index_attr) LDAP_P(( BackendDB *be,
994                 char* type ));
995         int (*bi_tool_index_change) LDAP_P(( BackendDB *be,
996                 char* type,
997                 struct berval **bv, ID id, int op ));
998 #endif
999         int (*bi_tool_sync) LDAP_P(( BackendDB *be ));
1000
1001 #ifdef HAVE_CYRUS_SASL
1002         int (*bi_sasl_authorize) LDAP_P(( BackendDB *be,
1003                 const char *authnid, const char *authzid,
1004                 const char **canon_authzid, const char **errstr ));
1005         int (*bi_sasl_getsecret) LDAP_P(( BackendDB *be,
1006                 const char *mechanism, const char *authzid,
1007                 const char *realm, sasl_secret_t **secret ));
1008         int (*bi_sasl_putsecret) LDAP_P(( BackendDB *be,
1009                 const char *mechanism, const char *auth_identity,
1010                 const char *realm, const sasl_secret_t *secret ));
1011 #endif /* HAVE_CYRUS_SASL */
1012
1013 #define SLAP_INDEX_ADD_OP               0x0001
1014 #define SLAP_INDEX_DELETE_OP    0x0002
1015
1016         char **bi_controls;             /* supported controls */
1017
1018         unsigned int bi_nDB;    /* number of databases of this type */
1019         void    *bi_private;    /* anything the backend type needs */
1020 };
1021
1022 /*
1023  * represents an operation pending from an ldap client
1024  */
1025
1026 typedef struct slap_op {
1027         ber_int_t       o_opid;         /* id of this operation           */
1028         ber_int_t       o_msgid;        /* msgid of the request           */
1029
1030         ldap_pvt_thread_t       o_tid;          /* thread handling this op        */
1031
1032         BerElement      *o_ber;         /* ber of the request             */
1033
1034         ber_tag_t       o_tag;          /* tag of the request             */
1035         time_t          o_time;         /* time op was initiated          */
1036
1037 #ifdef SLAP_AUTHZID
1038         /* should only be used for reporting purposes */
1039         char    *o_authc_dn;    /* authentication DN */
1040
1041         /* should be used as the DN of the User */
1042         char    *o_authz_dn;    /* authorization DN */
1043         char    *o_authz_ndn;   /* authorizaiton NDN */
1044
1045 #else
1046         char            *o_dn;          /* dn bound when op was initiated */
1047         char            *o_ndn;         /* normalized dn bound when op was initiated */
1048 #endif
1049
1050         ber_int_t       o_protocol;     /* version of the LDAP protocol used by client */
1051         ber_tag_t       o_authtype;     /* auth method used to bind dn    */
1052                                         /* values taken from ldap.h       */
1053                                         /* LDAP_AUTH_*                    */
1054         char            *o_authmech; /* SASL mechanism used to bind dn */
1055
1056         LDAPControl     **o_ctrls;       /* controls */
1057
1058         unsigned long   o_connid; /* id of conn initiating this op  */
1059
1060 #ifdef LDAP_CONNECTIONLESS
1061         int             o_cldap;        /* != 0 if this came in via CLDAP */
1062         struct sockaddr o_clientaddr;   /* client address if via CLDAP    */
1063         char            o_searchbase;   /* search base if via CLDAP       */
1064 #endif
1065
1066         ldap_pvt_thread_mutex_t o_abandonmutex; /* protects o_abandon  */
1067         int             o_abandon;      /* abandon flag */
1068
1069         struct slap_op  *o_next;        /* next operation in list         */
1070         void    *o_private;     /* anything the backend needs     */
1071 } Operation;
1072
1073 /*
1074  * represents a connection from an ldap client
1075  */
1076
1077 typedef struct slap_conn {
1078         int                     c_struct_state; /* structure management state */
1079         int                     c_conn_state;   /* connection state */
1080
1081         ldap_pvt_thread_mutex_t c_mutex; /* protect the connection */
1082         Sockbuf         *c_sb;                  /* ber connection stuff           */
1083
1084         /* only can be changed by connect_init */
1085         time_t          c_starttime;    /* when the connection was opened */
1086         time_t          c_activitytime; /* when the connection was last used */
1087         unsigned long           c_connid;       /* id of this connection for stats*/
1088
1089         char            *c_listener_url;        /* listener URL */
1090         char            *c_peer_domain; /* DNS name of client */
1091         char            *c_peer_name;   /* peer name (trans=addr:port) */
1092         char            *c_sock_name;   /* sock name (trans=addr:port) */
1093
1094         /* only can be changed by binding thread */
1095         int             c_sasl_bind_in_progress;        /* multi-op bind in progress */
1096         char    *c_sasl_bind_mech;                      /* mech in progress */
1097 #ifdef HAVE_CYRUS_SASL
1098         sasl_conn_t     *c_sasl_bind_context;   /* Cyrus SASL state data */
1099 #endif
1100
1101         /* authentication backend */
1102         Backend *c_authc_backend;
1103
1104         /* authorization backend - normally same as c_authc_backend */
1105         Backend *c_authz_backend;
1106
1107 #ifdef SLAP_AUTHZID
1108         /* authentication backend */
1109         /* should only be used for reporting purposes */
1110         char    *c_authc_dn;    /* authentication DN */
1111
1112         /* should be used as the DN of the User */
1113         char    *c_authz_dn;    /* authorization DN */
1114         char    *c_authz_ndn;   /* authorization NDN */
1115
1116 #else
1117         char    *c_cdn;         /* DN provided by the client */
1118         char    *c_dn;          /* DN bound to this conn  */
1119 #endif
1120
1121         ber_int_t       c_protocol;     /* version of the LDAP protocol used by client */
1122         ber_tag_t       c_authtype;/* auth method used to bind c_dn  */
1123         char    *c_authmech;    /* SASL mechanism used to bind c_dn */
1124
1125         Operation       *c_ops;                 /* list of operations being processed */
1126         Operation       *c_pending_ops; /* list of pending operations */
1127
1128         ldap_pvt_thread_mutex_t c_write_mutex;  /* only one pdu written at a time */
1129         ldap_pvt_thread_cond_t  c_write_cv;             /* used to wait for sd write-ready*/
1130
1131         BerElement      *c_currentber;  /* ber we're attempting to read */
1132         int             c_writewaiter;  /* true if writer is waiting */
1133
1134 #ifdef HAVE_TLS
1135         int     c_is_tls;               /* true if this LDAP over raw TLS */
1136         int     c_needs_tls_accept;     /* true if SSL_accept should be called */
1137 #endif
1138
1139         long    c_n_ops_received;               /* num of ops received (next op_id) */
1140         long    c_n_ops_executing;      /* num of ops currently executing */
1141         long    c_n_ops_pending;                /* num of ops pending execution */
1142         long    c_n_ops_completed;      /* num of ops completed */
1143
1144         long    c_n_get;                /* num of get calls */
1145         long    c_n_read;               /* num of read calls */
1146         long    c_n_write;              /* num of write calls */
1147 } Connection;
1148
1149 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
1150 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )  \
1151         do { \
1152                 if ( ldap_debug & (level) ) \
1153                         fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
1154                 if ( ldap_syslog & (level) ) \
1155                         syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \
1156                                 (arg2), (arg3) ); \
1157         } while (0)
1158 #else
1159 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
1160 #endif
1161
1162 LDAP_END_DECL
1163
1164 #include "proto-slap.h"
1165
1166 #endif /* _SLAP_H_ */