Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions | Variables
ldap-int.h File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/select.h>
#include "../liblber/lber-int.h"
#include "ldap.h"
#include "ldaprot.h"
#include "ldaplog.h"
#include "portable.h"

Go to the source code of this file.

Classes

struct  ldapmsg
struct  ldap_server
struct  ldap_conn
struct  ldapreq
struct  ldappend
struct  ldap_x_ext_io_fns_rev0
struct  ldap
struct  ldap_filt_list
struct  ldap_filt_desc

Defines

#define NSLBERI_LBER_INT_FRIEND
#define NSLDAPI_HAVE_POLL   1
#define SSL_VERSION   0
#define LDAP_URL_URLCOLON   "URL:"
#define LDAP_URL_URLCOLON_LEN   4
#define LDAP_LDAP_REF_STR   LDAP_URL_PREFIX
#define LDAP_LDAP_REF_STR_LEN   LDAP_URL_PREFIX_LEN
#define LDAP_LDAPS_REF_STR   LDAPS_URL_PREFIX
#define LDAP_LDAPS_REF_STR_LEN   LDAPS_URL_PREFIX_LEN
#define LDAP_DEFAULT_REFHOPLIMIT   5
#define LDAP_SRV_OPT_SECURE   0x01
#define LDAP_CONNST_NEEDSOCKET   1
#define LDAP_CONNST_CONNECTING   2
#define LDAP_CONNST_CONNECTED   3
#define LDAP_CONNST_DEAD   4
#define LDAP_REQST_INPROGRESS   1
#define LDAP_REQST_CHASINGREFS   2
#define LDAP_REQST_NOTCONNECTED   3
#define LDAP_REQST_WRITING   4
#define LDAP_REQST_CONNDEAD   5 /* associated conn. has failed */
#define LDAP_X_EXTIO_FNS_SIZE_REV0   sizeof(struct ldap_x_ext_io_fns_rev0)
#define LDAP_BITOPT_REFERRALS   0x80000000
#define LDAP_BITOPT_SSL   0x40000000
#define LDAP_BITOPT_DNS   0x20000000
#define LDAP_BITOPT_RESTART   0x10000000
#define LDAP_BITOPT_RECONNECT   0x08000000
#define LDAP_BITOPT_ASYNC   0x04000000
#define ld_extio_size   ld_ext_io_fns.lextiof_size
#define ld_extclose_fn   ld_ext_io_fns.lextiof_close
#define ld_extconnect_fn   ld_ext_io_fns.lextiof_connect
#define ld_extread_fn   ld_ext_io_fns.lextiof_read
#define ld_extwrite_fn   ld_ext_io_fns.lextiof_write
#define ld_extwritev_fn   ld_ext_io_fns.lextiof_writev
#define ld_extpoll_fn   ld_ext_io_fns.lextiof_poll
#define ld_extnewhandle_fn   ld_ext_io_fns.lextiof_newhandle
#define ld_extdisposehandle_fn   ld_ext_io_fns.lextiof_disposehandle
#define ld_ext_session_arg   ld_ext_io_fns.lextiof_session_arg
#define NSLDAPI_USING_CLASSIC_IO_FUNCTIONS(ld)   ((ld)->ld_io_fns_ptr != NULL)
#define ld_dns_extradata   ld_dnsfn.lddnsfn_extradata
#define ld_dns_bufsize   ld_dnsfn.lddnsfn_bufsize
#define ld_dns_gethostbyname_fn   ld_dnsfn.lddnsfn_gethostbyname
#define ld_dns_gethostbyaddr_fn   ld_dnsfn.lddnsfn_gethostbyaddr
#define ld_mutex_alloc_fn   ld_thread.ltf_mutex_alloc
#define ld_mutex_free_fn   ld_thread.ltf_mutex_free
#define ld_mutex_lock_fn   ld_thread.ltf_mutex_lock
#define ld_mutex_unlock_fn   ld_thread.ltf_mutex_unlock
#define ld_get_errno_fn   ld_thread.ltf_get_errno
#define ld_set_errno_fn   ld_thread.ltf_set_errno
#define ld_get_lderrno_fn   ld_thread.ltf_get_lderrno
#define ld_set_lderrno_fn   ld_thread.ltf_set_lderrno
#define ld_lderrno_arg   ld_thread.ltf_lderrno_arg
#define ld_cache_config   ld_cache.lcf_config
#define ld_cache_bind   ld_cache.lcf_bind
#define ld_cache_unbind   ld_cache.lcf_unbind
#define ld_cache_search   ld_cache.lcf_search
#define ld_cache_compare   ld_cache.lcf_compare
#define ld_cache_add   ld_cache.lcf_add
#define ld_cache_delete   ld_cache.lcf_delete
#define ld_cache_modify   ld_cache.lcf_modify
#define ld_cache_modrdn   ld_cache.lcf_modrdn
#define ld_cache_abandon   ld_cache.lcf_abandon
#define ld_cache_result   ld_cache.lcf_result
#define ld_cache_flush   ld_cache.lcf_flush
#define ld_cache_arg   ld_cache.lcf_arg
#define ld_mutex_trylock_fn   ld_thread2.ltf_mutex_trylock
#define ld_sema_alloc_fn   ld_thread2.ltf_sema_alloc
#define ld_sema_free_fn   ld_thread2.ltf_sema_free
#define ld_sema_wait_fn   ld_thread2.ltf_sema_wait
#define ld_sema_post_fn   ld_thread2.ltf_sema_post
#define ld_threadid_fn   ld_thread2.ltf_threadid_fn
#define LDAP_MUTEX_ALLOC(ld)   (((ld)->ld_mutex_alloc_fn != NULL) ? (ld)->ld_mutex_alloc_fn() : NULL)
#define LDAP_MUTEX_FREE(ld, m)
#define LDAP_MUTEX_LOCK(ld, lock)
#define LDAP_MUTEX_UNLOCK(ld, lock)
#define LDAP_MUTEX_BC_LOCK(ld, i)
#define LDAP_MUTEX_BC_UNLOCK(ld, i)
#define LDAP_SEMA_ALLOC(ld)   (((ld)->ld_sema_alloc_fn != NULL) ? (ld)->ld_sema_alloc_fn() : NULL)
#define LDAP_SEMA_FREE(ld, m)
#define LDAP_SEMA_WAIT(ld, lp)
#define LDAP_SEMA_POST(ld, lp)
#define POST(ld, y, z)
#define LDAP_SET_ERRNO(ld, e)
#define LDAP_GET_ERRNO(ld)
#define LDAP_SET_LDERRNO(ld, e, m, s)   ldap_set_lderrno( ld, e, m, s )
#define LDAP_GET_LDERRNO(ld, m, s)   ldap_get_lderrno( ld, m, s )
#define NSLDAPI_MIN(a, b)   (((a) < (b)) ? (a) : (b))
#define LDAP_IS_CLDAP(ld)   ( ld->ld_sbp->sb_naddr > 0 )
#define NSLDAPI_ERRNO_IO_INPROGRESS(e)   ((e) == EWOULDBLOCK || (e) == EINPROGRESS)
#define NSLDAPI_LDAP_VERSION(ld)
#define LDAP_FILT_MAXSIZ   1024
#define NSLDAPI_MALLOC(size)   ldap_x_malloc( size )
#define NSLDAPI_CALLOC(nelem, elsize)   ldap_x_calloc( nelem, elsize )
#define NSLDAPI_REALLOC(ptr, size)   ldap_x_realloc( ptr, size )
#define NSLDAPI_FREE(ptr)   ldap_x_free( ptr )
#define NSLDAPI_VALID_LDAP_POINTER(ld)   ( (ld) != NULL )
#define NSLDAPI_VALID_LDAPMESSAGE_POINTER(lm)   ( (lm) != NULL )
#define NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER(lm)   ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_SEARCH_ENTRY )
#define NSLDAPI_VALID_LDAPMESSAGE_REFERENCE_POINTER(lm)   ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_SEARCH_REFERENCE )
#define NSLDAPI_VALID_LDAPMESSAGE_BINDRESULT_POINTER(lm)   ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_BIND )
#define NSLDAPI_VALID_LDAPMESSAGE_EXRESULT_POINTER(lm)   ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_EXTENDED )
#define NSLDAPI_VALID_LDAPMOD_ARRAY(mods)   ( (mods) != NULL )
#define NSLDAPI_VALID_NONEMPTY_LDAPMOD_ARRAY(mods)   ( (mods) != NULL && (mods)[0] != NULL )
#define NSLDAPI_IS_SEARCH_ENTRY(code)   ((code) == LDAP_RES_SEARCH_ENTRY)
#define NSLDAPI_IS_SEARCH_RESULT(code)   ((code) == LDAP_RES_SEARCH_RESULT)
#define NSLDAPI_SEARCH_RELATED_RESULT(code)   (NSLDAPI_IS_SEARCH_RESULT( code ) || NSLDAPI_IS_SEARCH_ENTRY( code ))

Typedefs

typedef struct ldap_server LDAPServer
typedef struct ldap_conn LDAPConn
typedef struct ldapreq LDAPRequest
typedef struct ldappend LDAPPend
typedef struct nsldapi_iostatus_info

Enumerations

enum  LDAPLock {
  LDAP_CACHE_LOCK, LDAP_MEMCACHE_LOCK, LDAP_MSGID_LOCK, LDAP_REQ_LOCK,
  LDAP_RESP_LOCK, LDAP_ABANDON_LOCK, LDAP_CTRL_LOCK, LDAP_OPTION_LOCK,
  LDAP_ERR_LOCK, LDAP_CONN_LOCK, LDAP_IOSTATUS_LOCK, LDAP_RESULT_LOCK,
  LDAP_PEND_LOCK, LDAP_THREADID_LOCK, LDAP_MAX_LOCK
}

Functions

char * nsldapi_get_binddn (LDAP *ld)
void nsldapi_add_result_to_cache (LDAP *ld, LDAPMessage *result)
int nsldapi_next_line_tokens (char **bufp, long *blenp, char ***toksp)
void nsldapi_free_strarray (char **sap)
int nsldapi_parse_result (LDAP *ld, int msgtype, BerElement *rber, int *errcodep, char **matchednp, char **errmsgp, char ***referralsp, LDAPControl ***serverctrlsp)
void nsldapi_initialize_defaults (void)
void nsldapi_mutex_alloc_all (LDAP *ld)
void nsldapi_mutex_free_all (LDAP *ld)
int nsldapi_open_ldap_defconn (LDAP *ld)
char * nsldapi_strdup (const char *s)
int nsldapi_connect_to_host (LDAP *ld, Sockbuf *sb, const char *host, int port, int secure, char **krbinstancep)
void nsldapi_close_connection (LDAP *ld, Sockbuf *sb)
int nsldapi_iostatus_poll (LDAP *ld, struct timeval *timeout)
void nsldapi_iostatus_free (LDAP *ld)
int nsldapi_iostatus_interest_write (LDAP *ld, Sockbuf *sb)
int nsldapi_iostatus_interest_read (LDAP *ld, Sockbuf *sb)
int nsldapi_iostatus_interest_clear (LDAP *ld, Sockbuf *sb)
int nsldapi_iostatus_is_read_ready (LDAP *ld, Sockbuf *sb)
int nsldapi_iostatus_is_write_ready (LDAP *ld, Sockbuf *sb)
int nsldapi_install_lber_extiofns (LDAP *ld, Sockbuf *sb)
int nsldapi_install_compat_io_fns (LDAP *ld, struct ldap_io_fns *iofns)
int nsldapi_parse_reference (LDAP *ld, BerElement *rber, char ***referralsp, LDAPControl ***serverctrlsp)
int ldap_msgdelete (LDAP *ld, int msgid)
int nsldapi_result_nolock (LDAP *ld, int msgid, int all, int unlock_permitted, struct timeval *timeout, LDAPMessage **result)
int nsldapi_wait_result (LDAP *ld, int msgid, int all, struct timeval *timeout, LDAPMessage **result)
int nsldapi_post_result (LDAP *ld, int msgid, LDAPMessage *result)
int nsldapi_send_initial_request (LDAP *ld, int msgid, unsigned long msgtype, char *dn, BerElement *ber)
int nsldapi_alloc_ber_with_options (LDAP *ld, BerElement **berp)
void nsldapi_set_ber_options (LDAP *ld, BerElement *ber)
int nsldapi_ber_flush (LDAP *ld, Sockbuf *sb, BerElement *ber, int freeit, int async)
int nsldapi_send_server_request (LDAP *ld, BerElement *ber, int msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, char *bindreqdn, int bind)
LDAPConnnsldapi_new_connection (LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind)
LDAPRequestnsldapi_find_request_by_msgid (LDAP *ld, int msgid)
void nsldapi_free_request (LDAP *ld, LDAPRequest *lr, int free_conn)
void nsldapi_free_connection (LDAP *ld, LDAPConn *lc, LDAPControl **serverctrls, LDAPControl **clientctrls, int force, int unbind)
void nsldapi_dump_connection (LDAP *ld, LDAPConn *lconns, int all)
void nsldapi_dump_requests_and_responses (LDAP *ld)
int nsldapi_chase_v2_referrals (LDAP *ld, LDAPRequest *lr, char **errstrp, int *totalcountp, int *chasingcountp)
int nsldapi_chase_v3_refs (LDAP *ld, LDAPRequest *lr, char **refs, int is_reference, int *totalcountp, int *chasingcountp)
int nsldapi_append_referral (LDAP *ld, char **referralsp, char *s)
void nsldapi_connection_lost_nolock (LDAP *ld, Sockbuf *sb)
int nsldapi_build_search_req (LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, int timelimit, int sizelimit, int msgid, BerElement **berp)
int ldap_ld_free (LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls, int close)
int nsldapi_send_unbind (LDAP *ld, Sockbuf *sb, LDAPControl **serverctrls, LDAPControl **clientctrls)
void nsldapi_hex_unescape (char *s)
LDAPMessage * ldap_delete_result_entry (LDAPMessage **list, LDAPMessage *e)
void ldap_add_result_entry (LDAPMessage **list, LDAPMessage *e)
int nsldapi_put_controls (LDAP *ld, LDAPControl **ctrls, int closeseq, BerElement *ber)
int nsldapi_get_controls (BerElement *ber, LDAPControl ***controlsp)
int nsldapi_dup_controls (LDAP *ld, LDAPControl ***ldctrls, LDAPControl **newctrls)
int nsldapi_build_control (char *oid, BerElement *ber, int freeber, char iscritical, LDAPControl **ctrlp)
int nsldapi_url_parse (const char *inurl, LDAPURLDesc **ludpp, int dn_required)
int ldap_memcache_createkey (LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, unsigned long *keyp)
int ldap_memcache_result (LDAP *ld, int msgid, unsigned long key)
int ldap_memcache_new (LDAP *ld, int msgid, unsigned long key, const char *basedn)
int ldap_memcache_append (LDAP *ld, int msgid, int bLast, LDAPMessage *result)
int ldap_memcache_abandon (LDAP *ld, int msgid)

Variables

int nsldapi_initialized

Class Documentation

struct ldapmsg

Definition at line 157 of file ldap-int.h.

Collaboration diagram for ldapmsg:
Class Members
BerElement * lm_ber
struct ldapmsg * lm_chain
int lm_fromcache
int lm_msgid
int lm_msgtype
struct ldapmsg * lm_next
struct ldap_server

Definition at line 169 of file ldap-int.h.

Collaboration diagram for ldap_server:
Class Members
char * lsrv_dn
char * lsrv_host
struct ldap_server * lsrv_next
unsigned long lsrv_options
int lsrv_port
struct ldap_conn

Definition at line 181 of file ldap-int.h.

Collaboration diagram for ldap_conn:
Class Members
BerElement * lconn_ber
char * lconn_binddn
int lconn_bound
char * lconn_krbinstance
unsigned long lconn_lastused
struct ldap_conn * lconn_next
int lconn_refcnt
Sockbuf * lconn_sb
LDAPServer * lconn_server
int lconn_status
int lconn_version
struct ldapreq

Definition at line 203 of file ldap-int.h.

