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