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