Collaboration diagram for ldapreq:
Class Members
BerElement * lr_ber
char * lr_binddn
struct ldapreq * lr_child
LDAPConn * lr_conn
int lr_msgid
struct ldapreq * lr_next
int lr_origid
int lr_outrefcnt
struct ldapreq * lr_parent
int lr_parentcnt
struct ldapreq * lr_prev
int lr_res_errno
char * lr_res_error
char * lr_res_matched
int lr_res_msgtype
struct ldapreq * lr_sibling
int lr_status
struct ldappend

Definition at line 228 of file ldap-int.h.

Collaboration diagram for ldappend:
Class Members
int lp_msgid
struct ldappend * lp_next
struct ldappend * lp_prev
LDAPMessage * lp_result
void * lp_sema
struct ldap_x_ext_io_fns_rev0

Definition at line 244 of file ldap-int.h.

Collaboration diagram for ldap_x_ext_io_fns_rev0:
Class Members
LDAP_X_EXTIOF_CLOSE_CALLBACK * lextiof_close
LDAP_X_EXTIOF_CONNECT_CALLBACK * lextiof_connect
LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK * lextiof_disposehandle
LDAP_X_EXTIOF_NEWHANDLE_CALLBACK * lextiof_newhandle
LDAP_X_EXTIOF_POLL_CALLBACK * lextiof_poll
LDAP_X_EXTIOF_READ_CALLBACK * lextiof_read
void * lextiof_session_arg
int lextiof_size
LDAP_X_EXTIOF_WRITE_CALLBACK * lextiof_write
struct ldap

Definition at line 261 of file ldap-int.h.

Collaboration diagram for ldap:
Class Members
int * ld_abandoned
int ld_cache_on
int ld_cache_strategy
char * ld_cldapdn
int ld_cldaptimeout
int ld_cldaptries
LDAPControl ** ld_clientcontrols
int ld_connect_timeout
LDAPConn * ld_conns
LDAPConn * ld_defconn
char * ld_defhost
int ld_defport
int ld_deref
int ld_errno
char * ld_error
struct ldap_filt_desc * ld_filtd
char * ld_host
struct ldap_io_fns * ld_io_fns_ptr
NSLDAPIIOStatus * ld_iostatus
BERTranslateProc ld_lber_decode_translate_proc
BERTranslateProc ld_lber_encode_translate_proc
char ld_lberoptions
char * ld_matched
LDAPMemCache * ld_memcache
int ld_msgid
void ** ld_mutex
unsigned long ld_mutex_refcnt
void * ld_mutex_threadid
unsigned long ld_options
LDAPPend * ld_pend
char * ld_preferred_language
void * ld_rebind_arg
LDAP_REBINDPROC_CALLBACK * ld_rebind_fn
int ld_refhoplimit
LDAPRequest * ld_requests
LDAPMessage * ld_responses
struct sockbuf * ld_sbp
LDAPControl ** ld_servercontrols
int ld_sizelimit
int ld_timelimit
char * ld_ufnprefix
int ld_version
struct ldap_filt_list

Definition at line 572 of file ldap-int.h.

Collaboration diagram for ldap_filt_list:
Class Members
char * lfl_delims
struct ldap_filt_info * lfl_ilist
struct ldap_filt_list * lfl_next
char * lfl_pattern
char * lfl_tag
struct ldap_filt_desc

Definition at line 580 of file ldap-int.h.

Collaboration diagram for ldap_filt_desc:
Class Members
LDAPFiltInfo * lfd_curfip
char * lfd_curval
char * lfd_curvalcopy
char ** lfd_curvalwords
char lfd_filter
LDAPFiltList * lfd_filtlist
char * lfd_filtprefix
char * lfd_filtsuffix
LDAPFiltInfo lfd_retfi

Define Documentation

#define ld_cache_abandon   ld_cache.lcf_abandon

Definition at line 362 of file ldap-int.h.

#define ld_cache_add   ld_cache.lcf_add

Definition at line 355 of file ldap-int.h.

#define ld_cache_arg   ld_cache.lcf_arg

Definition at line 365 of file ldap-int.h.

#define ld_cache_bind   ld_cache.lcf_bind

Definition at line 351 of file ldap-int.h.

#define ld_cache_compare   ld_cache.lcf_compare

Definition at line 354 of file ldap-int.h.

#define ld_cache_config   ld_cache.lcf_config

Definition at line 350 of file ldap-int.h.

#define ld_cache_delete   ld_cache.lcf_delete

Definition at line 356 of file ldap-int.h.

#define ld_cache_flush   ld_cache.lcf_flush

Definition at line 364 of file ldap-int.h.

#define ld_cache_modify   ld_cache.lcf_modify

Definition at line 360 of file ldap-int.h.

#define ld_cache_modrdn   ld_cache.lcf_modrdn

Definition at line 361 of file ldap-int.h.

#define ld_cache_result   ld_cache.lcf_result

Definition at line 363 of file ldap-int.h.

#define ld_cache_search   ld_cache.lcf_search

Definition at line 353 of file ldap-int.h.

#define ld_cache_unbind   ld_cache.lcf_unbind

Definition at line 352 of file ldap-int.h.

#define ld_dns_bufsize   ld_dnsfn.lddnsfn_bufsize

Definition at line 329 of file ldap-int.h.

#define ld_dns_extradata   ld_dnsfn.lddnsfn_extradata

Definition at line 328 of file ldap-int.h.

#define ld_dns_gethostbyaddr_fn   ld_dnsfn.lddnsfn_gethostbyaddr

Definition at line 331 of file ldap-int.h.

#define ld_dns_gethostbyname_fn   ld_dnsfn.lddnsfn_gethostbyname

Definition at line 330 of file ldap-int.h.

#define ld_ext_session_arg   ld_ext_io_fns.lextiof_session_arg

Definition at line 320 of file ldap-int.h.

#define ld_extclose_fn   ld_ext_io_fns.lextiof_close

Definition at line 312 of file ldap-int.h.

#define ld_extconnect_fn   ld_ext_io_fns.lextiof_connect

Definition at line 313 of file ldap-int.h.

#define ld_extdisposehandle_fn   ld_ext_io_fns.lextiof_disposehandle

Definition at line 319 of file ldap-int.h.

#define ld_extio_size   ld_ext_io_fns.lextiof_size

Definition at line 311 of file ldap-int.h.

#define ld_extnewhandle_fn   ld_ext_io_fns.lextiof_newhandle

Definition at line 318 of file ldap-int.h.

#define ld_extpoll_fn   ld_ext_io_fns.lextiof_poll

Definition at line 317 of file ldap-int.h.

#define ld_extread_fn   ld_ext_io_fns.lextiof_read

Definition at line 314 of file ldap-int.h.

#define ld_extwrite_fn   ld_ext_io_fns.lextiof_write

Definition at line 315 of file ldap-int.h.

#define ld_extwritev_fn   ld_ext_io_fns.lextiof_writev

Definition at line 316 of file ldap-int.h.

#define ld_get_errno_fn   ld_thread.ltf_get_errno

Definition at line 339 of file ldap-int.h.

#define ld_get_lderrno_fn   ld_thread.ltf_get_lderrno

Definition at line 341 of file ldap-int.h.

#define ld_lderrno_arg   ld_thread.ltf_lderrno_arg

Definition at line 343 of file ldap-int.h.

#define ld_mutex_alloc_fn   ld_thread.ltf_mutex_alloc

Definition at line 335 of file ldap-int.h.

#define ld_mutex_free_fn   ld_thread.ltf_mutex_free

Definition at line 336 of file ldap-int.h.

#define ld_mutex_lock_fn   ld_thread.ltf_mutex_lock

Definition at line 337 of file ldap-int.h.

#define ld_mutex_trylock_fn   ld_thread2.ltf_mutex_trylock

Definition at line 388 of file ldap-int.h.

#define ld_mutex_unlock_fn   ld_thread.ltf_mutex_unlock

Definition at line 338 of file ldap-int.h.

#define ld_sema_alloc_fn   ld_thread2.ltf_sema_alloc

Definition at line 389 of file ldap-int.h.

#define ld_sema_free_fn   ld_thread2.ltf_sema_free

Definition at line 390 of file ldap-int.h.

#define ld_sema_post_fn   ld_thread2.ltf_sema_post

Definition at line 392 of file ldap-int.h.

#define ld_sema_wait_fn   ld_thread2.ltf_sema_wait

Definition at line 391 of file ldap-int.h.

#define ld_set_errno_fn   ld_thread.ltf_set_errno

Definition at line 340 of file ldap-int.h.

#define ld_set_lderrno_fn   ld_thread.ltf_set_lderrno

Definition at line 342 of file ldap-int.h.

#define ld_threadid_fn   ld_thread2.ltf_threadid_fn

Definition at line 393 of file ldap-int.h.

#define LDAP_BITOPT_ASYNC   0x04000000

Definition at line 296 of file ldap-int.h.

#define LDAP_BITOPT_DNS   0x20000000

Definition at line 293 of file ldap-int.h.

#define LDAP_BITOPT_RECONNECT   0x08000000

Definition at line 295 of file ldap-int.h.

#define LDAP_BITOPT_REFERRALS   0x80000000

Definition at line 291 of file ldap-int.h.

#define LDAP_BITOPT_RESTART   0x10000000

Definition at line 294 of file ldap-int.h.

#define LDAP_BITOPT_SSL   0x40000000

Definition at line 292 of file ldap-int.h.

Definition at line 190 of file ldap-int.h.

Definition at line 189 of file ldap-int.h.

Definition at line 191 of file ldap-int.h.

Definition at line 188 of file ldap-int.h.

Definition at line 127 of file ldap-int.h.

Definition at line 570 of file ldap-int.h.

Value:

Definition at line 508 of file ldap-int.h.

#define LDAP_GET_LDERRNO (   ld,
  m,
  s 
)    ldap_get_lderrno( ld, m, s )

Definition at line 524 of file ldap-int.h.

#define LDAP_IS_CLDAP (   ld)    ( ld->ld_sbp->sb_naddr > 0 )

Definition at line 534 of file ldap-int.h.

Definition at line 121 of file ldap-int.h.

Definition at line 122 of file ldap-int.h.

Definition at line 123 of file ldap-int.h.

Definition at line 124 of file ldap-int.h.

Definition at line 404 of file ldap-int.h.

#define LDAP_MUTEX_BC_LOCK (   ld,
  i 
)
Value:
/* the ld_mutex_trylock_fn is always set to NULL */ \
       /* in setoption.c as the extra thread functions were */ \
       /* turned off in the 4.0 SDK.  This check will  */ \
       /* always be true */ \
       if( (ld)->ld_mutex_trylock_fn == NULL ) { \
              LDAP_MUTEX_LOCK( ld, i ) ; \
       }

Definition at line 457 of file ldap-int.h.

Value:
/* the ld_mutex_trylock_fn is always set to NULL */ \
       /* in setoption.c as the extra thread functions were */ \
       /* turned off in the 4.0 SDK.  This check will  */ \
       /* always be true */ \
       if( (ld)->ld_mutex_trylock_fn == NULL ) { \
              LDAP_MUTEX_UNLOCK( ld, i ) ; \
       }

Definition at line 465 of file ldap-int.h.

#define LDAP_MUTEX_FREE (   ld,
  m 
)
Value:
if ( (ld)->ld_mutex_free_fn != NULL && m != NULL ) { \
              (ld)->ld_mutex_free_fn( m ); \
       }

Definition at line 408 of file ldap-int.h.

#define LDAP_MUTEX_LOCK (   ld,
  lock 
)
Value:
if ((ld)->ld_mutex_lock_fn != NULL && ld->ld_mutex != NULL) { \
        if ((ld)->ld_threadid_fn != NULL) { \
            if ((ld)->ld_mutex_threadid[lock] == (ld)->ld_threadid_fn()) { \
                (ld)->ld_mutex_refcnt[lock]++; \
            } else { \
                (ld)->ld_mutex_lock_fn(ld->ld_mutex[lock]); \
                (ld)->ld_mutex_threadid[lock] = ld->ld_threadid_fn(); \
                (ld)->ld_mutex_refcnt[lock] = 1; \
            } \
        } else { \
            (ld)->ld_mutex_lock_fn(ld->ld_mutex[lock]); \
        } \
    }

Definition at line 425 of file ldap-int.h.

Value:
if ((ld)->ld_mutex_lock_fn != NULL && ld->ld_mutex != NULL) { \
        if ((ld)->ld_threadid_fn != NULL) { \
            if ((ld)->ld_mutex_threadid[lock] == (ld)->ld_threadid_fn()) { \
                (ld)->ld_mutex_refcnt[lock]--; \
                if ((ld)->ld_mutex_refcnt[lock] <= 0) { \
                    (ld)->ld_mutex_threadid[lock] = (void *) -1; \
                    (ld)->ld_mutex_refcnt[lock] = 0; \
                    (ld)->ld_mutex_unlock_fn(ld->ld_mutex[lock]); \
                } \
            } \
        } else { \
            ld->ld_mutex_unlock_fn(ld->ld_mutex[lock]); \
        } \
    }

Definition at line 440 of file ldap-int.h.

Definition at line 207 of file ldap-int.h.

#define LDAP_REQST_CONNDEAD   5 /* associated conn. has failed */

Definition at line 210 of file ldap-int.h.

Definition at line 206 of file ldap-int.h.

Definition at line 208 of file ldap-int.h.

Definition at line 209 of file ldap-int.h.

Definition at line 475 of file ldap-int.h.

#define LDAP_SEMA_FREE (   ld,
  m 
)
Value:
if ( (ld)->ld_sema_free_fn != NULL && m != NULL ) { \
              (ld)->ld_sema_free_fn( m ); \
       }

Definition at line 477 of file ldap-int.h.

#define LDAP_SEMA_POST (   ld,
  lp 
)
Value:
if ( (ld)->ld_sema_post_fn != NULL ) { \
              (ld)->ld_sema_post_fn( lp->lp_sema ); \
       }

Definition at line 487 of file ldap-int.h.

#define LDAP_SEMA_WAIT (   ld,
  lp 
)
Value:
if ( (ld)->ld_sema_wait_fn != NULL ) { \
              (ld)->ld_sema_wait_fn( lp->lp_sema ); \
       }

Definition at line 483 of file ldap-int.h.

#define LDAP_SET_ERRNO (   ld,
  e 
)
Value:
if ( (ld)->ld_set_errno_fn != NULL ) { \
              (ld)->ld_set_errno_fn( e ); \
       } else { \
              errno = e; \
       }

Definition at line 502 of file ldap-int.h.

#define LDAP_SET_LDERRNO (   ld,
  e,
  m,
  s 
)    ldap_set_lderrno( ld, e, m, s )

Definition at line 523 of file ldap-int.h.

Definition at line 174 of file ldap-int.h.

#define LDAP_URL_URLCOLON   "URL:"

Definition at line 118 of file ldap-int.h.

Definition at line 119 of file ldap-int.h.

Definition at line 255 of file ldap-int.h.

Definition at line 78 of file ldap-int.h.

#define NSLDAPI_CALLOC (   nelem,
  elsize 
)    ldap_x_calloc( nelem, elsize )

Definition at line 607 of file ldap-int.h.

Definition at line 556 of file ldap-int.h.

Definition at line 609 of file ldap-int.h.

Definition at line 107 of file ldap-int.h.

Definition at line 639 of file ldap-int.h.

Definition at line 642 of file ldap-int.h.

Value:
( (ld)->ld_defconn == NULL ? \
                                   (ld)->ld_version : \
                                   (ld)->ld_defconn->lconn_version )

Definition at line 563 of file ldap-int.h.

Definition at line 606 of file ldap-int.h.

#define NSLDAPI_MIN (   a,
  b 
)    (((a) < (b)) ? (a) : (b))

Definition at line 529 of file ldap-int.h.

Definition at line 608 of file ldap-int.h.

Definition at line 645 of file ldap-int.h.

#define NSLDAPI_USING_CLASSIC_IO_FUNCTIONS (   ld)    ((ld)->ld_io_fns_ptr != NULL)

Definition at line 324 of file ldap-int.h.

#define NSLDAPI_VALID_LDAP_POINTER (   ld)    ( (ld) != NULL )

Definition at line 615 of file ldap-int.h.

#define NSLDAPI_VALID_LDAPMESSAGE_BINDRESULT_POINTER (   lm)    ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_BIND )

