xref: /titanic_44/usr/src/lib/libldap5/sources/ldap/common/ldap-int.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*7c478bd9Sstevel@tonic-gate 
8*7c478bd9Sstevel@tonic-gate /*
9*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the Netscape Public
10*7c478bd9Sstevel@tonic-gate  * License Version 1.1 (the "License"); you may not use this file
11*7c478bd9Sstevel@tonic-gate  * except in compliance with the License. You may obtain a copy of
12*7c478bd9Sstevel@tonic-gate  * the License at http://www.mozilla.org/NPL/
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * Software distributed under the License is distributed on an "AS
15*7c478bd9Sstevel@tonic-gate  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16*7c478bd9Sstevel@tonic-gate  * implied. See the License for the specific language governing
17*7c478bd9Sstevel@tonic-gate  * rights and limitations under the License.
18*7c478bd9Sstevel@tonic-gate  *
19*7c478bd9Sstevel@tonic-gate  * The Original Code is Mozilla Communicator client code, released
20*7c478bd9Sstevel@tonic-gate  * March 31, 1998.
21*7c478bd9Sstevel@tonic-gate  *
22*7c478bd9Sstevel@tonic-gate  * The Initial Developer of the Original Code is Netscape
23*7c478bd9Sstevel@tonic-gate  * Communications Corporation. Portions created by Netscape are
24*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
25*7c478bd9Sstevel@tonic-gate  * Rights Reserved.
26*7c478bd9Sstevel@tonic-gate  *
27*7c478bd9Sstevel@tonic-gate  * Contributor(s):
28*7c478bd9Sstevel@tonic-gate  */
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifndef _LDAPINT_H
31*7c478bd9Sstevel@tonic-gate #define _LDAPINT_H
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #include <stdio.h>
34*7c478bd9Sstevel@tonic-gate #include <string.h>
35*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
36*7c478bd9Sstevel@tonic-gate #include <errno.h>
37*7c478bd9Sstevel@tonic-gate #include <time.h>
38*7c478bd9Sstevel@tonic-gate #include <fcntl.h>
39*7c478bd9Sstevel@tonic-gate #ifdef hpux
40*7c478bd9Sstevel@tonic-gate #include <strings.h>
41*7c478bd9Sstevel@tonic-gate #endif /* hpux */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #ifdef _WINDOWS
44*7c478bd9Sstevel@tonic-gate #  define FD_SETSIZE		256	/* number of connections we support */
45*7c478bd9Sstevel@tonic-gate #  define WIN32_LEAN_AND_MEAN
46*7c478bd9Sstevel@tonic-gate # include <windows.h>
47*7c478bd9Sstevel@tonic-gate #elif defined(macintosh)
48*7c478bd9Sstevel@tonic-gate #include "ldap-macos.h"
49*7c478bd9Sstevel@tonic-gate #elif defined(XP_OS2)
50*7c478bd9Sstevel@tonic-gate #include <os2sock.h>
51*7c478bd9Sstevel@tonic-gate #else /* _WINDOWS */
52*7c478bd9Sstevel@tonic-gate # include <sys/time.h>
53*7c478bd9Sstevel@tonic-gate # include <sys/types.h>
54*7c478bd9Sstevel@tonic-gate # include <sys/socket.h>
55*7c478bd9Sstevel@tonic-gate # include <netinet/in.h>
56*7c478bd9Sstevel@tonic-gate # include <arpa/inet.h>
57*7c478bd9Sstevel@tonic-gate # include <netdb.h>
58*7c478bd9Sstevel@tonic-gate #if !defined(hpux) && !defined(SUNOS4) && !defined(LINUX)
59*7c478bd9Sstevel@tonic-gate # include <sys/select.h>
60*7c478bd9Sstevel@tonic-gate #endif /* !defined(hpux) and others */
61*7c478bd9Sstevel@tonic-gate #endif /* _WINDOWS */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate #if defined(IRIX)
64*7c478bd9Sstevel@tonic-gate #include <bstring.h>
65*7c478bd9Sstevel@tonic-gate #endif /* IRIX */
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate #define NSLBERI_LBER_INT_FRIEND
68*7c478bd9Sstevel@tonic-gate #ifdef macintosh
69*7c478bd9Sstevel@tonic-gate #include "lber-int.h"
70*7c478bd9Sstevel@tonic-gate #elif defined(_SOLARIS_SDK)
71*7c478bd9Sstevel@tonic-gate #include "../ber/lber-int.h"
72*7c478bd9Sstevel@tonic-gate #else /* _SOLARIS_SDK */
73*7c478bd9Sstevel@tonic-gate #include "../liblber/lber-int.h"
74*7c478bd9Sstevel@tonic-gate #endif /* macintosh */
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #include "ldap.h"
77*7c478bd9Sstevel@tonic-gate #include "ldaprot.h"
78*7c478bd9Sstevel@tonic-gate #include "ldaplog.h"
79*7c478bd9Sstevel@tonic-gate #include "portable.h"
80*7c478bd9Sstevel@tonic-gate #include "regex.h"
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #ifdef LDAP_ASYNC_IO
83*7c478bd9Sstevel@tonic-gate #ifdef NEED_FILIO
84*7c478bd9Sstevel@tonic-gate #include <sys/filio.h>		/* to get FIONBIO for ioctl() call */
85*7c478bd9Sstevel@tonic-gate #else /* NEED_FILIO */
86*7c478bd9Sstevel@tonic-gate #if !defined( _WINDOWS) && !defined (macintosh)
87*7c478bd9Sstevel@tonic-gate #include <sys/ioctl.h>		/* to get FIONBIO for ioctl() call */
88*7c478bd9Sstevel@tonic-gate #endif /* _WINDOWS && macintosh */
89*7c478bd9Sstevel@tonic-gate #endif /* NEED_FILIO */
90*7c478bd9Sstevel@tonic-gate #endif /* LDAP_ASYNC_IO */
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate #ifdef USE_SYSCONF
93*7c478bd9Sstevel@tonic-gate #  include <unistd.h>
94*7c478bd9Sstevel@tonic-gate #endif /* USE_SYSCONF */
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate #ifdef _SOLARIS_SDK
97*7c478bd9Sstevel@tonic-gate #include <libintl.h>
98*7c478bd9Sstevel@tonic-gate #endif
99*7c478bd9Sstevel@tonic-gate #ifdef LDAP_SASLIO_HOOKS
100*7c478bd9Sstevel@tonic-gate #include <sasl/sasl.h>
101*7c478bd9Sstevel@tonic-gate #define SASL_MAX_BUFF_SIZE	65536
102*7c478bd9Sstevel@tonic-gate #define SASL_MIN_BUFF_SIZE	4096
103*7c478bd9Sstevel@tonic-gate #endif
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate #if !defined(_WINDOWS) && !defined(macintosh) && !defined(LINUX) && !defined(BSDI)
106*7c478bd9Sstevel@tonic-gate #define NSLDAPI_HAVE_POLL	1
107*7c478bd9Sstevel@tonic-gate #endif
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /* SSL version, or 0 if not built with SSL */
110*7c478bd9Sstevel@tonic-gate #if defined(NET_SSL)
111*7c478bd9Sstevel@tonic-gate #  define SSL_VERSION 3
112*7c478bd9Sstevel@tonic-gate #else
113*7c478bd9Sstevel@tonic-gate #  define SSL_VERSION 0
114*7c478bd9Sstevel@tonic-gate #endif
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate #define LDAP_URL_URLCOLON	"URL:"
118*7c478bd9Sstevel@tonic-gate #define LDAP_URL_URLCOLON_LEN	4
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #define LDAP_LDAP_REF_STR	LDAP_URL_PREFIX
121*7c478bd9Sstevel@tonic-gate #define LDAP_LDAP_REF_STR_LEN	LDAP_URL_PREFIX_LEN
122*7c478bd9Sstevel@tonic-gate #define LDAP_LDAPS_REF_STR	LDAPS_URL_PREFIX
123*7c478bd9Sstevel@tonic-gate #define LDAP_LDAPS_REF_STR_LEN	LDAPS_URL_PREFIX_LEN
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /* default limit on nesting of referrals */
126*7c478bd9Sstevel@tonic-gate #define LDAP_DEFAULT_REFHOPLIMIT	5
127*7c478bd9Sstevel@tonic-gate #ifdef LDAP_DNS
128*7c478bd9Sstevel@tonic-gate #define LDAP_DX_REF_STR		"dx://"
129*7c478bd9Sstevel@tonic-gate #define LDAP_DX_REF_STR_LEN	5
130*7c478bd9Sstevel@tonic-gate #endif /* LDAP_DNS */
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate typedef enum {
133*7c478bd9Sstevel@tonic-gate     LDAP_CACHE_LOCK,
134*7c478bd9Sstevel@tonic-gate     LDAP_MEMCACHE_LOCK,
135*7c478bd9Sstevel@tonic-gate     LDAP_MSGID_LOCK,
136*7c478bd9Sstevel@tonic-gate     LDAP_REQ_LOCK,
137*7c478bd9Sstevel@tonic-gate     LDAP_RESP_LOCK,
138*7c478bd9Sstevel@tonic-gate     LDAP_ABANDON_LOCK,
139*7c478bd9Sstevel@tonic-gate     LDAP_CTRL_LOCK,
140*7c478bd9Sstevel@tonic-gate     LDAP_OPTION_LOCK,
141*7c478bd9Sstevel@tonic-gate     LDAP_ERR_LOCK,
142*7c478bd9Sstevel@tonic-gate     LDAP_CONN_LOCK,
143*7c478bd9Sstevel@tonic-gate     LDAP_IOSTATUS_LOCK,		/* serializes access to ld->ld_iostatus */
144*7c478bd9Sstevel@tonic-gate     LDAP_RESULT_LOCK,
145*7c478bd9Sstevel@tonic-gate     LDAP_PEND_LOCK,
146*7c478bd9Sstevel@tonic-gate     LDAP_THREADID_LOCK,
147*7c478bd9Sstevel@tonic-gate #ifdef LDAP_SASLIO_HOOKS
148*7c478bd9Sstevel@tonic-gate     LDAP_SASL_LOCK,
149*7c478bd9Sstevel@tonic-gate #endif
150*7c478bd9Sstevel@tonic-gate     LDAP_MAX_LOCK
151*7c478bd9Sstevel@tonic-gate } LDAPLock;
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate /*
154*7c478bd9Sstevel@tonic-gate  * This structure represents both ldap messages and ldap responses.
155*7c478bd9Sstevel@tonic-gate  * These are really the same, except in the case of search responses,
156*7c478bd9Sstevel@tonic-gate  * where a response has multiple messages.
157*7c478bd9Sstevel@tonic-gate  */
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate struct ldapmsg {
160*7c478bd9Sstevel@tonic-gate 	int		lm_msgid;	/* the message id */
161*7c478bd9Sstevel@tonic-gate 	int		lm_msgtype;	/* the message type */
162*7c478bd9Sstevel@tonic-gate 	BerElement	*lm_ber;	/* the ber encoded message contents */
163*7c478bd9Sstevel@tonic-gate 	struct ldapmsg	*lm_chain;	/* for search - next msg in the resp */
164*7c478bd9Sstevel@tonic-gate 	struct ldapmsg	*lm_next;	/* next response */
165*7c478bd9Sstevel@tonic-gate 	int		lm_fromcache;	/* memcache: origin of message */
166*7c478bd9Sstevel@tonic-gate };
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate /*
169*7c478bd9Sstevel@tonic-gate  * structure for tracking LDAP server host, ports, DNs, etc.
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate typedef struct ldap_server {
172*7c478bd9Sstevel@tonic-gate 	char			*lsrv_host;
173*7c478bd9Sstevel@tonic-gate 	char			*lsrv_dn;	/* if NULL, use default */
174*7c478bd9Sstevel@tonic-gate 	int			lsrv_port;
175*7c478bd9Sstevel@tonic-gate 	unsigned long		lsrv_options;	/* boolean options */
176*7c478bd9Sstevel@tonic-gate #define LDAP_SRV_OPT_SECURE	0x01
177*7c478bd9Sstevel@tonic-gate 	struct ldap_server	*lsrv_next;
178*7c478bd9Sstevel@tonic-gate } LDAPServer;
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate /*
181*7c478bd9Sstevel@tonic-gate  * structure for representing an LDAP server connection
182*7c478bd9Sstevel@tonic-gate  */
183*7c478bd9Sstevel@tonic-gate typedef struct ldap_conn {
184*7c478bd9Sstevel@tonic-gate 	Sockbuf			*lconn_sb;
185*7c478bd9Sstevel@tonic-gate 	BerElement		*lconn_ber;  /* non-NULL if in midst of msg. */
186*7c478bd9Sstevel@tonic-gate 	int			lconn_version;	/* LDAP protocol version */
187*7c478bd9Sstevel@tonic-gate 	int			lconn_refcnt;
188*7c478bd9Sstevel@tonic-gate 	unsigned long		lconn_lastused;	/* time */
189*7c478bd9Sstevel@tonic-gate 	int			lconn_status;
190*7c478bd9Sstevel@tonic-gate #define LDAP_CONNST_NEEDSOCKET		1
191*7c478bd9Sstevel@tonic-gate #define LDAP_CONNST_CONNECTING		2
192*7c478bd9Sstevel@tonic-gate #define LDAP_CONNST_CONNECTED		3
193*7c478bd9Sstevel@tonic-gate #define LDAP_CONNST_DEAD		4
194*7c478bd9Sstevel@tonic-gate 	LDAPServer		*lconn_server;
195*7c478bd9Sstevel@tonic-gate 	char			*lconn_binddn;	/* DN of last successful bind */
196*7c478bd9Sstevel@tonic-gate 	int			lconn_bound;	/* has a bind been done? */
197*7c478bd9Sstevel@tonic-gate 	char			*lconn_krbinstance;
198*7c478bd9Sstevel@tonic-gate 	struct ldap_conn	*lconn_next;
199*7c478bd9Sstevel@tonic-gate } LDAPConn;
200*7c478bd9Sstevel@tonic-gate 
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate /*
203*7c478bd9Sstevel@tonic-gate  * structure used to track outstanding requests
204*7c478bd9Sstevel@tonic-gate  */
205*7c478bd9Sstevel@tonic-gate typedef struct ldapreq {
206*7c478bd9Sstevel@tonic-gate 	int		lr_msgid;	/* the message id */
207*7c478bd9Sstevel@tonic-gate 	int		lr_status;	/* status of request */
208*7c478bd9Sstevel@tonic-gate #define LDAP_REQST_INPROGRESS	1
209*7c478bd9Sstevel@tonic-gate #define LDAP_REQST_CHASINGREFS	2
210*7c478bd9Sstevel@tonic-gate #define LDAP_REQST_NOTCONNECTED	3
211*7c478bd9Sstevel@tonic-gate #define LDAP_REQST_WRITING	4
212*7c478bd9Sstevel@tonic-gate #define LDAP_REQST_CONNDEAD	5	/* associated conn. has failed */
213*7c478bd9Sstevel@tonic-gate 	int		lr_outrefcnt;	/* count of outstanding referrals */
214*7c478bd9Sstevel@tonic-gate 	int		lr_origid;	/* original request's message id */
215*7c478bd9Sstevel@tonic-gate 	int		lr_parentcnt;	/* count of parent requests */
216*7c478bd9Sstevel@tonic-gate 	int		lr_res_msgtype;	/* result message type */
217*7c478bd9Sstevel@tonic-gate 	int		lr_res_errno;	/* result LDAP errno */
218*7c478bd9Sstevel@tonic-gate 	char		*lr_res_error;	/* result error string */
219*7c478bd9Sstevel@tonic-gate 	char		*lr_res_matched;/* result matched DN string */
220*7c478bd9Sstevel@tonic-gate 	BerElement	*lr_ber;	/* ber encoded request contents */
221*7c478bd9Sstevel@tonic-gate 	LDAPConn	*lr_conn;	/* connection used to send request */
222*7c478bd9Sstevel@tonic-gate 	char		*lr_binddn;	/* request is a bind for this DN */
223*7c478bd9Sstevel@tonic-gate 	struct ldapreq	*lr_parent;	/* request that spawned this referral */
224*7c478bd9Sstevel@tonic-gate 	struct ldapreq	*lr_child;	/* list of requests we spawned */
225*7c478bd9Sstevel@tonic-gate 	struct ldapreq	*lr_sibling;	/* next referral spawned */
226*7c478bd9Sstevel@tonic-gate 	struct ldapreq	*lr_prev;	/* ld->ld_requests previous request */
227*7c478bd9Sstevel@tonic-gate 	struct ldapreq	*lr_next;	/* ld->ld_requests next request */
228*7c478bd9Sstevel@tonic-gate } LDAPRequest;
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate typedef struct ldappend {
231*7c478bd9Sstevel@tonic-gate 	void		*lp_sema;	/* semaphore to post */
232*7c478bd9Sstevel@tonic-gate 	int		lp_msgid;	/* message id */
233*7c478bd9Sstevel@tonic-gate 	LDAPMessage	*lp_result;	/* result storage */
234*7c478bd9Sstevel@tonic-gate 	struct ldappend	*lp_prev;	/* previous pending */
235*7c478bd9Sstevel@tonic-gate 	struct ldappend	*lp_next;	/* next pending */
236*7c478bd9Sstevel@tonic-gate } LDAPPend;
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate /*
239*7c478bd9Sstevel@tonic-gate  * forward declaration for I/O status structure (defined in os-ip.c)
240*7c478bd9Sstevel@tonic-gate  */
241*7c478bd9Sstevel@tonic-gate typedef struct nsldapi_iostatus_info NSLDAPIIOStatus;
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate /*
244*7c478bd9Sstevel@tonic-gate  * old extended IO structure (before writev callback was added)
245*7c478bd9Sstevel@tonic-gate  */
246*7c478bd9Sstevel@tonic-gate struct ldap_x_ext_io_fns_rev0 {
247*7c478bd9Sstevel@tonic-gate         int                                     lextiof_size;
248*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_CONNECT_CALLBACK          *lextiof_connect;
249*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_CLOSE_CALLBACK            *lextiof_close;
250*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_READ_CALLBACK             *lextiof_read;
251*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_WRITE_CALLBACK            *lextiof_write;
252*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_POLL_CALLBACK             *lextiof_poll;
253*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_NEWHANDLE_CALLBACK        *lextiof_newhandle;
254*7c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK    *lextiof_disposehandle;
255*7c478bd9Sstevel@tonic-gate         void                                    *lextiof_session_arg;
256*7c478bd9Sstevel@tonic-gate };
257*7c478bd9Sstevel@tonic-gate #define LDAP_X_EXTIO_FNS_SIZE_REV0   sizeof(struct ldap_x_ext_io_fns_rev0)
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate /*
260*7c478bd9Sstevel@tonic-gate  * structure representing an ldap connection
261*7c478bd9Sstevel@tonic-gate  */
262*7c478bd9Sstevel@tonic-gate struct ldap {
263*7c478bd9Sstevel@tonic-gate 	struct sockbuf	*ld_sbp;	/* pointer to socket desc. & buffer */
264*7c478bd9Sstevel@tonic-gate 	char		*ld_host;
265*7c478bd9Sstevel@tonic-gate 	int		ld_version;	/* LDAP protocol version */
266*7c478bd9Sstevel@tonic-gate 	char		ld_lberoptions;
267*7c478bd9Sstevel@tonic-gate 	int		ld_deref;
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate 	int		ld_timelimit;
270*7c478bd9Sstevel@tonic-gate 	int		ld_sizelimit;
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate 	struct ldap_filt_desc	*ld_filtd;	/* from getfilter for ufn searches */
273*7c478bd9Sstevel@tonic-gate 	char		*ld_ufnprefix;	/* for incomplete ufn's */
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate 	int		ld_errno;
276*7c478bd9Sstevel@tonic-gate 	char		*ld_error;
277*7c478bd9Sstevel@tonic-gate 	char		*ld_matched;
278*7c478bd9Sstevel@tonic-gate 	int		ld_msgid;
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate 	/* do not mess with these */
281*7c478bd9Sstevel@tonic-gate 	LDAPRequest	*ld_requests;	/* list of outstanding requests */
282*7c478bd9Sstevel@tonic-gate 	LDAPMessage	*ld_responses;	/* list of outstanding responses */
283*7c478bd9Sstevel@tonic-gate 	int		*ld_abandoned;	/* array of abandoned requests */
284*7c478bd9Sstevel@tonic-gate 	char		*ld_cldapdn;	/* DN used in connectionless search */
285*7c478bd9Sstevel@tonic-gate 
286*7c478bd9Sstevel@tonic-gate 	/* it is OK to change these next four values directly */
287*7c478bd9Sstevel@tonic-gate 	int		ld_cldaptries;	/* connectionless search retry count */
288*7c478bd9Sstevel@tonic-gate 	int		ld_cldaptimeout;/* time between retries */
289*7c478bd9Sstevel@tonic-gate 	int		ld_refhoplimit;	/* limit on referral nesting */
290*7c478bd9Sstevel@tonic-gate 	unsigned long	ld_options;	/* boolean options */
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate #define LDAP_BITOPT_REFERRALS	0x80000000
293*7c478bd9Sstevel@tonic-gate #define LDAP_BITOPT_SSL		0x40000000
294*7c478bd9Sstevel@tonic-gate #define LDAP_BITOPT_DNS		0x20000000
295*7c478bd9Sstevel@tonic-gate #define LDAP_BITOPT_RESTART	0x10000000
296*7c478bd9Sstevel@tonic-gate #define LDAP_BITOPT_RECONNECT	0x08000000
297*7c478bd9Sstevel@tonic-gate #define LDAP_BITOPT_ASYNC       0x04000000
298*7c478bd9Sstevel@tonic-gate 
299*7c478bd9Sstevel@tonic-gate 	/* do not mess with the rest though */
300*7c478bd9Sstevel@tonic-gate 	char		*ld_defhost;	/* full name of default server */
301*7c478bd9Sstevel@tonic-gate 	int		ld_defport;	/* port of default server */
302*7c478bd9Sstevel@tonic-gate 	BERTranslateProc ld_lber_encode_translate_proc;
303*7c478bd9Sstevel@tonic-gate 	BERTranslateProc ld_lber_decode_translate_proc;
304*7c478bd9Sstevel@tonic-gate 	LDAPConn	*ld_defconn;	/* default connection */
305*7c478bd9Sstevel@tonic-gate 	LDAPConn	*ld_conns;	/* list of all server connections */
306*7c478bd9Sstevel@tonic-gate 	NSLDAPIIOStatus	*ld_iostatus;	/* status info. about network sockets */
307*7c478bd9Sstevel@tonic-gate 	LDAP_REBINDPROC_CALLBACK *ld_rebind_fn;
308*7c478bd9Sstevel@tonic-gate 	void		*ld_rebind_arg;
309*7c478bd9Sstevel@tonic-gate 
310*7c478bd9Sstevel@tonic-gate 	/* function pointers, etc. for extended I/O */
311*7c478bd9Sstevel@tonic-gate 	struct ldap_x_ext_io_fns ld_ext_io_fns;
312*7c478bd9Sstevel@tonic-gate #define ld_extio_size		ld_ext_io_fns.lextiof_size
313*7c478bd9Sstevel@tonic-gate #define ld_extclose_fn		ld_ext_io_fns.lextiof_close
314*7c478bd9Sstevel@tonic-gate #define ld_extconnect_fn	ld_ext_io_fns.lextiof_connect
315*7c478bd9Sstevel@tonic-gate #define ld_extread_fn		ld_ext_io_fns.lextiof_read
316*7c478bd9Sstevel@tonic-gate #define ld_extwrite_fn		ld_ext_io_fns.lextiof_write
317*7c478bd9Sstevel@tonic-gate #define ld_extwritev_fn		ld_ext_io_fns.lextiof_writev
318*7c478bd9Sstevel@tonic-gate #define ld_extpoll_fn		ld_ext_io_fns.lextiof_poll
319*7c478bd9Sstevel@tonic-gate #define ld_extnewhandle_fn	ld_ext_io_fns.lextiof_newhandle
320*7c478bd9Sstevel@tonic-gate #define ld_extdisposehandle_fn	ld_ext_io_fns.lextiof_disposehandle
321*7c478bd9Sstevel@tonic-gate #define ld_ext_session_arg	ld_ext_io_fns.lextiof_session_arg
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate 	/* allocated pointer for older I/O functions */
324*7c478bd9Sstevel@tonic-gate 	struct ldap_io_fns	*ld_io_fns_ptr;
325*7c478bd9Sstevel@tonic-gate #define NSLDAPI_USING_CLASSIC_IO_FUNCTIONS( ld ) ((ld)->ld_io_fns_ptr != NULL)
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate 	/* function pointers, etc. for DNS */
328*7c478bd9Sstevel@tonic-gate 	struct ldap_dns_fns	ld_dnsfn;
329*7c478bd9Sstevel@tonic-gate #define ld_dns_extradata	ld_dnsfn.lddnsfn_extradata
330*7c478bd9Sstevel@tonic-gate #define ld_dns_bufsize		ld_dnsfn.lddnsfn_bufsize
331*7c478bd9Sstevel@tonic-gate #define ld_dns_gethostbyname_fn	ld_dnsfn.lddnsfn_gethostbyname
332*7c478bd9Sstevel@tonic-gate #define ld_dns_gethostbyaddr_fn	ld_dnsfn.lddnsfn_gethostbyaddr
333*7c478bd9Sstevel@tonic-gate #define ld_dns_getpeername_fn	ld_dnsfn.lddnsfn_getpeername
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate 	/* function pointers, etc. for threading */
336*7c478bd9Sstevel@tonic-gate 	struct ldap_thread_fns	ld_thread;
337*7c478bd9Sstevel@tonic-gate #define ld_mutex_alloc_fn	ld_thread.ltf_mutex_alloc
338*7c478bd9Sstevel@tonic-gate #define ld_mutex_free_fn	ld_thread.ltf_mutex_free
339*7c478bd9Sstevel@tonic-gate #define ld_mutex_lock_fn	ld_thread.ltf_mutex_lock
340*7c478bd9Sstevel@tonic-gate #define ld_mutex_unlock_fn	ld_thread.ltf_mutex_unlock
341*7c478bd9Sstevel@tonic-gate #define ld_get_errno_fn		ld_thread.ltf_get_errno
342*7c478bd9Sstevel@tonic-gate #define ld_set_errno_fn		ld_thread.ltf_set_errno
343*7c478bd9Sstevel@tonic-gate #define ld_get_lderrno_fn	ld_thread.ltf_get_lderrno
344*7c478bd9Sstevel@tonic-gate #define ld_set_lderrno_fn	ld_thread.ltf_set_lderrno
345*7c478bd9Sstevel@tonic-gate #define ld_lderrno_arg		ld_thread.ltf_lderrno_arg
346*7c478bd9Sstevel@tonic-gate 	void			**ld_mutex;
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate 	/* function pointers, etc. for caching */
349*7c478bd9Sstevel@tonic-gate 	int			ld_cache_on;
350*7c478bd9Sstevel@tonic-gate 	int			ld_cache_strategy;
351*7c478bd9Sstevel@tonic-gate 	struct ldap_cache_fns	ld_cache;
352*7c478bd9Sstevel@tonic-gate #define ld_cache_config		ld_cache.lcf_config
353*7c478bd9Sstevel@tonic-gate #define ld_cache_bind		ld_cache.lcf_bind
354*7c478bd9Sstevel@tonic-gate #define ld_cache_unbind		ld_cache.lcf_unbind
355*7c478bd9Sstevel@tonic-gate #define ld_cache_search		ld_cache.lcf_search
356*7c478bd9Sstevel@tonic-gate #define ld_cache_compare	ld_cache.lcf_compare
357*7c478bd9Sstevel@tonic-gate #define ld_cache_add		ld_cache.lcf_add
358*7c478bd9Sstevel@tonic-gate #define ld_cache_delete		ld_cache.lcf_delete
359*7c478bd9Sstevel@tonic-gate #if 0
360*7c478bd9Sstevel@tonic-gate #define ld_cache_rename		ld_cache.lcf_rename
361*7c478bd9Sstevel@tonic-gate #endif
362*7c478bd9Sstevel@tonic-gate #define ld_cache_modify		ld_cache.lcf_modify
363*7c478bd9Sstevel@tonic-gate #define ld_cache_modrdn		ld_cache.lcf_modrdn
364*7c478bd9Sstevel@tonic-gate #define ld_cache_abandon	ld_cache.lcf_abandon
365*7c478bd9Sstevel@tonic-gate #define ld_cache_result		ld_cache.lcf_result
366*7c478bd9Sstevel@tonic-gate #define ld_cache_flush		ld_cache.lcf_flush
367*7c478bd9Sstevel@tonic-gate #define ld_cache_arg		ld_cache.lcf_arg
368*7c478bd9Sstevel@tonic-gate 
369*7c478bd9Sstevel@tonic-gate 	/* ldapv3 controls */
370*7c478bd9Sstevel@tonic-gate 	LDAPControl		**ld_servercontrols;
371*7c478bd9Sstevel@tonic-gate 	LDAPControl		**ld_clientcontrols;
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate 	/* Preferred language */
374*7c478bd9Sstevel@tonic-gate 	char            *ld_preferred_language;
375*7c478bd9Sstevel@tonic-gate 
376*7c478bd9Sstevel@tonic-gate 	/* MemCache */
377*7c478bd9Sstevel@tonic-gate 	LDAPMemCache	*ld_memcache;
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate 	/* Pending results */
380*7c478bd9Sstevel@tonic-gate 	LDAPPend	*ld_pend;	/* list of pending results */
381*7c478bd9Sstevel@tonic-gate 
382*7c478bd9Sstevel@tonic-gate 	/* extra thread function pointers */
383*7c478bd9Sstevel@tonic-gate 	struct ldap_extra_thread_fns	ld_thread2;
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate 	/* With the 4.0 version of the LDAP SDK */
386*7c478bd9Sstevel@tonic-gate 	/* the extra thread functions except for */
387*7c478bd9Sstevel@tonic-gate 	/* the ld_threadid_fn has been disabled */
388*7c478bd9Sstevel@tonic-gate 	/* Look at the release notes for the full */
389*7c478bd9Sstevel@tonic-gate 	/* explanation */
390*7c478bd9Sstevel@tonic-gate #define ld_mutex_trylock_fn		ld_thread2.ltf_mutex_trylock
391*7c478bd9Sstevel@tonic-gate #define ld_sema_alloc_fn		ld_thread2.ltf_sema_alloc
392*7c478bd9Sstevel@tonic-gate #define ld_sema_free_fn			ld_thread2.ltf_sema_free
393*7c478bd9Sstevel@tonic-gate #define ld_sema_wait_fn			ld_thread2.ltf_sema_wait
394*7c478bd9Sstevel@tonic-gate #define ld_sema_post_fn			ld_thread2.ltf_sema_post
395*7c478bd9Sstevel@tonic-gate #define ld_threadid_fn			ld_thread2.ltf_threadid_fn
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate 	/* extra data for mutex handling in referrals */
398*7c478bd9Sstevel@tonic-gate 	void 			*ld_mutex_threadid[LDAP_MAX_LOCK];
399*7c478bd9Sstevel@tonic-gate 	unsigned long		ld_mutex_refcnt[LDAP_MAX_LOCK];
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate 	/* connect timeout value (milliseconds) */
402*7c478bd9Sstevel@tonic-gate 	int				ld_connect_timeout;
403*7c478bd9Sstevel@tonic-gate 
404*7c478bd9Sstevel@tonic-gate #ifdef LDAP_SASLIO_HOOKS
405*7c478bd9Sstevel@tonic-gate 	/* SASL default option settings */
406*7c478bd9Sstevel@tonic-gate 	char			*ld_def_sasl_mech;
407*7c478bd9Sstevel@tonic-gate 	char			*ld_def_sasl_realm;
408*7c478bd9Sstevel@tonic-gate 	char			*ld_def_sasl_authcid;
409*7c478bd9Sstevel@tonic-gate 	char			*ld_def_sasl_authzid;
410*7c478bd9Sstevel@tonic-gate 	/* SASL Security properties */
411*7c478bd9Sstevel@tonic-gate 	struct sasl_security_properties ld_sasl_secprops;
412*7c478bd9Sstevel@tonic-gate 	/* prldap shadow io functions */
413*7c478bd9Sstevel@tonic-gate 	struct ldap_x_ext_io_fns ld_sasl_io_fns;
414*7c478bd9Sstevel@tonic-gate #endif
415*7c478bd9Sstevel@tonic-gate };
416*7c478bd9Sstevel@tonic-gate 
417*7c478bd9Sstevel@tonic-gate /* allocate/free mutex */
418*7c478bd9Sstevel@tonic-gate #define LDAP_MUTEX_ALLOC( ld ) \
419*7c478bd9Sstevel@tonic-gate 	(((ld)->ld_mutex_alloc_fn != NULL) ? (ld)->ld_mutex_alloc_fn() : NULL)
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate /* allocate/free mutex */
422*7c478bd9Sstevel@tonic-gate #define LDAP_MUTEX_FREE( ld, m ) \
423*7c478bd9Sstevel@tonic-gate 	if ( (ld)->ld_mutex_free_fn != NULL && m != NULL ) { \
424*7c478bd9Sstevel@tonic-gate 		(ld)->ld_mutex_free_fn( m ); \
425*7c478bd9Sstevel@tonic-gate 	}
426*7c478bd9Sstevel@tonic-gate 
427*7c478bd9Sstevel@tonic-gate /* enter/exit critical sections */
428*7c478bd9Sstevel@tonic-gate /*
429*7c478bd9Sstevel@tonic-gate  * The locks assume that the locks are thread safe.  XXXmcs: which means???
430*7c478bd9Sstevel@tonic-gate  *
431*7c478bd9Sstevel@tonic-gate  * Note that we test for both ld_mutex_lock_fn != NULL AND ld_mutex != NULL.
432*7c478bd9Sstevel@tonic-gate  * This is necessary because there is a window in ldap_init() between the
433*7c478bd9Sstevel@tonic-gate  * time we set the ld_mutex_lock_fn pointer and the time we allocate the
434*7c478bd9Sstevel@tonic-gate  * mutexes in which external code COULD be called which COULD make a call to
435*7c478bd9Sstevel@tonic-gate  * something like ldap_get_option(), which uses LDAP_MUTEX_LOCK().  The
436*7c478bd9Sstevel@tonic-gate  * libprldap code does this in its newhandle callback (prldap_newhandle).
437*7c478bd9Sstevel@tonic-gate  */
438*7c478bd9Sstevel@tonic-gate 
439*7c478bd9Sstevel@tonic-gate #define LDAP_MUTEX_LOCK(ld, lock) \
440*7c478bd9Sstevel@tonic-gate     if ((ld)->ld_mutex_lock_fn != NULL && ld->ld_mutex != NULL) { \
441*7c478bd9Sstevel@tonic-gate         if ((ld)->ld_threadid_fn != NULL) { \
442*7c478bd9Sstevel@tonic-gate             if ((ld)->ld_mutex_threadid[lock] == (ld)->ld_threadid_fn()) { \
443*7c478bd9Sstevel@tonic-gate                 (ld)->ld_mutex_refcnt[lock]++; \
444*7c478bd9Sstevel@tonic-gate             } else { \
445*7c478bd9Sstevel@tonic-gate                 (ld)->ld_mutex_lock_fn(ld->ld_mutex[lock]); \
446*7c478bd9Sstevel@tonic-gate                 (ld)->ld_mutex_threadid[lock] = ld->ld_threadid_fn(); \
447*7c478bd9Sstevel@tonic-gate                 (ld)->ld_mutex_refcnt[lock] = 1; \
448*7c478bd9Sstevel@tonic-gate             } \
449*7c478bd9Sstevel@tonic-gate         } else { \
450*7c478bd9Sstevel@tonic-gate             (ld)->ld_mutex_lock_fn(ld->ld_mutex[lock]); \
451*7c478bd9Sstevel@tonic-gate         } \
452*7c478bd9Sstevel@tonic-gate     }
453*7c478bd9Sstevel@tonic-gate 
454*7c478bd9Sstevel@tonic-gate #define LDAP_MUTEX_UNLOCK(ld, lock) \
455*7c478bd9Sstevel@tonic-gate     if ((ld)->ld_mutex_lock_fn != NULL && ld->ld_mutex != NULL) { \
456*7c478bd9Sstevel@tonic-gate         if ((ld)->ld_threadid_fn != NULL) { \
457*7c478bd9Sstevel@tonic-gate             if ((ld)->ld_mutex_threadid[lock] == (ld)->ld_threadid_fn()) { \
458*7c478bd9Sstevel@tonic-gate                 (ld)->ld_mutex_refcnt[lock]--; \
459*7c478bd9Sstevel@tonic-gate                 if ((ld)->ld_mutex_refcnt[lock] <= 0) { \
460*7c478bd9Sstevel@tonic-gate                     (ld)->ld_mutex_threadid[lock] = (void *) -1; \
461*7c478bd9Sstevel@tonic-gate                     (ld)->ld_mutex_refcnt[lock] = 0; \
462*7c478bd9Sstevel@tonic-gate                     (ld)->ld_mutex_unlock_fn(ld->ld_mutex[lock]); \
463*7c478bd9Sstevel@tonic-gate                 } \
464*7c478bd9Sstevel@tonic-gate             } \
465*7c478bd9Sstevel@tonic-gate         } else { \
466*7c478bd9Sstevel@tonic-gate             ld->ld_mutex_unlock_fn(ld->ld_mutex[lock]); \
467*7c478bd9Sstevel@tonic-gate         } \
468*7c478bd9Sstevel@tonic-gate     }
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate /* Backward compatibility locks */
471*7c478bd9Sstevel@tonic-gate #define LDAP_MUTEX_BC_LOCK( ld, i ) \
472*7c478bd9Sstevel@tonic-gate 	/* the ld_mutex_trylock_fn is always set to NULL */ \
473*7c478bd9Sstevel@tonic-gate 	/* in setoption.c as the extra thread functions were */ \
474*7c478bd9Sstevel@tonic-gate 	/* turned off in the 4.0 SDK.  This check will  */ \
475*7c478bd9Sstevel@tonic-gate 	/* always be true */ \
476*7c478bd9Sstevel@tonic-gate 	if( (ld)->ld_mutex_trylock_fn == NULL ) { \
477*7c478bd9Sstevel@tonic-gate 		LDAP_MUTEX_LOCK( ld, i ) ; \
478*7c478bd9Sstevel@tonic-gate 	}
479*7c478bd9Sstevel@tonic-gate #define LDAP_MUTEX_BC_UNLOCK( ld, i ) \
480*7c478bd9Sstevel@tonic-gate 	/* the ld_mutex_trylock_fn is always set to NULL */ \
481*7c478bd9Sstevel@tonic-gate 	/* in setoption.c as the extra thread functions were */ \
482*7c478bd9Sstevel@tonic-gate 	/* turned off in the 4.0 SDK.  This check will  */ \
483*7c478bd9Sstevel@tonic-gate 	/* always be true */ \
484*7c478bd9Sstevel@tonic-gate 	if( (ld)->ld_mutex_trylock_fn == NULL ) { \
485*7c478bd9Sstevel@tonic-gate 		LDAP_MUTEX_UNLOCK( ld, i ) ; \
486*7c478bd9Sstevel@tonic-gate 	}
487*7c478bd9Sstevel@tonic-gate 
488*7c478bd9Sstevel@tonic-gate /* allocate/free semaphore */
489*7c478bd9Sstevel@tonic-gate #define LDAP_SEMA_ALLOC( ld ) \
490*7c478bd9Sstevel@tonic-gate 	(((ld)->ld_sema_alloc_fn != NULL) ? (ld)->ld_sema_alloc_fn() : NULL)
491*7c478bd9Sstevel@tonic-gate #define LDAP_SEMA_FREE( ld, m ) \
492*7c478bd9Sstevel@tonic-gate 	if ( (ld)->ld_sema_free_fn != NULL && m != NULL ) { \
493*7c478bd9Sstevel@tonic-gate 		(ld)->ld_sema_free_fn( m ); \
494*7c478bd9Sstevel@tonic-gate 	}
495*7c478bd9Sstevel@tonic-gate 
496*7c478bd9Sstevel@tonic-gate /* wait/post binary semaphore */
497*7c478bd9Sstevel@tonic-gate #define LDAP_SEMA_WAIT( ld, lp ) \
498*7c478bd9Sstevel@tonic-gate 	if ( (ld)->ld_sema_wait_fn != NULL ) { \
499*7c478bd9Sstevel@tonic-gate 		(ld)->ld_sema_wait_fn( lp->lp_sema ); \
500*7c478bd9Sstevel@tonic-gate 	}
501*7c478bd9Sstevel@tonic-gate #define LDAP_SEMA_POST( ld, lp ) \
502*7c478bd9Sstevel@tonic-gate 	if ( (ld)->ld_sema_post_fn != NULL ) { \
503*7c478bd9Sstevel@tonic-gate 		(ld)->ld_sema_post_fn( lp->lp_sema ); \
504*7c478bd9Sstevel@tonic-gate 	}
505*7c478bd9Sstevel@tonic-gate #define POST( ld, y, z ) \
506*7c478bd9Sstevel@tonic-gate 	/* the ld_mutex_trylock_fn is always set to NULL */ \
507*7c478bd9Sstevel@tonic-gate 	/* in setoption.c as the extra thread functions were */ \
508*7c478bd9Sstevel@tonic-gate 	/* turned off in the 4.0 SDK.  This check will  */ \
509*7c478bd9Sstevel@tonic-gate 	/* always be false */ \
510*7c478bd9Sstevel@tonic-gate 	if( (ld)->ld_mutex_trylock_fn != NULL ) { \
511*7c478bd9Sstevel@tonic-gate 		nsldapi_post_result( ld, y, z ); \
512*7c478bd9Sstevel@tonic-gate 	}
513*7c478bd9Sstevel@tonic-gate 
514*7c478bd9Sstevel@tonic-gate /* get/set errno */
515*7c478bd9Sstevel@tonic-gate #ifndef macintosh
516*7c478bd9Sstevel@tonic-gate #define LDAP_SET_ERRNO( ld, e ) \
517*7c478bd9Sstevel@tonic-gate 	if ( (ld)->ld_set_errno_fn != NULL ) { \
518*7c478bd9Sstevel@tonic-gate 		(ld)->ld_set_errno_fn( e ); \
519*7c478bd9Sstevel@tonic-gate 	} else { \
520*7c478bd9Sstevel@tonic-gate 		errno = e; \
521*7c478bd9Sstevel@tonic-gate 	}
522*7c478bd9Sstevel@tonic-gate #define LDAP_GET_ERRNO( ld ) \
523*7c478bd9Sstevel@tonic-gate 	(((ld)->ld_get_errno_fn != NULL) ? \
524*7c478bd9Sstevel@tonic-gate 		(ld)->ld_get_errno_fn() : errno)
525*7c478bd9Sstevel@tonic-gate #else /* macintosh */
526*7c478bd9Sstevel@tonic-gate #define LDAP_SET_ERRNO( ld, e ) \
527*7c478bd9Sstevel@tonic-gate 	if ( (ld)->ld_set_errno_fn != NULL ) { \
528*7c478bd9Sstevel@tonic-gate 		(ld)->ld_set_errno_fn( e ); \
529*7c478bd9Sstevel@tonic-gate 	}
530*7c478bd9Sstevel@tonic-gate #define LDAP_GET_ERRNO( ld ) \
531*7c478bd9Sstevel@tonic-gate 	(((ld)->ld_get_errno_fn != NULL) ? \
532*7c478bd9Sstevel@tonic-gate 		(ld)->ld_get_errno_fn() : 0)
533*7c478bd9Sstevel@tonic-gate #endif
534*7c478bd9Sstevel@tonic-gate 
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate /* get/set ldap-specific errno */
537*7c478bd9Sstevel@tonic-gate #define LDAP_SET_LDERRNO( ld, e, m, s )	ldap_set_lderrno( ld, e, m, s )
538*7c478bd9Sstevel@tonic-gate #define LDAP_GET_LDERRNO( ld, m, s ) ldap_get_lderrno( ld, m, s )
539*7c478bd9Sstevel@tonic-gate 
540*7c478bd9Sstevel@tonic-gate /*
541*7c478bd9Sstevel@tonic-gate  * your standard "mimimum of two values" macro
542*7c478bd9Sstevel@tonic-gate  */
543*7c478bd9Sstevel@tonic-gate #define NSLDAPI_MIN(a, b)	(((a) < (b)) ? (a) : (b))
544*7c478bd9Sstevel@tonic-gate 
545*7c478bd9Sstevel@tonic-gate /*
546*7c478bd9Sstevel@tonic-gate  * handy macro to check whether LDAP struct is set up for CLDAP or not
547*7c478bd9Sstevel@tonic-gate  */
548*7c478bd9Sstevel@tonic-gate #define LDAP_IS_CLDAP( ld )	( ld->ld_sbp->sb_naddr > 0 )
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate /*
551*7c478bd9Sstevel@tonic-gate  * handy macro to check errno "e" for an "in progress" sort of error
552*7c478bd9Sstevel@tonic-gate  */
553*7c478bd9Sstevel@tonic-gate #if defined(macintosh) || defined(_WINDOWS)
554*7c478bd9Sstevel@tonic-gate #define NSLDAPI_ERRNO_IO_INPROGRESS( e )  ((e) == EWOULDBLOCK || (e) == EAGAIN)
555*7c478bd9Sstevel@tonic-gate #else
556*7c478bd9Sstevel@tonic-gate #ifdef EAGAIN
557*7c478bd9Sstevel@tonic-gate #define NSLDAPI_ERRNO_IO_INPROGRESS( e )  ((e) == EWOULDBLOCK || (e) == EINPROGRESS || (e) == EAGAIN)
558*7c478bd9Sstevel@tonic-gate #else /* EAGAIN */
559*7c478bd9Sstevel@tonic-gate #define NSLDAPI_ERRNO_IO_INPROGRESS( e )  ((e) == EWOULDBLOCK || (e) == EINPROGRESS)
560*7c478bd9Sstevel@tonic-gate #endif /* EAGAIN */
561*7c478bd9Sstevel@tonic-gate #endif /* macintosh || _WINDOWS*/
562*7c478bd9Sstevel@tonic-gate 
563*7c478bd9Sstevel@tonic-gate /*
564*7c478bd9Sstevel@tonic-gate  * macro to return the LDAP protocol version we are using
565*7c478bd9Sstevel@tonic-gate  */
566*7c478bd9Sstevel@tonic-gate #define NSLDAPI_LDAP_VERSION( ld )	( (ld)->ld_defconn == NULL ? \
567*7c478bd9Sstevel@tonic-gate 					(ld)->ld_version : \
568*7c478bd9Sstevel@tonic-gate 					(ld)->ld_defconn->lconn_version )
569*7c478bd9Sstevel@tonic-gate 
570*7c478bd9Sstevel@tonic-gate /*
571*7c478bd9Sstevel@tonic-gate  * Structures used for handling client filter lists.
572*7c478bd9Sstevel@tonic-gate  */
573*7c478bd9Sstevel@tonic-gate #define LDAP_FILT_MAXSIZ	1024
574*7c478bd9Sstevel@tonic-gate 
575*7c478bd9Sstevel@tonic-gate struct ldap_filt_list {
576*7c478bd9Sstevel@tonic-gate     char			*lfl_tag;
577*7c478bd9Sstevel@tonic-gate     char			*lfl_pattern;
578*7c478bd9Sstevel@tonic-gate     char			*lfl_delims;
579*7c478bd9Sstevel@tonic-gate     struct ldap_filt_info	*lfl_ilist;
580*7c478bd9Sstevel@tonic-gate     struct ldap_filt_list	*lfl_next;
581*7c478bd9Sstevel@tonic-gate };
582*7c478bd9Sstevel@tonic-gate 
583*7c478bd9Sstevel@tonic-gate struct ldap_filt_desc {
584*7c478bd9Sstevel@tonic-gate 	LDAPFiltList		*lfd_filtlist;
585*7c478bd9Sstevel@tonic-gate 	LDAPFiltInfo		*lfd_curfip;
586*7c478bd9Sstevel@tonic-gate 	LDAPFiltInfo		lfd_retfi;
587*7c478bd9Sstevel@tonic-gate 	char			lfd_filter[ LDAP_FILT_MAXSIZ ];
588*7c478bd9Sstevel@tonic-gate 	char			*lfd_curval;
589*7c478bd9Sstevel@tonic-gate 	char			*lfd_curvalcopy;
590*7c478bd9Sstevel@tonic-gate 	char			**lfd_curvalwords;
591*7c478bd9Sstevel@tonic-gate 	char			*lfd_filtprefix;
592*7c478bd9Sstevel@tonic-gate 	char			*lfd_filtsuffix;
593*7c478bd9Sstevel@tonic-gate };
594*7c478bd9Sstevel@tonic-gate 
595*7c478bd9Sstevel@tonic-gate /*
596*7c478bd9Sstevel@tonic-gate  * "internal" globals used to track defaults and memory allocation callbacks:
597*7c478bd9Sstevel@tonic-gate  *    (the actual definitions are in open.c)
598*7c478bd9Sstevel@tonic-gate  */
599*7c478bd9Sstevel@tonic-gate extern struct ldap			nsldapi_ld_defaults;
600*7c478bd9Sstevel@tonic-gate extern struct ldap_memalloc_fns		nsldapi_memalloc_fns;
601*7c478bd9Sstevel@tonic-gate extern int				nsldapi_initialized;
602*7c478bd9Sstevel@tonic-gate 
603*7c478bd9Sstevel@tonic-gate 
604*7c478bd9Sstevel@tonic-gate /*
605*7c478bd9Sstevel@tonic-gate  * Memory allocation done in liblber should all go through one of the
606*7c478bd9Sstevel@tonic-gate  * following macros. This is so we can plug-in alternative memory
607*7c478bd9Sstevel@tonic-gate  * allocators, etc. as the need arises.
608*7c478bd9Sstevel@tonic-gate  */
609*7c478bd9Sstevel@tonic-gate #define NSLDAPI_MALLOC( size )		ldap_x_malloc( size )
610*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CALLOC( nelem, elsize )	ldap_x_calloc( nelem, elsize )
611*7c478bd9Sstevel@tonic-gate #define NSLDAPI_REALLOC( ptr, size )	ldap_x_realloc( ptr, size )
612*7c478bd9Sstevel@tonic-gate #define NSLDAPI_FREE( ptr )		ldap_x_free( ptr )
613*7c478bd9Sstevel@tonic-gate 
614*7c478bd9Sstevel@tonic-gate 
615*7c478bd9Sstevel@tonic-gate /*
616*7c478bd9Sstevel@tonic-gate  * macros used to check validity of data structures and parameters
617*7c478bd9Sstevel@tonic-gate  */
618*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAP_POINTER( ld ) \
619*7c478bd9Sstevel@tonic-gate 	( (ld) != NULL )
620*7c478bd9Sstevel@tonic-gate 
621*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAPMESSAGE_POINTER( lm ) \
622*7c478bd9Sstevel@tonic-gate 	( (lm) != NULL )
623*7c478bd9Sstevel@tonic-gate 
624*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER( lm ) \
625*7c478bd9Sstevel@tonic-gate 	( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_SEARCH_ENTRY )
626*7c478bd9Sstevel@tonic-gate 
627*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAPMESSAGE_REFERENCE_POINTER( lm ) \
628*7c478bd9Sstevel@tonic-gate 	( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_SEARCH_REFERENCE )
629*7c478bd9Sstevel@tonic-gate 
630*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAPMESSAGE_BINDRESULT_POINTER( lm ) \
631*7c478bd9Sstevel@tonic-gate 	( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_BIND )
632*7c478bd9Sstevel@tonic-gate 
633*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAPMESSAGE_EXRESULT_POINTER( lm ) \
634*7c478bd9Sstevel@tonic-gate 	( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_EXTENDED )
635*7c478bd9Sstevel@tonic-gate 
636*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_LDAPMOD_ARRAY( mods ) \
637*7c478bd9Sstevel@tonic-gate 	( (mods) != NULL )
638*7c478bd9Sstevel@tonic-gate 
639*7c478bd9Sstevel@tonic-gate #define NSLDAPI_VALID_NONEMPTY_LDAPMOD_ARRAY( mods ) \
640*7c478bd9Sstevel@tonic-gate 	( (mods) != NULL && (mods)[0] != NULL )
641*7c478bd9Sstevel@tonic-gate 
642*7c478bd9Sstevel@tonic-gate #define NSLDAPI_IS_SEARCH_ENTRY( code ) \
643*7c478bd9Sstevel@tonic-gate 	((code) == LDAP_RES_SEARCH_ENTRY)
644*7c478bd9Sstevel@tonic-gate 
645*7c478bd9Sstevel@tonic-gate #define NSLDAPI_IS_SEARCH_RESULT( code ) \
646*7c478bd9Sstevel@tonic-gate 	((code) == LDAP_RES_SEARCH_RESULT)
647*7c478bd9Sstevel@tonic-gate 
648*7c478bd9Sstevel@tonic-gate #define NSLDAPI_SEARCH_RELATED_RESULT( code ) \
649*7c478bd9Sstevel@tonic-gate 	(NSLDAPI_IS_SEARCH_RESULT( code ) || NSLDAPI_IS_SEARCH_ENTRY( code ))
650*7c478bd9Sstevel@tonic-gate 
651*7c478bd9Sstevel@tonic-gate /*
652*7c478bd9Sstevel@tonic-gate  * in bind.c
653*7c478bd9Sstevel@tonic-gate  */
654*7c478bd9Sstevel@tonic-gate char *nsldapi_get_binddn( LDAP *ld );
655*7c478bd9Sstevel@tonic-gate 
656*7c478bd9Sstevel@tonic-gate /*
657*7c478bd9Sstevel@tonic-gate  * in cache.c
658*7c478bd9Sstevel@tonic-gate  */
659*7c478bd9Sstevel@tonic-gate void nsldapi_add_result_to_cache( LDAP *ld, LDAPMessage *result );
660*7c478bd9Sstevel@tonic-gate 
661*7c478bd9Sstevel@tonic-gate /*
662*7c478bd9Sstevel@tonic-gate  * in dsparse.c
663*7c478bd9Sstevel@tonic-gate  */
664*7c478bd9Sstevel@tonic-gate int ldap_next_line_tokens( char **bufp, long *blenp, char ***toksp );
665*7c478bd9Sstevel@tonic-gate void ldap_free_strarray( char **sap );
666*7c478bd9Sstevel@tonic-gate 
667*7c478bd9Sstevel@tonic-gate /*
668*7c478bd9Sstevel@tonic-gate  * in error.c
669*7c478bd9Sstevel@tonic-gate  */
670*7c478bd9Sstevel@tonic-gate int nsldapi_parse_result( LDAP *ld, int msgtype, BerElement *rber,
671*7c478bd9Sstevel@tonic-gate     int *errcodep, char **matchednp, char **errmsgp, char ***referralsp,
672*7c478bd9Sstevel@tonic-gate     LDAPControl ***serverctrlsp );
673*7c478bd9Sstevel@tonic-gate 
674*7c478bd9Sstevel@tonic-gate /*
675*7c478bd9Sstevel@tonic-gate  * in open.c
676*7c478bd9Sstevel@tonic-gate  */
677*7c478bd9Sstevel@tonic-gate void nsldapi_initialize_defaults( void );
678*7c478bd9Sstevel@tonic-gate void nsldapi_mutex_alloc_all( LDAP *ld );
679*7c478bd9Sstevel@tonic-gate void nsldapi_mutex_free_all( LDAP *ld );
680*7c478bd9Sstevel@tonic-gate int nsldapi_open_ldap_defconn( LDAP *ld );
681*7c478bd9Sstevel@tonic-gate char *nsldapi_strdup( const char *s );  /* if s is NULL, returns NULL */
682*7c478bd9Sstevel@tonic-gate 
683*7c478bd9Sstevel@tonic-gate /*
684*7c478bd9Sstevel@tonic-gate  * in os-ip.c
685*7c478bd9Sstevel@tonic-gate  */
686*7c478bd9Sstevel@tonic-gate int nsldapi_connect_to_host( LDAP *ld, Sockbuf *sb, const char *host,
687*7c478bd9Sstevel@tonic-gate 	int port, int secure, char **krbinstancep );
688*7c478bd9Sstevel@tonic-gate void nsldapi_close_connection( LDAP *ld, Sockbuf *sb );
689*7c478bd9Sstevel@tonic-gate 
690*7c478bd9Sstevel@tonic-gate int nsldapi_iostatus_poll( LDAP *ld, struct timeval *timeout );
691*7c478bd9Sstevel@tonic-gate void nsldapi_iostatus_free( LDAP *ld );
692*7c478bd9Sstevel@tonic-gate int nsldapi_iostatus_interest_write( LDAP *ld, Sockbuf *sb );
693*7c478bd9Sstevel@tonic-gate int nsldapi_iostatus_interest_read( LDAP *ld, Sockbuf *sb );
694*7c478bd9Sstevel@tonic-gate int nsldapi_iostatus_interest_clear( LDAP *ld, Sockbuf *sb );
695*7c478bd9Sstevel@tonic-gate int nsldapi_iostatus_is_read_ready( LDAP *ld, Sockbuf *sb );
696*7c478bd9Sstevel@tonic-gate int nsldapi_iostatus_is_write_ready( LDAP *ld, Sockbuf *sb );
697*7c478bd9Sstevel@tonic-gate int nsldapi_install_lber_extiofns( LDAP *ld, Sockbuf *sb );
698*7c478bd9Sstevel@tonic-gate int nsldapi_install_compat_io_fns( LDAP *ld, struct ldap_io_fns *iofns );
699*7c478bd9Sstevel@tonic-gate 
700*7c478bd9Sstevel@tonic-gate /*
701*7c478bd9Sstevel@tonic-gate  * if referral.c
702*7c478bd9Sstevel@tonic-gate  */
703*7c478bd9Sstevel@tonic-gate int nsldapi_parse_reference( LDAP *ld, BerElement *rber, char ***referralsp,
704*7c478bd9Sstevel@tonic-gate 	LDAPControl ***serverctrlsp );
705*7c478bd9Sstevel@tonic-gate 
706*7c478bd9Sstevel@tonic-gate /*
707*7c478bd9Sstevel@tonic-gate  * in result.c
708*7c478bd9Sstevel@tonic-gate  */
709*7c478bd9Sstevel@tonic-gate int ldap_msgdelete( LDAP *ld, int msgid );
710*7c478bd9Sstevel@tonic-gate int nsldapi_result_nolock( LDAP *ld, int msgid, int all, int unlock_permitted,
711*7c478bd9Sstevel@tonic-gate     struct timeval *timeout, LDAPMessage **result );
712*7c478bd9Sstevel@tonic-gate int nsldapi_wait_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
713*7c478bd9Sstevel@tonic-gate     LDAPMessage **result );
714*7c478bd9Sstevel@tonic-gate int nsldapi_post_result( LDAP *ld, int msgid, LDAPMessage *result );
715*7c478bd9Sstevel@tonic-gate 
716*7c478bd9Sstevel@tonic-gate /*
717*7c478bd9Sstevel@tonic-gate  * in request.c
718*7c478bd9Sstevel@tonic-gate  */
719*7c478bd9Sstevel@tonic-gate int nsldapi_send_initial_request( LDAP *ld, int msgid, unsigned long msgtype,
720*7c478bd9Sstevel@tonic-gate 	char *dn, BerElement *ber );
721*7c478bd9Sstevel@tonic-gate int nsldapi_alloc_ber_with_options( LDAP *ld, BerElement **berp );
722*7c478bd9Sstevel@tonic-gate void nsldapi_set_ber_options( LDAP *ld, BerElement *ber );
723*7c478bd9Sstevel@tonic-gate int nsldapi_ber_flush( LDAP *ld, Sockbuf *sb, BerElement *ber, int freeit,
724*7c478bd9Sstevel@tonic-gate 	int async );
725*7c478bd9Sstevel@tonic-gate int nsldapi_send_server_request( LDAP *ld, BerElement *ber, int msgid,
726*7c478bd9Sstevel@tonic-gate 	LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
727*7c478bd9Sstevel@tonic-gate 	char *bindreqdn, int bind );
728*7c478bd9Sstevel@tonic-gate LDAPConn *nsldapi_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
729*7c478bd9Sstevel@tonic-gate 	int connect, int bind );
730*7c478bd9Sstevel@tonic-gate LDAPRequest *nsldapi_find_request_by_msgid( LDAP *ld, int msgid );
731*7c478bd9Sstevel@tonic-gate void nsldapi_free_request( LDAP *ld, LDAPRequest *lr, int free_conn );
732*7c478bd9Sstevel@tonic-gate void nsldapi_free_connection( LDAP *ld, LDAPConn *lc,
733*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
734*7c478bd9Sstevel@tonic-gate 	int force, int unbind );
735*7c478bd9Sstevel@tonic-gate void nsldapi_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
736*7c478bd9Sstevel@tonic-gate void nsldapi_dump_requests_and_responses( LDAP *ld );
737*7c478bd9Sstevel@tonic-gate int nsldapi_chase_v2_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp,
738*7c478bd9Sstevel@tonic-gate 	int *totalcountp, int *chasingcountp );
739*7c478bd9Sstevel@tonic-gate int nsldapi_chase_v3_refs( LDAP *ld, LDAPRequest *lr, char **refs,
740*7c478bd9Sstevel@tonic-gate 	int is_reference, int *totalcountp, int *chasingcountp );
741*7c478bd9Sstevel@tonic-gate int nsldapi_append_referral( LDAP *ld, char **referralsp, char *s );
742*7c478bd9Sstevel@tonic-gate void nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb );
743*7c478bd9Sstevel@tonic-gate 
744*7c478bd9Sstevel@tonic-gate /*
745*7c478bd9Sstevel@tonic-gate  * in search.c
746*7c478bd9Sstevel@tonic-gate  */
747*7c478bd9Sstevel@tonic-gate int nsldapi_build_search_req( LDAP *ld, const char *base, int scope,
748*7c478bd9Sstevel@tonic-gate 	const char *filter, char **attrs, int attrsonly,
749*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
750*7c478bd9Sstevel@tonic-gate 	int timelimit, int sizelimit, int msgid, BerElement **berp );
751*7c478bd9Sstevel@tonic-gate 
752*7c478bd9Sstevel@tonic-gate int ldap_put_filter( BerElement *ber, char *str );
753*7c478bd9Sstevel@tonic-gate /*
754*7c478bd9Sstevel@tonic-gate  * in unbind.c
755*7c478bd9Sstevel@tonic-gate  */
756*7c478bd9Sstevel@tonic-gate int ldap_ld_free( LDAP *ld, LDAPControl **serverctrls,
757*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls, int close );
758*7c478bd9Sstevel@tonic-gate int nsldapi_send_unbind( LDAP *ld, Sockbuf *sb, LDAPControl **serverctrls,
759*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls );
760*7c478bd9Sstevel@tonic-gate 
761*7c478bd9Sstevel@tonic-gate #ifdef LDAP_DNS
762*7c478bd9Sstevel@tonic-gate /*
763*7c478bd9Sstevel@tonic-gate  * in getdxbyname.c
764*7c478bd9Sstevel@tonic-gate  */
765*7c478bd9Sstevel@tonic-gate char **nsldapi_getdxbyname( char *domain );
766*7c478bd9Sstevel@tonic-gate 
767*7c478bd9Sstevel@tonic-gate #endif /* LDAP_DNS */
768*7c478bd9Sstevel@tonic-gate 
769*7c478bd9Sstevel@tonic-gate /*
770*7c478bd9Sstevel@tonic-gate  * in unescape.c
771*7c478bd9Sstevel@tonic-gate  */
772*7c478bd9Sstevel@tonic-gate void nsldapi_hex_unescape( char *s );
773*7c478bd9Sstevel@tonic-gate 
774*7c478bd9Sstevel@tonic-gate /*
775*7c478bd9Sstevel@tonic-gate  * in reslist.c
776*7c478bd9Sstevel@tonic-gate  */
777*7c478bd9Sstevel@tonic-gate LDAPMessage *ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e );
778*7c478bd9Sstevel@tonic-gate void ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e );
779*7c478bd9Sstevel@tonic-gate 
780*7c478bd9Sstevel@tonic-gate /*
781*7c478bd9Sstevel@tonic-gate  * in compat.c
782*7c478bd9Sstevel@tonic-gate  */
783*7c478bd9Sstevel@tonic-gate #ifdef hpux
784*7c478bd9Sstevel@tonic-gate char *nsldapi_compat_ctime_r( const time_t *clock, char *buf, int buflen );
785*7c478bd9Sstevel@tonic-gate struct hostent *nsldapi_compat_gethostbyname_r( const char *name,
786*7c478bd9Sstevel@tonic-gate 	struct hostent *result, char *buffer, int buflen, int *h_errnop );
787*7c478bd9Sstevel@tonic-gate #endif /* hpux */
788*7c478bd9Sstevel@tonic-gate 
789*7c478bd9Sstevel@tonic-gate /*
790*7c478bd9Sstevel@tonic-gate  * in control.c
791*7c478bd9Sstevel@tonic-gate  */
792*7c478bd9Sstevel@tonic-gate int nsldapi_put_controls( LDAP *ld, LDAPControl **ctrls, int closeseq,
793*7c478bd9Sstevel@tonic-gate 	BerElement *ber );
794*7c478bd9Sstevel@tonic-gate int nsldapi_get_controls( BerElement *ber, LDAPControl ***controlsp );
795*7c478bd9Sstevel@tonic-gate int nsldapi_dup_controls( LDAP *ld, LDAPControl ***ldctrls,
796*7c478bd9Sstevel@tonic-gate 	LDAPControl **newctrls );
797*7c478bd9Sstevel@tonic-gate int nsldapi_build_control( char *oid, BerElement *ber, int freeber,
798*7c478bd9Sstevel@tonic-gate     char iscritical, LDAPControl **ctrlp );
799*7c478bd9Sstevel@tonic-gate 
800*7c478bd9Sstevel@tonic-gate 
801*7c478bd9Sstevel@tonic-gate /*
802*7c478bd9Sstevel@tonic-gate  * in url.c
803*7c478bd9Sstevel@tonic-gate  */
804*7c478bd9Sstevel@tonic-gate int nsldapi_url_parse( const char *inurl, LDAPURLDesc **ludpp,
805*7c478bd9Sstevel@tonic-gate 	int dn_required );
806*7c478bd9Sstevel@tonic-gate 
807*7c478bd9Sstevel@tonic-gate /*
808*7c478bd9Sstevel@tonic-gate  * in ../ber/bprint.c
809*7c478bd9Sstevel@tonic-gate  */
810*7c478bd9Sstevel@tonic-gate void ber_err_print( char *data );
811*7c478bd9Sstevel@tonic-gate 
812*7c478bd9Sstevel@tonic-gate #ifdef _SOLARIS_SDK
813*7c478bd9Sstevel@tonic-gate /*
814*7c478bd9Sstevel@tonic-gate  * in ../prldap/ldappr-dns.c
815*7c478bd9Sstevel@tonic-gate  */
816*7c478bd9Sstevel@tonic-gate int  prldap_x_install_dns_skipdb(LDAP *ld, const char *skip);
817*7c478bd9Sstevel@tonic-gate /*
818*7c478bd9Sstevel@tonic-gate  * in ../prldap/ldappr-threads.c
819*7c478bd9Sstevel@tonic-gate  */
820*7c478bd9Sstevel@tonic-gate void prldap_nspr_init(void);
821*7c478bd9Sstevel@tonic-gate #endif
822*7c478bd9Sstevel@tonic-gate 
823*7c478bd9Sstevel@tonic-gate /*
824*7c478bd9Sstevel@tonic-gate  * in ../prldap/ldappr-public.c
825*7c478bd9Sstevel@tonic-gate  */
826*7c478bd9Sstevel@tonic-gate int
827*7c478bd9Sstevel@tonic-gate prldap_install_io_functions( LDAP *ld, int shared );
828*7c478bd9Sstevel@tonic-gate int
829*7c478bd9Sstevel@tonic-gate prldap_install_dns_functions( LDAP *ld );
830*7c478bd9Sstevel@tonic-gate int
831*7c478bd9Sstevel@tonic-gate prldap_install_thread_functions( LDAP *ld, int shared );
832*7c478bd9Sstevel@tonic-gate 
833*7c478bd9Sstevel@tonic-gate 
834*7c478bd9Sstevel@tonic-gate 
835*7c478bd9Sstevel@tonic-gate #ifndef _SOLARIS_SDK
836*7c478bd9Sstevel@tonic-gate 
837*7c478bd9Sstevel@tonic-gate /*
838*7c478bd9Sstevel@tonic-gate  * in charset.c
839*7c478bd9Sstevel@tonic-gate  *
840*7c478bd9Sstevel@tonic-gate  * If we ever want to expose character set translation functionality to
841*7c478bd9Sstevel@tonic-gate  * users of libldap, all of these prototypes will need to be moved to ldap.h
842*7c478bd9Sstevel@tonic-gate  *
843*7c478bd9Sstevel@tonic-gate  * These are moved to ldap.h in the Solaris version of the library
844*7c478bd9Sstevel@tonic-gate  *
845*7c478bd9Sstevel@tonic-gate  */
846*7c478bd9Sstevel@tonic-gate #ifdef STR_TRANSLATION
847*7c478bd9Sstevel@tonic-gate void ldap_set_string_translators( LDAP *ld,
848*7c478bd9Sstevel@tonic-gate         BERTranslateProc encode_proc, BERTranslateProc decode_proc );
849*7c478bd9Sstevel@tonic-gate int ldap_translate_from_t61( LDAP *ld, char **bufp,
850*7c478bd9Sstevel@tonic-gate         unsigned long *lenp, int free_input );
851*7c478bd9Sstevel@tonic-gate int ldap_translate_to_t61( LDAP *ld, char **bufp,
852*7c478bd9Sstevel@tonic-gate         unsigned long *lenp, int free_input );
853*7c478bd9Sstevel@tonic-gate void ldap_enable_translation( LDAP *ld, LDAPMessage *entry,
854*7c478bd9Sstevel@tonic-gate         int enable );
855*7c478bd9Sstevel@tonic-gate #ifdef LDAP_CHARSET_8859
856*7c478bd9Sstevel@tonic-gate int ldap_t61_to_8859( char **bufp, unsigned long *buflenp,
857*7c478bd9Sstevel@tonic-gate         int free_input );
858*7c478bd9Sstevel@tonic-gate int ldap_8859_to_t61( char **bufp, unsigned long *buflenp,
859*7c478bd9Sstevel@tonic-gate         int free_input );
860*7c478bd9Sstevel@tonic-gate #endif /* LDAP_CHARSET_8859 */
861*7c478bd9Sstevel@tonic-gate #endif /* STR_TRANSLATION */
862*7c478bd9Sstevel@tonic-gate 
863*7c478bd9Sstevel@tonic-gate #endif /* _SOLARIS_SDK */
864*7c478bd9Sstevel@tonic-gate 
865*7c478bd9Sstevel@tonic-gate /*
866*7c478bd9Sstevel@tonic-gate  * in memcache.h
867*7c478bd9Sstevel@tonic-gate  */
868*7c478bd9Sstevel@tonic-gate int ldap_memcache_createkey( LDAP *ld, const char *base, int scope,
869*7c478bd9Sstevel@tonic-gate 	const char *filter, char **attrs, int attrsonly,
870*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
871*7c478bd9Sstevel@tonic-gate 	unsigned long *keyp );
872*7c478bd9Sstevel@tonic-gate int ldap_memcache_result( LDAP *ld, int msgid, unsigned long key );
873*7c478bd9Sstevel@tonic-gate int ldap_memcache_new( LDAP *ld, int msgid, unsigned long key,
874*7c478bd9Sstevel@tonic-gate 	const char *basedn );
875*7c478bd9Sstevel@tonic-gate int ldap_memcache_append( LDAP *ld, int msgid, int bLast, LDAPMessage *result );
876*7c478bd9Sstevel@tonic-gate int ldap_memcache_abandon( LDAP *ld, int msgid );
877*7c478bd9Sstevel@tonic-gate 
878*7c478bd9Sstevel@tonic-gate #endif /* _LDAPINT_H */
879