2 * Copyright (c) 1995 Regents of the University of Michigan.
5 * ldap-int.h - defines & prototypes internal to the LDAP library
11 #include "../liblber/lber-int.h"
17 #define LDAP_URL_PREFIX "ldap://"
18 #define LDAP_URL_PREFIX_LEN 7
19 #define LDAP_URL_URLCOLON "URL:"
20 #define LDAP_URL_URLCOLON_LEN 4
23 #define LDAP_REF_STR "Referral:\n"
24 #define LDAP_REF_STR_LEN 10
25 #define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
26 #define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
28 #define LDAP_DX_REF_STR "dx://"
29 #define LDAP_DX_REF_STR_LEN 5
31 #endif /* LDAP_REFERRALS */
33 #define LDAP_BOOL_REFERRALS 0
34 #define LDAP_BOOL_RESTART 1
35 #define LDAP_BOOL_DNS 2
37 #define LDAP_BOOLEANS unsigned long
38 #define LDAP_BOOL(n) (1 << (n))
39 #define LDAP_BOOL_GET(lo, bool) ((lo)->ldo_booleans & LDAP_BOOL(bool) \
40 ? LDAP_OPT_ON : LDAP_OPT_OFF)
41 #define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool))
42 #define LDAP_BOOL_CLR(lo, bool) ((lo)->ldo_booleans &= ~LDAP_BOOL(bool))
43 #define LDAP_BOOL_ZERO(lo) ((lo)->ldo_booleans = 0)
46 * This structure represents both ldap messages and ldap responses.
47 * These are really the same, except in the case of search responses,
48 * where a response has multiple messages.
52 int lm_msgid; /* the message id */
53 int lm_msgtype; /* the message type */
54 BerElement *lm_ber; /* the ber encoded message contents */
55 struct ldapmsg *lm_chain; /* for search - next msg in the resp */
56 struct ldapmsg *lm_next; /* next response */
57 unsigned int lm_time; /* used to maintain cache */
61 * structure representing get/set'able options
62 * which have global defaults.
65 int ldo_version; /* version to connect at */
70 int ldo_cldaptries; /* connectionless search retry count */
71 int ldo_cldaptimeout;/* time between retries */
72 int ldo_refhoplimit; /* limit on referral nesting */
74 LDAP_BOOLEANS ldo_booleans; /* boolean options */
78 * structure representing an ldap connection
82 Sockbuf ld_sb; /* socket descriptor & buffer */
84 struct ldapoptions ld_options;
86 #define ld_deref ld_options.ldo_deref
87 #define ld_timelimit ld_options.ldo_timelimit
88 #define ld_sizelimit ld_options.ldo_sizelimit
90 #define ld_cldaptries ld_options.ldo_cldaptries
91 #define ld_cldaptimeout ld_options.ldo_cldaptimeout
92 #define ld_refhoplimit ld_options.ldo_refhoplimit
94 int ld_version; /* version connected at */
98 LDAPFiltDesc *ld_filtd; /* from getfilter for ufn searches */
99 char *ld_ufnprefix; /* for incomplete ufn's */
106 /* do not mess with these */
107 #ifdef LDAP_REFERRALS
108 LDAPRequest *ld_requests; /* list of outstanding requests */
109 #else /* LDAP_REFERRALS */
110 LDAPMessage *ld_requests; /* list of outstanding requests */
111 #endif /* LDAP_REFERRALS */
112 LDAPMessage *ld_responses; /* list of outstanding responses */
113 int *ld_abandoned; /* array of abandoned requests */
114 char ld_attrbuffer[LDAP_MAX_ATTR_LEN];
115 LDAPCache *ld_cache; /* non-null if cache is initialized */
116 char *ld_cldapdn; /* DN used in connectionless search */
118 /* do not mess with the rest though */
119 char *ld_defhost; /* full name of default server */
120 int ld_defport; /* port of default server */
121 BERTranslateProc ld_lber_encode_translate_proc;
122 BERTranslateProc ld_lber_decode_translate_proc;
124 #ifdef LDAP_REFERRALS
125 LDAPConn *ld_defconn; /* default connection */
126 LDAPConn *ld_conns; /* list of server connections */
127 void *ld_selectinfo; /* platform specifics for select */
128 int (*ld_rebindproc)( struct ldap *ld, char **dnp,
129 char **passwdp, int *authmethodp, int freeit );
130 /* routine to get info needed for re-bind */
131 #endif /* LDAP_REFERRALS */
138 extern int openldap_ldap_initialized;
139 extern struct ldapoptions openldap_ldap_global_options;
140 void openldap_ldap_initialize LDAP_P((void));
145 void ldap_add_request_to_cache LDAP_P(( LDAP *ld, unsigned long msgtype,
146 BerElement *request ));
147 void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
148 int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
155 char *ldap_get_kerberosv4_credentials LDAP_P(( LDAP *ld, char *who, char *service,
158 #endif /* HAVE_KERBEROS */
164 int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport,
165 char **krbinstancep, int async );
171 int ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port,
173 void ldap_close_connection( Sockbuf *sb );
176 char *ldap_host_connected_to( Sockbuf *sb );
177 #endif /* HAVE_KERBEROS */
179 #ifdef LDAP_REFERRALS
180 int do_ldap_select( LDAP *ld, struct timeval *timeout );
181 void *ldap_new_select_info( void );
182 void ldap_free_select_info( void *sip );
183 void ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
184 void ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
185 void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
186 int ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
187 int ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
188 #endif /* LDAP_REFERRALS */
194 int ldap_send_initial_request( LDAP *ld, unsigned long msgtype,
195 char *dn, BerElement *ber );
196 BerElement *ldap_alloc_ber_with_options( LDAP *ld );
197 void ldap_set_ber_options( LDAP *ld, BerElement *ber );
199 #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS )
200 int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid,
201 LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
203 LDAPConn *ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
204 int connect, int bind );
205 LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid );
206 void ldap_free_request( LDAP *ld, LDAPRequest *lr );
207 void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
208 void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
209 void ldap_dump_requests_and_responses( LDAP *ld );
210 #endif /* LDAP_REFERRALS || LDAP_DNS */
212 #ifdef LDAP_REFERRALS
213 int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
214 int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
215 #endif /* LDAP_REFERRALS */
221 BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope,
222 char *filter, char **attrs, int attrsonly );
228 int ldap_ld_free( LDAP *ld, int close );
229 int ldap_send_unbind( LDAP *ld, Sockbuf *sb );
235 char **ldap_getdxbyname( char *domain );
236 #endif /* LDAP_DNS */
238 #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
242 * added-in this stuff so that libldap.a would build, i.e. refs to
243 * these routines from open.c would resolve.
244 * hodges@stanford.edu 5-Feb-96
246 #if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
248 int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input );
250 int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
251 #endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
254 #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
256 #endif /* _LDAP_INT_H */