Definition at line 627 of file ldap-int.h.

Definition at line 621 of file ldap-int.h.

#define NSLDAPI_VALID_LDAPMESSAGE_EXRESULT_POINTER (   lm)    ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_EXTENDED )

Definition at line 630 of file ldap-int.h.

Definition at line 618 of file ldap-int.h.

Definition at line 624 of file ldap-int.h.

Definition at line 633 of file ldap-int.h.

Definition at line 636 of file ldap-int.h.

#define POST (   ld,
  y,
 
)
Value:
/* the ld_mutex_trylock_fn is always set to NULL */ \
       /* in setoption.c as the extra thread functions were */ \
       /* turned off in the 4.0 SDK.  This check will  */ \
       /* always be false */ \
       if( (ld)->ld_mutex_trylock_fn != NULL ) { \
              nsldapi_post_result( ld, y, z ); \
       }

Definition at line 491 of file ldap-int.h.

Definition at line 114 of file ldap-int.h.


Typedef Documentation

typedef struct ldap_conn LDAPConn
typedef struct ldappend LDAPPend
typedef struct ldapreq LDAPRequest
typedef struct ldap_server LDAPServer
typedef struct nsldapi_iostatus_info

Definition at line 239 of file ldap-int.h.


Enumeration Type Documentation

enum LDAPLock
Enumerator:
LDAP_CACHE_LOCK 
LDAP_MEMCACHE_LOCK 
LDAP_MSGID_LOCK 
LDAP_REQ_LOCK 
LDAP_RESP_LOCK 
LDAP_ABANDON_LOCK 
LDAP_CTRL_LOCK 
LDAP_OPTION_LOCK 
LDAP_ERR_LOCK 
LDAP_CONN_LOCK 
LDAP_IOSTATUS_LOCK 
LDAP_RESULT_LOCK 
LDAP_PEND_LOCK 
LDAP_THREADID_LOCK 
LDAP_MAX_LOCK 

Definition at line 133 of file ldap-int.h.


Function Documentation

void ldap_add_result_entry ( LDAPMessage **  list,
LDAPMessage *  e 
)

Definition at line 74 of file reslist.c.

{
       e->lm_chain = *list;
       *list = e;
}

Here is the call graph for this function:

LDAPMessage* ldap_delete_result_entry ( LDAPMessage **  list,
LDAPMessage *  e 
)

Definition at line 54 of file reslist.c.

{
       LDAPMessage   *tmp, *prev = NULL;

       for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain )
              prev = tmp;

       if ( tmp == NULL )
              return( NULL );

       if ( prev == NULL )
              *list = tmp->lm_chain;
       else
              prev->lm_chain = tmp->lm_chain;
       tmp->lm_chain = NULL;

       return( tmp );
}
int ldap_ld_free ( LDAP *  ld,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls,
int  close 
)

Definition at line 86 of file unbind.c.

{
       LDAPMessage   *lm, *next;
       int           err = LDAP_SUCCESS;
       LDAPRequest   *lr, *nextlr;

       if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
              return( LDAP_PARAM_ERROR );
       }

       if ( ld->ld_sbp->sb_naddr == 0 ) {
              LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK );
              /* free LDAP structure and outstanding requests/responses */
              for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
                     nextlr = lr->lr_next;
                     nsldapi_free_request( ld, lr, 0 );
              }
              LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK );

              /* free and unbind from all open connections */
              LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK );
              while ( ld->ld_conns != NULL ) {
                     nsldapi_free_connection( ld, ld->ld_conns, serverctrls,
                         clientctrls, 1, close );
              }
              LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );

       } else {
              int    i;

              for ( i = 0; i < ld->ld_sbp->sb_naddr; ++i ) {
                     NSLDAPI_FREE( ld->ld_sbp->sb_addrs[ i ] );
              }
              NSLDAPI_FREE( ld->ld_sbp->sb_addrs );
              NSLDAPI_FREE( ld->ld_sbp->sb_fromaddr );
       }

       LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK );
       for ( lm = ld->ld_responses; lm != NULL; lm = next ) {
              next = lm->lm_next;
              ldap_msgfree( lm );
       }
       LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK );

       /* call cache unbind function to allow it to clean up after itself */
       if ( ld->ld_cache_unbind != NULL ) {
              LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK );
              (void)ld->ld_cache_unbind( ld, 0, 0 );
              LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK );
       }

       /* call the dispose handle I/O callback if one is defined */
       if ( ld->ld_extdisposehandle_fn != NULL ) {
           /*
            * We always pass the session extended I/O argument to
            * the dispose handle callback.
            */
           ld->ld_extdisposehandle_fn( ld, ld->ld_ext_session_arg );
       }

       if ( ld->ld_error != NULL )
              NSLDAPI_FREE( ld->ld_error );
       if ( ld->ld_matched != NULL )
              NSLDAPI_FREE( ld->ld_matched );
       if ( ld->ld_host != NULL )
              NSLDAPI_FREE( ld->ld_host );
       if ( ld->ld_ufnprefix != NULL )
              NSLDAPI_FREE( ld->ld_ufnprefix );
       if ( ld->ld_filtd != NULL )
              ldap_getfilter_free( ld->ld_filtd );
       if ( ld->ld_abandoned != NULL )
              NSLDAPI_FREE( ld->ld_abandoned );
       if ( ld->ld_sbp != NULL )
              ber_sockbuf_free( ld->ld_sbp );
       if ( ld->ld_defhost != NULL )
              NSLDAPI_FREE( ld->ld_defhost );
       if ( ld->ld_servercontrols != NULL )
              ldap_controls_free( ld->ld_servercontrols );
       if ( ld->ld_clientcontrols != NULL )
              ldap_controls_free( ld->ld_clientcontrols );
       if ( ld->ld_preferred_language != NULL )
              NSLDAPI_FREE( ld->ld_preferred_language );
       nsldapi_iostatus_free( ld );

       /*
        * XXXmcs: should use cache function pointers to hook in memcache
        */
       if ( ld->ld_memcache != NULL ) {
              ldap_memcache_set( ld, NULL );
       }

       /* free all mutexes we have allocated */
       nsldapi_mutex_free_all( ld );
       NSLDAPI_FREE( ld->ld_mutex );

       NSLDAPI_FREE( (char *) ld );

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ldap_memcache_abandon ( LDAP *  ld,
int  msgid 
)

Definition at line 802 of file memcache.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ldap_memcache_append ( LDAP *  ld,
int  msgid,
int  bLast,
LDAPMessage *  result 
)

Definition at line 763 of file memcache.c.

{
    int nRes = LDAP_SUCCESS;

    LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_append( ld: 0x%x, ", ld, 0, 0 );
    LDAPDebug( LDAP_DEBUG_TRACE, "msgid %d, bLast: %d, result: 0x%x)\n",
           msgid, bLast, result );

    if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || !result ) {
       return( LDAP_PARAM_ERROR );
    }

    LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK );

    if (!memcache_exist(ld)) {
        LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK );
       return( LDAP_LOCAL_ERROR );
    }

    LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache );

    if (!bLast)
       nRes = memcache_append(ld, msgid, result);
    else
       nRes = memcache_append_last(ld, msgid, result);

    LDAPDebug( LDAP_DEBUG_TRACE,
           "ldap_memcache_append: %s result for msgid %d\n",
           ( nRes == LDAP_SUCCESS ) ? "added" : "failed to add", msgid , 0 );

    LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache );
    LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK );

    return nRes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ldap_memcache_createkey ( LDAP *  ld,
const char *  base,
int  scope,
const char *  filter,
char **  attrs,
int  attrsonly,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls,
unsigned long keyp 
)

Definition at line 586 of file memcache.c.

{
    int nRes, i, j, i_smallest;
    int len;
    int defport;
    char buf[50];
    char *tmp, *defhost, *binddn, *keystr, *tmpbase;

    if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (keyp == NULL) )
       return( LDAP_PARAM_ERROR );

    *keyp = 0;

    if (!memcache_exist(ld))
       return( LDAP_LOCAL_ERROR );

    LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK );
    LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache );
    nRes = memcache_validate_basedn(ld->ld_memcache, base);
    LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache );
    LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK );

    if (nRes != LDAP_SUCCESS)
       return nRes;

    defhost = NSLDAPI_STR_NONNULL(ld->ld_defhost);
    defport = ld->ld_defport;
    tmpbase = nsldapi_strdup(NSLDAPI_STR_NONNULL(base));
    memcache_trim_basedn_spaces(tmpbase);

    if ((binddn = nsldapi_get_binddn(ld)) == NULL)
       binddn = "";

    sprintf(buf, "%i\n%i\n%i\n", defport, scope, (attrsonly ? 1 : 0));
    len = NSLDAPI_SAFE_STRLEN(buf) + NSLDAPI_SAFE_STRLEN(tmpbase) +
         NSLDAPI_SAFE_STRLEN(filter) + NSLDAPI_SAFE_STRLEN(defhost) +
         NSLDAPI_SAFE_STRLEN(binddn);

    if (attrs) {
       for (i = 0; attrs[i]; i++) {

           for (i_smallest = j = i; attrs[j]; j++) {
              if (strcasecmp(attrs[i_smallest], attrs[j]) > 0)
                  i_smallest = j;
           }

           if (i != i_smallest) {
              tmp = attrs[i];
              attrs[i] = attrs[i_smallest];
              attrs[i_smallest] = tmp;
           }

           len += NSLDAPI_SAFE_STRLEN(attrs[i]);
       }
    } else {
       len += 1;
    }

    len += memcache_get_ctrls_len(serverctrls) + 
          memcache_get_ctrls_len(clientctrls) + 1;

    if ((keystr = (char*)NSLDAPI_CALLOC(len, sizeof(char))) == NULL) {
       NSLDAPI_FREE(defhost);
       return( LDAP_NO_MEMORY );
    }

    sprintf(keystr, "%s\n%s\n%s\n%s\n%s\n", binddn, tmpbase,
           NSLDAPI_STR_NONNULL(defhost), NSLDAPI_STR_NONNULL(filter), 
           NSLDAPI_STR_NONNULL(buf));

    if (attrs) {
       for (i = 0; attrs[i]; i++) {
           strcat(keystr, NSLDAPI_STR_NONNULL(attrs[i]));
           strcat(keystr, "\n");
       }
    } else {
       strcat(keystr, "\n");
    }

    for (tmp = keystr; *tmp; 
         *tmp += (*tmp >= 'a' && *tmp <= 'z' ? 'A'-'a' : 0), tmp++) {
              ;
       }

    memcache_append_ctrls(keystr, serverctrls, clientctrls);

    /* CRC algorithm */
    *keyp = crc32_convert(keystr, len);

    NSLDAPI_FREE(keystr);
    NSLDAPI_FREE(tmpbase);

    return LDAP_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ldap_memcache_new ( LDAP *  ld,
int  msgid,
unsigned long  key,
const char *  basedn 
)

Definition at line 736 of file memcache.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ldap_memcache_result ( LDAP *  ld,
int  msgid,
unsigned long  key 
)

Definition at line 688 of file memcache.c.

{
    int nRes;
    LDAPMessage *pMsg = NULL;

    LDAPDebug( LDAP_DEBUG_TRACE,
           "ldap_memcache_result( ld: 0x%x, msgid: %d, key: 0x%8.8lx)\n",
           ld, msgid, key );

    if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (msgid < 0) ) {
       return( LDAP_PARAM_ERROR );
    }

    if (!memcache_exist(ld)) {
       return( LDAP_LOCAL_ERROR );
    }

    LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK );
    LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache );

    /* Search the cache and append the results to ld if found */
    ++ld->ld_memcache->ldmemc_stats.ldmemcstat_tries;
    if ((nRes = memcache_search(ld, key, &pMsg)) == LDAP_SUCCESS) {
       nRes = memcache_add_to_ld(ld, msgid, pMsg);
       ++ld->ld_memcache->ldmemc_stats.ldmemcstat_hits;
       LDAPDebug( LDAP_DEBUG_TRACE,
              "ldap_memcache_result: key 0x%8.8lx found in cache\n",
              key, 0, 0 );
    } else {
       LDAPDebug( LDAP_DEBUG_TRACE,
              "ldap_memcache_result: key 0x%8.8lx not found in cache\n",
              key, 0, 0 );
    }

#ifdef LDAP_DEBUG
    memcache_print_list( ld->ld_memcache, LIST_LRU );
    memcache_report_statistics( ld->ld_memcache );
#endif /* LDAP_DEBUG */

    LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache );
    LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK );

    return nRes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ldap_msgdelete ( LDAP *  ld,
int  msgid 
)

Definition at line 1154 of file result.c.

{
       LDAPMessage   *lm, *prev;
       int           msgtype;

       LDAPDebug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 );

       if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
              return( -1 ); /* punt */
       }

       prev = NULL;
        LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK );
       for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) {
              if ( lm->lm_msgid == msgid )
                     break;
              prev = lm;
       }

       if ( lm == NULL )
       {
              LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK );
              return( -1 );
       }

       if ( prev == NULL )
              ld->ld_responses = lm->lm_next;
       else
              prev->lm_next = lm->lm_next;
        LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK );

       msgtype = ldap_msgfree( lm );
       if ( msgtype == LDAP_RES_SEARCH_ENTRY
           || msgtype == LDAP_RES_SEARCH_REFERENCE ) {
              return( -1 );
       }

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_add_result_to_cache ( LDAP *  ld,
LDAPMessage *  result 
)

Definition at line 75 of file cache.c.

