]> git.sur5r.net Git - openldap/blob - libraries/libldap/ldap-int.h
Move extern declarations to headers.
[openldap] / libraries / libldap / ldap-int.h
1 /*
2  *  Copyright (c) 1995 Regents of the University of Michigan.
3  *  All rights reserved.
4  *
5  *  ldap-int.h - defines & prototypes internal to the LDAP library
6  */
7
8 #ifndef _LDAP_INT_H
9 #define _LDAP_INT_H 1
10
11 #include "../liblber/lber-int.h"
12 #include "ldap_log.h"
13 #include "ldap.h"
14
15 LDAP_BEGIN_DECL
16
17 #define LDAP_URL_PREFIX         "ldap://"
18 #define LDAP_URL_PREFIX_LEN     7
19 #define LDAP_URL_URLCOLON       "URL:"
20 #define LDAP_URL_URLCOLON_LEN   4
21
22 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
23 #define LDAP_REF_STR            "Referral:\n"
24 #define LDAP_REF_STR_LEN        10
25 #define LDAP_LDAP_REF_STR       LDAP_URL_PREFIX
26 #define LDAP_LDAP_REF_STR_LEN   LDAP_URL_PREFIX_LEN
27 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
28 #define LDAP_DX_REF_STR         "dx://"
29 #define LDAP_DX_REF_STR_LEN     5
30 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
31 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
32
33 #define LDAP_BOOL_REFERRALS             0
34 #define LDAP_BOOL_RESTART               1
35 #define LDAP_BOOL_DNS                   2
36
37 #define LDAP_BOOLEANS   unsigned long
38 #define LDAP_BOOL(n)    (1 << (n))
39 #define LDAP_BOOL_GET(lo, bool) ((lo)->ldo_booleans & LDAP_BOOL(bool) \
40                                                                         ?  LDAP_OPT_ON : LDAP_OPT_OFF)
41 #define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool))
42 #define LDAP_BOOL_CLR(lo, bool) ((lo)->ldo_booleans &= ~LDAP_BOOL(bool))
43 #define LDAP_BOOL_ZERO(lo) ((lo)->ldo_booleans = 0)
44
45 /*
46  * This structure represents both ldap messages and ldap responses.
47  * These are really the same, except in the case of search responses,
48  * where a response has multiple messages.
49  */
50
51 struct ldapmsg {
52         int             lm_msgid;       /* the message id */
53         int             lm_msgtype;     /* the message type */
54         BerElement      *lm_ber;        /* the ber encoded message contents */
55         struct ldapmsg  *lm_chain;      /* for search - next msg in the resp */
56         struct ldapmsg  *lm_next;       /* next response */
57         unsigned int    lm_time;        /* used to maintain cache */
58 };
59
60 /*
61  * structure representing get/set'able options
62  * which have global defaults.
63  */
64 struct ldapoptions {
65         int             ldo_version;    /* version to connect at */
66         int             ldo_deref;
67         int             ldo_timelimit;
68         int             ldo_sizelimit;
69
70         char*   ldo_defbase;
71         char*   ldo_defhost;
72         int             ldo_defport;
73
74         int             ldo_cldaptries; /* connectionless search retry count */
75         int             ldo_cldaptimeout;/* time between retries */
76         int             ldo_refhoplimit;        /* limit on referral nesting */
77
78         LDAP_BOOLEANS ldo_booleans;     /* boolean options */
79 };
80
81 /*
82  * structure representing an ldap connection
83  */
84
85 struct ldap {
86         Sockbuf         ld_sb;          /* socket descriptor & buffer */
87
88         struct ldapoptions ld_options;
89
90 #define ld_deref                ld_options.ldo_deref
91 #define ld_timelimit    ld_options.ldo_timelimit
92 #define ld_sizelimit    ld_options.ldo_sizelimit
93
94 #define ld_defbase              ld_options.ldo_defbase
95 #define ld_defhost              ld_options.ldo_defhost
96 #define ld_defport              ld_options.ldo_defport
97
98 #define ld_cldaptries   ld_options.ldo_cldaptries
99 #define ld_cldaptimeout ld_options.ldo_cldaptimeout
100 #define ld_refhoplimit  ld_options.ldo_refhoplimit
101
102         int             ld_version;             /* version connected at */
103         char    *ld_host;
104         int             ld_port;
105
106         char    ld_lberoptions;
107
108         LDAPFiltDesc    *ld_filtd;      /* from getfilter for ufn searches */
109         char            *ld_ufnprefix;  /* for incomplete ufn's */
110
111         int             ld_errno;
112         char    *ld_error;
113         char    *ld_matched;
114         int             ld_msgid;
115
116         /* do not mess with these */
117 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
118         LDAPRequest     *ld_requests;   /* list of outstanding requests */
119 #else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
120         LDAPMessage     *ld_requests;   /* list of outstanding requests */
121 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
122         LDAPMessage     *ld_responses;  /* list of outstanding responses */
123         int             *ld_abandoned;  /* array of abandoned requests */
124         char            ld_attrbuffer[LDAP_MAX_ATTR_LEN];
125         LDAPCache       *ld_cache;      /* non-null if cache is initialized */
126         char            *ld_cldapdn;    /* DN used in connectionless search */
127
128         /* do not mess with the rest though */
129         BERTranslateProc ld_lber_encode_translate_proc;
130         BERTranslateProc ld_lber_decode_translate_proc;
131
132 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
133         LDAPConn        *ld_defconn;    /* default connection */
134         LDAPConn        *ld_conns;      /* list of server connections */
135         void            *ld_selectinfo; /* platform specifics for select */
136         int             (*ld_rebindproc)( struct ldap *ld, char **dnp,
137                                 char **passwdp, int *authmethodp, int freeit );
138                                 /* routine to get info needed for re-bind */
139 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
140 };
141
142
143 /*
144  * in init.c
145  */
146 extern int openldap_ldap_initialized;
147 extern struct ldapoptions openldap_ldap_global_options;
148 void openldap_ldap_initialize LDAP_P((void));
149
150 /*
151  * in cache.c
152  */
153 void ldap_add_request_to_cache LDAP_P(( LDAP *ld, unsigned long msgtype,
154         BerElement *request ));
155 void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
156 int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
157
158 /*
159  * in dparse.c
160  */
161 int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp ));
162 void free_strarray LDAP_P(( char **sap ));
163
164 #ifdef HAVE_KERBEROS
165 /*
166  * in kerberos.c
167  */
168 char *ldap_get_kerberosv4_credentials LDAP_P(( LDAP *ld, char *who, char *service,
169         int *len ));
170
171 #endif /* HAVE_KERBEROS */
172
173
174 /*
175  * in open.c
176  */
177 int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport,
178         char **krbinstancep, int async );
179
180
181 /*
182  * in os-ip.c
183  */
184 int ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port,
185         int async );
186 void ldap_close_connection( Sockbuf *sb );
187
188 #ifdef HAVE_KERBEROS
189 char *ldap_host_connected_to( Sockbuf *sb );
190 #endif /* HAVE_KERBEROS */
191
192 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
193 int do_ldap_select( LDAP *ld, struct timeval *timeout );
194 void *ldap_new_select_info( void );
195 void ldap_free_select_info( void *sip );
196 void ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
197 void ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
198 void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
199 int ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
200 int ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
201 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
202
203
204 /*
205  * in request.c
206  */
207 int ldap_send_initial_request( LDAP *ld, unsigned long msgtype,
208         char *dn, BerElement *ber );
209 BerElement *ldap_alloc_ber_with_options( LDAP *ld );
210 void ldap_set_ber_options( LDAP *ld, BerElement *ber );
211
212 #if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) || defined( LDAP_API_FEATURE_X_OPENLDAP_V2_DNS )
213 int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid,
214         LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
215         int bind );
216 LDAPConn *ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
217         int connect, int bind );
218 LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid );
219 void ldap_free_request( LDAP *ld, LDAPRequest *lr );
220 void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
221 void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
222 void ldap_dump_requests_and_responses( LDAP *ld );
223 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS || LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
224
225 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
226 int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
227 int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
228 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
229
230
231 /*
232  * in search.c
233  */
234 BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope,
235         char *filter, char **attrs, int attrsonly );
236
237
238 /*
239  * in unbind.c
240  */
241 int ldap_ld_free( LDAP *ld, int close );
242 int ldap_send_unbind( LDAP *ld, Sockbuf *sb );
243
244 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
245 /*
246  * in getdxbyname.c
247  */
248 char **ldap_getdxbyname( char *domain );
249 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
250
251 #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
252 /*
253  * in charset.c
254  *
255  * added-in this stuff so that libldap.a would build, i.e. refs to 
256  * these routines from open.c would resolve. 
257  * hodges@stanford.edu 5-Feb-96
258  */
259 #if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
260 extern 
261 int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input );
262 extern 
263 int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
264 #endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
265  #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
266
267 LDAP_END_DECL
268
269 #endif /* _LDAP_INT_H */