Back to index

openldap  2.4.31
ldap-int.h
Go to the documentation of this file.
00001 /*  ldap-int.h - defines & prototypes internal to the LDAP library */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 /*  Portions Copyright (c) 1995 Regents of the University of Michigan.
00017  *  All rights reserved.
00018  */
00019 
00020 #ifndef       _LDAP_INT_H
00021 #define       _LDAP_INT_H 1
00022 
00023 #ifdef LDAP_R_COMPILE
00024 #define LDAP_THREAD_SAFE 1
00025 #endif
00026 
00027 #include "../liblber/lber-int.h"
00028 #include "lutil.h"
00029 
00030 #ifdef LDAP_R_COMPILE
00031 #include <ldap_pvt_thread.h>
00032 #endif
00033 
00034 #ifdef HAVE_CYRUS_SASL
00035        /* the need for this should be removed */
00036 #ifdef HAVE_SASL_SASL_H
00037 #include <sasl/sasl.h>
00038 #else
00039 #include <sasl.h>
00040 #endif
00041 
00042 #define SASL_MAX_BUFF_SIZE  (0xffffff)
00043 #define SASL_MIN_BUFF_SIZE  4096
00044 #endif
00045 
00046 /* for struct timeval */
00047 #include <ac/time.h>
00048 
00049 #undef TV2MILLISEC
00050 #define TV2MILLISEC(tv) (((tv)->tv_sec * 1000) + ((tv)->tv_usec/1000))
00051 
00052 /* 
00053  * Support needed if the library is running in the kernel
00054  */
00055 #if LDAP_INT_IN_KERNEL
00056        /* 
00057         * Platform specific function to return a pointer to the
00058         * process-specific global options. 
00059         *
00060         * This function should perform the following functions:
00061         *  Allocate and initialize a global options struct on a per process basis
00062         *  Use callers process identifier to return its global options struct
00063         *  Note: Deallocate structure when the process exits
00064         */
00065 #      define LDAP_INT_GLOBAL_OPT() ldap_int_global_opt()
00066        struct ldapoptions *ldap_int_global_opt(void);
00067 #else
00068 #      define LDAP_INT_GLOBAL_OPT() (&ldap_int_global_options)
00069 #endif
00070 
00071 #define ldap_debug   ((LDAP_INT_GLOBAL_OPT())->ldo_debug)
00072 
00073 #include "ldap_log.h"
00074 
00075 #undef Debug
00076 
00077 #ifdef LDAP_DEBUG
00078 
00079 #define DebugTest( level ) \
00080        ( ldap_debug & level )
00081 
00082 #define Debug( level, fmt, arg1, arg2, arg3 ) \
00083        do { if ( ldap_debug & level ) \
00084        ldap_log_printf( NULL, (level), (fmt), (arg1), (arg2), (arg3) ); \
00085        } while ( 0 )
00086 
00087 #define LDAP_Debug( subsystem, level, fmt, arg1, arg2, arg3 )\
00088        ldap_log_printf( NULL, (level), (fmt), (arg1), (arg2), (arg3) )
00089 
00090 #else
00091 
00092 #define DebugTest( level )                                    (0 == 1)
00093 #define Debug( level, fmt, arg1, arg2, arg3 )                 ((void)0)
00094 #define LDAP_Debug( subsystem, level, fmt, arg1, arg2, arg3 ) ((void)0)
00095 
00096 #endif /* LDAP_DEBUG */
00097 
00098 #define LDAP_DEPRECATED 1
00099 #include "ldap.h"
00100 
00101 #include "ldap_pvt.h"
00102 
00103 LDAP_BEGIN_DECL
00104 
00105 #define LDAP_URL_PREFIX         "ldap://"
00106 #define LDAP_URL_PREFIX_LEN     STRLENOF(LDAP_URL_PREFIX)
00107 #define LDAPS_URL_PREFIX    "ldaps://"
00108 #define LDAPS_URL_PREFIX_LEN       STRLENOF(LDAPS_URL_PREFIX)
00109 #define LDAPI_URL_PREFIX    "ldapi://"
00110 #define LDAPI_URL_PREFIX_LEN       STRLENOF(LDAPI_URL_PREFIX)
00111 #ifdef LDAP_CONNECTIONLESS
00112 #define LDAPC_URL_PREFIX    "cldap://"
00113 #define LDAPC_URL_PREFIX_LEN       STRLENOF(LDAPC_URL_PREFIX)
00114 #endif
00115 #define LDAP_URL_URLCOLON   "URL:"
00116 #define LDAP_URL_URLCOLON_LEN      STRLENOF(LDAP_URL_URLCOLON)
00117 
00118 #define LDAP_REF_STR        "Referral:\n"
00119 #define LDAP_REF_STR_LEN    STRLENOF(LDAP_REF_STR)
00120 #define LDAP_LDAP_REF_STR   LDAP_URL_PREFIX
00121 #define LDAP_LDAP_REF_STR_LEN      LDAP_URL_PREFIX_LEN
00122 
00123 #define LDAP_DEFAULT_REFHOPLIMIT 5
00124 
00125 #define LDAP_BOOL_REFERRALS        0
00126 #define LDAP_BOOL_RESTART          1
00127 #define LDAP_BOOL_TLS                     3
00128 #define       LDAP_BOOL_CONNECT_ASYNC            4
00129 #define       LDAP_BOOL_SASL_NOCANON             5
00130 
00131 #define LDAP_BOOLEANS       unsigned long
00132 #define LDAP_BOOL(n) ((LDAP_BOOLEANS)1 << (n))
00133 #define LDAP_BOOL_GET(lo, bool)    \
00134        ((lo)->ldo_booleans & LDAP_BOOL(bool) ? -1 : 0)
00135 #define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool))
00136 #define LDAP_BOOL_CLR(lo, bool) ((lo)->ldo_booleans &= ~LDAP_BOOL(bool))
00137 #define LDAP_BOOL_ZERO(lo) ((lo)->ldo_booleans = 0)
00138 
00139 /*
00140  * This structure represents both ldap messages and ldap responses.
00141  * These are really the same, except in the case of search responses,
00142  * where a response has multiple messages.
00143  */
00144 
00145 struct ldapmsg {
00146        ber_int_t            lm_msgid;     /* the message id */
00147        ber_tag_t            lm_msgtype;   /* the message type */
00148        BerElement    *lm_ber;      /* the ber encoded message contents */
00149        struct ldapmsg       *lm_chain;    /* for search - next msg in the resp */
00150        struct ldapmsg       *lm_chain_tail;
00151        struct ldapmsg       *lm_next;     /* next response */
00152        time_t lm_time;      /* used to maintain cache */
00153 };
00154 
00155 #ifdef HAVE_TLS
00156 struct ldaptls {
00157        char          *lt_certfile;
00158        char          *lt_keyfile;
00159        char          *lt_dhfile;
00160        char          *lt_cacertfile;
00161        char          *lt_cacertdir;
00162        char          *lt_ciphersuite;
00163        char          *lt_crlfile;
00164        char          *lt_randfile; /* OpenSSL only */
00165        int           lt_protocol_min;
00166 };
00167 #endif
00168 
00169 typedef struct ldaplist {
00170        struct ldaplist *ll_next;
00171        void *ll_data;
00172 } ldaplist;
00173 
00174 /*
00175  * structure representing get/set'able options
00176  * which have global defaults.
00177  * Protect access to this struct with ldo_mutex
00178  * ldap_log.h:ldapoptions_prefix must match the head of this struct.
00179  */
00180 struct ldapoptions {
00181        short ldo_valid;
00182 #define LDAP_UNINITIALIZED  0x0
00183 #define LDAP_INITIALIZED    0x1
00184 #define LDAP_VALID_SESSION  0x2
00185 #define LDAP_TRASHED_SESSION       0xFF
00186        int   ldo_debug;
00187 
00188 #ifdef LDAP_R_COMPILE
00189        ldap_pvt_thread_mutex_t     ldo_mutex;
00190 #define LDAP_LDO_MUTEX_NULLARG     , LDAP_PVT_MUTEX_NULL
00191 #else
00192 #define LDAP_LDO_MUTEX_NULLARG
00193 #endif
00194 
00195 #ifdef LDAP_CONNECTIONLESS
00196 #define       LDAP_IS_UDP(ld)             ((ld)->ld_options.ldo_is_udp)
00197        void*                ldo_peer;     /* struct sockaddr* */
00198        char*                ldo_cldapdn;
00199        int                  ldo_is_udp;
00200 #endif
00201 
00202        /* per API call timeout */
00203        struct timeval              ldo_tm_api;
00204        struct timeval              ldo_tm_net;
00205 
00206        ber_int_t            ldo_version;
00207        ber_int_t            ldo_deref;
00208        ber_int_t            ldo_timelimit;
00209        ber_int_t            ldo_sizelimit;
00210 
00211 #ifdef HAVE_TLS
00212        /* tls context */
00213        void          *ldo_tls_ctx;
00214        LDAP_TLS_CONNECT_CB  *ldo_tls_connect_cb;
00215        void*                ldo_tls_connect_arg;
00216        struct ldaptls ldo_tls_info;
00217 #define ldo_tls_certfile    ldo_tls_info.lt_certfile
00218 #define ldo_tls_keyfile     ldo_tls_info.lt_keyfile
00219 #define ldo_tls_dhfile      ldo_tls_info.lt_dhfile
00220 #define ldo_tls_cacertfile  ldo_tls_info.lt_cacertfile
00221 #define ldo_tls_cacertdir   ldo_tls_info.lt_cacertdir
00222 #define ldo_tls_ciphersuite ldo_tls_info.lt_ciphersuite
00223 #define ldo_tls_protocol_min       ldo_tls_info.lt_protocol_min
00224 #define ldo_tls_crlfile     ldo_tls_info.lt_crlfile
00225 #define ldo_tls_randfile    ldo_tls_info.lt_randfile
00226        int                  ldo_tls_mode;
00227        int                  ldo_tls_require_cert;
00228        int                  ldo_tls_impl;
00229 #ifdef HAVE_OPENSSL_CRL
00230        int                  ldo_tls_crlcheck;
00231 #endif
00232 #endif
00233 
00234        LDAPURLDesc *ldo_defludp;
00235        int           ldo_defport;
00236        char*  ldo_defbase;
00237        char*  ldo_defbinddn;       /* bind dn */
00238 
00239 #ifdef HAVE_CYRUS_SASL
00240        char*  ldo_def_sasl_mech;          /* SASL Mechanism(s) */
00241        char*  ldo_def_sasl_realm;         /* SASL realm */
00242        char*  ldo_def_sasl_authcid;       /* SASL authentication identity */
00243        char*  ldo_def_sasl_authzid;       /* SASL authorization identity */
00244 
00245        /* SASL Security Properties */
00246        struct sasl_security_properties    ldo_sasl_secprops;
00247 #endif
00248 
00249 #ifdef HAVE_GSSAPI
00250        unsigned gssapi_flags;
00251 
00252        unsigned ldo_gssapi_flags;
00253 #define LDAP_GSSAPI_OPT_DO_NOT_FREE_GSS_CONTEXT  0x0001
00254 #define LDAP_GSSAPI_OPT_ALLOW_REMOTE_PRINCIPAL   0x0002
00255        unsigned ldo_gssapi_options;
00256 #endif
00257 
00258        /*
00259         * Per connection tcp-keepalive settings (Linux only,
00260         * ignored where unsupported)
00261         */
00262        ber_int_t ldo_keepalive_idle;
00263        ber_int_t ldo_keepalive_probes;
00264        ber_int_t ldo_keepalive_interval;
00265 
00266        int           ldo_refhoplimit;     /* limit on referral nesting */
00267 
00268        /* LDAPv3 server and client controls */
00269        LDAPControl   **ldo_sctrls;
00270        LDAPControl **ldo_cctrls;
00271 
00272        /* LDAP rebind callback function */
00273        LDAP_REBIND_PROC *ldo_rebind_proc;
00274        void *ldo_rebind_params;
00275        LDAP_NEXTREF_PROC *ldo_nextref_proc;
00276        void *ldo_nextref_params;
00277        LDAP_URLLIST_PROC *ldo_urllist_proc;
00278        void *ldo_urllist_params;
00279 
00280        /* LDAP connection callback stack */
00281        ldaplist *ldo_conn_cbs;
00282 
00283        LDAP_BOOLEANS ldo_booleans; /* boolean options */
00284 };
00285 
00286 
00287 /*
00288  * structure for representing an LDAP server connection
00289  */
00290 typedef struct ldap_conn {
00291        Sockbuf              *lconn_sb;
00292 #ifdef HAVE_CYRUS_SASL
00293        void          *lconn_sasl_authctx; /* context for bind */
00294        void          *lconn_sasl_sockctx; /* for security layer */
00295 #endif
00296 #ifdef HAVE_GSSAPI
00297        void          *lconn_gss_ctx;             /* gss_ctx_id_t */
00298 #endif
00299        int                  lconn_refcnt;
00300        time_t        lconn_created;       /* time */
00301        time_t        lconn_lastused;      /* time */
00302        int                  lconn_rebind_inprogress;    /* set if rebind in progress */
00303        char          ***lconn_rebind_queue;             /* used if rebind in progress */
00304        int                  lconn_status;
00305 #define LDAP_CONNST_NEEDSOCKET            1
00306 #define LDAP_CONNST_CONNECTING            2
00307 #define LDAP_CONNST_CONNECTED             3
00308        LDAPURLDesc          *lconn_server;
00309        BerElement           *lconn_ber;   /* ber receiving on this conn. */
00310 
00311        struct ldap_conn *lconn_next;
00312 } LDAPConn;
00313 
00314 
00315 /*
00316  * structure used to track outstanding requests
00317  */
00318 typedef struct ldapreq {
00319        ber_int_t     lr_msgid;     /* the message id */
00320        int           lr_status;    /* status of request */
00321 #define LDAP_REQST_COMPLETED       0
00322 #define LDAP_REQST_INPROGRESS      1
00323 #define LDAP_REQST_CHASINGREFS     2
00324 #define LDAP_REQST_NOTCONNECTED    3
00325 #define LDAP_REQST_WRITING  4
00326        int           lr_refcnt;    /* count of references */
00327        int           lr_outrefcnt; /* count of outstanding referrals */
00328        int           lr_abandoned; /* the request has been abandoned */
00329        ber_int_t     lr_origid;    /* original request's message id */
00330        int           lr_parentcnt; /* count of parent requests */
00331        ber_tag_t     lr_res_msgtype;      /* result message type */
00332        ber_int_t     lr_res_errno; /* result LDAP errno */
00333        char          *lr_res_error;       /* result error string */
00334        char          *lr_res_matched;/* result matched DN string */
00335        BerElement    *lr_ber;      /* ber encoded request contents */
00336        LDAPConn      *lr_conn;     /* connection used to send request */
00337        struct berval lr_dn;        /* DN of request, in lr_ber */
00338        struct ldapreq       *lr_parent;   /* request that spawned this referral */
00339        struct ldapreq       *lr_child;    /* first child request */
00340        struct ldapreq       *lr_refnext;  /* next referral spawned */
00341        struct ldapreq       *lr_prev;     /* previous request */
00342        struct ldapreq       *lr_next;     /* next request */
00343 } LDAPRequest;
00344 
00345 /*
00346  * structure for client cache
00347  */
00348 #define LDAP_CACHE_BUCKETS  31     /* cache hash table size */
00349 typedef struct ldapcache {
00350        LDAPMessage   *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
00351        LDAPMessage   *lc_requests;               /* unfulfilled reqs */
00352        long          lc_timeout;                 /* request timeout */
00353        ber_len_t            lc_maxmem;                  /* memory to use */
00354        ber_len_t            lc_memused;                 /* memory in use */
00355        int           lc_enabled;                 /* enabled? */
00356        unsigned long lc_options;                 /* options */
00357 #define LDAP_CACHE_OPT_CACHENOERRS 0x00000001
00358 #define LDAP_CACHE_OPT_CACHEALLERRS       0x00000002
00359 }  LDAPCache;
00360 
00361 /*
00362  * structure containing referral request info for rebind procedure
00363  */
00364 typedef struct ldapreqinfo {
00365        ber_len_t     ri_msgid;
00366        int                  ri_request;
00367        char          *ri_url;
00368 } LDAPreqinfo;
00369 
00370 /*
00371  * structure representing an ldap connection
00372  */
00373 
00374 struct ldap_common {
00375        Sockbuf              *ldc_sb;      /* socket descriptor & buffer */
00376 #define ld_sb               ldc->ldc_sb
00377 
00378        /* protected by ldo_mutex */
00379        struct ldapoptions ldc_options;
00380 #define ld_options          ldc->ldc_options
00381 
00382 #define ld_valid            ld_options.ldo_valid
00383 #define ld_debug            ld_options.ldo_debug
00384 
00385 #define ld_deref            ld_options.ldo_deref
00386 #define ld_timelimit        ld_options.ldo_timelimit
00387 #define ld_sizelimit        ld_options.ldo_sizelimit
00388 
00389 #define ld_defbinddn        ld_options.ldo_defbinddn
00390 #define ld_defbase          ld_options.ldo_defbase
00391 #define ld_defhost          ld_options.ldo_defhost
00392 #define ld_defport          ld_options.ldo_defport
00393 
00394 #define ld_refhoplimit             ld_options.ldo_refhoplimit
00395 
00396 #define ld_sctrls           ld_options.ldo_sctrls
00397 #define ld_cctrls           ld_options.ldo_cctrls
00398 #define ld_rebind_proc             ld_options.ldo_rebind_proc
00399 #define ld_rebind_params    ld_options.ldo_rebind_params
00400 #define ld_nextref_proc            ld_options.ldo_nextref_proc
00401 #define ld_nextref_params   ld_options.ldo_nextref_params
00402 #define ld_urllist_proc            ld_options.ldo_urllist_proc
00403 #define ld_urllist_params   ld_options.ldo_urllist_params
00404 
00405 #define ld_version          ld_options.ldo_version
00406 #ifdef LDAP_R_COMPILE
00407 #define       ld_ldopts_mutex             ld_options.ldo_mutex
00408 #endif
00409 
00410        unsigned short       ldc_lberoptions;
00411 #define       ld_lberoptions              ldc->ldc_lberoptions
00412 
00413        /* protected by msgid_mutex */
00414        ber_len_t            ldc_msgid;
00415 #define       ld_msgid             ldc->ldc_msgid
00416 
00417        /* do not mess with these */
00418        /* protected by req_mutex */
00419        LDAPRequest   *ldc_requests;       /* list of outstanding requests */
00420        /* protected by res_mutex */
00421        LDAPMessage   *ldc_responses;      /* list of outstanding responses */
00422 #define       ld_requests          ldc->ldc_requests
00423 #define       ld_responses         ldc->ldc_responses
00424 
00425 #ifdef LDAP_R_COMPILE
00426        ldap_pvt_thread_mutex_t     ldc_msgid_mutex;
00427        ldap_pvt_thread_mutex_t     ldc_conn_mutex;
00428        ldap_pvt_thread_mutex_t     ldc_req_mutex;
00429        ldap_pvt_thread_mutex_t     ldc_res_mutex;
00430        ldap_pvt_thread_mutex_t     ldc_abandon_mutex;
00431 #define       ld_msgid_mutex              ldc->ldc_msgid_mutex
00432 #define       ld_conn_mutex        ldc->ldc_conn_mutex
00433 #define       ld_req_mutex         ldc->ldc_req_mutex
00434 #define       ld_res_mutex         ldc->ldc_res_mutex
00435 #define       ld_abandon_mutex     ldc->ldc_abandon_mutex
00436 #endif
00437 
00438        /* protected by abandon_mutex */
00439        ber_len_t     ldc_nabandoned;
00440        ber_int_t     *ldc_abandoned;      /* array of abandoned requests */
00441 #define       ld_nabandoned        ldc->ldc_nabandoned
00442 #define       ld_abandoned         ldc->ldc_abandoned
00443 
00444        /* unused by libldap */
00445        LDAPCache     *ldc_cache;   /* non-null if cache is initialized */
00446 #define       ld_cache             ldc->ldc_cache
00447 
00448        /* do not mess with the rest though */
00449 
00450        /* protected by conn_mutex */
00451        LDAPConn      *ldc_defconn; /* default connection */
00452 #define       ld_defconn           ldc->ldc_defconn
00453        LDAPConn      *ldc_conns;   /* list of server connections */
00454 #define       ld_conns             ldc->ldc_conns
00455        void          *ldc_selectinfo;/* platform specifics for select */
00456 #define       ld_selectinfo        ldc->ldc_selectinfo
00457 
00458        /* ldap_common refcnt - free only if 0 */
00459 #ifdef LDAP_R_COMPILE
00460        ldap_pvt_thread_mutex_t     ldc_mutex;
00461 #define       ld_ldcmutex          ldc->ldc_mutex
00462 #endif
00463        /* protected by ldc_mutex */
00464        unsigned int         ldc_refcnt;
00465 #define       ld_ldcrefcnt         ldc->ldc_refcnt
00466 };
00467 
00468 struct ldap {
00469        /* thread shared */
00470        struct ldap_common   *ldc;
00471 
00472        /* thread specific */
00473        ber_int_t            ld_errno;
00474        char                 *ld_error;
00475        char                 *ld_matched;
00476        char                 **ld_referrals;
00477 };
00478 
00479 #define LDAP_VALID(ld)             ( (ld)->ld_valid == LDAP_VALID_SESSION )
00480 #define LDAP_TRASHED(ld)    ( (ld)->ld_valid == LDAP_TRASHED_SESSION )
00481 #define LDAP_TRASH(ld)             ( (ld)->ld_valid = LDAP_TRASHED_SESSION )
00482 
00483 #ifdef LDAP_R_COMPILE
00484 LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
00485 
00486 #ifdef HAVE_CYRUS_SASL
00487 LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_sasl_mutex;
00488 #endif
00489 #ifdef HAVE_GSSAPI
00490 LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;
00491 #endif
00492 #endif
00493 
00494 #ifdef LDAP_R_COMPILE
00495 #define LDAP_MUTEX_LOCK(mutex)    ldap_pvt_thread_mutex_lock( mutex )
00496 #define LDAP_MUTEX_UNLOCK(mutex)  ldap_pvt_thread_mutex_unlock( mutex )
00497 #define LDAP_ASSERT_MUTEX_OWNER(mutex) \
00498        LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex)
00499 #else
00500 #define LDAP_MUTEX_LOCK(mutex)    ((void) 0)
00501 #define LDAP_MUTEX_UNLOCK(mutex)  ((void) 0)
00502 #define LDAP_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
00503 #endif
00504 
00505 #define       LDAP_NEXT_MSGID(ld, id) do { \
00506        LDAP_MUTEX_LOCK( &(ld)->ld_msgid_mutex ); \
00507        (id) = ++(ld)->ld_msgid; \
00508        LDAP_MUTEX_UNLOCK( &(ld)->ld_msgid_mutex ); \
00509 } while (0)
00510 
00511 /*
00512  * in abandon.c
00513  */
00514 
00515 LDAP_F (int)
00516 ldap_int_bisect_find( ber_int_t *v, ber_len_t n, ber_int_t id, int *idxp );
00517 LDAP_F (int)
00518 ldap_int_bisect_insert( ber_int_t **vp, ber_len_t *np, int id, int idx );
00519 LDAP_F (int)
00520 ldap_int_bisect_delete( ber_int_t **vp, ber_len_t *np, int id, int idx );
00521 
00522 /*
00523  * in init.c
00524  */
00525 
00526 LDAP_V ( struct ldapoptions ) ldap_int_global_options;
00527 
00528 LDAP_F ( void ) ldap_int_initialize LDAP_P((struct ldapoptions *, int *));
00529 LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P((
00530        struct ldapoptions *, int *));
00531 
00532 /* memory.c */
00533        /* simple macros to realloc for now */
00534 #define LDAP_MALLOC(s)             (ber_memalloc_x((s),NULL))
00535 #define LDAP_CALLOC(n,s)    (ber_memcalloc_x((n),(s),NULL))
00536 #define LDAP_REALLOC(p,s)   (ber_memrealloc_x((p),(s),NULL))
00537 #define LDAP_FREE(p)        (ber_memfree_x((p),NULL))
00538 #define LDAP_VFREE(v)              (ber_memvfree_x((void **)(v),NULL))
00539 #define LDAP_STRDUP(s)             (ber_strdup_x((s),NULL))
00540 #define LDAP_STRNDUP(s,l)   (ber_strndup_x((s),(l),NULL))
00541 
00542 #define LDAP_MALLOCX(s,x)   (ber_memalloc_x((s),(x)))
00543 #define LDAP_CALLOCX(n,s,x) (ber_memcalloc_x((n),(s),(x)))
00544 #define LDAP_REALLOCX(p,s,x)       (ber_memrealloc_x((p),(s),(x)))
00545 #define LDAP_FREEX(p,x)            (ber_memfree_x((p),(x)))
00546 #define LDAP_VFREEX(v,x)    (ber_memvfree_x((void **)(v),(x)))
00547 #define LDAP_STRDUPX(s,x)   (ber_strdup_x((s),(x)))
00548 #define LDAP_STRNDUPX(s,l,x)       (ber_strndup_x((s),(l),(x)))
00549 
00550 /*
00551  * in error.c
00552  */
00553 LDAP_F (void) ldap_int_error_init( void );
00554 
00555 /*
00556  * in unit-int.c
00557  */
00558 LDAP_F (void) ldap_int_utils_init LDAP_P(( void ));
00559 
00560 
00561 /*
00562  * in print.c
00563  */
00564 LDAP_F (int) ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...)) LDAP_GCCATTR((format(printf, 3, 4)));
00565 
00566 /*
00567  * in cache.c
00568  */
00569 LDAP_F (void) ldap_add_request_to_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype,
00570         BerElement *request ));
00571 LDAP_F (void) ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
00572 LDAP_F (int) ldap_check_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype, BerElement *request ));
00573 
00574 /*
00575  * in controls.c
00576  */
00577 LDAP_F (int) ldap_int_put_controls LDAP_P((
00578        LDAP *ld,
00579        LDAPControl *const *ctrls,
00580        BerElement *ber ));
00581 
00582 LDAP_F (int) ldap_int_client_controls LDAP_P((
00583        LDAP *ld,
00584        LDAPControl **ctrlp ));
00585 
00586 /*
00587  * in dsparse.c
00588  */
00589 LDAP_F (int) ldap_int_next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp ));
00590 
00591 
00592 /*
00593  * in open.c
00594  */
00595 LDAP_F (int) ldap_open_defconn( LDAP *ld );
00596 LDAP_F (int) ldap_int_open_connection( LDAP *ld,
00597        LDAPConn *conn, LDAPURLDesc *srvlist, int async );
00598 LDAP_F (int) ldap_int_check_async_open( LDAP *ld, ber_socket_t sd );
00599 
00600 /*
00601  * in os-ip.c
00602  */
00603 #ifndef HAVE_POLL
00604 LDAP_V (int) ldap_int_tblsize;
00605 LDAP_F (void) ldap_int_ip_init( void );
00606 #endif
00607 
00608 LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest,
00609        const struct timeval *tm );
00610 LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb,
00611        int proto, LDAPURLDesc *srv, int async );
00612 LDAP_F (int) ldap_int_poll( LDAP *ld, ber_socket_t s,
00613        struct timeval *tvp );
00614 
00615 #if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
00616 LDAP_V (char *) ldap_int_hostname;
00617 LDAP_F (char *) ldap_host_connected_to( Sockbuf *sb,
00618        const char *host );
00619 #endif
00620 
00621 LDAP_F (int) ldap_int_select( LDAP *ld, struct timeval *timeout );
00622 LDAP_F (void *) ldap_new_select_info( void );
00623 LDAP_F (void) ldap_free_select_info( void *sip );
00624 LDAP_F (void) ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
00625 LDAP_F (void) ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
00626 LDAP_F (void) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
00627 LDAP_F (void) ldap_clear_select_write( LDAP *ld, Sockbuf *sb );
00628 LDAP_F (int) ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
00629 LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
00630 
00631 LDAP_F (int) ldap_int_connect_cbs( LDAP *ld, Sockbuf *sb,
00632        ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr );
00633 
00634 /*
00635  * in os-local.c
00636  */
00637 #ifdef LDAP_PF_LOCAL
00638 LDAP_F (int) ldap_connect_to_path( LDAP *ld, Sockbuf *sb,
00639        LDAPURLDesc *srv, int async );
00640 #endif /* LDAP_PF_LOCAL */
00641 
00642 /*
00643  * in request.c
00644  */
00645 LDAP_F (ber_int_t) ldap_send_initial_request( LDAP *ld, ber_tag_t msgtype,
00646        const char *dn, BerElement *ber, ber_int_t msgid );
00647 LDAP_F (BerElement *) ldap_alloc_ber_with_options( LDAP *ld );
00648 LDAP_F (void) ldap_set_ber_options( LDAP *ld, BerElement *ber );
00649 
00650 LDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber,
00651        ber_int_t msgid, LDAPRequest *parentreq, LDAPURLDesc **srvlist,
00652        LDAPConn *lc, LDAPreqinfo *bind, int noconn, int m_res );
00653 LDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist,
00654        int use_ldsb, int connect, LDAPreqinfo *bind, int m_req, int m_res );
00655 LDAP_F (LDAPRequest *) ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
00656 LDAP_F (void) ldap_return_request( LDAP *ld, LDAPRequest *lr, int freeit );
00657 LDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
00658 LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
00659 LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
00660 LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld );
00661 LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
00662        char **errstrp, int sref, int *hadrefp );
00663 LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
00664        char **refs, int sref, char **referralsp, int *hadrefp );
00665 LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
00666 LDAP_F (int) ldap_int_flush_request( LDAP *ld, LDAPRequest *lr );
00667 
00668 /*
00669  * in result.c:
00670  */
00671 LDAP_F (const char *) ldap_int_msgtype2str( ber_tag_t tag );
00672 
00673 /*
00674  * in search.c
00675  */
00676 LDAP_F (BerElement *) ldap_build_search_req LDAP_P((
00677        LDAP *ld,
00678        const char *base,
00679        ber_int_t scope,
00680        const char *filter,
00681        char **attrs,
00682        ber_int_t attrsonly,
00683        LDAPControl **sctrls,
00684        LDAPControl **cctrls,
00685        ber_int_t timelimit,
00686        ber_int_t sizelimit,
00687        ber_int_t deref,
00688        ber_int_t *msgidp));
00689 
00690 
00691 /*
00692  * in unbind.c
00693  */
00694 LDAP_F (int) ldap_ld_free LDAP_P((
00695        LDAP *ld,
00696        int close,
00697        LDAPControl **sctrls,
00698        LDAPControl **cctrls ));
00699 
00700 LDAP_F (int) ldap_send_unbind LDAP_P((
00701        LDAP *ld,
00702        Sockbuf *sb,
00703        LDAPControl **sctrls,
00704        LDAPControl **cctrls ));
00705 
00706 /*
00707  * in url.c
00708  */
00709 LDAP_F (LDAPURLDesc *) ldap_url_dup LDAP_P((
00710        LDAPURLDesc *ludp ));
00711 
00712 LDAP_F (LDAPURLDesc *) ldap_url_duplist LDAP_P((
00713        LDAPURLDesc *ludlist ));
00714 
00715 LDAP_F (int) ldap_url_parsehosts LDAP_P((
00716        LDAPURLDesc **ludlist,
00717        const char *hosts,
00718        int port ));
00719 
00720 LDAP_F (char *) ldap_url_list2hosts LDAP_P((
00721        LDAPURLDesc *ludlist ));
00722 
00723 /*
00724  * in cyrus.c
00725  */
00726 
00727 LDAP_F (int) ldap_int_sasl_init LDAP_P(( void ));
00728 
00729 LDAP_F (int) ldap_int_sasl_open LDAP_P((
00730        LDAP *ld, LDAPConn *conn,
00731        const char* host ));
00732 LDAP_F (int) ldap_int_sasl_close LDAP_P(( LDAP *ld, LDAPConn *conn ));
00733 
00734 LDAP_F (int) ldap_int_sasl_external LDAP_P((
00735        LDAP *ld, LDAPConn *conn,
00736        const char* authid, ber_len_t ssf ));
00737 
00738 LDAP_F (int) ldap_int_sasl_get_option LDAP_P(( LDAP *ld,
00739        int option, void *arg ));
00740 LDAP_F (int) ldap_int_sasl_set_option LDAP_P(( LDAP *ld,
00741        int option, void *arg ));
00742 LDAP_F (int) ldap_int_sasl_config LDAP_P(( struct ldapoptions *lo,
00743        int option, const char *arg ));
00744 
00745 LDAP_F (int) ldap_int_sasl_bind LDAP_P((
00746        LDAP *ld,
00747        const char *,
00748        const char *,
00749        LDAPControl **, LDAPControl **,
00750 
00751        /* should be passed in client controls */
00752        unsigned flags,
00753        LDAP_SASL_INTERACT_PROC *interact,
00754        void *defaults,
00755        LDAPMessage *result,
00756        const char **rmech,
00757        int *msgid ));
00758 
00759 /* in schema.c */
00760 LDAP_F (char *) ldap_int_parse_numericoid LDAP_P((
00761        const char **sp,
00762        int *code,
00763        const int flags ));
00764 
00765 /*
00766  * in tls.c
00767  */
00768 LDAP_F (int) ldap_int_tls_config LDAP_P(( LDAP *ld,
00769        int option, const char *arg ));
00770 
00771 LDAP_F (int) ldap_int_tls_start LDAP_P(( LDAP *ld,
00772        LDAPConn *conn, LDAPURLDesc *srv ));
00773 
00774 LDAP_F (void) ldap_int_tls_destroy LDAP_P(( struct ldapoptions *lo ));
00775 
00776 /*
00777  *     in getvalues.c
00778  */
00779 LDAP_F (char **) ldap_value_dup LDAP_P((
00780        char *const *vals ));
00781 
00782 /*
00783  *     in gssapi.c
00784  */
00785 #ifdef HAVE_GSSAPI
00786 LDAP_F(int) ldap_int_gssapi_get_option LDAP_P(( LDAP *ld, int option, void *arg ));
00787 LDAP_F(int) ldap_int_gssapi_set_option LDAP_P(( LDAP *ld, int option, void *arg ));
00788 LDAP_F(int) ldap_int_gssapi_config LDAP_P(( struct ldapoptions *lo, int option, const char *arg ));
00789 LDAP_F(void) ldap_int_gssapi_close LDAP_P(( LDAP *ld, LDAPConn *lc ));
00790 #endif 
00791 
00792 LDAP_END_DECL
00793 
00794 #endif /* _LDAP_INT_H */