{
       char          *dn;
       LDAPMod              **mods;
       int           i, max, rc;
       char          *a;
       BerElement    *ber;
       char          buf[50];
       struct berval bv;
       struct berval *bvp[2];

       LDAPDebug( LDAP_DEBUG_TRACE, "=> nsldapi_add_result_to_cache id %d type %d\n",
           m->lm_msgid, m->lm_msgtype, 0 );
       if ( m->lm_msgtype != LDAP_RES_SEARCH_ENTRY ||
           ld->ld_cache_add == NULL ) {
              LDAPDebug( LDAP_DEBUG_TRACE,
                  "<= nsldapi_add_result_to_cache not added\n", 0, 0, 0 );
              return;
       }

#define GRABSIZE     5

       dn = ldap_get_dn( ld, m );
       mods = (LDAPMod **)NSLDAPI_MALLOC( GRABSIZE * sizeof(LDAPMod *) );
       max = GRABSIZE;
       for ( i = 0, a = ldap_first_attribute( ld, m, &ber ); a != NULL;
           a = ldap_next_attribute( ld, m, ber ), i++ ) {
              if ( i == (max - 1) ) {
                     max += GRABSIZE;
                     mods = (LDAPMod **)NSLDAPI_REALLOC( mods,
                         sizeof(LDAPMod *) * max );
              }

              mods[i] = (LDAPMod *)NSLDAPI_CALLOC( 1, sizeof(LDAPMod) );
              mods[i]->mod_op = LDAP_MOD_BVALUES;
              mods[i]->mod_type = a;
              mods[i]->mod_bvalues = ldap_get_values_len( ld, m, a );
       }
       if ( ber != NULL ) {
              ber_free( ber, 0 );
       }
       if (( rc = LDAP_GET_LDERRNO( ld, NULL, NULL )) != LDAP_SUCCESS ) {
              LDAPDebug( LDAP_DEBUG_TRACE,
                  "<= nsldapi_add_result_to_cache error: failed to construct mod list (%s)\n",
                  ldap_err2string( rc ), 0, 0 );
              ldap_mods_free( mods, 1 );
              return;
       }

       /* update special cachedtime attribute */
       if ( i == (max - 1) ) {
              max++;
              mods = (LDAPMod **)NSLDAPI_REALLOC( mods,
                  sizeof(LDAPMod *) * max );
       }
       mods[i] = (LDAPMod *)NSLDAPI_CALLOC( 1, sizeof(LDAPMod) );
       mods[i]->mod_op = LDAP_MOD_BVALUES;
       mods[i]->mod_type = "cachedtime";
       sprintf( buf, "%d", time( NULL ) );
       bv.bv_val = buf;
       bv.bv_len = strlen( buf );
       bvp[0] = &bv;
       bvp[1] = NULL;
       mods[i]->mod_bvalues = bvp;
       mods[++i] = NULL;

       /* msgid of -1 means don't send the result */
       rc = (ld->ld_cache_add)( ld, -1, m->lm_msgtype, dn, mods );
       LDAPDebug( LDAP_DEBUG_TRACE,
           "<= nsldapi_add_result_to_cache added (rc %d)\n", rc, 0, 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_alloc_ber_with_options ( LDAP *  ld,
BerElement **  berp 
)

Definition at line 68 of file request.c.

{
       int    err;

       LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK );
       if (( *berp = ber_alloc_t( ld->ld_lberoptions )) == NULLBER ) {
              err = LDAP_NO_MEMORY;
              LDAP_SET_LDERRNO( ld, err, NULL, NULL );
       } else {
              err = LDAP_SUCCESS;
#ifdef STR_TRANSLATION
              nsldapi_set_ber_options( ld, *berp );
#endif /* STR_TRANSLATION */
       }
       LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_append_referral ( LDAP *  ld,
char **  referralsp,
char *  s 
)

Definition at line 1071 of file request.c.

{
       int    first;

       if ( *referralsp == NULL ) {
              first = 1;
              *referralsp = (char *)NSLDAPI_MALLOC( strlen( s ) +
                  LDAP_REF_STR_LEN + 1 );
       } else {
              first = 0;
              *referralsp = (char *)NSLDAPI_REALLOC( *referralsp,
                  strlen( *referralsp ) + strlen( s ) + 2 );
       }

       if ( *referralsp == NULL ) {
              return( LDAP_NO_MEMORY );
       }

       if ( first ) {
              strcpy( *referralsp, LDAP_REF_STR );
       } else {
              strcat( *referralsp, "\n" );
       }
       strcat( *referralsp, s );

       return( LDAP_SUCCESS );
}

Here is the caller graph for this function:

int nsldapi_ber_flush ( LDAP *  ld,
Sockbuf *  sb,
BerElement *  ber,
int  freeit,
int  async 
)

Definition at line 331 of file request.c.

{
       int    terrno;

       for ( ;; ) {
               /*
                * ber_flush() doesn't set errno on EOF, so we pre-set it to
                * zero to avoid getting tricked by leftover "EAGAIN" errors
                */
              LDAP_SET_ERRNO( ld, 0 );

              if ( ber_flush( sb, ber, freeit ) == 0 ) {
                     return( 0 );  /* success */
              }

              terrno = LDAP_GET_ERRNO( ld );

        if (ld->ld_options & LDAP_BITOPT_ASYNC) {
            if ( terrno != 0 && !NSLDAPI_ERRNO_IO_INPROGRESS( terrno )) {
                nsldapi_connection_lost_nolock( ld, sb );
                return( -1 );      /* fatal error */
            }
        }
        else if ( !NSLDAPI_ERRNO_IO_INPROGRESS( terrno )) {

                     nsldapi_connection_lost_nolock( ld, sb );
                     return( -1 ); /* fatal error */
              }

              if ( async ) {
                     return( -2 ); /* would block */
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_build_control ( char *  oid,
BerElement *  ber,
int  freeber,
char  iscritical,
LDAPControl **  ctrlp 
)

Definition at line 461 of file control.c.

{
       int           rc;
       struct berval *bvp;

       if ( ber == NULL ) {
              bvp = NULL;
       } else {
              /* allocate struct berval with contents of the BER encoding */
              rc = ber_flatten( ber, &bvp );
              if ( freeber ) {
                     ber_free( ber, 1 );
              }
              if ( rc == -1 ) {
                     return( LDAP_NO_MEMORY );
              }
       }

       /* allocate the new control structure */
       if (( *ctrlp = (LDAPControl *)NSLDAPI_MALLOC( sizeof(LDAPControl)))
           == NULL ) {
              if ( bvp != NULL ) {
                     ber_bvfree( bvp );
              }
              return( LDAP_NO_MEMORY );
       }

       /* fill in the fields of this new control */
       (*ctrlp)->ldctl_iscritical = iscritical;  
       if (( (*ctrlp)->ldctl_oid = nsldapi_strdup( oid )) == NULL ) {
              NSLDAPI_FREE( *ctrlp ); 
              if ( bvp != NULL ) {
                     ber_bvfree( bvp );
              }
              return( LDAP_NO_MEMORY );
       }                           

       if ( bvp == NULL ) {
              (*ctrlp)->ldctl_value.bv_len = 0;
              (*ctrlp)->ldctl_value.bv_val = NULL;
       } else {
              (*ctrlp)->ldctl_value = *bvp;      /* struct copy */
              NSLDAPI_FREE( bvp ); /* free container, not contents! */
       }

       return( LDAP_SUCCESS );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_build_search_req ( LDAP *  ld,
const char *  base,
int  scope,
const char *  filter,
char **  attrs,
int  attrsonly,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls,
int  timelimit,
int  sizelimit,
int  msgid,
BerElement **  berp 
)

Definition at line 277 of file search.c.

{
       BerElement    *ber;
       int           err;
       char          *fdup;

       /*
        * Create the search request.  It looks like this:
        *     SearchRequest := [APPLICATION 3] SEQUENCE {
        *            baseObject    DistinguishedName,
        *            scope         ENUMERATED {
        *                   baseObject    (0),
        *                   singleLevel   (1),
        *                   wholeSubtree  (2)
        *            },
        *            derefAliases  ENUMERATED {
        *                   neverDerefaliases    (0),
        *                   derefInSearching     (1),
        *                   derefFindingBaseObj  (2),
        *                   alwaysDerefAliases   (3)
        *            },
        *            sizelimit     INTEGER (0 .. 65535),
        *            timelimit     INTEGER (0 .. 65535),
        *            attrsOnly     BOOLEAN,
        *            filter        Filter,
        *            attributes    SEQUENCE OF AttributeType
        *     }
        * wrapped in an ldap message.
        */

       /* create a message to send */
       if (( err = nsldapi_alloc_ber_with_options( ld, &ber ))
           != LDAP_SUCCESS ) {
              return( err );
       }

       if ( base == NULL ) {
           base = "";
       }

       if ( sizelimit == -1 ) {
           sizelimit = ld->ld_sizelimit;
       }

       if ( timelimit == -1 ) {
           timelimit = ld->ld_timelimit;
       }

#ifdef CLDAP
       if ( ld->ld_sbp->sb_naddr > 0 ) {
           err = ber_printf( ber, "{ist{seeiib", msgid,
              ld->ld_cldapdn, LDAP_REQ_SEARCH, base, scope, ld->ld_deref,
              sizelimit, timelimit, attrsonly );
       } else {
#endif /* CLDAP */
              err = ber_printf( ber, "{it{seeiib", msgid,
                  LDAP_REQ_SEARCH, base, scope, ld->ld_deref,
                  sizelimit, timelimit, attrsonly );
#ifdef CLDAP
       }
#endif /* CLDAP */

       if ( err == -1 ) {
              LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL );
              ber_free( ber, 1 );
              return( LDAP_ENCODING_ERROR );
       }

       fdup = nsldapi_strdup( filter );
       err = put_filter( ber, fdup );
       NSLDAPI_FREE( fdup );

       if ( err == -1 ) {
              LDAP_SET_LDERRNO( ld, LDAP_FILTER_ERROR, NULL, NULL );
              ber_free( ber, 1 );
              return( LDAP_FILTER_ERROR );
       }

       if ( ber_printf( ber, "{v}}", attrs ) == -1 ) {
              LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL );
              ber_free( ber, 1 );
              return( LDAP_ENCODING_ERROR );
       }

       if ( (err = nsldapi_put_controls( ld, serverctrls, 1, ber ))
           != LDAP_SUCCESS ) {
              ber_free( ber, 1 );
              return( err );
       }

       *berp = ber;
       return( LDAP_SUCCESS );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_chase_v2_referrals ( LDAP *  ld,
LDAPRequest lr,
char **  errstrp,
int totalcountp,
int chasingcountp 
)

Definition at line 824 of file request.c.

{
       char          *p, *ref, *unfollowed;
       LDAPRequest   *origreq;
       int           rc, tmprc, len, unknown;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_chase_v2_referrals\n", 0, 0, 0 );

       *totalcountp = *chasingcountp = 0;

       if ( *errstrp == NULL ) {
              return( LDAP_SUCCESS );
       }

       len = strlen( *errstrp );
       for ( p = *errstrp; len >= LDAP_REF_STR_LEN; ++p, --len ) {
              if (( *p == 'R' || *p == 'r' ) && strncasecmp( p,
                  LDAP_REF_STR, LDAP_REF_STR_LEN ) == 0 ) {
                     *p = '\0';
                     p += LDAP_REF_STR_LEN;
                     break;
              }
       }

       if ( len < LDAP_REF_STR_LEN ) {
              return( LDAP_SUCCESS );
       }

       if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) {
              LDAPDebug( LDAP_DEBUG_TRACE,
                  "more than %d referral hops (dropping)\n",
                  ld->ld_refhoplimit, 0, 0 );
              return( LDAP_REFERRAL_LIMIT_EXCEEDED );
       }

       /* find original request */
       for ( origreq = lr; origreq->lr_parent != NULL;
            origreq = origreq->lr_parent ) {
              ;
       }

       unfollowed = NULL;
       rc = LDAP_SUCCESS;

       /* parse out & follow referrals */
       for ( ref = p; rc == LDAP_SUCCESS && ref != NULL; ref = p ) {
              if (( p = strchr( ref, '\n' )) != NULL ) {
                     *p++ = '\0';
              } else {
                     p = NULL;
              }

              ++*totalcountp;

              rc = chase_one_referral( ld, lr, origreq, ref, "v2 referral",
                  &unknown );

              if ( rc != LDAP_SUCCESS || unknown ) {
                     if (( tmprc = nsldapi_append_referral( ld, &unfollowed,
                         ref )) != LDAP_SUCCESS ) {
                            rc = tmprc;
                     }
              } else {
                     ++*chasingcountp;
              }
       }

       NSLDAPI_FREE( *errstrp );
       *errstrp = unfollowed;

       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_chase_v3_refs ( LDAP *  ld,
LDAPRequest lr,
char **  refs,
int  is_reference,
int totalcountp,
int chasingcountp 
)

Definition at line 901 of file request.c.

{
       int           i, rc, unknown;
       LDAPRequest   *origreq;

       *totalcountp = *chasingcountp = 0;

       if ( v3refs == NULL || v3refs[0] == NULL ) {
              return( LDAP_SUCCESS );
       }

       *totalcountp = 1;

       if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) {
              LDAPDebug( LDAP_DEBUG_TRACE,
                  "more than %d referral hops (dropping)\n",
                  ld->ld_refhoplimit, 0, 0 );
              return( LDAP_REFERRAL_LIMIT_EXCEEDED );
       }

       /* find original request */
       for ( origreq = lr; origreq->lr_parent != NULL;
           origreq = origreq->lr_parent ) {
              ;
       }

       /*
        * in LDAPv3, we just need to follow one referral in the set.
        * we dp this by stopping as soon as we succeed in initiating a
        * chase on any referral (basically this means we were able to connect
        * to the server and bind).
        */
       for ( i = 0; v3refs[i] != NULL; ++i ) {
              rc = chase_one_referral( ld, lr, origreq, v3refs[i],
                  is_reference ? "v3 reference" : "v3 referral", &unknown );
              if ( rc == LDAP_SUCCESS && !unknown ) {
                     *chasingcountp = 1;
                     break;
              }
       }

       /* XXXmcs: should we save unfollowed referrals somewhere? */

       return( rc ); /* last error is as good as any other I guess... */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_close_connection ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 752 of file os-ip.c.

{
       if ( ld->ld_extclose_fn == NULL ) {
#ifndef NSLDAPI_AVOID_OS_SOCKETS
              nsldapi_os_closesocket( sb->sb_sd );
#endif /* NSLDAPI_AVOID_OS_SOCKETS */
       } else {
              ld->ld_extclose_fn( sb->sb_sd,
                         sb->sb_ext_io_fns.lbextiofn_socket_arg );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_connect_to_host ( LDAP *  ld,
Sockbuf *  sb,
const char *  host,
int  port,
int  secure,
char **  krbinstancep 
)

Definition at line 479 of file os-ip.c.

{
       int           s;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_connect_to_host: %s, port: %d\n",
           NULL == hostlist ? "NULL" : hostlist, defport, 0 );

       /*
        * If an extended I/O connect callback has been defined, just use it.
        */
       if ( NULL != ld->ld_extconnect_fn ) {
              unsigned long connect_opts = 0;

              if ( ld->ld_options & LDAP_BITOPT_ASYNC) {
                     connect_opts |= LDAP_X_EXTIOF_OPT_NONBLOCKING;
              }
              if ( secure ) {
                     connect_opts |= LDAP_X_EXTIOF_OPT_SECURE;
              }
              s = ld->ld_extconnect_fn( hostlist, defport,
                  ld->ld_connect_timeout, connect_opts,
                  ld->ld_ext_session_arg,
                  &sb->sb_ext_io_fns.lbextiofn_socket_arg );

       } else {
#ifdef NSLDAPI_AVOID_OS_SOCKETS
              return( -1 );
#else /* NSLDAPI_AVOID_OS_SOCKETS */
              s = nsldapi_try_each_host( ld, hostlist,
                     defport, secure, nsldapi_os_socket,
                     nsldapi_os_ioctl, nsldapi_os_connect_with_to,
                     NULL, nsldapi_os_closesocket );
#endif /* NSLDAPI_AVOID_OS_SOCKETS */
       }

       if ( s < 0 ) {
              LDAP_SET_LDERRNO( ld, LDAP_CONNECT_ERROR, NULL, NULL );
              return( -1 );
       }

       sb->sb_sd = s;

       /*
        * Set krbinstancep (canonical name of host for use by Kerberos).
        */
#ifdef KERBEROS
       char   *p;

       if (( *krbinstancep = nsldapi_host_connected_to( sb )) != NULL
           && ( p = strchr( *krbinstancep, '.' )) != NULL ) {
              *p = '\0';
       }
#else /* KERBEROS */
       *krbinstancep = NULL;
#endif /* KERBEROS */

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_connection_lost_nolock ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 1239 of file request.c.

{
       LDAPRequest   *lr;

       /*
        * change status of all pending requests that are associated with "sb
        *     to "connection dead."
        * also change the connection status to "dead" and remove it from
        *     the list of sockets we are interested in.
        */
       for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
              if ( sb == NULL ||
                  ( lr->lr_conn != NULL && lr->lr_conn->lconn_sb == sb )) {
                     lr->lr_status = LDAP_REQST_CONNDEAD;
                     if ( lr->lr_conn != NULL ) {
                            lr->lr_conn->lconn_status = LDAP_CONNST_DEAD;
                            nsldapi_iostatus_interest_clear( ld,
                                lr->lr_conn->lconn_sb );
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_dump_connection ( LDAP *  ld,
LDAPConn lconns,
int  all 
)

Here is the caller graph for this function:

Here is the caller graph for this function:

int nsldapi_dup_controls ( LDAP *  ld,
LDAPControl ***  ldctrls,
LDAPControl **  newctrls 
)

Definition at line 355 of file control.c.

{
       int    count;

       if ( *ldctrls != NULL ) {
              ldap_controls_free( *ldctrls );
       }

       if ( newctrls == NULL || newctrls[0] == NULL ) {
              *ldctrls = NULL;
              return( 0 );
       }

       for ( count = 0; newctrls[ count ] != NULL; ++count ) {
              ;
       }

       if (( *ldctrls = (LDAPControl **)NSLDAPI_MALLOC(( count + 1 ) *
           sizeof( LDAPControl *))) == NULL ) {
              LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
              return( -1 );
       }
       (*ldctrls)[ count ] = NULL;

       for ( count = 0; newctrls[ count ] != NULL; ++count ) {
              if (( (*ldctrls)[ count ] =
                  ldap_control_dup( newctrls[ count ] )) == NULL ) {
                     ldap_controls_free( *ldctrls );
                     *ldctrls = NULL;
                     LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
                     return( -1 );
              }
       }

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

LDAPRequest* nsldapi_find_request_by_msgid ( LDAP *  ld,
int  msgid 
)

Definition at line 1218 of file request.c.

{
       LDAPRequest   *lr;

       for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
              if ( msgid == lr->lr_msgid ) {
                     break;
              }
       }

       return( lr );
}

Here is the caller graph for this function:

void nsldapi_free_connection ( LDAP *  ld,
LDAPConn lc,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls,
int  force,
int  unbind 
)

Definition at line 579 of file request.c.

{
       LDAPConn      *tmplc, *prevlc;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection\n", 0, 0, 0 );

       if ( force || --lc->lconn_refcnt <= 0 ) {
              if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) {
                     nsldapi_iostatus_interest_clear( ld, lc->lconn_sb );
                     if ( unbind ) {
                            nsldapi_send_unbind( ld, lc->lconn_sb,
                                serverctrls, clientctrls );
                     }
              }
              nsldapi_close_connection( ld, lc->lconn_sb );
              prevlc = NULL;
              for ( tmplc = ld->ld_conns; tmplc != NULL;
                  tmplc = tmplc->lconn_next ) {
                     if ( tmplc == lc ) {
                            if ( prevlc == NULL ) {
                                ld->ld_conns = tmplc->lconn_next;
                            } else {
                                prevlc->lconn_next = tmplc->lconn_next;
                            }
                            break;
                     }
                     prevlc = tmplc;
              }
              free_servers( lc->lconn_server );
              if ( lc->lconn_krbinstance != NULL ) {
                     NSLDAPI_FREE( lc->lconn_krbinstance );
              }
              /*
               * if this is the default connection (lc->lconn_sb==ld->ld_sbp)
               * we do not free the Sockbuf here since it will be freed
               * later inside ldap_unbind().
               */
              if ( lc->lconn_sb != ld->ld_sbp ) {
                     ber_sockbuf_free( lc->lconn_sb );
                     lc->lconn_sb = NULL;
              }
              if ( lc->lconn_ber != NULLBER ) {
                     ber_free( lc->lconn_ber, 1 );
              }
              if ( lc->lconn_binddn != NULL ) {
                     NSLDAPI_FREE( lc->lconn_binddn );
              }
              NSLDAPI_FREE( lc );
              LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection: actually freed\n",
                  0, 0, 0 );
       } else {
              lc->lconn_lastused = time( 0 );
              LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection: refcnt %d\n",
                  lc->lconn_refcnt, 0, 0 );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_free_request ( LDAP *  ld,
LDAPRequest lr,
int  free_conn 
)

Definition at line 743 of file request.c.

{
       LDAPRequest   *tmplr, *nextlr;

       LDAPDebug( LDAP_DEBUG_TRACE,
              "nsldapi_free_request 0x%x (origid %d, msgid %d)\n",
              lr, lr->lr_origid, lr->lr_msgid );

       if ( lr->lr_parent != NULL ) {
              --lr->lr_parent->lr_outrefcnt;
       }

       /* free all of our spawned referrals (child requests) */
       for ( tmplr = lr->lr_child; tmplr != NULL; tmplr = nextlr ) {
              nextlr = tmplr->lr_sibling;
              nsldapi_free_request( ld, tmplr, free_conn );
       }

       if ( free_conn ) {
              nsldapi_free_connection( ld, lr->lr_conn, NULL, NULL, 0, 1 );
       }

       if ( lr->lr_prev == NULL ) {
              ld->ld_requests = lr->lr_next;
       } else {
              lr->lr_prev->lr_next = lr->lr_next;
       }

       if ( lr->lr_next != NULL ) {
              lr->lr_next->lr_prev = lr->lr_prev;
       }

       if ( lr->lr_ber != NULL ) {
              ber_free( lr->lr_ber, 1 );
       }

       if ( lr->lr_res_error != NULL ) {
              NSLDAPI_FREE( lr->lr_res_error );
       }

       if ( lr->lr_res_matched != NULL ) {
              NSLDAPI_FREE( lr->lr_res_matched );
       }

       if ( lr->lr_binddn != NULL ) {
              NSLDAPI_FREE( lr->lr_binddn );
       }
       NSLDAPI_FREE( lr );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_free_strarray ( char **  sap)

Definition at line 217 of file dsparse.c.

{
    int              i;

    if ( sap != NULL ) {
       for ( i = 0; sap[ i ] != NULL; ++i ) {
           NSLDAPI_FREE( sap[ i ] );
       }
       NSLDAPI_FREE( (char *)sap );
    }
}
char* nsldapi_get_binddn ( LDAP *  ld)

Definition at line 154 of file bind.c.

{
       char   *binddn;

       binddn = NULL;       /* default -- assume they are not bound */

       LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK );
       if ( NULL != ld->ld_defconn && LDAP_CONNST_CONNECTED ==
           ld->ld_defconn->lconn_status && ld->ld_defconn->lconn_bound ) {
              if (( binddn = ld->ld_defconn->lconn_binddn ) == NULL ) {
                     binddn = "";
              }
       }
       LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );

       return( binddn );
}

Here is the caller graph for this function:

int nsldapi_get_controls ( BerElement *  ber,
LDAPControl ***  controlsp 
)

Definition at line 145 of file control.c.

{
       LDAPControl          *newctrl;
       unsigned long        tag, len;
       int                  rc, maxcontrols, curcontrols;
       char                 *last;

       /*
        * Each LDAPMessage can have a set of controls appended
        * to it. Controls are used to extend the functionality
        * of an LDAP operation (e.g., add an attribute size limit
        * to the search operation). These controls look like this:
        *
        *     Controls ::= SEQUENCE OF Control
        *
        *     Control ::= SEQUENCE {
        *            controlType   LDAPOID,
        *            criticality   BOOLEAN DEFAULT FALSE,
        *            controlValue  OCTET STRING
        *     }
        */
       LDAPDebug( LDAP_DEBUG_TRACE, "=> nsldapi_get_controls\n", 0, 0, 0 );

       *controlsp = NULL;

       /*
         * check to see if controls were included
        */
       if ( ber_get_option( ber, LBER_OPT_REMAINING_BYTES, &len ) != 0 ) {
              return( LDAP_DECODING_ERROR );     /* unexpected error */
       }
       if ( len == 0 ) {
              LDAPDebug( LDAP_DEBUG_TRACE,
                  "<= nsldapi_get_controls no controls\n", 0, 0, 0 );
              return( LDAP_SUCCESS );                   /* no controls */
       }
       if (( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) {
              if ( tag == LBER_ERROR ) {
                     LDAPDebug( LDAP_DEBUG_TRACE,
                         "<= nsldapi_get_controls LDAP_PROTOCOL_ERROR\n",
                         0, 0, 0 );
                     return( LDAP_DECODING_ERROR );     /* decoding error */
              }
              /*
               * We found something other than controls.  This should never
               * happen in LDAPv3, but we don't treat this is a hard error --
               * we just ignore the extra stuff.
               */
              LDAPDebug( LDAP_DEBUG_TRACE,
                  "<= nsldapi_get_controls ignoring unrecognized data in message (tag 0x%x)\n",
                  tag, 0, 0 );
              return( LDAP_SUCCESS );
       }

       maxcontrols = curcontrols = 0;
       for ( tag = ber_first_element( ber, &len, &last );
           tag != LBER_ERROR && tag != LBER_END_OF_SEQORSET;
           tag = ber_next_element( ber, &len, last ) ) {
              if ( curcontrols >= maxcontrols - 1 ) {
#define CONTROL_GRABSIZE    5
                     maxcontrols += CONTROL_GRABSIZE;
                     *controlsp = (struct ldapcontrol **)NSLDAPI_REALLOC(
                         (char *)*controlsp, maxcontrols *
                         sizeof(struct ldapcontrol *) );
                     if ( *controlsp == NULL ) {
                         rc = LDAP_NO_MEMORY;
                         goto free_and_return;
                     }
              }
              if (( newctrl = (struct ldapcontrol *)NSLDAPI_CALLOC( 1,
                  sizeof(LDAPControl))) == NULL ) {
                     rc = LDAP_NO_MEMORY;
                     goto free_and_return;
              }
              
              (*controlsp)[curcontrols++] = newctrl;
              (*controlsp)[curcontrols] = NULL;

              if ( ber_scanf( ber, "{a", &newctrl->ldctl_oid )
                  == LBER_ERROR ) {
                     rc = LDAP_DECODING_ERROR;
                     goto free_and_return;
              }

              /* the criticality is optional */
              if ( ber_peek_tag( ber, &len ) == LBER_BOOLEAN ) {
                     int           aint;

                     if ( ber_scanf( ber, "b", &aint ) == LBER_ERROR ) {
                            rc = LDAP_DECODING_ERROR;
                            goto free_and_return;
                     }
                     newctrl->ldctl_iscritical = (char)aint;   /* XXX lossy cast */
              } else {
                     /* absent is synonomous with FALSE */
                     newctrl->ldctl_iscritical = 0;
              }

              /* the control value is optional */
              if ( ber_peek_tag( ber, &len ) == LBER_OCTETSTRING ) {
                     if ( ber_scanf( ber, "o", &newctrl->ldctl_value )
                         == LBER_ERROR ) {
                            rc = LDAP_DECODING_ERROR;
                            goto free_and_return;
                     }
              } else {
                     (newctrl->ldctl_value).bv_val = NULL;
                     (newctrl->ldctl_value).bv_len = 0;
              }

       }

       if ( tag == LBER_ERROR ) {
              rc = LDAP_DECODING_ERROR;
              goto free_and_return;
       }

       LDAPDebug( LDAP_DEBUG_TRACE,
           "<= nsldapi_get_controls found %d controls\n", curcontrols, 0, 0 );
       return( LDAP_SUCCESS );

free_and_return:;
       ldap_controls_free( *controlsp );
       *controlsp = NULL;
       LDAPDebug( LDAP_DEBUG_TRACE,
           "<= nsldapi_get_controls error 0x%x\n", rc, 0, 0 );
       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_hex_unescape ( char *  s)

Definition at line 50 of file unescape.c.

{
/*
 * Remove URL hex escapes from s... done in place.  The basic concept for
 * this routine is borrowed from the WWW library HTUnEscape() routine.
 */
       char   *p;

       for ( p = s; *s != '\0'; ++s ) {
              if ( *s == '%' ) {
                     if ( *++s != '\0' ) {
                            *p = unhex( *s ) << 4;
                     }
                     if ( *++s != '\0' ) {
                            *p++ += unhex( *s );
                     }
              } else {
                     *p++ = *s;
              }
       }

       *p = '\0';
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 371 of file open.c.

{

       if ( nsldapi_initialized ) {
              return;
       }

#ifdef USE_PTHREADS
        if ( pthread_key_create(&nsldapi_key, free ) != 0) {
                perror("pthread_key_create");
        }
#elif defined(USE_WINDOWS_TLS)
       dwTlsIndex = TlsAlloc();
#endif /* USE_WINDOWS_TLS */

       nsldapi_initialized = 1;
       memset( &nsldapi_memalloc_fns, 0, sizeof( nsldapi_memalloc_fns ));
       memset( &nsldapi_ld_defaults, 0, sizeof( nsldapi_ld_defaults ));
       nsldapi_ld_defaults.ld_options = LDAP_BITOPT_REFERRALS;
       nsldapi_ld_defaults.ld_version = LDAP_VERSION2;
       nsldapi_ld_defaults.ld_lberoptions = LBER_OPT_USE_DER;
       nsldapi_ld_defaults.ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;

#if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
       nsldapi_ld_defaults.ld_lberoptions |= LBER_OPT_TRANSLATE_STRINGS;
#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
       ldap_set_string_translators( &nsldapi_ld_defaults, ldap_8859_to_t61,
           ldap_t61_to_8859 );
#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */

        /* set default connect timeout (in milliseconds) */
        /* this was picked as it is the standard tcp timeout as well */
        nsldapi_ld_defaults.ld_connect_timeout = LDAP_X_IO_TIMEOUT_NO_TIMEOUT;

#if defined(USE_PTHREADS) || defined(_WINDOWS)
        /* load up default platform specific locking routines */
        if (ldap_set_option( NULL, LDAP_OPT_THREAD_FN_PTRS,
                (void *)&nsldapi_default_thread_fns) != LDAP_SUCCESS) {
                return;
        }

#ifndef _WINDOWS
        /* load up default threadid function */
        if (ldap_set_option( NULL, LDAP_OPT_EXTRA_THREAD_FN_PTRS,
                (void *)&nsldapi_default_extra_thread_fns) != LDAP_SUCCESS) {
                return;
        }
#endif /* _WINDOWS */
#endif /* use_pthreads || _windows */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_install_compat_io_fns ( LDAP *  ld,
struct ldap_io_fns iofns 
)

Definition at line 1800 of file os-ip.c.

{
       NSLDAPICompatSocketInfo            *defcsip;

       if (( defcsip = (NSLDAPICompatSocketInfo *)NSLDAPI_CALLOC( 1,
           sizeof( NSLDAPICompatSocketInfo ))) == NULL ) {
              return( LDAP_NO_MEMORY );
       }

       defcsip->csi_socket = -1;
       defcsip->csi_ld = ld;

       if ( ld->ld_io_fns_ptr != NULL ) {
              (void)memset( (char *)ld->ld_io_fns_ptr, 0,
                  sizeof( struct ldap_io_fns ));
       } else if (( ld->ld_io_fns_ptr = (struct ldap_io_fns *)NSLDAPI_CALLOC(
           1, sizeof( struct ldap_io_fns ))) == NULL ) {
              NSLDAPI_FREE( defcsip );
              return( LDAP_NO_MEMORY );
       }

       /* struct copy */
       *(ld->ld_io_fns_ptr) = *iofns;

       ld->ld_extio_size = LBER_X_EXTIO_FNS_SIZE;
       ld->ld_ext_session_arg = defcsip;
       ld->ld_extread_fn = nsldapi_ext_compat_read;
       ld->ld_extwrite_fn = nsldapi_ext_compat_write;
       ld->ld_extpoll_fn = nsldapi_ext_compat_poll;
       ld->ld_extconnect_fn = nsldapi_ext_compat_connect;
       ld->ld_extclose_fn = nsldapi_ext_compat_close;

       return( nsldapi_install_lber_extiofns( ld, ld->ld_sbp ));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_install_lber_extiofns ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 1517 of file os-ip.c.

{
       struct lber_x_ext_io_fns    lberiofns;

       if ( NULL != sb ) {
              lberiofns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
              lberiofns.lbextiofn_read = ld->ld_extread_fn;
              lberiofns.lbextiofn_write = ld->ld_extwrite_fn;
              lberiofns.lbextiofn_writev = ld->ld_extwritev_fn;
              lberiofns.lbextiofn_socket_arg = ld->ld_ext_session_arg;

              if ( ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_EXT_IO_FNS,
                  &lberiofns ) != 0 ) {
                     return( LDAP_LOCAL_ERROR );
              }
       }

       return( LDAP_SUCCESS );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_iostatus_free ( LDAP *  ld)

Definition at line 1119 of file os-ip.c.

{
       if ( ld == NULL ) {
              return;
       }

              
       /* clean up classic I/O compatibility glue */
       if ( ld->ld_io_fns_ptr != NULL ) {
              if ( ld->ld_ext_session_arg != NULL ) {
                     NSLDAPI_FREE( ld->ld_ext_session_arg );
              }
              NSLDAPI_FREE( ld->ld_io_fns_ptr );
       }

       /* clean up I/O status tracking info. */
       if ( ld->ld_iostatus != NULL ) {
              NSLDAPIIOStatus      *iosp = ld->ld_iostatus;

              if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifdef NSLDAPI_HAVE_POLL
                     if ( iosp->ios_status.ios_osinfo.ossi_pollfds
                         != NULL ) {
                            NSLDAPI_FREE(
                                iosp->ios_status.ios_osinfo.ossi_pollfds );
                     }
#endif /* NSLDAPI_HAVE_POLL */

              } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
                     if ( iosp->ios_status.ios_cbinfo.cbsi_pollfds
                         != NULL ) {
                            NSLDAPI_FREE(
                                iosp->ios_status.ios_cbinfo.cbsi_pollfds );
                     }
              } else {
                     LDAPDebug( LDAP_DEBUG_ANY,
                         "nsldapi_iostatus_free: unknown I/O type %d\n",
                          iosp->ios_type, 0, 0 );
              }

              NSLDAPI_FREE( iosp );
       }
}

Here is the caller graph for this function:

int nsldapi_iostatus_interest_clear ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 914 of file os-ip.c.

{
       NSLDAPIIOStatus      *iosp;

       LDAP_MUTEX_LOCK( ld, LDAP_IOSTATUS_LOCK );

       if ( ld->ld_iostatus == NULL
           && nsldapi_iostatus_init_nolock( ld ) < 0 ) {
              LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );
              return( -1 );
       }

       iosp = ld->ld_iostatus;

       if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifdef NSLDAPI_AVOID_OS_SOCKETS
              return( -1 );
#else /* NSLDAPI_AVOID_OS_SOCKETS */
#ifdef NSLDAPI_HAVE_POLL
              if ( nsldapi_clear_from_os_pollfds( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo, POLLOUT )) {
                     --iosp->ios_write_count;
              }
              if ( nsldapi_clear_from_os_pollfds( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo, POLLIN )) {
                     --iosp->ios_read_count;
              }
#else /* NSLDAPI_HAVE_POLL */
              if ( FD_ISSET( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo.ossi_writefds )) {
                     FD_CLR( sb->sb_sd,
                         &iosp->ios_status.ios_osinfo.ossi_writefds );
                     --iosp->ios_write_count;
              }
              if ( FD_ISSET( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo.ossi_readfds )) {
                     FD_CLR( sb->sb_sd,
                         &iosp->ios_status.ios_osinfo.ossi_readfds );
                     --iosp->ios_read_count;
              }
#endif /* else NSLDAPI_HAVE_POLL */
#endif /* NSLDAPI_AVOID_OS_SOCKETS */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
              if ( nsldapi_clear_from_cb_pollfds( sb,
                  &iosp->ios_status.ios_cbinfo, LDAP_X_POLLOUT )) {
                     --iosp->ios_write_count;
              }
              if ( nsldapi_clear_from_cb_pollfds( sb,
                  &iosp->ios_status.ios_cbinfo, LDAP_X_POLLIN )) {
                     --iosp->ios_read_count;
              }
       } else {
              LDAPDebug( LDAP_DEBUG_ANY,
                  "nsldapi_iostatus_interest_clear: unknown I/O type %d\n",
                   iosp->ios_type, 0, 0 );
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_iostatus_interest_read ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 859 of file os-ip.c.

{
       NSLDAPIIOStatus      *iosp;

       LDAP_MUTEX_LOCK( ld, LDAP_IOSTATUS_LOCK );

       if ( ld->ld_iostatus == NULL
           && nsldapi_iostatus_init_nolock( ld ) < 0 ) {
              LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );
              return( -1 );
       }

       iosp = ld->ld_iostatus;

       if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifdef NSLDAPI_AVOID_OS_SOCKETS
              return( -1 );
#else /* NSLDAPI_AVOID_OS_SOCKETS */
#ifdef NSLDAPI_HAVE_POLL
              if ( nsldapi_add_to_os_pollfds( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo, POLLIN )) {
                     ++iosp->ios_read_count;
              }
#else /* NSLDAPI_HAVE_POLL */
              if ( !FD_ISSET( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo.ossi_readfds )) {
                     FD_SET( sb->sb_sd,
                         &iosp->ios_status.ios_osinfo.ossi_readfds );
                     ++iosp->ios_read_count;
              }
#endif /* else NSLDAPI_HAVE_POLL */
#endif /* NSLDAPI_AVOID_OS_SOCKETS */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
              if ( nsldapi_add_to_cb_pollfds( sb,
                  &iosp->ios_status.ios_cbinfo, LDAP_X_POLLIN )) {
                     ++iosp->ios_read_count;
              }
       } else {
              LDAPDebug( LDAP_DEBUG_ANY,
                  "nsldapi_iostatus_interest_read: unknown I/O type %d\n",
                   iosp->ios_type, 0, 0 );
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_iostatus_interest_write ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 803 of file os-ip.c.

{
       NSLDAPIIOStatus      *iosp;

       LDAP_MUTEX_LOCK( ld, LDAP_IOSTATUS_LOCK );

       if ( ld->ld_iostatus == NULL
           && nsldapi_iostatus_init_nolock( ld ) < 0 ) {
              LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );
              return( -1 );
       }

       iosp = ld->ld_iostatus;

       if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifdef NSLDAPI_AVOID_OS_SOCKETS
              return( -1 );
#else /* NSLDAPI_AVOID_OS_SOCKETS */
#ifdef NSLDAPI_HAVE_POLL
              if ( nsldapi_add_to_os_pollfds( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo, POLLOUT )) {
                     ++iosp->ios_write_count;
              }
#else /* NSLDAPI_HAVE_POLL */
              if ( !FD_ISSET( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo.ossi_writefds )) {
                     FD_SET( sb->sb_sd,
                         &iosp->ios_status.ios_osinfo.ossi_writefds );
                     ++iosp->ios_write_count;
              }
#endif /* else NSLDAPI_HAVE_POLL */
#endif /* NSLDAPI_AVOID_OS_SOCKETS */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
              if ( nsldapi_add_to_cb_pollfds( sb,
                  &iosp->ios_status.ios_cbinfo, LDAP_X_POLLOUT )) {
                     ++iosp->ios_write_count;
              }

       } else {
              LDAPDebug( LDAP_DEBUG_ANY,
                  "nsldapi_iostatus_interest_write: unknown I/O type %d\n",
                   iosp->ios_type, 0, 0 );
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_iostatus_is_read_ready ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 1032 of file os-ip.c.

{
       int           rc;
       NSLDAPIIOStatus      *iosp;

       LDAP_MUTEX_LOCK( ld, LDAP_IOSTATUS_LOCK );
       iosp = ld->ld_iostatus;

       if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifdef NSLDAPI_AVOID_OS_SOCKETS
              return 0;
#else /* NSLDAPI_AVOID_OS_SOCKETS */
#ifdef NSLDAPI_HAVE_POLL
              /*
               * if we are using poll() we do something a little tricky: if
               * any bits in the socket's returned events field other than
               * POLLOUT (ready for write) are set, we return true.  This
               * is done so we notice when a server closes a connection
               * or when another error occurs.  The actual error will be
               * noticed later when we call read() or recv().
               */
              rc = nsldapi_find_in_os_pollfds( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo, ~POLLOUT );

#else /* NSLDAPI_HAVE_POLL */
              rc = FD_ISSET( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo.ossi_use_readfds );
#endif /* else NSLDAPI_HAVE_POLL */
#endif /* NSLDAPI_AVOID_OS_SOCKETS */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
              rc = nsldapi_find_in_cb_pollfds( sb,
                  &iosp->ios_status.ios_cbinfo, ~LDAP_X_POLLOUT );

       } else {
              LDAPDebug( LDAP_DEBUG_ANY,
                  "nsldapi_iostatus_is_read_ready: unknown I/O type %d\n",
                   iosp->ios_type, 0, 0 );
              rc = 0;
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );
       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_iostatus_is_write_ready ( LDAP *  ld,
Sockbuf *  sb 
)

Definition at line 982 of file os-ip.c.

{
       int           rc;
       NSLDAPIIOStatus      *iosp;

       LDAP_MUTEX_LOCK( ld, LDAP_IOSTATUS_LOCK );
       iosp = ld->ld_iostatus;

       if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifdef NSLDAPI_AVOID_OS_SOCKETS
              return 0;
#else  /* NSLDAPI_AVOID_OS_SOCKETS */
#ifdef NSLDAPI_HAVE_POLL
              /*
               * if we are using poll() we do something a little tricky: if
               * any bits in the socket's returned events field other than
               * POLLIN (ready for read) are set, we return true.  This
               * is done so we notice when a server closes a connection
               * or when another error occurs.  The actual error will be
               * noticed later when we call write() or send().
               */
              rc = nsldapi_find_in_os_pollfds( sb->sb_sd,
                  &iosp->ios_status.ios_osinfo, ~POLLIN );

#else /* NSLDAPI_HAVE_POLL */
              rc = FD_ISSET( sb->sb_sd,
                     &iosp->ios_status.ios_osinfo.ossi_use_writefds );
#endif /* else NSLDAPI_HAVE_POLL */
#endif /* NSLDAPI_AVOID_OS_SOCKETS */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
              rc = nsldapi_find_in_cb_pollfds( sb,
                  &iosp->ios_status.ios_cbinfo, ~LDAP_X_POLLIN );

       } else {
              LDAPDebug( LDAP_DEBUG_ANY,
                  "nsldapi_iostatus_is_write_ready: unknown I/O type %d\n",
                   iosp->ios_type, 0, 0 );
              rc = 0;
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );
       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_iostatus_poll ( LDAP *  ld,
struct timeval timeout 
)

Definition at line 1207 of file os-ip.c.

{
       int                  rc;
       NSLDAPIIOStatus             *iosp;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_iostatus_poll\n", 0, 0, 0 );

       LDAP_MUTEX_LOCK( ld, LDAP_IOSTATUS_LOCK );
       iosp = ld->ld_iostatus;

       if ( iosp == NULL ||
           ( iosp->ios_read_count <= 0 && iosp->ios_read_count <= 0 )) {
              rc = 0;              /* simulate a timeout */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_OSNATIVE ) {
#ifndef NSLDAPI_AVOID_OS_SOCKETS
#ifdef NSLDAPI_HAVE_POLL

              rc = NSLDAPI_POLL( iosp->ios_status.ios_osinfo.ossi_pollfds,
                  iosp->ios_status.ios_osinfo.ossi_pollfds_size,
                  nsldapi_tv2ms( timeout ));

#else /* NSLDAPI_HAVE_POLL */

              /* two (potentially large) struct copies */
              iosp->ios_status.ios_osinfo.ossi_use_readfds
                  = iosp->ios_status.ios_osinfo.ossi_readfds;
              iosp->ios_status.ios_osinfo.ossi_use_writefds
                  = iosp->ios_status.ios_osinfo.ossi_writefds;

#ifdef HPUX9
              rc = NSLDAPI_SELECT( nsldapi_get_select_table_size(),
                  (int *)&iosp->ios_status.ios_osinfo.ossi_use_readfds
                  (int *)&iosp->ios_status.ios_osinfo.ossi_use_writefds,
                  NULL, timeout );
#else
              rc = NSLDAPI_SELECT( nsldapi_get_select_table_size(),
                  &iosp->ios_status.ios_osinfo.ossi_use_readfds,
                  &iosp->ios_status.ios_osinfo.ossi_use_writefds,
                  NULL, timeout );
#endif /* else HPUX9 */
#endif /* else NSLDAPI_HAVE_POLL */
#endif /* NSLDAPI_AVOID_OS_SOCKETS */

       } else if ( iosp->ios_type == NSLDAPI_IOSTATUS_TYPE_CALLBACK ) {
              /*
               * We always pass the session extended I/O argument to
               * the extended poll() callback.
               */
              rc = ld->ld_extpoll_fn( 
                  iosp->ios_status.ios_cbinfo.cbsi_pollfds,
                  iosp->ios_status.ios_cbinfo.cbsi_pollfds_size,
                  nsldapi_tv2ms( timeout ), ld->ld_ext_session_arg );

       } else {
              LDAPDebug( LDAP_DEBUG_ANY,
                  "nsldapi_iostatus_poll: unknown I/O type %d\n",
                   iosp->ios_type, 0, 0 );
              rc = 0;       /* simulate a timeout (what else to do?) */
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_IOSTATUS_LOCK );
       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_mutex_alloc_all ( LDAP *  ld)

Definition at line 610 of file open.c.

{
       int    i;

       if ( ld != &nsldapi_ld_defaults && ld->ld_mutex != NULL ) {
              for ( i = 0; i<LDAP_MAX_LOCK; i++ ) {
                     ld->ld_mutex[i] = LDAP_MUTEX_ALLOC( ld );
                     ld->ld_mutex_threadid[i] = (void *) -1; 
                     ld->ld_mutex_refcnt[i] = 0; 
              }
       } 
}

Here is the caller graph for this function:

void nsldapi_mutex_free_all ( LDAP *  ld)

Definition at line 625 of file open.c.

{
       int    i;

       if ( ld != &nsldapi_ld_defaults && ld->ld_mutex != NULL ) {
              for ( i = 0; i<LDAP_MAX_LOCK; i++ ) {
                     LDAP_MUTEX_FREE( ld, ld->ld_mutex[i] );
              }
       }
}

Here is the caller graph for this function:

LDAPConn* nsldapi_new_connection ( LDAP *  ld,
LDAPServer **  srvlistp,
int  use_ldsb,
int  connect,
int  bind 
)

Definition at line 368 of file request.c.

{
    int       rc;
    
       LDAPConn      *lc;
       LDAPServer    *prevsrv, *srv;
       Sockbuf              *sb = NULL;

       /*
        * make a new LDAP server connection
        */
       if (( lc = (LDAPConn *)NSLDAPI_CALLOC( 1, sizeof( LDAPConn ))) == NULL
           || ( !use_ldsb && ( sb = ber_sockbuf_alloc()) == NULL )) {
              if ( lc != NULL ) {
                     NSLDAPI_FREE( (char *)lc );
              }
              LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
              return( NULL );
       }

       LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK );
       if ( !use_ldsb ) {
              /*
               * we have allocated a new sockbuf
               * set I/O routines to match those in default LDAP sockbuf
               */
              IFP                         sb_fn;
              struct lber_x_ext_io_fns    extiofns;
              
              extiofns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;

              if ( ber_sockbuf_get_option( ld->ld_sbp,
                  LBER_SOCKBUF_OPT_EXT_IO_FNS, &extiofns ) == 0 ) {
                     ber_sockbuf_set_option( sb,
                         LBER_SOCKBUF_OPT_EXT_IO_FNS, &extiofns );
              }
              if ( ber_sockbuf_get_option( ld->ld_sbp,
                  LBER_SOCKBUF_OPT_READ_FN, (void *)&sb_fn ) == 0
                  && sb_fn != NULL ) {
                     ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_READ_FN,
                         (void *)sb_fn );
              }
              if ( ber_sockbuf_get_option( ld->ld_sbp,
                  LBER_SOCKBUF_OPT_WRITE_FN, (void *)&sb_fn ) == 0
                  && sb_fn != NULL ) {
                     ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_WRITE_FN,
                         (void *)sb_fn );
              }
       }

       lc->lconn_sb = ( use_ldsb ) ? ld->ld_sbp : sb;
       lc->lconn_version = ld->ld_version;       /* inherited */
       LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );

       if ( connect ) {
              prevsrv = NULL;
        /* 
         * save the return code for later
         */ 
              for ( srv = *srvlistp; srv != NULL; srv = srv->lsrv_next ) {
                     rc = nsldapi_connect_to_host( ld, lc->lconn_sb,
                               srv->lsrv_host, srv->lsrv_port,
                            (  srv->lsrv_options & LDAP_SRV_OPT_SECURE ) != 0,
                                   &lc->lconn_krbinstance );
                     if (rc != -1) {
                            break;
                     }
                     prevsrv = srv;
              }

              if ( srv == NULL ) {
                  if ( !use_ldsb ) {
                     NSLDAPI_FREE( (char *)lc->lconn_sb );
                  }
                  NSLDAPI_FREE( (char *)lc );
                  /* nsldapi_open_ldap_connection has already set ld_errno */
                  return( NULL );
              }

              if ( prevsrv == NULL ) {
                  *srvlistp = srv->lsrv_next;
              } else {
                  prevsrv->lsrv_next = srv->lsrv_next;
              }
              lc->lconn_server = srv;
       }

       if (ld->ld_options & LDAP_BITOPT_ASYNC && rc == -2)
    {
        lc->lconn_status = LDAP_CONNST_CONNECTING;
    }
    else {
        lc->lconn_status = LDAP_CONNST_CONNECTED;
    }
    
       lc->lconn_next = ld->ld_conns;
       ld->ld_conns = lc;

       /*
        * XXX for now, we always do a synchronous bind.  This will have
        * to change in the long run...
        */
       if ( bind ) {
              int           err, lderr, freepasswd, authmethod;
              char          *binddn, *passwd;
              LDAPConn      *savedefconn;

              freepasswd = err = 0;

              if ( ld->ld_rebind_fn == NULL ) {
                     binddn = passwd = "";
                     authmethod = LDAP_AUTH_SIMPLE;
              } else {
                     if (( lderr = (*ld->ld_rebind_fn)( ld, &binddn, &passwd,
                         &authmethod, 0, ld->ld_rebind_arg ))
                         == LDAP_SUCCESS ) {
                            freepasswd = 1;
                     } else {
                            LDAP_SET_LDERRNO( ld, lderr, NULL, NULL );
                            err = -1;
                     }
              }


              if ( err == 0 ) {
                     savedefconn = ld->ld_defconn;
                     ld->ld_defconn = lc;
                     ++lc->lconn_refcnt;  /* avoid premature free */

                     /*
                      * when binding, we will back down as low as LDAPv2
                      * if we get back "protocol error" from bind attempts
                      */
                     for ( ;; ) {
                            /* LDAP_MUTEX_UNLOCK(ld, LDAP_CONN_LOCK); */
                            if (( lderr = ldap_bind_s( ld, binddn, passwd,
                                authmethod )) == LDAP_SUCCESS ) {
                                   /* LDAP_MUTEX_LOCK(ld, LDAP_CONN_LOCK); */
                                   break;
                            }
                            /* LDAP_MUTEX_LOCK(ld, LDAP_CONN_LOCK); */
                            if ( lc->lconn_version <= LDAP_VERSION2
                                || lderr != LDAP_PROTOCOL_ERROR ) {
                                   err = -1;
                                   break;
                            }
                            --lc->lconn_version; /* try lower version */
                     }
                     --lc->lconn_refcnt;
                     ld->ld_defconn = savedefconn;
              }

              if ( freepasswd ) {
                     (*ld->ld_rebind_fn)( ld, &binddn, &passwd,
                            &authmethod, 1, ld->ld_rebind_arg );
              }

              if ( err != 0 ) {
                     nsldapi_free_connection( ld, lc, NULL, NULL, 1, 0 );
                     lc = NULL;
              }
       }

       return( lc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_next_line_tokens ( char **  bufp,
long blenp,
char ***  toksp 
)

Definition at line 60 of file dsparse.c.

{
    char      *p, *line, *token, **toks;
    int              rc, tokcnt;

    *toksp = NULL;

    if (( rc = next_line( bufp, blenp, &line )) <= 0 ) {
       return( rc );
    }

    if (( toks = (char **)NSLDAPI_CALLOC( 1, sizeof( char * ))) == NULL ) {
       NSLDAPI_FREE( line );
       return( -1 );
    }
    tokcnt = 0;

    p = line;
    while (( token = next_token( &p )) != NULL ) {
       if (( toks = (char **)NSLDAPI_REALLOC( toks, ( tokcnt + 2 ) *
              sizeof( char * ))) == NULL ) {
           NSLDAPI_FREE( (char *)toks );
           NSLDAPI_FREE( line );
           return( -1 );
       }
       toks[ tokcnt ] = token;
       toks[ ++tokcnt ] = NULL;
    }

    if ( tokcnt == 1 && strcasecmp( toks[ 0 ], "END" ) == 0 ) {
       tokcnt = 0;
       nsldapi_free_strarray( toks );
       toks = NULL;
    }

    NSLDAPI_FREE( line );

    if ( tokcnt == 0 ) {
       if ( toks != NULL ) {
           NSLDAPI_FREE( (char *)toks );
       }
    } else {
       *toksp = toks;
    }

    return( tokcnt );
}

Definition at line 639 of file open.c.

{
       LDAPServer    *srv;

       if (( srv = (LDAPServer *)NSLDAPI_CALLOC( 1, sizeof( LDAPServer ))) ==
           NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
           nsldapi_strdup( ld->ld_defhost )) == NULL )) {
              LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
              return( -1 );
       }
       srv->lsrv_port = ld->ld_defport;

       if (( ld->ld_options & LDAP_BITOPT_SSL ) != 0 ) {
              srv->lsrv_options |= LDAP_SRV_OPT_SECURE;
       }

       if (( ld->ld_defconn = nsldapi_new_connection( ld, &srv, 1, 1, 0 ))
           == NULL ) {
              if ( ld->ld_defhost != NULL ) {
                     NSLDAPI_FREE( srv->lsrv_host );
              }
              NSLDAPI_FREE( (char *)srv );
              return( -1 );
       }
       ++ld->ld_defconn->lconn_refcnt;    /* so it never gets closed/freed */

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_parse_reference ( LDAP *  ld,
BerElement *  rber,
char ***  referralsp,
LDAPControl ***  serverctrlsp 
)

Definition at line 131 of file referral.c.

{
       int           err;
       BerElement    ber;
       char          **refs;

       /*
        * Parse a searchResultReference message.  These are used in LDAPv3
        * and beyond and look like this:
        *
        *     SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
        *
        * all wrapped up in an LDAPMessage sequence which looks like this:
        *
        *     LDAPMessage ::= SEQUENCE {
        *            messageID     MessageID,
        *            SearchResultReference
        *            controls      [0] Controls OPTIONAL
        *     }
        *
        * ldap_result() pulls out the message id, so by the time a result
        * message gets here we are conveniently sitting at the start of the
        * SearchResultReference itself.
        */
       err = LDAP_SUCCESS;  /* optimistic */
       ber = *rber;         /* struct copy */

       if ( ber_scanf( &ber, "{v", &refs ) == LBER_ERROR ) {
           err = LDAP_DECODING_ERROR;
       } else if ( serverctrlsp != NULL ) {
           /* pull out controls (if requested and any are present) */
           if ( ber_scanf( &ber, "}" ) == LBER_ERROR ) {
              err = LDAP_DECODING_ERROR;
           } else {
              err = nsldapi_get_controls( &ber, serverctrlsp );
           }
       }

       if ( referralsp == NULL ) {
           ldap_value_free( refs );
       } else {
           *referralsp = refs;
       }

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_parse_result ( LDAP *  ld,
int  msgtype,
BerElement *  rber,
int errcodep,
char **  matchednp,
char **  errmsgp,
char ***  referralsp,
LDAPControl ***  serverctrlsp 
)

Definition at line 354 of file error.c.

{
       BerElement    ber;
       unsigned long len;
       int           berrc, err, errcode;
       long          along;
       char          *m, *e;

       /*
        * Parse the result message.  LDAPv3 result messages look like this:
        *
        *     LDAPResult ::= SEQUENCE {
        *            resultCode    ENUMERATED { ... },
        *            matchedDN     LDAPDN,
        *            errorMessage  LDAPString,
        *            referral      [3] Referral OPTIONAL
        *            opSpecificStuff      OPTIONAL
        *     }
        *
        * all wrapped up in an LDAPMessage sequence which looks like this:
        *     LDAPMessage ::= SEQUENCE {
        *            messageID     MessageID,
        *            LDAPResult    CHOICE { ... },      // message type
        *            controls      [0] Controls OPTIONAL
        *     }
        *
        * LDAPv2 messages don't include referrals or controls.
        * LDAPv1 messages don't include matchedDN, referrals, or controls.
        *
        * ldap_result() pulls out the message id, so by the time a result
        * message gets here we are sitting at the start of the LDAPResult.
        */

       err = LDAP_SUCCESS;  /* optimistic */
       m = e = NULL;
       if ( matchednp != NULL ) {
              *matchednp = NULL;
       }
       if ( errmsgp != NULL ) {
              *errmsgp = NULL;
       }
       if ( referralsp != NULL ) {
              *referralsp = NULL;
       }
       if ( serverctrlsp != NULL ) {
              *serverctrlsp = NULL;
       }
       ber = *rber;         /* struct copy */

       if ( NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION2 ) {
              berrc = ber_scanf( &ber, "{ia}", &along, &e );
              errcode = (int)along;       /* XXX lossy cast */
       } else {
              if (( berrc = ber_scanf( &ber, "{iaa", &along, &m, &e ))
                  != LBER_ERROR ) {
                     errcode = (int)along;       /* XXX lossy cast */
                     /* check for optional referrals */
                     if ( ber_peek_tag( &ber, &len ) == LDAP_TAG_REFERRAL ) {
                            if ( referralsp == NULL ) {
                                   /* skip referrals */
                                   berrc = ber_scanf( &ber, "x" );
                            } else {
                                   /* suck out referrals */
                                   berrc = ber_scanf( &ber, "v",
                                       referralsp );
                            }
                     } else if ( referralsp != NULL ) {
                            *referralsp = NULL;
                     }
              }

              if ( berrc != LBER_ERROR ) {
                     /*
                      * skip past optional operation-specific elements:
                      *   bind results - serverSASLcreds
                      *   extendedop results -  OID plus value
                      */
                     if ( msgtype == LDAP_RES_BIND ) {
                            if ( ber_peek_tag( &ber, &len ) == 
                                LDAP_TAG_SASL_RES_CREDS ) {
                                   berrc = ber_scanf( &ber, "x" );
                            }
                     } else if ( msgtype == LDAP_RES_EXTENDED ) {
                            if ( ber_peek_tag( &ber, &len ) ==
                                LDAP_TAG_EXOP_RES_OID ) {
                                   berrc = ber_scanf( &ber, "x" );
                            }
                            if ( berrc != LBER_ERROR &&
                                ber_peek_tag( &ber, &len ) ==
                                LDAP_TAG_EXOP_RES_VALUE ) {
                                   berrc = ber_scanf( &ber, "x" );
                            }
                     }
              }

              /* pull out controls (if requested and any are present) */
              if ( berrc != LBER_ERROR && serverctrlsp != NULL &&
                  ( berrc = ber_scanf( &ber, "}" )) != LBER_ERROR ) {
                     err = nsldapi_get_controls( &ber, serverctrlsp );
              }
       }

       if ( berrc == LBER_ERROR && err == LDAP_SUCCESS ) {
              err = LDAP_DECODING_ERROR;
       }

       if ( errcodep != NULL ) {
              *errcodep = errcode;
       }
       if ( matchednp != NULL ) {
              *matchednp = m;
       } else if ( m != NULL ) {
              NSLDAPI_FREE( m );
       }
       if ( errmsgp != NULL ) {
              *errmsgp = e;
       } else if ( e != NULL ) {
              NSLDAPI_FREE( e );
       }

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_post_result ( LDAP *  ld,
int  msgid,
LDAPMessage *  result 
)

Definition at line 1282 of file result.c.

{
       LDAPPend      *lp;

       LDAPDebug( LDAP_DEBUG_TRACE,
           "nsldapi_post_result(ld=0x%x, msgid=%d, result=0x%x)\n",
           ld, msgid, result );
       LDAP_MUTEX_LOCK( ld, LDAP_PEND_LOCK );
       if( msgid == LDAP_RES_ANY ) {
              /*
               * Look for any pending request for which someone is waiting.
               */
              for( lp = ld->ld_pend; lp != NULL; lp = lp->lp_next )
              {
                     if ( lp->lp_sema != NULL ) {
                            break;
                     } 
              }
              /*
               * If we did't find a pending request, lp is NULL at this
               * point, and we will leave this function without doing
               * anything more -- which is exactly what we want to do.
               */
       }
       else
       {
              /*
               * Look for a pending request specific to this message id
               */
              for( lp = ld->ld_pend; lp != NULL; lp = lp->lp_next )
              {
                     if( lp->lp_msgid == msgid )
                            break;
              }

              if( lp == NULL )
              {
                     /*
                      * No pending requests for this response... append to
                      * our pending result list.
                      */
                     LDAPPend      *newlp;
                     newlp = (LDAPPend *)NSLDAPI_CALLOC( 1,
                         sizeof( LDAPPend ));
                     if( newlp == NULL )
                     {
                            LDAP_MUTEX_UNLOCK( ld, LDAP_PEND_LOCK );
                            LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL,
                                NULL );
                            return (-1);
                     }
                     newlp->lp_msgid = msgid;
                     newlp->lp_result = result;
                     link_pend( ld, newlp );
              }
       }


       if( lp != NULL )
       {
              /*
               * Wake up a thread that is waiting for this result.
               */
              lp->lp_msgid = msgid;
              lp->lp_result = result;
              LDAP_SEMA_POST( ld, lp );
       }

       LDAP_MUTEX_UNLOCK( ld, LDAP_PEND_LOCK );
       return (0);
}

Here is the call graph for this function:

int nsldapi_put_controls ( LDAP *  ld,
LDAPControl **  ctrls,
int  closeseq,
BerElement *  ber 
)

Definition at line 52 of file control.c.

{
       LDAPControl   *c;
       int           rc, i;

       rc = LDAP_ENCODING_ERROR;   /* the most popular error */

       /* if no controls were passed in, use global list from LDAP * */
       LDAP_MUTEX_LOCK( ld, LDAP_CTRL_LOCK );
       if ( ctrls == NULL ) {
              ctrls = ld->ld_servercontrols;
       }

       /* if there are no controls then we are done */
       if ( ctrls == NULL || ctrls[ 0 ] == NULL ) {
              goto clean_exit;
       }

       /*
        * If we're using LDAPv2 or earlier we can't send any controls, so
        * we just ignore them unless one is marked critical, in which case
        * we return an error.
        */
       if ( NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3 ) {
              for ( i = 0; ctrls != NULL && ctrls[i] != NULL; i++ ) {
                     if ( ctrls[i]->ldctl_iscritical ) {
                            rc = LDAP_NOT_SUPPORTED;
                            goto error_exit;
                     }
              }
              goto clean_exit;
       }

       /*
        * encode the controls as a Sequence of Sequence
        */
       if ( ber_printf( ber, "t{", LDAP_TAG_CONTROLS ) == -1 ) {
              goto error_exit;
       }

       for ( i = 0; ctrls[i] != NULL; i++ ) {
              c = ctrls[i];

              if ( ber_printf( ber, "{s", c->ldctl_oid ) == -1 ) {
                     goto error_exit;
              }

              /* criticality is "BOOLEAN DEFAULT FALSE" */
              /* therefore, it should only be encoded if it exists AND is TRUE */
              if ( c->ldctl_iscritical ) {
                     if ( ber_printf( ber, "b", (int)c->ldctl_iscritical )
                         == -1 ) {
                            goto error_exit;
                     }
              }

              if ( c->ldctl_value.bv_val != NULL ) {
                     if ( ber_printf( ber, "o", c->ldctl_value.bv_val,
                         (int)c->ldctl_value.bv_len /* XXX lossy cast */ )
                         == -1 ) {
                            goto error_exit;
                     }
              }

              if ( ber_put_seq( ber ) == -1 ) {
                     goto error_exit;
              }
       }

       if ( ber_put_seq( ber ) == -1 ) {
              goto error_exit;
       }

clean_exit:
       LDAP_MUTEX_UNLOCK( ld, LDAP_CTRL_LOCK );
       if ( closeseq && ber_put_seq( ber ) == -1 ) {
              goto error_exit;
       }
       return( LDAP_SUCCESS );

error_exit:
       LDAP_MUTEX_UNLOCK( ld, LDAP_CTRL_LOCK );
       LDAP_SET_LDERRNO( ld, rc, NULL, NULL );
       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_result_nolock ( LDAP *  ld,
int  msgid,
int  all,
int  unlock_permitted,
struct timeval timeout,
LDAPMessage **  result 
)

Definition at line 117 of file result.c.

{
       int           rc;

       LDAPDebug( LDAP_DEBUG_TRACE,
              "nsldapi_result_nolock (msgid=%d, all=%d)\n", msgid, all, 0 );

       /*
        * First, look through the list of responses we have received on
        * this association and see if the response we're interested in
        * is there.  If it is, return it.  If not, call wait4msg() to
        * wait until it arrives or timeout occurs.
        */

       if ( result == NULL ) {
              LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL );
              return( -1 );
       }

       if ( check_response_queue( ld, msgid, all, 1, result ) != 0 ) {
              LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL );
              rc = (*result)->lm_msgtype;
       } else {
              rc = wait4msg( ld, msgid, all, unlock_permitted, timeout,
                  result );
       }

       /*
        * XXXmcs should use cache function pointers to hook in memcache
        */
       if ( ld->ld_memcache != NULL && NSLDAPI_SEARCH_RELATED_RESULT( rc ) &&
            !((*result)->lm_fromcache )) {
              ldap_memcache_append( ld, (*result)->lm_msgid,
                  (all || NSLDAPI_IS_SEARCH_RESULT( rc )), *result );
       }

       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_send_initial_request ( LDAP *  ld,
int  msgid,
unsigned long  msgtype,
char *  dn,
BerElement *  ber 
)

Definition at line 104 of file request.c.

{
       LDAPServer    *servers;
       
       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_initial_request\n", 0,0,0 );

#ifdef LDAP_DNS
       LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK );
       if (( ld->ld_options & LDAP_BITOPT_DNS ) != 0 && ldap_is_dns_dn( dn )) {
              if (( servers = dn2servers( ld, dn )) == NULL ) {
                     ber_free( ber, 1 );
                     LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );
                     return( -1 );
              }

#ifdef LDAP_DEBUG
              if ( ldap_debug & LDAP_DEBUG_TRACE ) {
                     LDAPServer    *srv;
                     char    msg[256];

                     for ( srv = servers; srv != NULL;
                         srv = srv->lsrv_next ) {
                            sprintf( msg,
                                "LDAP server %s:  dn %s, port %d\n",
                                srv->lsrv_host, ( srv->lsrv_dn == NULL ) ?
                                "(default)" : srv->lsrv_dn,
                                srv->lsrv_port );
                            ber_err_print( msg );
                     }
              }
#endif /* LDAP_DEBUG */
       } else {
#endif /* LDAP_DNS */
              /*
               * use of DNS is turned off or this is an LDAP DN...
               * use our default connection
               */
              servers = NULL;
#ifdef LDAP_DNS
       }      
       LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );
#endif /* LDAP_DNS */

       return( nsldapi_send_server_request( ld, ber, msgid, NULL,
           servers, NULL, ( msgtype == LDAP_REQ_BIND ) ? dn : NULL, 0 ));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_send_server_request ( LDAP *  ld,
BerElement *  ber,
int  msgid,
LDAPRequest parentreq,
LDAPServer srvlist,
LDAPConn lc,
char *  bindreqdn,
int  bind 
)

Definition at line 155 of file request.c.

{
       LDAPRequest   *lr;
       int           err;
       int           incparent;    /* did we bump parent's ref count? */

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_server_request\n", 0, 0, 0 );

       incparent = 0;
       LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK );
       if ( lc == NULL ) {
              if ( srvlist == NULL ) {
                     if ( ld->ld_defconn == NULL ) {
                            LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK );
                            if ( bindreqdn == NULL && ( ld->ld_options
                                & LDAP_BITOPT_RECONNECT ) != 0 ) {
                                   LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN,
                                       NULL, NULL );
                                   ber_free( ber, 1 );
                                   LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );
                                   LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
                                   return( -1 );
                            }
                            LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );

                            if ( nsldapi_open_ldap_defconn( ld ) < 0 ) {
                                   ber_free( ber, 1 );
                                   LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
                                   return( -1 );
                            }
                     }
                     lc = ld->ld_defconn;
              } else {
                     if (( lc = find_connection( ld, srvlist, 1 )) ==
                         NULL ) {
                            if ( bind && (parentreq != NULL) ) {
                                   /* Remember the bind in the parent */
                                   incparent = 1;
                                   ++parentreq->lr_outrefcnt;
                            }

                            lc = nsldapi_new_connection( ld, &srvlist, 0,
                                   1, bind );
                     }
                     free_servers( srvlist );
              }
       }


    /*
     * the logic here is:
     * if 
     * 1. no connections exists, 
     * or 
     * 2. if the connection is either not in the connected 
     *     or connecting state in an async io model
     * or 
     * 3. the connection is notin a connected state with normal (non async io)
     */
       if (   lc == NULL
              || (  (ld->ld_options & LDAP_BITOPT_ASYNC 
               && lc->lconn_status != LDAP_CONNST_CONNECTING
                  && lc->lconn_status != LDAP_CONNST_CONNECTED)
              || (!(ld->ld_options & LDAP_BITOPT_ASYNC )
                  && lc->lconn_status != LDAP_CONNST_CONNECTED) ) ) {

              ber_free( ber, 1 );
              if ( lc != NULL ) {
                     LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL );
              }
              if ( incparent ) {
                     /* Forget about the bind */
                     --parentreq->lr_outrefcnt; 
              }
              LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
              return( -1 );
       }

       use_connection( ld, lc );
       if (( lr = (LDAPRequest *)NSLDAPI_CALLOC( 1, sizeof( LDAPRequest ))) ==
           NULL || ( bindreqdn != NULL && ( bindreqdn =
           nsldapi_strdup( bindreqdn )) == NULL )) {
              if ( lr != NULL ) {
                     NSLDAPI_FREE( lr );
              }
              LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
              nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 );
              ber_free( ber, 1 );
              if ( incparent ) {
                     /* Forget about the bind */
                     --parentreq->lr_outrefcnt; 
              }
              LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
              return( -1 );
       } 
       lr->lr_binddn = bindreqdn;
       lr->lr_msgid = msgid;
       lr->lr_status = LDAP_REQST_INPROGRESS;
       lr->lr_res_errno = LDAP_SUCCESS;   /* optimistic */
       lr->lr_ber = ber;
       lr->lr_conn = lc;

       if ( parentreq != NULL ) {  /* sub-request */
              if ( !incparent ) { 
                     /* Increment if we didn't do it before the bind */
                     ++parentreq->lr_outrefcnt;
              }
              lr->lr_origid = parentreq->lr_origid;
              lr->lr_parentcnt = parentreq->lr_parentcnt + 1;
              lr->lr_parent = parentreq;
              if ( parentreq->lr_child != NULL ) {
                     lr->lr_sibling = parentreq->lr_child;
              }
              parentreq->lr_child = lr;
       } else {                    /* original request */
              lr->lr_origid = lr->lr_msgid;
       }

       LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK );
       if (( lr->lr_next = ld->ld_requests ) != NULL ) {
              lr->lr_next->lr_prev = lr;
       }
       ld->ld_requests = lr;
       lr->lr_prev = NULL;

       if (( err = nsldapi_ber_flush( ld, lc->lconn_sb, ber, 0, 1 )) != 0 ) {

              /* need to continue write later */
              if (ld->ld_options & LDAP_BITOPT_ASYNC && err == -2 ) { 
                     lr->lr_status = LDAP_REQST_WRITING;
                     nsldapi_iostatus_interest_write( ld, lc->lconn_sb );
              } else {

                     LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL );
                     nsldapi_free_request( ld, lr, 0 );
                     nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 );
                     LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK );
                     LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
                     return( -1 );
              }

       } else {
              if ( parentreq == NULL ) {
                     ber->ber_end = ber->ber_ptr;
                     ber->ber_ptr = ber->ber_buf;
              }

              /* sent -- waiting for a response */
              if (ld->ld_options & LDAP_BITOPT_ASYNC) {
                     lc->lconn_status = LDAP_CONNST_CONNECTED;
              }

              nsldapi_iostatus_interest_read( ld, lc->lconn_sb );
       }
       LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK );
       LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );

       LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL );
       return( msgid );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_send_unbind ( LDAP *  ld,
Sockbuf *  sb,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls 
)

