]> git.sur5r.net Git - openldap/blob - libraries/libldap/ldap-int.h
Silence warning in print_deref(): cast lutil_b64_ntop() arg to unsigned char*
[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         int             ldo_refhoplimit;        /* limit on referral nesting */
248
249         /* LDAPv3 server and client controls */
250         LDAPControl     **ldo_sctrls;
251         LDAPControl **ldo_cctrls;
252
253         /* LDAP rebind callback function */
254         LDAP_REBIND_PROC *ldo_rebind_proc;
255         void *ldo_rebind_params;
256         LDAP_NEXTREF_PROC *ldo_nextref_proc;
257         void *ldo_nextref_params;
258         LDAP_URLLIST_PROC *ldo_urllist_proc;
259         void *ldo_urllist_params;
260
261         /* LDAP connection callback stack */
262         ldaplist *ldo_conn_cbs;
263
264         LDAP_BOOLEANS ldo_booleans;     /* boolean options */
265 };
266
267
268 /*
269  * structure for representing an LDAP server connection
270  */
271 typedef struct ldap_conn {
272         Sockbuf         *lconn_sb;
273 #ifdef HAVE_CYRUS_SASL
274         void            *lconn_sasl_authctx;    /* context for bind */
275         void            *lconn_sasl_sockctx;    /* for security layer */
276 #endif
277 #ifdef HAVE_GSSAPI
278         void            *lconn_gss_ctx;         /* gss_ctx_id_t */
279 #endif
280         int                     lconn_refcnt;
281         time_t          lconn_created;  /* time */
282         time_t          lconn_lastused; /* time */
283         int                     lconn_rebind_inprogress;        /* set if rebind in progress */
284         char            ***lconn_rebind_queue;          /* used if rebind in progress */
285         int                     lconn_status;
286 #define LDAP_CONNST_NEEDSOCKET          1
287 #define LDAP_CONNST_CONNECTING          2
288 #define LDAP_CONNST_CONNECTED           3
289         LDAPURLDesc             *lconn_server;
290         BerElement              *lconn_ber;     /* ber receiving on this conn. */
291
292         struct ldap_conn *lconn_next;
293 } LDAPConn;
294
295
296 /*
297  * structure used to track outstanding requests
298  */
299 typedef struct ldapreq {
300         ber_int_t       lr_msgid;       /* the message id */
301         int             lr_status;      /* status of request */
302 #define LDAP_REQST_COMPLETED    0
303 #define LDAP_REQST_INPROGRESS   1
304 #define LDAP_REQST_CHASINGREFS  2
305 #define LDAP_REQST_NOTCONNECTED 3
306 #define LDAP_REQST_WRITING      4
307         int             lr_refcnt;      /* count of references */
308         int             lr_outrefcnt;   /* count of outstanding referrals */
309         int             lr_abandoned;   /* the request has been abandoned */
310         ber_int_t       lr_origid;      /* original request's message id */
311         int             lr_parentcnt;   /* count of parent requests */
312         ber_tag_t       lr_res_msgtype; /* result message type */
313         ber_int_t       lr_res_errno;   /* result LDAP errno */
314         char            *lr_res_error;  /* result error string */
315         char            *lr_res_matched;/* result matched DN string */
316         BerElement      *lr_ber;        /* ber encoded request contents */
317         LDAPConn        *lr_conn;       /* connection used to send request */
318         struct berval   lr_dn;          /* DN of request, in lr_ber */
319         struct ldapreq  *lr_parent;     /* request that spawned this referral */
320         struct ldapreq  *lr_child;      /* first child request */
321         struct ldapreq  *lr_refnext;    /* next referral spawned */
322         struct ldapreq  *lr_prev;       /* previous request */
323         struct ldapreq  *lr_next;       /* next request */
324 } LDAPRequest;
325
326 /*
327  * structure for client cache
328  */
329 #define LDAP_CACHE_BUCKETS      31      /* cache hash table size */
330 typedef struct ldapcache {
331         LDAPMessage     *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
332         LDAPMessage     *lc_requests;                   /* unfulfilled reqs */
333         long            lc_timeout;                     /* request timeout */
334         ber_len_t               lc_maxmem;                      /* memory to use */
335         ber_len_t               lc_memused;                     /* memory in use */
336         int             lc_enabled;                     /* enabled? */
337         unsigned long   lc_options;                     /* options */
338 #define LDAP_CACHE_OPT_CACHENOERRS      0x00000001
339 #define LDAP_CACHE_OPT_CACHEALLERRS     0x00000002
340 }  LDAPCache;
341
342 /*
343  * structure containing referral request info for rebind procedure
344  */
345 typedef struct ldapreqinfo {
346         ber_len_t       ri_msgid;
347         int                     ri_request;
348         char            *ri_url;
349 } LDAPreqinfo;
350
351 /*
352  * structure representing an ldap connection
353  */
354
355 struct ldap {
356         Sockbuf         *ld_sb;         /* socket descriptor & buffer */
357
358         struct ldapoptions ld_options;
359
360 #define ld_valid                ld_options.ldo_valid
361 #define ld_debug                ld_options.ldo_debug
362
363 #define ld_deref                ld_options.ldo_deref
364 #define ld_timelimit    ld_options.ldo_timelimit
365 #define ld_sizelimit    ld_options.ldo_sizelimit
366
367 #define ld_defbinddn    ld_options.ldo_defbinddn
368 #define ld_defbase              ld_options.ldo_defbase
369 #define ld_defhost              ld_options.ldo_defhost
370 #define ld_defport              ld_options.ldo_defport
371
372 #define ld_refhoplimit  ld_options.ldo_refhoplimit
373
374 #define ld_sctrls               ld_options.ldo_sctrls
375 #define ld_cctrls               ld_options.ldo_cctrls
376 #define ld_rebind_proc          ld_options.ldo_rebind_proc
377 #define ld_rebind_params        ld_options.ldo_rebind_params
378 #define ld_nextref_proc         ld_options.ldo_nextref_proc
379 #define ld_nextref_params       ld_options.ldo_nextref_params
380 #define ld_urllist_proc         ld_options.ldo_urllist_proc
381 #define ld_urllist_params       ld_options.ldo_urllist_params
382
383 #define ld_version              ld_options.ldo_version
384
385         unsigned short  ld_lberoptions;
386
387         ber_int_t       ld_errno;
388         char    *ld_error;
389         char    *ld_matched;
390         char    **ld_referrals;
391         ber_len_t               ld_msgid;
392
393         /* do not mess with these */
394         LDAPRequest     *ld_requests;   /* list of outstanding requests */
395         LDAPMessage     *ld_responses;  /* list of outstanding responses */
396
397 #ifdef LDAP_R_COMPILE
398         ldap_pvt_thread_mutex_t ld_conn_mutex;
399         ldap_pvt_thread_mutex_t ld_req_mutex;
400         ldap_pvt_thread_mutex_t ld_res_mutex;
401 #endif
402
403         ber_len_t       ld_nabandoned;
404         ber_int_t       *ld_abandoned;  /* array of abandoned requests */
405
406         LDAPCache       *ld_cache;      /* non-null if cache is initialized */
407
408         /* do not mess with the rest though */
409
410         LDAPConn        *ld_defconn;    /* default connection */
411         LDAPConn        *ld_conns;      /* list of server connections */
412         void            *ld_selectinfo; /* platform specifics for select */
413 };
414 #define LDAP_VALID(ld)          ( (ld)->ld_valid == LDAP_VALID_SESSION )
415 #define LDAP_TRASHED(ld)        ( (ld)->ld_valid == LDAP_TRASHED_SESSION )
416 #define LDAP_TRASH(ld)          ( (ld)->ld_valid = LDAP_TRASHED_SESSION )
417
418 #ifdef LDAP_R_COMPILE
419 LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
420
421 #ifdef HAVE_CYRUS_SASL
422 LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_sasl_mutex;
423 #endif
424 #ifdef HAVE_GSSAPI
425 LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;
426 #endif
427 #endif
428
429 #ifdef LDAP_R_COMPILE
430 #define LDAP_NEXT_MSGID(ld, id) \
431         ldap_pvt_thread_mutex_lock( &(ld)->ld_req_mutex ); \
432         id = ++(ld)->ld_msgid; \
433         ldap_pvt_thread_mutex_unlock( &(ld)->ld_req_mutex )
434 #else
435 #define LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid
436 #endif
437
438 /*
439  * in abandon.c
440  */
441
442 LDAP_F (int)
443 ldap_int_bisect_find( ber_int_t *v, ber_len_t n, ber_int_t id, int *idxp );
444 LDAP_F (int)
445 ldap_int_bisect_insert( ber_int_t **vp, ber_len_t *np, int id, int idx );
446 LDAP_F (int)
447 ldap_int_bisect_delete( ber_int_t **vp, ber_len_t *np, int id, int idx );
448
449 /*
450  * in init.c
451  */
452
453 LDAP_V ( struct ldapoptions ) ldap_int_global_options;
454
455 LDAP_F ( void ) ldap_int_initialize LDAP_P((struct ldapoptions *, int *));
456 LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P((
457         struct ldapoptions *, int *));
458
459 /* memory.c */
460         /* simple macros to realloc for now */
461 #define LDAP_MALLOC(s)          (ber_memalloc_x((s),NULL))
462 #define LDAP_CALLOC(n,s)        (ber_memcalloc_x((n),(s),NULL))
463 #define LDAP_REALLOC(p,s)       (ber_memrealloc_x((p),(s),NULL))
464 #define LDAP_FREE(p)            (ber_memfree_x((p),NULL))
465 #define LDAP_VFREE(v)           (ber_memvfree_x((void **)(v),NULL))
466 #define LDAP_STRDUP(s)          (ber_strdup_x((s),NULL))
467 #define LDAP_STRNDUP(s,l)       (ber_strndup_x((s),(l),NULL))
468
469 #define LDAP_MALLOCX(s,x)       (ber_memalloc_x((s),(x)))
470 #define LDAP_CALLOCX(n,s,x)     (ber_memcalloc_x((n),(s),(x)))
471 #define LDAP_REALLOCX(p,s,x)    (ber_memrealloc_x((p),(s),(x)))
472 #define LDAP_FREEX(p,x)         (ber_memfree_x((p),(x)))
473 #define LDAP_VFREEX(v,x)        (ber_memvfree_x((void **)(v),(x)))
474 #define LDAP_STRDUPX(s,x)       (ber_strdup_x((s),(x)))
475 #define LDAP_STRNDUPX(s,l,x)    (ber_strndup_x((s),(l),(x)))
476
477 /*
478  * in error.c
479  */
480 LDAP_F (void) ldap_int_error_init( void );
481
482 /*
483  * in unit-int.c
484  */
485 LDAP_F (void) ldap_int_utils_init LDAP_P(( void ));
486
487
488 /*
489  * in print.c
490  */
491 LDAP_F (int) ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...)) LDAP_GCCATTR((format(printf, 3, 4)));
492
493 /*
494  * in cache.c
495  */
496 LDAP_F (void) ldap_add_request_to_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype,
497         BerElement *request ));
498 LDAP_F (void) ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
499 LDAP_F (int) ldap_check_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype, BerElement *request ));
500
501 /*
502  * in controls.c
503  */
504 LDAP_F (int) ldap_int_put_controls LDAP_P((
505         LDAP *ld,
506         LDAPControl *const *ctrls,
507         BerElement *ber ));
508
509 LDAP_F (int) ldap_int_client_controls LDAP_P((
510         LDAP *ld,
511         LDAPControl **ctrlp ));
512
513 /*
514  * in dsparse.c
515  */
516 LDAP_F (int) ldap_int_next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp ));
517
518
519 /*
520  * in open.c
521  */
522 LDAP_F (int) ldap_open_defconn( LDAP *ld );
523 LDAP_F (int) ldap_int_open_connection( LDAP *ld,
524         LDAPConn *conn, LDAPURLDesc *srvlist, int async );
525
526 /*
527  * in os-ip.c
528  */
529 #ifndef HAVE_POLL
530 LDAP_V (int) ldap_int_tblsize;
531 LDAP_F (void) ldap_int_ip_init( void );
532 #endif
533
534 LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest,
535         const struct timeval *tm );
536 LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb,
537         int proto, LDAPURLDesc *srv, int async );
538 LDAP_F (int) ldap_int_poll( LDAP *ld, ber_socket_t s,
539         struct timeval *tvp );
540
541 #if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
542 LDAP_V (char *) ldap_int_hostname;
543 LDAP_F (char *) ldap_host_connected_to( Sockbuf *sb,
544         const char *host );
545 #endif
546
547 LDAP_F (int) ldap_int_select( LDAP *ld, struct timeval *timeout );
548 LDAP_F (void *) ldap_new_select_info( void );
549 LDAP_F (void) ldap_free_select_info( void *sip );
550 LDAP_F (void) ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
551 LDAP_F (void) ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
552 LDAP_F (void) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
553 LDAP_F (int) ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
554 LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
555
556 LDAP_F (int) ldap_int_connect_cbs( LDAP *ld, Sockbuf *sb,
557         ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr );
558
559 /*
560  * in os-local.c
561  */
562 #ifdef LDAP_PF_LOCAL
563 LDAP_F (int) ldap_connect_to_path( LDAP *ld, Sockbuf *sb,
564         LDAPURLDesc *srv, int async );
565 #endif /* LDAP_PF_LOCAL */
566
567 /*
568  * in request.c
569  */
570 LDAP_F (ber_int_t) ldap_send_initial_request( LDAP *ld, ber_tag_t msgtype,
571         const char *dn, BerElement *ber, ber_int_t msgid );
572 LDAP_F (BerElement *) ldap_alloc_ber_with_options( LDAP *ld );
573 LDAP_F (void) ldap_set_ber_options( LDAP *ld, BerElement *ber );
574
575 LDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid, LDAPRequest *parentreq, LDAPURLDesc **srvlist, LDAPConn *lc, LDAPreqinfo *bind );
576 LDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb, int connect, LDAPreqinfo *bind );
577 LDAP_F (LDAPRequest *) ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
578 LDAP_F (void) ldap_return_request( LDAP *ld, LDAPRequest *lr, int freeit );
579 LDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
580 LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
581 LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
582 LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld );
583 LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
584         char **errstrp, int sref, int *hadrefp );
585 LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
586         char **refs, int sref, char **referralsp, int *hadrefp );
587 LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
588 LDAP_F (int) ldap_int_flush_request( LDAP *ld, LDAPRequest *lr );
589
590 /*
591  * in result.c:
592  */
593 LDAP_F (const char *) ldap_int_msgtype2str( ber_tag_t tag );
594
595 /*
596  * in search.c
597  */
598 LDAP_F (BerElement *) ldap_build_search_req LDAP_P((
599         LDAP *ld,
600         const char *base,
601         ber_int_t scope,
602         const char *filter,
603         char **attrs,
604         ber_int_t attrsonly,
605         LDAPControl **sctrls,
606         LDAPControl **cctrls,
607         ber_int_t timelimit,
608         ber_int_t sizelimit,
609         ber_int_t deref,
610         ber_int_t *msgidp));
611
612
613 /*
614  * in unbind.c
615  */
616 LDAP_F (int) ldap_ld_free LDAP_P((
617         LDAP *ld,
618         int close,
619         LDAPControl **sctrls,
620         LDAPControl **cctrls ));
621
622 LDAP_F (int) ldap_send_unbind LDAP_P((
623         LDAP *ld,
624         Sockbuf *sb,
625         LDAPControl **sctrls,
626         LDAPControl **cctrls ));
627
628 /*
629  * in url.c
630  */
631 LDAP_F (LDAPURLDesc *) ldap_url_dup LDAP_P((
632         LDAPURLDesc *ludp ));
633
634 LDAP_F (LDAPURLDesc *) ldap_url_duplist LDAP_P((
635         LDAPURLDesc *ludlist ));
636
637 LDAP_F (int) ldap_url_parsehosts LDAP_P((
638         LDAPURLDesc **ludlist,
639         const char *hosts,
640         int port ));
641
642 LDAP_F (char *) ldap_url_list2hosts LDAP_P((
643         LDAPURLDesc *ludlist ));
644
645 /*
646  * in cyrus.c
647  */
648
649 LDAP_F (int) ldap_int_sasl_init LDAP_P(( void ));
650
651 LDAP_F (int) ldap_int_sasl_open LDAP_P((
652         LDAP *ld, LDAPConn *conn,
653         const char* host ));
654 LDAP_F (int) ldap_int_sasl_close LDAP_P(( LDAP *ld, LDAPConn *conn ));
655
656 LDAP_F (int) ldap_int_sasl_external LDAP_P((
657         LDAP *ld, LDAPConn *conn,
658         const char* authid, ber_len_t ssf ));
659
660 LDAP_F (int) ldap_int_sasl_get_option LDAP_P(( LDAP *ld,
661         int option, void *arg ));
662 LDAP_F (int) ldap_int_sasl_set_option LDAP_P(( LDAP *ld,
663         int option, void *arg ));
664 LDAP_F (int) ldap_int_sasl_config LDAP_P(( struct ldapoptions *lo,
665         int option, const char *arg ));
666
667 LDAP_F (int) ldap_int_sasl_bind LDAP_P((
668         LDAP *ld,
669         const char *,
670         const char *,
671         LDAPControl **, LDAPControl **,
672
673         /* should be passed in client controls */
674         unsigned flags,
675         LDAP_SASL_INTERACT_PROC *interact,
676         void *defaults ));
677
678 /* in schema.c */
679 LDAP_F (char *) ldap_int_parse_numericoid LDAP_P((
680         const char **sp,
681         int *code,
682         const int flags ));
683
684 /*
685  * in tls.c
686  */
687 LDAP_F (int) ldap_int_tls_config LDAP_P(( LDAP *ld,
688         int option, const char *arg ));
689
690 LDAP_F (int) ldap_int_tls_start LDAP_P(( LDAP *ld,
691         LDAPConn *conn, LDAPURLDesc *srv ));
692
693 LDAP_F (void) ldap_int_tls_destroy LDAP_P(( struct ldapoptions *lo ));
694
695 /*
696  *      in getvalues.c
697  */
698 LDAP_F (char **) ldap_value_dup LDAP_P((
699         char *const *vals ));
700
701 /*
702  *      in gssapi.c
703  */
704 #ifdef HAVE_GSSAPI
705 LDAP_F(int) ldap_int_gssapi_get_option LDAP_P(( LDAP *ld, int option, void *arg ));
706 LDAP_F(int) ldap_int_gssapi_set_option LDAP_P(( LDAP *ld, int option, void *arg ));
707 LDAP_F(int) ldap_int_gssapi_config LDAP_P(( struct ldapoptions *lo, int option, const char *arg ));
708 LDAP_F(void) ldap_int_gssapi_close LDAP_P(( LDAP *ld, LDAPConn *lc ));
709 #endif 
710
711 LDAP_END_DECL
712
713 #endif /* _LDAP_INT_H */