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