Definition at line 190 of file unbind.c.

{
       BerElement    *ber;
       int           err, msgid;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_unbind\n", 0, 0, 0 );

       /* create a message to send */
       if (( err = nsldapi_alloc_ber_with_options( ld, &ber ))
           != LDAP_SUCCESS ) {
              return( err );
       }

       /* fill it in */
       LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK );
       msgid = ++ld->ld_msgid;
       LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK );

       if ( ber_printf( ber, "{itn", msgid, LDAP_REQ_UNBIND ) == -1 ) {
              ber_free( ber, 1 );
              err = LDAP_ENCODING_ERROR;
              LDAP_SET_LDERRNO( ld, err, NULL, NULL );
              return( err );
       }

       if (( err = nsldapi_put_controls( ld, serverctrls, 1, ber ))
           != LDAP_SUCCESS ) {
              ber_free( ber, 1 );
              return( err );
       }

       /* send the message */
       if ( nsldapi_ber_flush( ld, sb, ber, 1, 0 ) != 0 ) {
              ber_free( ber, 1 );
              err = LDAP_SERVER_DOWN;
              LDAP_SET_LDERRNO( ld, err, NULL, NULL );
              return( err );
       }

       return( LDAP_SUCCESS );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsldapi_set_ber_options ( LDAP *  ld,
BerElement *  ber 
)

