ldap-private.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef _LDAP_PRIVATE_H
#define _LDAP_PRIVATE_H
#include <signal.h>
#include <pthread.h> /* rri */
#define pthread_self _thr_self
#define pthread_kill _thr_kill
#ifdef _REENTRANT
#ifndef MAX_THREAD_ID
#define MAX_THREAD_ID 500
#endif /* MAX_THREAD_ID */
#else /* _REENTRANT */
#ifndef MAX_THREAD_ID
#define MAX_THREAD_ID 1
#endif /* MAX_THREAD_ID */
#endif /* _REENTRANT */
#define COMPAT20
#define COMPAT30
#define COMPAT
#endif
#ifdef LDAP_DNS
#endif /* LDAP_DNS */
/*
#define DBG_LOCK1(st) printf("%d> %s %d:%s\n", _thr_self(), st, __LINE__, __FILE__);
#define DBG_LOCK2(ld,st) printf("%d> %s ld_lockcount=%d %d:%s\n", _thr_self(), st, (ld)->ld_lockcount, __LINE__, __FILE__);
*/
#define LOCK_RESPONSE(ld) \
DBG_LOCK1("waiting for response lock") \
DBG_LOCK1("got response lock") \
} else { \
(ld)->ld_response_lockcount++; \
}
#define UNLOCK_RESPONSE(ld) \
if ((ld)->ld_response_lockcount==0) { \
(ld)->ld_response_lockthread = 0; \
DBG_LOCK1("freed response lock") \
} else { \
(ld)->ld_response_lockcount--; \
}
DBG_LOCK1("waiting for ldap lock") \
DBG_LOCK1("got ldap lock") \
} else { \
(ld)->ld_lockcount++; \
}
#define UNLOCK_LDAP(ld) \
if ((ld)->ld_lockcount==0) { \
(ld)->ld_lockthread = 0; \
DBG_LOCK1("freed ldap lock") \
} else { \
(ld)->ld_lockcount--; \
}
/*
* structure representing a Ber Element
*/
typedef struct berelement {
char *ber_buf;
char *ber_ptr;
char *ber_end;
unsigned int ber_tag;
unsigned int ber_len;
int ber_usertag;
char ber_options;
#define LBER_USE_DER 0x01
#define LBER_USE_INDEFINITE_LEN 0x02
#define LBER_TRANSLATE_STRINGS 0x04
char *ber_rwptr;
/*
* This structure represents both ldap messages and ldap responses.
* These are really the same, except in the case of search responses,
* where a response has multiple messages.
*/
typedef struct ldapmsg {
int lm_msgid; /* the message id */
int lm_msgtype; /* the message type */
unsigned long lm_time; /* used to maintain cache */
typedef struct ldap_filt_list {
char *lfl_tag;
char *lfl_pattern;
char *lfl_delims;
struct ldap_filt_list *lfl_next;
typedef struct ldap_filt_desc {
char lfd_filter[ LDAP_FILT_MAXSIZ ];
char *lfd_curval;
char *lfd_curvalcopy;
char **lfd_curvalwords;
char *lfd_filtprefix;
char *lfd_filtsuffix;
/*
* structure for tracking LDAP server host, ports, DNs, etc.
*/
typedef struct ldap_server {
char *lsrv_host;
char *lsrv_dn; /* if NULL, use default */
int lsrv_port;
struct ldap_server *lsrv_next;
} LDAPServer;
/*
* structure representing a Socket buffer
*/
typedef struct sockbuf {
#ifndef MACOS
int sb_sd;
#else /* MACOS */
void *sb_sd;
#endif /* MACOS */
int sb_naddr; /* > 0 implies using CLDAP (UDP) */
void *sb_useaddr; /* pointer to sockaddr to use next */
void *sb_fromaddr; /* pointer to message source sockaddr */
void **sb_addrs; /* actually an array of pointers to */
/* sockaddrs */
int sb_options; /* to support copying ber elements */
int sb_fd;
int sb_max_incoming;
#ifdef LDAP_SSL
int sb_ssl_tls;
#endif /* LDAP_SSL */
} Sockbuf;
#define READBUFSIZ 8192
/*
* structure for representing an LDAP server connection
*/
typedef struct ldap_conn {
int lconn_refcnt;
unsigned long lconn_lastused; /* time */
int lconn_status;
#define LDAP_CONNST_NEEDSOCKET 1
#define LDAP_CONNST_CONNECTING 2
#define LDAP_CONNST_CONNECTED 3
#define LDAP_CONNST_DEAD 4
char *lconn_krbinstance;
struct ldap_conn *lconn_next;
} LDAPConn;
/*
* Structure used to keep track of search references
*/
typedef struct ldap_reference {
char ** lref_refs;
struct ldap_reference *lref_next;
} LDAPRef;
/*
* structure used to track outstanding requests
*/
typedef struct ldapreq {
int lr_msgid; /* the message id */
int lr_status; /* status of request */
#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
int lr_outrefcnt; /* count of outstanding referrals */
int lr_origid; /* original request's message id */
int lr_parentcnt; /* count of parent requests */
int lr_res_msgtype; /* result message type */
int lr_res_errno; /* result LDAP errno */
char *lr_res_error; /* result error string */
char *lr_res_matched;/* result matched DN string */
char **lr_ref_followed; /* referral being followed */
char **lr_ref_unfollowed; /* Not being followed */
char **lr_ref_tofollow; /* referral to follow if the one being
followed fails. */
} LDAPRequest;
/*
* structure for client cache
*/
typedef struct ldapcache {
int lc_enabled; /* enabled? */
unsigned int lc_options; /* options */
#define LDAP_CACHE_OPT_CACHENOERRS 0x00000001
#define LDAP_CACHE_OPT_CACHEALLERRS 0x00000002
} LDAPCache;
/*
* structure representing an ldap connection
*/
typedef struct ldap {
char *ld_host;
int ld_version;
char ld_lberoptions;
int ld_deref;
int ld_timelimit;
int ld_sizelimit;
char *ld_ufnprefix; /* for incomplete ufn's */
int ld_msgid;
int ld_follow_referral; /* flag set to true if lib follow referrals */
int *ld_abandoned; /* array of abandoned requests */
int ld_response_lockcount; /* response lock depth */
char *ld_attrbuffer[MAX_THREAD_ID];
char *ld_cldapdn; /* DN used in connectionless search */
/* it is OK to change these next four values directly */
int ld_cldaptries; /* connectionless search retry count */
int ld_cldaptimeout;/* time between retries */
int ld_refhoplimit; /* limit on referral nesting */
/* LP TO CHANGE */
char ld_restart;
#ifdef LDAP_SSL
int ld_use_ssl;
char *ld_ssl_key;
#endif
unsigned int ld_options; /* boolean options */
/* do not mess with the rest though */
char *ld_defhost; /* full name of default server */
int ld_defport; /* port of default server */
void *ld_selectinfo; /* platform specifics for select */
void *ld_rebind_extra_arg;
/* int (*ld_rebindproc)( struct ldap *ld, char **dnp, */
/* char **passwdp, int *authmethodp, int freeit ); */
/* routine to get info needed for re-bind */
int ld_lockcount; /* lock depth */
/* KE: Lists of unsolicited notifications */
/* How long to wait for while connecting to a server */
int ld_connect_timeout;
} _struct_LDAP;
/*
* handy macro to check whether LDAP struct is set up for CLDAP or not
*/
#endif /* _LDAP_PRIVATE_H */