]> git.sur5r.net Git - openldap/blob - servers/slapd/slap.h
Add limited LDAP_INVALID_DN_SYNTAX support. dn_normalize{,_case}() now returns
[openldap] / servers / slapd / slap.h
1 /* slap.h - stand alone ldap server include file */
2
3 #ifndef _SLDAPD_H_
4 #define _SLDAPD_H_
5
6 #include <ac/stdlib.h>
7
8 #include <sys/types.h>
9 #include <ac/syslog.h>
10 #include <ac/regex.h>
11 #include <ac/socket.h>
12 #include <ac/time.h>
13
14 #include "avl.h"
15
16 #ifndef ldap_debug
17 #define ldap_debug slap_debug
18 #endif
19
20
21 #include "ldap_log.h"
22
23 #include "lber.h"
24 #include "ldap.h"
25
26 #include "ldap_schema.h"
27
28 #include "ldap_pvt_thread.h"
29 #include "ldif.h"
30
31 LDAP_BEGIN_DECL
32
33 #ifdef f_next
34 #undef f_next /* name conflict between sys/file.h on SCO and struct filter */
35 #endif
36
37 #define SERVICE_NAME  OPENLDAP_PACKAGE "-slapd"
38
39 /* LDAPMod.mod_op value ===> Must be kept in sync with ldap.h!
40  *
41  * This is a value used internally by the backends. It is needed to allow
42  * adding values that already exist without getting an error as required by
43  * modrdn when the new rdn was already an attribute value itself.
44  * JCG 05/1999 (gomez@engr.sgi.com)
45  */
46 #define LDAP_MOD_SOFTADD        0x1000
47
48 #ifdef DNS_DN
49 #define DN_DNS  0
50 #define DN_X500 1
51 #endif
52
53 #define ON      1
54 #define OFF     (-1)
55 #define UNDEFINED 0
56
57 #define MAXREMATCHES 10
58
59 #define DNSEPARATOR(c)  ((c) == ',' || (c) == ';')
60 #define SEPARATOR(c)    ((c) == ',' || (c) == ';' || (c) == '+')
61 #define SPACE(c)        ((c) == ' ' || (c) == '\n')
62 #define NEEDSESCAPE(c)  ((c) == '\\' || (c) == '"')
63
64 #define SLAP_SCHERR_OUTOFMEM            1
65 #define SLAP_SCHERR_CLASS_NOT_FOUND     2
66 #define SLAP_SCHERR_ATTR_NOT_FOUND      3
67 #define SLAP_SCHERR_DUP_CLASS           4
68 #define SLAP_SCHERR_DUP_ATTR            5
69 #define SLAP_SCHERR_DUP_SYNTAX          6
70 #define SLAP_SCHERR_DUP_RULE            7
71 #define SLAP_SCHERR_NO_NAME             8
72 #define SLAP_SCHERR_ATTR_INCOMPLETE     9
73 #define SLAP_SCHERR_MR_NOT_FOUND        10
74 #define SLAP_SCHERR_SYN_NOT_FOUND       11
75 #define SLAP_SCHERR_MR_INCOMPLETE       12
76
77 extern int slap_debug;
78
79 struct slap_op;
80 struct slap_conn;
81
82 /*
83  * represents an attribute value assertion (i.e., attr=value)
84  */
85 typedef struct slap_ava {
86         char            *ava_type;
87         struct berval   ava_value;
88 } Ava;
89
90 typedef struct slap_mra {
91         char    *mra_rule;
92         char    *mra_type;
93         char    *mra_value;
94         int             mra_dnattrs;
95 } Mra;
96
97 /*
98  * represents a search filter
99  */
100 typedef struct slap_filter {
101         ber_tag_t       f_choice;       /* values taken from ldap.h */
102
103         union f_un_u {
104                 /* present */
105                 char            *f_un_type;
106
107                 /* equality, lessorequal, greaterorequal, approx */
108                 Ava             f_un_ava;
109
110                 /* extensible */
111                 Mra             f_un_fra;       
112
113                 /* and, or, not */
114                 struct slap_filter      *f_un_complex;
115
116                 /* substrings */
117                 struct sub {
118                         char    *f_un_sub_type;
119                         char    *f_un_sub_initial;
120                         char    **f_un_sub_any;
121                         char    *f_un_sub_final;
122                 } f_un_sub;
123         } f_un;
124 #define f_type          f_un.f_un_type
125 #define f_ava           f_un.f_un_ava
126 #define f_avtype        f_un.f_un_ava.ava_type
127 #define f_avvalue       f_un.f_un_ava.ava_value
128 #define f_mra           f_un.f_un_mra
129 #define f_mrtype        f_un.f_un_mra.mra_type
130 #define f_mrvalue       f_un.f_un_mra.mra_value
131 #define f_mrdnaddrs     f_un.f_un_mra.mra_dnattrs
132 #define f_and           f_un.f_un_complex
133 #define f_or            f_un.f_un_complex
134 #define f_not           f_un.f_un_complex
135 #define f_list          f_un.f_un_complex
136 #define f_sub           f_un.f_un_sub
137 #define f_sub_type      f_un.f_un_sub.f_un_sub_type
138 #define f_sub_initial   f_un.f_un_sub.f_un_sub_initial
139 #define f_sub_any       f_un.f_un_sub.f_un_sub_any
140 #define f_sub_final     f_un.f_un_sub.f_un_sub_final
141
142         struct slap_filter      *f_next;
143 } Filter;
144
145 /*
146  * represents an attribute (type + values + syntax)
147  */
148 typedef struct slap_attr {
149         char            *a_type;
150         struct berval   **a_vals;
151         int             a_syntax;
152         struct slap_attr        *a_next;
153 } Attribute;
154
155 /*
156  * the attr_syntax() routine returns one of these values
157  * telling what kind of syntax an attribute supports.
158  */
159 #define SYNTAX_CIS      0x01    /* case insensitive string              */
160 #define SYNTAX_CES      0x02    /* case sensitive string                */
161 #define SYNTAX_BIN      0x04    /* binary data                          */
162 #define SYNTAX_TEL      0x08    /* telephone number string              */
163 #define SYNTAX_DN       0x10    /* dn string                            */
164
165 /*
166  * the id used in the indexes to refer to an entry
167  */
168 typedef unsigned long   ID;
169 #define NOID    ((ID)~0)
170
171 /*
172  * represents an entry in core
173  */
174 typedef struct slap_entry {
175         /*
176          * The ID field should only be changed before entry is
177          * inserted into a cache.  The ID value is backend
178          * specific.
179          */
180         ID              e_id;
181
182         char            *e_dn;          /* DN of this entry */
183         char            *e_ndn;         /* normalized DN of this entry */
184         Attribute       *e_attrs;       /* list of attributes + values */
185
186         /* for use by the backend for any purpose */
187         void*   e_private;
188 } Entry;
189
190 /*
191  * represents an access control list
192  */
193
194 /* the "by" part */
195 typedef struct slap_access {
196
197 #define ACL_NONE                0x0001
198 #define ACL_AUTH                0x0004
199 #define ACL_COMPARE             0x0008
200 #define ACL_SEARCH              0x0010
201 #define ACL_READ                0x0020
202 #define ACL_WRITE               0x0040
203 #define ACL_PRIV_MASK   0x00ff
204
205 #define ACL_SELF                0x4000
206 #define ACL_INVALID             (-1)
207
208 #define ACL_IS(a,lvl)   (((a) & (lvl)) == (lvl))
209
210 #define ACL_IS_NONE(a)          ACL_IS((a),ACL_SELF)
211 #define ACL_IS_AUTH(a)          ACL_IS((a),ACL_AUTH)
212 #define ACL_IS_COMPARE(a)       ACL_IS((a),ACL_COMPARE)
213 #define ACL_IS_SEARCH(a)        ACL_IS((a),ACL_SEARCH)
214 #define ACL_IS_READ(a)          ACL_IS((a),ACL_READ)
215 #define ACL_IS_WRITE(a)         ACL_IS((a),ACL_WRITE)
216 #define ACL_IS_SELF(a)          ACL_IS((a),ACL_SELF)
217 #define ACL_IS_INVALID(a)       ((a) == ACL_INVALID)
218
219 #define ACL_CLR(a)                      ((a) = 0)
220 #define ACL_SET(a,lvl)          ((a) |= (lvl))
221 #define ACL_SET_NONE(a)         ACL_SET((a),ACL_SELF)
222 #define ACL_SET_AUTH(a)         ACL_SET((a),ACL_AUTH)
223 #define ACL_SET_COMPARE(a)      ACL_SET((a),ACL_COMPARE)
224 #define ACL_SET_SEARCH(a)       ACL_SET((a),ACL_SEARCH)
225 #define ACL_SET_READ(a)         ACL_SET((a),ACL_READ)
226 #define ACL_SET_WRITE(a)        ACL_SET((a),ACL_WRITE)
227 #define ACL_SET_SELF(a)         ACL_SET((a),ACL_SELF)
228 #define ACL_SET_INVALID(a)      ((a) = ACL_INVALID)
229
230 #define ACL_PRIV(a)                     ((a) & ACL_PRIV_MASK)
231 #define ACL_GRANT(a,lvl)        (ACL_PRIV(a) >= (lvl))
232
233         int                     a_access;
234
235         char            *a_dn_pat;
236         char            *a_dn_at;
237
238         char            *a_peername_pat;
239         char            *a_sockname_pat;
240
241         char            *a_domain_pat;
242         char            *a_sockurl_pat;
243
244         /* ACL Groups */
245         char            *a_group_pat;
246         char            *a_group_oc;
247         char            *a_group_at;
248
249         struct slap_access      *a_next;
250 } Access;
251
252 /* the "to" part */
253 typedef struct slap_acl {
254         /* "to" part: the entries this acl applies to */
255         Filter          *acl_filter;
256         regex_t         acl_dn_re;
257         char            *acl_dn_pat;
258         char            **acl_attrs;
259
260         /* "by" part: list of who has what access to the entries */
261         Access  *acl_access;
262
263         struct slap_acl *acl_next;
264 } AccessControl;
265
266 /*
267  * A list of LDAPMods
268  */
269 typedef struct ldapmodlist {
270         struct ldapmod ml_mod;
271         struct ldapmodlist *ml_next;
272 #define ml_op           ml_mod.mod_op
273 #define ml_type         ml_mod.mod_type
274 #define ml_values       ml_mod.mod_values
275 #define ml_bvalues      ml_mod.mod_bvalues
276 } LDAPModList;
277
278 /*
279  * represents schema information for a database
280  */
281 typedef int slap_syntax_check_func LDAP_P((struct berval * val));
282
283 typedef struct slap_syntax {
284         LDAP_SYNTAX                     ssyn_syn;
285         slap_syntax_check_func          *ssyn_check;
286         struct slap_syntax              *ssyn_next;
287 } Syntax;
288 #define ssyn_oid                        ssyn_syn.syn_oid
289 #define ssyn_desc                       ssyn_syn.syn_desc
290
291 typedef int slap_mr_normalize_func LDAP_P((struct berval * val, struct berval **normalized));
292 typedef int slap_mr_compare_func LDAP_P((struct berval * val1, struct berval * val2));
293
294 typedef struct slap_matching_rule {
295         LDAP_MATCHING_RULE              smr_mrule;
296         slap_mr_normalize_func          *smr_normalize;
297         slap_mr_compare_func            *smr_compare;
298         Syntax                          *smr_syntax;
299         struct slap_matching_rule       *smr_next;
300 } MatchingRule;
301 #define smr_oid                         smr_mrule.mr_oid
302 #define smr_names                       smr_mrule.mr_names
303 #define smr_desc                        smr_mrule.mr_desc
304 #define smr_obsolete                    smr_mrule.mr_obsolete
305 #define smr_syntax_oid                  smr_mrule.mr_syntax_oid
306
307 typedef struct slap_attribute_type {
308         LDAP_ATTRIBUTE_TYPE             sat_atype;
309         struct slap_attribute_type      *sat_sup;
310         struct slap_attribute_type      **sat_subtypes;
311         MatchingRule                    *sat_equality;
312         MatchingRule                    *sat_ordering;
313         MatchingRule                    *sat_substr;
314         Syntax                          *sat_syntax;
315         /* The next one is created to help in the transition */
316         int                             sat_syntax_compat;
317         struct slap_attribute_type      *sat_next;
318 } AttributeType;
319 #define sat_oid                 sat_atype.at_oid
320 #define sat_names               sat_atype.at_names
321 #define sat_desc                sat_atype.at_desc
322 #define sat_obsolete            sat_atype.at_obsolete
323 #define sat_sup_oid             sat_atype.at_sup_oid
324 #define sat_equality_oid        sat_atype.at_equality_oid
325 #define sat_ordering_oid        sat_atype.at_ordering_oid
326 #define sat_substr_oid          sat_atype.at_substr_oid
327 #define sat_syntax_oid          sat_atype.at_syntax_oid
328 #define sat_syntax_len          sat_atype.at_syntax_len
329 #define sat_single_value        sat_atype.at_single_value
330 #define sat_collective          sat_atype.at_collective
331 #define sat_no_user_mods        sat_atype.at_no_user_mods
332 #define sat_usage               sat_atype.at_usage
333
334 typedef struct slap_object_class {
335         LDAP_OBJECT_CLASS               soc_oclass;
336         struct slap_object_class        **soc_sups;
337         AttributeType                   **soc_required;
338         AttributeType                   **soc_allowed;
339         struct slap_object_class        *soc_next;
340 } ObjectClass;
341 #define soc_oid                 soc_oclass.oc_oid
342 #define soc_names               soc_oclass.oc_names
343 #define soc_desc                soc_oclass.oc_desc
344 #define soc_obsolete            soc_oclass.oc_obsolete
345 #define soc_sup_oids            soc_oclass.oc_sup_oids
346 #define soc_kind                soc_oclass.oc_kind
347 #define soc_at_oids_must        soc_oclass.oc_at_oids_must
348 #define soc_at_oids_may         soc_oclass.oc_at_oids_may
349
350 /*
351  * Backend-info
352  * represents a backend 
353  */
354
355 typedef struct slap_backend_info BackendInfo;   /* per backend type */
356 typedef struct slap_backend_db BackendDB;               /* per backend database */
357
358 extern int nBackendInfo;
359 extern int nBackendDB;
360 extern BackendInfo      *backendInfo;
361 extern BackendDB        *backendDB;
362
363 extern int                      slapMode;       
364 #define SLAP_UNDEFINED_MODE     0
365 #define SLAP_SERVER_MODE        1
366 #define SLAP_TOOL_MODE          2
367 #ifdef SLAPD_BDB2
368 #  define SLAP_TIMEDSERVER_MODE  3
369 #  define SLAP_TOOLID_MODE       4
370 #endif
371
372 /* temporary aliases */
373 typedef BackendDB Backend;
374 #define nbackends nBackendDB
375 #define backends backendDB
376
377 struct slap_backend_db {
378         BackendInfo     *bd_info;       /* pointer to shared backend info */
379
380         /* BackendInfo accessors */
381 #define         be_config       bd_info->bi_db_config
382 #define         be_type         bd_info->bi_type
383
384 #define         be_bind         bd_info->bi_op_bind
385 #define         be_unbind       bd_info->bi_op_unbind
386 #define         be_add          bd_info->bi_op_add
387 #define         be_compare      bd_info->bi_op_compare
388 #define         be_delete       bd_info->bi_op_delete
389 #define         be_modify       bd_info->bi_op_modify
390 #define         be_modrdn       bd_info->bi_op_modrdn
391 #define         be_search       bd_info->bi_op_search
392
393 #define         be_release      bd_info->bi_entry_release_rw
394 #define         be_group        bd_info->bi_acl_group
395
396 #define         be_connection_init      bd_info->bi_connection_init
397 #define         be_connection_destroy   bd_info->bi_connection_destroy
398
399
400         /* these should be renamed from be_ to bd_ */
401         char    **be_suffix;    /* the DN suffixes of data in this backend */
402         char    **be_nsuffix;   /* the normalized DN suffixes in this backend */
403         char    *be_root_dn;    /* the magic "root" dn for this db      */
404         char    *be_root_ndn;   /* the magic "root" normalized dn for this db   */
405         char    *be_root_pw;    /* the magic "root" password for this db        */
406         int     be_readonly;    /* 1 => db is in "read only" mode          */
407         unsigned int be_max_deref_depth;       /* limit for depth of an alias deref  */
408         int     be_sizelimit;   /* size limit for this backend             */
409         int     be_timelimit;   /* time limit for this backend             */
410         AccessControl *be_acl;  /* access control list for this backend    */
411         int     be_dfltaccess;  /* access given if no acl matches          */
412         char    **be_replica;   /* replicas of this backend (in master)    */
413         char    *be_replogfile; /* replication log file (in master)        */
414         char    *be_update_ndn; /* allowed to make changes (in replicas)   */
415         struct berval **be_update_refs; /* where to refer modifying clients to */
416         int     be_lastmod;     /* keep track of lastmodified{by,time}     */
417
418         char    *be_realm;
419
420         void    *be_private;    /* anything the backend database needs     */
421 };
422
423 struct slap_backend_info {
424         char    *bi_type;       /* type of backend */
425
426         /*
427          * per backend type routines:
428          * bi_init: called to allocate a backend_info structure,
429          *              called once BEFORE configuration file is read.
430          *              bi_init() initializes this structure hence is
431          *              called directly from be_initialize()
432          * bi_config: called per 'backend' specific option
433          *              all such options must before any 'database' options
434          *              bi_config() is called only from read_config()
435          * bi_open: called to open each database, called
436          *              once AFTER configuration file is read but
437          *              BEFORE any bi_db_open() calls.
438          *              bi_open() is called from backend_startup()
439          * bi_close: called to close each database, called
440          *              once during shutdown after all bi_db_close calls.
441          *              bi_close() is called from backend_shutdown()
442          * bi_destroy: called to destroy each database, called
443          *              once during shutdown after all bi_db_destroy calls.
444          *              bi_destory() is called from backend_destroy()
445          */
446         int (*bi_init)  LDAP_P((BackendInfo *bi));
447         int     (*bi_config) LDAP_P((BackendInfo *bi,
448                 char *fname, int lineno, int argc, char **argv ));
449         int (*bi_open) LDAP_P((BackendInfo *bi));
450         int (*bi_close) LDAP_P((BackendInfo *bi));
451         int (*bi_destroy) LDAP_P((BackendInfo *bi));
452
453         /*
454          * per database routines:
455          * bi_db_init: called to initialize each database,
456          *      called upon reading 'database <type>' 
457          *      called only from backend_db_init()
458          * bi_db_config: called to configure each database,
459          *  called per database to handle per database options
460          *      called only from read_config()
461          * bi_db_open: called to open each database
462          *      called once per database immediately AFTER bi_open()
463          *      calls but before daemon startup.
464          *  called only by backend_startup()
465          * bi_db_close: called to close each database
466          *      called once per database during shutdown but BEFORE
467          *  any bi_close call.
468          *  called only by backend_shutdown()
469          * bi_db_destroy: called to destroy each database
470          *  called once per database during shutdown AFTER all
471          *  bi_close calls but before bi_destory calls.
472          *  called only by backend_destory()
473          */
474         int (*bi_db_init) LDAP_P((Backend *bd));
475         int     (*bi_db_config) LDAP_P((Backend *bd,
476                 char *fname, int lineno, int argc, char **argv ));
477         int (*bi_db_open) LDAP_P((Backend *bd));
478         int (*bi_db_close) LDAP_P((Backend *bd));
479         int (*bi_db_destroy) LDAP_P((Backend *db));
480
481         /* LDAP Operations Handling Routines */
482         int     (*bi_op_bind)  LDAP_P(( BackendDB *bd,
483                 struct slap_conn *c, struct slap_op *o,
484                 char *dn, int method, char* mechanism,
485                 struct berval *cred, char** edn ));
486         int (*bi_op_unbind) LDAP_P((BackendDB *bd,
487                 struct slap_conn *c, struct slap_op *o ));
488         int     (*bi_op_search) LDAP_P((BackendDB *bd,
489                 struct slap_conn *c, struct slap_op *o,
490                 char *base, int scope, int deref,
491                 int slimit, int tlimit,
492                 Filter *f, char *filterstr, char **attrs,
493                 int attrsonly));
494         int     (*bi_op_compare)LDAP_P((BackendDB *bd,
495                 struct slap_conn *c, struct slap_op *o,
496                 char *dn, Ava *ava));
497         int     (*bi_op_modify) LDAP_P((BackendDB *bd,
498                 struct slap_conn *c, struct slap_op *o,
499                 char *dn, LDAPModList *m));
500         int     (*bi_op_modrdn) LDAP_P((BackendDB *bd,
501                 struct slap_conn *c, struct slap_op *o,
502                 char *dn, char *newrdn, int deleteoldrdn,
503                 char *newSuperior));
504         int     (*bi_op_add)    LDAP_P((BackendDB *bd,
505                 struct slap_conn *c, struct slap_op *o,
506                 Entry *e));
507         int     (*bi_op_delete) LDAP_P((BackendDB *bd,
508                 struct slap_conn *c, struct slap_op *o,
509                 char *dn));
510         int     (*bi_op_abandon) LDAP_P((BackendDB *bd,
511                 struct slap_conn *c, struct slap_op *o,
512                 ber_int_t msgid));
513
514         /* Auxilary Functions */
515         int     (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
516
517         int     (*bi_acl_group)  LDAP_P((Backend *bd,
518                 Entry *e, char *bdn, char *edn,
519                 char *objectclassValue, char *groupattrName ));
520
521         int     (*bi_connection_init) LDAP_P((BackendDB *bd,
522                 struct slap_conn *c));
523         int     (*bi_connection_destroy) LDAP_P((BackendDB *bd,
524                 struct slap_conn *c));
525
526
527         unsigned int bi_nDB;    /* number of databases of this type */
528         void    *bi_private;    /* anything the backend type needs */
529 };
530
531 /*
532  * represents an operation pending from an ldap client
533  */
534
535 typedef struct slap_op {
536         ber_int_t       o_opid;         /* id of this operation           */
537         ber_int_t       o_msgid;        /* msgid of the request           */
538
539         ldap_pvt_thread_t       o_tid;          /* thread handling this op        */
540
541         BerElement      *o_ber;         /* ber of the request             */
542
543         ber_tag_t       o_tag;          /* tag of the request             */
544         time_t          o_time;         /* time op was initiated          */
545
546         int             o_bind_in_progress;     /* multi-step bind in progress */
547
548         char            *o_dn;          /* dn bound when op was initiated */
549         char            *o_ndn;         /* normalized dn bound when op was initiated */
550         ber_int_t       o_protocol;     /* version of the LDAP protocol used by client */
551         ber_tag_t       o_authtype;     /* auth method used to bind dn    */
552                                         /* values taken from ldap.h       */
553                                         /* LDAP_AUTH_*                    */
554         char            *o_authmech; /* SASL mechanism used to bind dn */
555
556         LDAPControl     **o_ctrls;       /* controls */
557
558         unsigned long   o_connid; /* id of conn initiating this op  */
559
560 #ifdef LDAP_CONNECTIONLESS
561         int             o_cldap;        /* != 0 if this came in via CLDAP */
562         struct sockaddr o_clientaddr;   /* client address if via CLDAP    */
563         char            o_searchbase;   /* search base if via CLDAP       */
564 #endif
565
566         ldap_pvt_thread_mutex_t o_abandonmutex; /* protects o_abandon  */
567         int             o_abandon;      /* abandon flag */
568
569         struct slap_op  *o_next;        /* next operation in list         */
570         void    *o_private;     /* anything the backend needs     */
571 } Operation;
572
573 /*
574  * represents a connection from an ldap client
575  */
576
577 typedef struct slap_conn {
578         int                     c_struct_state; /* structure management state */
579         int                     c_conn_state;   /* connection state */
580
581         ldap_pvt_thread_mutex_t c_mutex; /* protect the connection */
582         Sockbuf         *c_sb;                  /* ber connection stuff           */
583
584         /* only can be changed by connect_init */
585         time_t          c_starttime;    /* when the connection was opened */
586         time_t          c_activitytime; /* when the connection was last used */
587         unsigned long           c_connid;       /* id of this connection for stats*/
588
589         char            *c_listener_url;        /* listener URL */
590         char            *c_peer_domain; /* DNS name of client */
591         char            *c_peer_name;   /* peer name (trans=addr:port) */
592         char            *c_sock_name;   /* sock name (trans=addr:port) */
593
594         /* only can be changed by binding thread */
595         int             c_bind_in_progress;     /* multi-op bind in progress */
596
597         char    *c_cdn;         /* DN provided by the client */
598         char    *c_dn;          /* DN bound to this conn  */
599         ber_int_t       c_protocol;     /* version of the LDAP protocol used by client */
600         ber_tag_t       c_authtype;/* auth method used to bind c_dn  */
601         char    *c_authmech;    /* SASL mechanism used to bind c_dn */
602         void    *c_authstate;   /* SASL state data */
603
604         Operation       *c_ops;                 /* list of operations being processed */
605         Operation       *c_pending_ops; /* list of pending operations */
606
607         ldap_pvt_thread_mutex_t c_write_mutex;  /* only one pdu written at a time */
608         ldap_pvt_thread_cond_t  c_write_cv;             /* used to wait for sd write-ready*/
609
610         BerElement      *c_currentber;  /* ber we're attempting to read */
611         int             c_writewaiter;  /* true if writer is waiting */
612
613 #ifdef HAVE_TLS
614         int     c_is_tls;               /* true if this LDAP over raw TLS */
615         int     c_needs_tls_accept;     /* true if SSL_accept should be called */
616 #endif
617
618         long    c_n_ops_received;               /* num of ops received (next op_id) */
619         long    c_n_ops_executing;      /* num of ops currently executing */
620         long    c_n_ops_pending;                /* num of ops pending execution */
621         long    c_n_ops_completed;      /* num of ops completed */
622
623         long    c_n_get;                /* num of get calls */
624         long    c_n_read;               /* num of read calls */
625         long    c_n_write;              /* num of write calls */
626 } Connection;
627
628 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
629 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )  \
630         do { \
631                 if ( ldap_debug & (level) ) \
632                         fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
633                 if ( ldap_syslog & (level) ) \
634                         syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \
635                                 (arg2), (arg3) ); \
636         } while (0)
637 #else
638 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
639 #endif
640
641 LDAP_END_DECL
642
643 #include "proto-slap.h"
644
645 #endif /* _slap_h_ */