Definition at line 89 of file request.c.

{
       ber->ber_options = ld->ld_lberoptions;
#ifdef STR_TRANSLATION
       if (( ld->ld_lberoptions & LBER_OPT_TRANSLATE_STRINGS ) != 0 ) {
              ber_set_string_translators( ber,
                  ld->ld_lber_encode_translate_proc,
                  ld->ld_lber_decode_translate_proc );
       }
#endif /* STR_TRANSLATION */
}

Here is the caller graph for this function:

char* nsldapi_strdup ( const char *  s)

Definition at line 841 of file open.c.

{
       char   *p;

       if ( s == NULL ||
           (p = (char *)NSLDAPI_MALLOC( strlen( s ) + 1 )) == NULL )
              return( NULL );

       strcpy( p, s );

       return( p );
}

Here is the caller graph for this function:

int nsldapi_url_parse ( const char *  inurl,
LDAPURLDesc **  ludpp,
int  dn_required 
)

Definition at line 178 of file url.c.

{

       LDAPURLDesc   *ludp;
       char          *urlcopy, *attrs, *scope, *extensions = NULL, *p, *q;
       int           enclosed, secure, i, nattrs, at_start;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_url_parse(%s)\n", url, 0, 0 );

       if ( url == NULL || ludpp == NULL ) {
              return( LDAP_URL_ERR_PARAM );
       }

       *ludpp = NULL;       /* pessimistic */

       if ( !skip_url_prefix( &url, &enclosed, &secure )) {
              return( LDAP_URL_ERR_NOTLDAP );
       }

       /* allocate return struct */
       if (( ludp = (LDAPURLDesc *)NSLDAPI_CALLOC( 1, sizeof( LDAPURLDesc )))
           == NULLLDAPURLDESC ) {
              return( LDAP_URL_ERR_MEM );
       }

       if ( secure ) {
              ludp->lud_options |= LDAP_URL_OPT_SECURE;
       }

       /* make working copy of the remainder of the URL */
       if (( urlcopy = nsldapi_strdup( url )) == NULL ) {
              ldap_free_urldesc( ludp );
              return( LDAP_URL_ERR_MEM );
       }

       if ( enclosed && *((p = urlcopy + strlen( urlcopy ) - 1)) == '>' ) {
              *p = '\0';
       }

       /* initialize scope and filter */
       ludp->lud_scope = -1;
       ludp->lud_filter = NULL;

       /* lud_string is the only malloc'd string space we use */
       ludp->lud_string = urlcopy;

       /* scan forward for '/' that marks end of hostport and begin. of dn */
       if (( ludp->lud_dn = strchr( urlcopy, '/' )) == NULL ) {
              if ( dn_required ) {
                     ldap_free_urldesc( ludp );
                     return( LDAP_URL_ERR_NODN );
              }
       } else {
              /* terminate hostport; point to start of dn */
              *ludp->lud_dn++ = '\0';
       }


       if ( *urlcopy == '\0' ) {
              ludp->lud_host = NULL;
       } else {
              ludp->lud_host = urlcopy;
              nsldapi_hex_unescape( ludp->lud_host );

              /*
               * Locate and strip off optional port number (:#) in host
               * portion of URL.
               *
               * If more than one space-separated host is listed, we only
               * look for a port number within the right-most one since
               * ldap_init() will handle host parameters that look like
               * host:port anyway.
               */
              if (( p = strrchr( ludp->lud_host, ' ' )) == NULL ) {
                     p = ludp->lud_host;
              } else {
                     ++p;
              }
              if ( *p == '[' && ( q = strchr( p, ']' )) != NULL ) {
                      /* square brackets present -- skip past them */
                     p = q++;
              }
              if (( p = strchr( p, ':' )) != NULL ) {
                     *p++ = '\0';
                     ludp->lud_port = atoi( p );
                     if ( *ludp->lud_host == '\0' ) {
                            ludp->lud_host = NULL;  /* no hostname */
                     }
              }
       }

       /* scan for '?' that marks end of dn and beginning of attributes */
       attrs = NULL;
       if ( ludp->lud_dn != NULL &&
           ( attrs = strchr( ludp->lud_dn, '?' )) != NULL ) {
              /* terminate dn; point to start of attrs. */
              *attrs++ = '\0';

              /* scan for '?' that marks end of attrs and begin. of scope */
              if (( p = strchr( attrs, '?' )) != NULL ) {
                     /*
                      * terminate attrs; point to start of scope and scan for
                      * '?' that marks end of scope and begin. of filter
                      */
                     *p++ = '\0';
                     scope = p;

                     if (( p = strchr( scope, '?' )) != NULL ) {
                            /* terminate scope; point to start of filter */
                            *p++ = '\0';
                            if ( *p != '\0' ) {
                                   ludp->lud_filter = p;
                                   /*
                                    * scan for the '?' that marks the end
                                    * of the filter and the start of any
                                    * extensions
                                    */
                                   if (( p = strchr( ludp->lud_filter, '?' ))
                                       != NULL ) {
                                          *p++ = '\0'; /* term. filter */
                                          extensions = p;
                                   }
                                   if ( *ludp->lud_filter == '\0' ) {
                                          ludp->lud_filter = NULL;
                                   } else {
                                          nsldapi_hex_unescape( ludp->lud_filter );
                                   }
                            }
                     }

                     if ( strcasecmp( scope, "one" ) == 0 ) {
                            ludp->lud_scope = LDAP_SCOPE_ONELEVEL;
                     } else if ( strcasecmp( scope, "base" ) == 0 ) {
                            ludp->lud_scope = LDAP_SCOPE_BASE;
                     } else if ( strcasecmp( scope, "sub" ) == 0 ) {
                            ludp->lud_scope = LDAP_SCOPE_SUBTREE;
                     } else if ( *scope != '\0' ) {
                            ldap_free_urldesc( ludp );
                            return( LDAP_URL_ERR_BADSCOPE );
                     }
              }
       }

       if ( ludp->lud_dn != NULL ) {
              nsldapi_hex_unescape( ludp->lud_dn );
       }

       /*
        * if attrs list was included, turn it into a null-terminated array
        */
       if ( attrs != NULL && *attrs != '\0' ) {
              nsldapi_hex_unescape( attrs );
              for ( nattrs = 1, p = attrs; *p != '\0'; ++p ) {
                  if ( *p == ',' ) {
                         ++nattrs;
                  }
              }

              if (( ludp->lud_attrs = (char **)NSLDAPI_CALLOC( nattrs + 1,
                  sizeof( char * ))) == NULL ) {
                     ldap_free_urldesc( ludp );
                     return( LDAP_URL_ERR_MEM );
              }

              for ( i = 0, p = attrs; i < nattrs; ++i ) {
                     ludp->lud_attrs[ i ] = p;
                     if (( p = strchr( p, ',' )) != NULL ) {
                            *p++ ='\0';
                     }
                     nsldapi_hex_unescape( ludp->lud_attrs[ i ] );
              }
       }

       /* if extensions list was included, check for critical ones */
       if ( extensions != NULL && *extensions != '\0' ) {
              /* Note: at present, we do not recognize ANY extensions */
              at_start = 1;
              for ( p = extensions; *p != '\0'; ++p ) {
                     if ( at_start ) {
                            if ( *p == '!' ) {   /* critical extension */
                                   ldap_free_urldesc( ludp );
                                   return( LDAP_URL_UNRECOGNIZED_CRITICAL_EXTENSION );
                            }
                            at_start = 0;
                     } else if ( *p == ',' ) {
                            at_start = 1;
                     }
              }
       }

       *ludpp = ludp;

       return( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_wait_result ( LDAP *  ld,
int  msgid,
int  all,
struct timeval timeout,
LDAPMessage **  result 
)

Variable Documentation

Definition at line 79 of file open.c.