]> git.sur5r.net Git - openldap/blob - libraries/libldap/ldap-int.h
API test for checking draft API issues.
[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_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_DNS
28 #define LDAP_DX_REF_STR         "dx://"
29 #define LDAP_DX_REF_STR_LEN     5
30 #endif /* LDAP_DNS */
31 #endif /* LDAP_REFERRALS */
32
33 #define LDAP_BOOL_REFERRALS             0
34 #define LDAP_BOOL_RESTART               1
35 #define LDAP_BOOL_DNS                   2
36
37 #define LDAP_BOOL(n)    (1 << (n))
38 #define LDAP_BOOL_GET(ld, bool) ((ld)->ld_booleans & LDAP_BOOL(bool) \
39                                                                         ?  LDAP_OPT_ON : LDAP_OPT_OFF)
40 #define LDAP_BOOL_SET(ld, bool) ((ld)->ld_booleans |= LDAP_BOOL(bool))
41 #define LDAP_BOOL_CLR(ld, bool) ((ld)->ld_booleans &= ~LDAP_BOOL(bool))
42 #define LDAP_BOOL_ZERO(ld) ((ld)->ld_booleans = 0)
43
44 /*
45  * This structure represents both ldap messages and ldap responses.
46  * These are really the same, except in the case of search responses,
47  * where a response has multiple messages.
48  */
49
50 struct ldapmsg {
51         int             lm_msgid;       /* the message id */
52         int             lm_msgtype;     /* the message type */
53         BerElement      *lm_ber;        /* the ber encoded message contents */
54         struct ldapmsg  *lm_chain;      /* for search - next msg in the resp */
55         struct ldapmsg  *lm_next;       /* next response */
56         unsigned int    lm_time;        /* used to maintain cache */
57 };
58
59 /*
60  * structure representing an ldap connection
61  */
62
63 struct ldap {
64         Sockbuf         ld_sb;          /* socket descriptor & buffer */
65         char            *ld_host;
66         int             ld_version;
67         char            ld_lberoptions;
68         int             ld_deref;
69         int             ld_timelimit;
70         int             ld_sizelimit;
71
72         LDAPFiltDesc    *ld_filtd;      /* from getfilter for ufn searches */
73         char            *ld_ufnprefix;  /* for incomplete ufn's */
74
75         int             ld_errno;
76         char            *ld_error;
77         char            *ld_matched;
78         int             ld_msgid;
79
80         /* do not mess with these */
81 #ifdef LDAP_REFERRALS
82         LDAPRequest     *ld_requests;   /* list of outstanding requests */
83 #else /* LDAP_REFERRALS */
84         LDAPMessage     *ld_requests;   /* list of outstanding requests */
85 #endif /* LDAP_REFERRALS */
86         LDAPMessage     *ld_responses;  /* list of outstanding responses */
87         int             *ld_abandoned;  /* array of abandoned requests */
88         char            ld_attrbuffer[LDAP_MAX_ATTR_LEN];
89         LDAPCache       *ld_cache;      /* non-null if cache is initialized */
90         char            *ld_cldapdn;    /* DN used in connectionless search */
91
92         /* it is OK to change these next four values directly */
93         int             ld_cldaptries;  /* connectionless search retry count */
94         int             ld_cldaptimeout;/* time between retries */
95         int             ld_refhoplimit; /* limit on referral nesting */
96         unsigned long   ld_booleans;    /* boolean options */
97
98         /* do not mess with the rest though */
99         char            *ld_defhost;    /* full name of default server */
100         int             ld_defport;     /* port of default server */
101         BERTranslateProc ld_lber_encode_translate_proc;
102         BERTranslateProc ld_lber_decode_translate_proc;
103 #ifdef LDAP_REFERRALS
104         LDAPConn        *ld_defconn;    /* default connection */
105         LDAPConn        *ld_conns;      /* list of server connections */
106         void            *ld_selectinfo; /* platform specifics for select */
107         int             (*ld_rebindproc)( struct ldap *ld, char **dnp,
108                                 char **passwdp, int *authmethodp, int freeit );
109                                 /* routine to get info needed for re-bind */
110 #endif /* LDAP_REFERRALS */
111 };
112
113
114 /*
115  * in init.c
116  */
117 extern int openldap_ldap_initialized;
118 extern struct ldap openldap_ld_globals;
119 void openldap_ldap_initialize LDAP_P((void));
120
121 /*
122  * in cache.c
123  */
124 void ldap_add_request_to_cache LDAP_P(( LDAP *ld, unsigned long msgtype,
125         BerElement *request ));
126 void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
127 int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
128
129
130 #ifdef HAVE_KERBEROS
131 /*
132  * in kerberos.c
133  */
134 char *ldap_get_kerberosv4_credentials LDAP_P(( LDAP *ld, char *who, char *service,
135         int *len ));
136
137 #endif /* HAVE_KERBEROS */
138
139
140 /*
141  * in open.c
142  */
143 int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport,
144         char **krbinstancep, int async );
145
146
147 /*
148  * in os-ip.c
149  */
150 int ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port,
151         int async );
152 void ldap_close_connection( Sockbuf *sb );
153
154 #ifdef HAVE_KERBEROS
155 char *ldap_host_connected_to( Sockbuf *sb );
156 #endif /* HAVE_KERBEROS */
157
158 #ifdef LDAP_REFERRALS
159 int do_ldap_select( LDAP *ld, struct timeval *timeout );
160 void *ldap_new_select_info( void );
161 void ldap_free_select_info( void *sip );
162 void ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
163 void ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
164 void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
165 int ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
166 int ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
167 #endif /* LDAP_REFERRALS */
168
169
170 /*
171  * in request.c
172  */
173 int ldap_send_initial_request( LDAP *ld, unsigned long msgtype,
174         char *dn, BerElement *ber );
175 BerElement *ldap_alloc_ber_with_options( LDAP *ld );
176 void ldap_set_ber_options( LDAP *ld, BerElement *ber );
177
178 #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS )
179 int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid,
180         LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
181         int bind );
182 LDAPConn *ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
183         int connect, int bind );
184 LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid );
185 void ldap_free_request( LDAP *ld, LDAPRequest *lr );
186 void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
187 void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
188 void ldap_dump_requests_and_responses( LDAP *ld );
189 #endif /* LDAP_REFERRALS || LDAP_DNS */
190
191 #ifdef LDAP_REFERRALS
192 int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
193 int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
194 #endif /* LDAP_REFERRALS */
195
196
197 /*
198  * in search.c
199  */
200 BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope,
201         char *filter, char **attrs, int attrsonly );
202
203
204 /*
205  * in unbind.c
206  */
207 int ldap_ld_free( LDAP *ld, int close );
208 int ldap_send_unbind( LDAP *ld, Sockbuf *sb );
209
210 #ifdef LDAP_DNS
211 /*
212  * in getdxbyname.c
213  */
214 char **ldap_getdxbyname( char *domain );
215 #endif /* LDAP_DNS */
216
217 #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
218 /*
219  * in charset.c
220  *
221  * added-in this stuff so that libldap.a would build, i.e. refs to 
222  * these routines from open.c would resolve. 
223  * hodges@stanford.edu 5-Feb-96
224  */
225 #if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
226 extern 
227 int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input );
228 extern 
229 int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
230 #endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
231
232 LDAP_END_DECL
233 #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
234
235 #endif /* _LDAP_INT_H */