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