]> git.sur5r.net Git - openldap/blob - libraries/libldap/ldap-int.h
More for prev commit - only set if URL was provided.
[openldap] / libraries / libldap / ldap-int.h
1 /*  ldap-int.h - defines & prototypes internal to the LDAP library */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2009 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /*  Portions Copyright (c) 1995 Regents of the University of Michigan.
17  *  All rights reserved.
18  */
19
20 #ifndef _LDAP_INT_H
21 #define _LDAP_INT_H 1
22
23 #ifdef LDAP_R_COMPILE
24 #define LDAP_THREAD_SAFE 1
25 #endif
26
27 #include "../liblber/lber-int.h"
28
29 #ifdef LDAP_R_COMPILE
30 #include <ldap_pvt_thread.h>
31 #endif
32
33 #ifdef HAVE_CYRUS_SASL
34         /* the need for this should be removed */
35 #ifdef HAVE_SASL_SASL_H
36 #include <sasl/sasl.h>
37 #else
38 #include <sasl.h>
39 #endif
40
41 #define SASL_MAX_BUFF_SIZE      (0xffffff)
42 #define SASL_MIN_BUFF_SIZE      4096
43 #endif
44
45 /* for struct timeval */
46 #include <ac/time.h>
47
48 #undef TV2MILLISEC
49 #define TV2MILLISEC(tv) (((tv)->tv_sec * 1000) + ((tv)->tv_usec/1000))
50
51 /* 
52  * Support needed if the library is running in the kernel
53  */
54 #if LDAP_INT_IN_KERNEL
55         /* 
56          * Platform specific function to return a pointer to the
57          * process-specific global options. 
58          *
59          * This function should perform the following functions:
60          *  Allocate and initialize a global options struct on a per process basis
61          *  Use callers process identifier to return its global options struct
62          *  Note: Deallocate structure when the process exits
63          */
64 #       define LDAP_INT_GLOBAL_OPT() ldap_int_global_opt()
65         struct ldapoptions *ldap_int_global_opt(void);
66 #else
67 #       define LDAP_INT_GLOBAL_OPT() (&ldap_int_global_options)
68 #endif
69
70 #define ldap_debug      ((LDAP_INT_GLOBAL_OPT())->ldo_debug)
71
72 #include "ldap_log.h"
73
74 #undef Debug
75
76 #ifdef LDAP_DEBUG
77
78 #define DebugTest( level ) \
79         ( ldap_debug & level )
80
81 #define Debug( level, fmt, arg1, arg2, arg3 ) \
82         do { if ( ldap_debug & level ) \
83         ldap_log_printf( NULL, (level), (fmt), (arg1), (arg2), (arg3) ); \
84         } while ( 0 )
85
86 #define LDAP_Debug( subsystem, level, fmt, arg1, arg2, arg3 )\
87         ldap_log_printf( NULL, (level), (fmt), (arg1), (arg2), (arg3) )
88
89 #else
90
91 #define DebugTest( level )                                    (0 == 1)
92 #define Debug( level, fmt, arg1, arg2, arg3 )                 ((void)0)
93 #define LDAP_Debug( subsystem, level, fmt, arg1, arg2, arg3 ) ((void)0)
94
95 #endif /* LDAP_DEBUG */
96
97 #define LDAP_DEPRECATED 1
98 #include "ldap.h"
99
100 #include "ldap_pvt.h"
101
102 LDAP_BEGIN_DECL
103
104 #define LDAP_URL_PREFIX         "ldap://"
105 #define LDAP_URL_PREFIX_LEN     STRLENOF(LDAP_URL_PREFIX)
106 #define LDAPS_URL_PREFIX        "ldaps://"
107 #define LDAPS_URL_PREFIX_LEN    STRLENOF(LDAPS_URL_PREFIX)
108 #define LDAPI_URL_PREFIX        "ldapi://"
109 #define LDAPI_URL_PREFIX_LEN    STRLENOF(LDAPI_URL_PREFIX)
110 #ifdef LDAP_CONNECTIONLESS
111 #define LDAPC_URL_PREFIX        "cldap://"
112 #define LDAPC_URL_PREFIX_LEN    STRLENOF(LDAPC_URL_PREFIX)
113 #endif
114 #define LDAP_URL_URLCOLON       "URL:"
115 #define LDAP_URL_URLCOLON_LEN   STRLENOF(LDAP_URL_URLCOLON)
116
117 #define LDAP_REF_STR            "Referral:\n"
118 #define LDAP_REF_STR_LEN        STRLENOF(LDAP_REF_STR)
119 #define LDAP_LDAP_REF_STR       LDAP_URL_PREFIX
120 #define LDAP_LDAP_REF_STR_LEN   LDAP_URL_PREFIX_LEN
121
122 #define LDAP_DEFAULT_REFHOPLIMIT 5
123
124 #define LDAP_BOOL_REFERRALS             0
125 #define LDAP_BOOL_RESTART               1
126 #define LDAP_BOOL_TLS                   3
127 #define LDAP_BOOL_CONNECT_ASYNC         4
128 #define LDAP_BOOL_SASL_NOCANON          5
129
130 #define LDAP_BOOLEANS   unsigned long
131 #define LDAP_BOOL(n)    ((LDAP_BOOLEANS)1 << (n))
132 #define LDAP_BOOL_GET(lo, bool) \
133         ((lo)->ldo_booleans & LDAP_BOOL(bool) ? -1 : 0)
134 #define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool))
135 #define LDAP_BOOL_CLR(lo, bool) ((lo)->ldo_booleans &= ~LDAP_BOOL(bool))
136 #define LDAP_BOOL_ZERO(lo) ((lo)->ldo_booleans = 0)
137
138 /*
139  * This structure represents both ldap messages and ldap responses.
140  * These are really the same, except in the case of search responses,
141  * where a response has multiple messages.
142  */
143
144 struct ldapmsg {
145         ber_int_t               lm_msgid;       /* the message id */
146         ber_tag_t               lm_msgtype;     /* the message type */
147         BerElement      *lm_ber;        /* the ber encoded message contents */
148         struct ldapmsg  *lm_chain;      /* for search - next msg in the resp */
149         struct ldapmsg  *lm_chain_tail;
150         struct ldapmsg  *lm_next;       /* next response */
151         time_t  lm_time;        /* used to maintain cache */
152 };
153
154 #ifdef HAVE_TLS
155 struct ldaptls {
156         char            *lt_certfile;
157         char            *lt_keyfile;
158         char            *lt_dhfile;
159         char            *lt_cacertfile;
160         char            *lt_cacertdir;
161         char            *lt_ciphersuite;
162         char            *lt_crlfile;
163         char            *lt_randfile;   /* OpenSSL only */
164         int             lt_protocol_min;
165 };
166 #endif
167
168 typedef struct ldaplist {
169         struct ldaplist *ll_next;
170         void *ll_data;
171 } ldaplist;
172
173 /*
174  * structure representing get/set'able options
175  * which have global defaults.
176  */
177 struct ldapoptions {
178         short ldo_valid;
179 #define LDAP_UNINITIALIZED      0x0
180 #define LDAP_INITIALIZED        0x1
181 #define LDAP_VALID_SESSION      0x2
182 #define LDAP_TRASHED_SESSION    0xFF
183         int   ldo_debug;
184 #ifdef LDAP_CONNECTIONLESS
185 #define LDAP_IS_UDP(ld)         ((ld)->ld_options.ldo_is_udp)
186         void*                   ldo_peer;       /* struct sockaddr* */
187         char*                   ldo_cldapdn;
188         int                     ldo_is_udp;
189 #endif
190
191         /* per API call timeout */
192         struct timeval          ldo_tm_api;
193         struct timeval          ldo_tm_net;
194
195         ber_int_t               ldo_version;
196         ber_int_t               ldo_deref;
197         ber_int_t               ldo_timelimit;
198         ber_int_t               ldo_sizelimit;
199
200 #ifdef HAVE_TLS
201         /* tls context */
202         void            *ldo_tls_ctx;
203         LDAP_TLS_CONNECT_CB     *ldo_tls_connect_cb;
204         void*                   ldo_tls_connect_arg;
205         struct ldaptls ldo_tls_info;
206 #define ldo_tls_certfile        ldo_tls_info.lt_certfile
207 #define ldo_tls_keyfile ldo_tls_info.lt_keyfile
208 #define ldo_tls_dhfile  ldo_tls_info.lt_dhfile
209 #define ldo_tls_cacertfile      ldo_tls_info.lt_cacertfile
210 #define ldo_tls_cacertdir       ldo_tls_info.lt_cacertdir
211 #define ldo_tls_ciphersuite     ldo_tls_info.lt_ciphersuite
212 #define ldo_tls_protocol_min    ldo_tls_info.lt_protocol_min
213 #define ldo_tls_crlfile ldo_tls_info.lt_crlfile
214 #define ldo_tls_randfile        ldo_tls_info.lt_randfile
215         int                     ldo_tls_mode;
216         int                     ldo_tls_require_cert;
217         int                     ldo_tls_impl;
218 #ifdef HAVE_OPENSSL_CRL
219         int                     ldo_tls_crlcheck;
220 #endif
221 #endif
222
223         LDAPURLDesc *ldo_defludp;
224         int             ldo_defport;
225         char*   ldo_defbase;
226         char*   ldo_defbinddn;  /* bind dn */
227
228 #ifdef HAVE_CYRUS_SASL
229         char*   ldo_def_sasl_mech;              /* SASL Mechanism(s) */
230         char*   ldo_def_sasl_realm;             /* SASL realm */
231         char*   ldo_def_sasl_authcid;   /* SASL authentication identity */
232         char*   ldo_def_sasl_authzid;   /* SASL authorization identity */
233
234         /* SASL Security Properties */
235         struct sasl_security_properties ldo_sasl_secprops;
236 #endif
237
238 #ifdef HAVE_GSSAPI
239         unsigned gssapi_flags;
240
241         unsigned ldo_gssapi_flags;
242 #define LDAP_GSSAPI_OPT_DO_NOT_FREE_GSS_CONTEXT 0x0001
243 #define LDAP_GSSAPI_OPT_ALLOW_REMOTE_PRINCIPAL  0x0002
244         unsigned ldo_gssapi_options;
245 #endif
246
247         /*
248          * Per connection tcp-keepalive settings (Linux only,
249          * ignored where unsupported)
250          */
251         ber_int_t ldo_keepalive_idle;
252         ber_int_t ldo_keepalive_probes;
253         ber_int_t ldo_keepalive_interval;
254
255         int             ldo_refhoplimit;        /* limit on referral nesting */
256
257         /* LDAPv3 server and client controls */
258         LDAPControl     **ldo_sctrls;
259         LDAPControl **ldo_cctrls;
260
261         /* LDAP rebind callback function */
262         LDAP_REBIND_PROC *ldo_rebind_proc;
263         void *ldo_rebind_params;
264         LDAP_NEXTREF_PROC *ldo_nextref_proc;
265         void *ldo_nextref_params;
266         LDAP_URLLIST_PROC *ldo_urllist_proc;
267         void *ldo_urllist_params;
268
269         /* LDAP connection callback stack */
270         ldaplist *ldo_conn_cbs;
271
272         LDAP_BOOLEANS ldo_booleans;     /* boolean options */
273 };
274
275
276 /*
277  * structure for representing an LDAP server connection
278  */
279 typedef struct ldap_conn {
280         Sockbuf         *lconn_sb;
281 #ifdef HAVE_CYRUS_SASL
282         void            *lconn_sasl_authctx;    /* context for bind */
283         void            *lconn_sasl_sockctx;    /* for security layer */
284 #endif
285 #ifdef HAVE_GSSAPI
286         void            *lconn_gss_ctx;         /* gss_ctx_id_t */
287 #endif
288         int                     lconn_refcnt;
289         time_t          lconn_created;  /* time */
290         time_t          lconn_lastused; /* time */
291         int                     lconn_rebind_inprogress;        /* set if rebind in progress */
292         char            ***lconn_rebind_queue;          /* used if rebind in progress */
293         int                     lconn_status;
294 #define LDAP_CONNST_NEEDSOCKET          1
295 #define LDAP_CONNST_CONNECTING          2
296 #define LDAP_CONNST_CONNECTED           3
297         LDAPURLDesc             *lconn_server;
298         BerElement              *lconn_ber;     /* ber receiving on this conn. */
299
300         struct ldap_conn *lconn_next;
301 } LDAPConn;
302
303
304 /*
305  * structure used to track outstanding requests
306  */
307 typedef struct ldapreq {
308         ber_int_t       lr_msgid;       /* the message id */
309         int             lr_status;      /* status of request */
310 #define LDAP_REQST_COMPLETED    0
311 #define LDAP_REQST_INPROGRESS   1
312 #define LDAP_REQST_CHASINGREFS  2
313 #define LDAP_REQST_NOTCONNECTED 3
314 #define LDAP_REQST_WRITING      4
315         int             lr_refcnt;      /* count of references */
316         int             lr_outrefcnt;   /* count of outstanding referrals */
317         int             lr_abandoned;   /* the request has been abandoned */
318         ber_int_t       lr_origid;      /* original request's message id */
319         int             lr_parentcnt;   /* count of parent requests */
320         ber_tag_t       lr_res_msgtype; /* result message type */
321         ber_int_t       lr_res_errno;   /* result LDAP errno */
322         char            *lr_res_error;  /* result error string */
323         char            *lr_res_matched;/* result matched DN string */
324         BerElement      *lr_ber;        /* ber encoded request contents */
325         LDAPConn        *lr_conn;       /* connection used to send request */
326         struct berval   lr_dn;          /* DN of request, in lr_ber */
327         struct ldapreq  *lr_parent;     /* request that spawned this referral */
328         struct ldapreq  *lr_child;      /* first child request */
329         struct ldapreq  *lr_refnext;    /* next referral spawned */
330         struct ldapreq  *lr_prev;       /* previous request */
331         struct ldapreq  *lr_next;       /* next request */
332 } LDAPRequest;
333
334 /*
335  * structure for client cache
336  */
337 #define LDAP_CACHE_BUCKETS      31      /* cache hash table size */
338 typedef struct ldapcache {
339         LDAPMessage     *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
340         LDAPMessage     *lc_requests;                   /* unfulfilled reqs */
341         long            lc_timeout;                     /* request timeout */
342         ber_len_t               lc_maxmem;                      /* memory to use */
343         ber_len_t               lc_memused;                     /* memory in use */
344         int             lc_enabled;                     /* enabled? */
345         unsigned long   lc_options;                     /* options */
346 #define LDAP_CACHE_OPT_CACHENOERRS      0x00000001
347 #define LDAP_CACHE_OPT_CACHEALLERRS     0x00000002
348 }  LDAPCache;
349
350 /*
351  * structure containing referral request info for rebind procedure
352  */
353 typedef struct ldapreqinfo {
354         ber_len_t       ri_msgid;
355         int                     ri_request;
356         char            *ri_url;
357 } LDAPreqinfo;
358
359 /*
360  * structure representing an ldap connection
361  */
362
363 struct ldap {
364         Sockbuf         *ld_sb;         /* socket descriptor & buffer */
365
366         struct ldapoptions ld_options;
367
368 #define ld_valid                ld_options.ldo_valid
369 #define ld_debug                ld_options.ldo_debug
370
371 #define ld_deref                ld_options.ldo_deref
372 #define ld_timelimit    ld_options.ldo_timelimit
373 #define ld_sizelimit    ld_options.ldo_sizelimit
374
375 #define ld_defbinddn    ld_options.ldo_defbinddn
376 #define ld_defbase              ld_options.ldo_defbase
377 #define ld_defhost              ld_options.ldo_defhost
378 #define ld_defport              ld_options.ldo_defport
379
380 #define ld_refhoplimit  ld_options.ldo_refhoplimit
381
382 #define ld_sctrls               ld_options.ldo_sctrls
383 #define ld_cctrls               ld_options.ldo_cctrls
384 #define ld_rebind_proc          ld_options.ldo_rebind_proc
385 #define ld_rebind_params        ld_options.ldo_rebind_params
386 #define ld_nextref_proc         ld_options.ldo_nextref_proc
387 #define ld_nextref_params       ld_options.ldo_nextref_params
388 #define ld_urllist_proc         ld_options.ldo_urllist_proc
389 #define ld_urllist_params       ld_options.ldo_urllist_params
390
391 #define ld_version              ld_options.ldo_version
392
393         unsigned short  ld_lberoptions;
394
395         ber_int_t       ld_errno;
396         char    *ld_error;
397         char    *ld_matched;
398         char    **ld_referrals;
399         ber_len_t               ld_msgid;
400
401         /* do not mess with these */
402         LDAPRequest     *ld_requests;   /* list of outstanding requests */
403         LDAPMessage     *ld_responses;  /* list of outstanding responses */
404
405 #ifdef LDAP_R_COMPILE
406         ldap_pvt_thread_mutex_t ld_conn_mutex;
407         ldap_pvt_thread_mutex_t ld_req_mutex;
408         ldap_pvt_thread_mutex_t ld_res_mutex;
409 #endif
410
411         ber_len_t       ld_nabandoned;
412         ber_int_t       *ld_abandoned;  /* array of abandoned requests */
413
414         LDAPCache       *ld_cache;      /* non-null if cache is initialized */
415
416         /* do not mess with the rest though */
417
418         LDAPConn        *ld_defconn;    /* default connection */
419         LDAPConn        *ld_conns;      /* list of server connections */
420         void            *ld_selectinfo; /* platform specifics for select */
421 };
422 #define LDAP_VALID(ld)          ( (ld)->ld_valid == LDAP_VALID_SESSION )
423 #define LDAP_TRASHED(ld)        ( (ld)->ld_valid == LDAP_TRASHED_SESSION )
424 #define LDAP_TRASH(ld)          ( (ld)->ld_valid = LDAP_TRASHED_SESSION )
425
426 #ifdef LDAP_R_COMPILE
427 LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
428
429 #ifdef HAVE_CYRUS_SASL
430 LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_sasl_mutex;
431 #endif
432 #ifdef HAVE_GSSAPI
433 LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;
434 #endif
435 #endif
436
437 #ifdef LDAP_R_COMPILE
438 #define LDAP_NEXT_MSGID(ld, id) \
439         ldap_pvt_thread_mutex_lock( &(ld)->ld_req_mutex ); \
440         id = ++(ld)->ld_msgid; \
441         ldap_pvt_thread_mutex_unlock( &(ld)->ld_req_mutex )
442 #else
443 #define LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid
444 #endif
445
446 /*
447  * in abandon.c
448  */
449
450 LDAP_F (int)
451 ldap_int_bisect_find( ber_int_t *v, ber_len_t n, ber_int_t id, int *idxp );
452 LDAP_F (int)
453 ldap_int_bisect_insert( ber_int_t **vp, ber_len_t *np, int id, int idx );
454 LDAP_F (int)
455 ldap_int_bisect_delete( ber_int_t **vp, ber_len_t *np, int id, int idx );
456
457 /*
458  * in init.c
459  */
460
461 LDAP_V ( struct ldapoptions ) ldap_int_global_options;
462
463 LDAP_F ( void ) ldap_int_initialize LDAP_P((struct ldapoptions *, int *));
464 LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P((
465         struct ldapoptions *, int *));
466
467 /* memory.c */
468         /* simple macros to realloc for now */
469 #define LDAP_MALLOC(s)          (ber_memalloc_x((s),NULL))
470 #define LDAP_CALLOC(n,s)        (ber_memcalloc_x((n),(s),NULL))
471 #define LDAP_REALLOC(p,s)       (ber_memrealloc_x((p),(s),NULL))
472 #define LDAP_FREE(p)            (ber_memfree_x((p),NULL))
473 #define LDAP_VFREE(v)           (ber_memvfree_x((void **)(v),NULL))
474 #define LDAP_STRDUP(s)          (ber_strdup_x((s),NULL))
475 #define LDAP_STRNDUP(s,l)       (ber_strndup_x((s),(l),NULL))
476
477 #define LDAP_MALLOCX(s,x)       (ber_memalloc_x((s),(x)))
478 #define LDAP_CALLOCX(n,s,x)     (ber_memcalloc_x((n),(s),(x)))
479 #define LDAP_REALLOCX(p,s,x)    (ber_memrealloc_x((p),(s),(x)))
480 #define LDAP_FREEX(p,x)         (ber_memfree_x((p),(x)))
481 #define LDAP_VFREEX(v,x)        (ber_memvfree_x((void **)(v),(x)))
482 #define LDAP_STRDUPX(s,x)       (ber_strdup_x((s),(x)))
483 #define LDAP_STRNDUPX(s,l,x)    (ber_strndup_x((s),(l),(x)))
484
485 /*
486  * in error.c
487  */
488 LDAP_F (void) ldap_int_error_init( void );
489
490 /*
491  * in unit-int.c
492  */
493 LDAP_F (void) ldap_int_utils_init LDAP_P(( void ));
494
495
496 /*
497  * in print.c
498  */
499 LDAP_F (int) ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...)) LDAP_GCCATTR((format(printf, 3, 4)));
500
501 /*
502  * in cache.c
503  */
504 LDAP_F (void) ldap_add_request_to_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype,
505         BerElement *request ));
506 LDAP_F (void) ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
507 LDAP_F (int) ldap_check_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype, BerElement *request ));
508
509 /*
510  * in controls.c
511  */
512 LDAP_F (int) ldap_int_put_controls LDAP_P((
513         LDAP *ld,
514         LDAPControl *const *ctrls,
515         BerElement *ber ));
516
517 LDAP_F (int) ldap_int_client_controls LDAP_P((
518         LDAP *ld,
519         LDAPControl **ctrlp ));
520
521 /*
522  * in dsparse.c
523  */
524 LDAP_F (int) ldap_int_next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp ));
525
526
527 /*
528  * in open.c
529  */
530 LDAP_F (int) ldap_open_defconn( LDAP *ld );
531 LDAP_F (int) ldap_int_open_connection( LDAP *ld,
532         LDAPConn *conn, LDAPURLDesc *srvlist, int async );
533
534 /*
535  * in os-ip.c
536  */
537 #ifndef HAVE_POLL
538 LDAP_V (int) ldap_int_tblsize;
539 LDAP_F (void) ldap_int_ip_init( void );
540 #endif
541
542 LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest,
543         const struct timeval *tm );
544 LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb,
545         int proto, LDAPURLDesc *srv, int async );
546 LDAP_F (int) ldap_int_poll( LDAP *ld, ber_socket_t s,
547         struct timeval *tvp );
548
549 #if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
550 LDAP_V (char *) ldap_int_hostname;
551 LDAP_F (char *) ldap_host_connected_to( Sockbuf *sb,
552         const char *host );
553 #endif
554
555 LDAP_F (int) ldap_int_select( LDAP *ld, struct timeval *timeout );
556 LDAP_F (void *) ldap_new_select_info( void );
557 LDAP_F (void) ldap_free_select_info( void *sip );
558 LDAP_F (void) ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
559 LDAP_F (void) ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
560 LDAP_F (void) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
561 LDAP_F (int) ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
562 LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
563
564 LDAP_F (int) ldap_int_connect_cbs( LDAP *ld, Sockbuf *sb,
565         ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr );
566
567 /*
568  * in os-local.c
569  */
570 #ifdef LDAP_PF_LOCAL
571 LDAP_F (int) ldap_connect_to_path( LDAP *ld, Sockbuf *sb,
572         LDAPURLDesc *srv, int async );
573 #endif /* LDAP_PF_LOCAL */
574
575 /*
576  * in request.c
577  */
578 LDAP_F (ber_int_t) ldap_send_initial_request( LDAP *ld, ber_tag_t msgtype,
579         const char *dn, BerElement *ber, ber_int_t msgid );
580 LDAP_F (BerElement *) ldap_alloc_ber_with_options( LDAP *ld );
581 LDAP_F (void) ldap_set_ber_options( LDAP *ld, BerElement *ber );
582
583 LDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid, LDAPRequest *parentreq, LDAPURLDesc **srvlist, LDAPConn *lc, LDAPreqinfo *bind );
584 LDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb, int connect, LDAPreqinfo *bind );
585 LDAP_F (LDAPRequest *) ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
586 LDAP_F (void) ldap_return_request( LDAP *ld, LDAPRequest *lr, int freeit );
587 LDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
588 LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
589 LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
590 LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld );
591 LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
592         char **errstrp, int sref, int *hadrefp );
593 LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
594         char **refs, int sref, char **referralsp, int *hadrefp );
595 LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
596 LDAP_F (int) ldap_int_flush_request( LDAP *ld, LDAPRequest *lr );
597
598 /*
599  * in result.c:
600  */
601 LDAP_F (const char *) ldap_int_msgtype2str( ber_tag_t tag );
602
603 /*
604  * in search.c
605  */
606 LDAP_F (BerElement *) ldap_build_search_req LDAP_P((
607         LDAP *ld,
608         const char *base,
609         ber_int_t scope,
610         const char *filter,
611         char **attrs,
612         ber_int_t attrsonly,
613         LDAPControl **sctrls,
614         LDAPControl **cctrls,
615         ber_int_t timelimit,
616         ber_int_t sizelimit,
617         ber_int_t deref,
618         ber_int_t *msgidp));
619
620
621 /*
622  * in unbind.c
623  */
624 LDAP_F (int) ldap_ld_free LDAP_P((
625         LDAP *ld,
626         int close,
627         LDAPControl **sctrls,
628         LDAPControl **cctrls ));
629
630 LDAP_F (int) ldap_send_unbind LDAP_P((
631         LDAP *ld,
632         Sockbuf *sb,
633         LDAPControl **sctrls,
634         LDAPControl **cctrls ));
635
636 /*
637  * in url.c
638  */
639 LDAP_F (LDAPURLDesc *) ldap_url_dup LDAP_P((
640         LDAPURLDesc *ludp ));
641
642 LDAP_F (LDAPURLDesc *) ldap_url_duplist LDAP_P((
643         LDAPURLDesc *ludlist ));
644
645 LDAP_F (int) ldap_url_parsehosts LDAP_P((
646         LDAPURLDesc **ludlist,
647         const char *hosts,
648         int port ));
649
650 LDAP_F (char *) ldap_url_list2hosts LDAP_P((
651         LDAPURLDesc *ludlist ));
652
653 /*
654  * in cyrus.c
655  */
656
657 LDAP_F (int) ldap_int_sasl_init LDAP_P(( void ));
658
659 LDAP_F (int) ldap_int_sasl_open LDAP_P((
660         LDAP *ld, LDAPConn *conn,
661         const char* host ));
662 LDAP_F (int) ldap_int_sasl_close LDAP_P(( LDAP *ld, LDAPConn *conn ));
663
664 LDAP_F (int) ldap_int_sasl_external LDAP_P((
665         LDAP *ld, LDAPConn *conn,
666         const char* authid, ber_len_t ssf ));
667
668 LDAP_F (int) ldap_int_sasl_get_option LDAP_P(( LDAP *ld,
669         int option, void *arg ));
670 LDAP_F (int) ldap_int_sasl_set_option LDAP_P(( LDAP *ld,
671         int option, void *arg ));
672 LDAP_F (int) ldap_int_sasl_config LDAP_P(( struct ldapoptions *lo,
673         int option, const char *arg ));
674
675 LDAP_F (int) ldap_int_sasl_bind LDAP_P((
676         LDAP *ld,
677         const char *,
678         const char *,
679         LDAPControl **, LDAPControl **,
680
681         /* should be passed in client controls */
682         unsigned flags,
683         LDAP_SASL_INTERACT_PROC *interact,
684         void *defaults ));
685
686 /* in schema.c */
687 LDAP_F (char *) ldap_int_parse_numericoid LDAP_P((
688         const char **sp,
689         int *code,
690         const int flags ));
691
692 /*
693  * in tls.c
694  */
695 LDAP_F (int) ldap_int_tls_config LDAP_P(( LDAP *ld,
696         int option, const char *arg ));
697
698 LDAP_F (int) ldap_int_tls_start LDAP_P(( LDAP *ld,
699         LDAPConn *conn, LDAPURLDesc *srv ));
700
701 LDAP_F (void) ldap_int_tls_destroy LDAP_P(( struct ldapoptions *lo ));
702
703 /*
704  *      in getvalues.c
705  */
706 LDAP_F (char **) ldap_value_dup LDAP_P((
707         char *const *vals ));
708
709 /*
710  *      in gssapi.c
711  */
712 #ifdef HAVE_GSSAPI
713 LDAP_F(int) ldap_int_gssapi_get_option LDAP_P(( LDAP *ld, int option, void *arg ));
714 LDAP_F(int) ldap_int_gssapi_set_option LDAP_P(( LDAP *ld, int option, void *arg ));
715 LDAP_F(int) ldap_int_gssapi_config LDAP_P(( struct ldapoptions *lo, int option, const char *arg ));
716 LDAP_F(void) ldap_int_gssapi_close LDAP_P(( LDAP *ld, LDAPConn *lc ));
717 #endif 
718
719 LDAP_END_DECL
720
721 #endif /* _LDAP_INT_H */