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