Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/ldap/libldap/ldap-int.h
4394 views
1
/* ldap-int.h - defines & prototypes internal to the LDAP library */
2
/* $OpenLDAP$ */
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
*
5
* Copyright 1998-2024 The OpenLDAP Foundation.
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted only as authorized by the OpenLDAP
10
* Public License.
11
*
12
* A copy of this license is available in the file LICENSE in the
13
* top-level directory of the distribution or, alternatively, at
14
* <http://www.OpenLDAP.org/license.html>.
15
*/
16
/* Portions Copyright (c) 1995 Regents of the University of Michigan.
17
* All rights reserved.
18
*/
19
20
#ifndef _LDAP_INT_H
21
#define _LDAP_INT_H 1
22
23
#ifndef NO_THREADS
24
#define LDAP_R_COMPILE 1
25
#endif
26
27
#include "../liblber/lber-int.h"
28
#include "lutil.h"
29
#include "ldap_avl.h"
30
31
#ifdef LDAP_R_COMPILE
32
#include <ldap_pvt_thread.h>
33
#endif
34
35
#ifdef HAVE_CYRUS_SASL
36
/* the need for this should be removed */
37
#ifdef HAVE_SASL_SASL_H
38
#include <sasl/sasl.h>
39
#else
40
#include <sasl.h>
41
#endif
42
43
#define SASL_MAX_BUFF_SIZE (0xffffff)
44
#define SASL_MIN_BUFF_SIZE 4096
45
#endif
46
47
/* for struct timeval */
48
#include <ac/time.h>
49
#include <ac/socket.h>
50
51
#undef TV2MILLISEC
52
#define TV2MILLISEC(tv) (((tv)->tv_sec * 1000) + ((tv)->tv_usec/1000))
53
54
/*
55
* Support needed if the library is running in the kernel
56
*/
57
#if LDAP_INT_IN_KERNEL
58
/*
59
* Platform specific function to return a pointer to the
60
* process-specific global options.
61
*
62
* This function should perform the following functions:
63
* Allocate and initialize a global options struct on a per process basis
64
* Use callers process identifier to return its global options struct
65
* Note: Deallocate structure when the process exits
66
*/
67
# define LDAP_INT_GLOBAL_OPT() ldap_int_global_opt()
68
struct ldapoptions *ldap_int_global_opt(void);
69
#else
70
# define LDAP_INT_GLOBAL_OPT() (&ldap_int_global_options)
71
#endif
72
73
/* if used from server code, ldap_debug already points elsewhere */
74
#ifndef ldap_debug
75
#define ldap_debug ((LDAP_INT_GLOBAL_OPT())->ldo_debug)
76
#endif /* !ldap_debug */
77
78
#define LDAP_INT_DEBUG
79
#include "ldap_log.h"
80
81
#ifdef LDAP_DEBUG
82
83
#define DebugTest( level ) \
84
( ldap_debug & level )
85
86
#define Debug0( level, fmt ) \
87
do { if ( DebugTest( (level) ) ) \
88
ldap_log_printf( NULL, (level), fmt ); \
89
} while ( 0 )
90
91
#define Debug1( level, fmt, arg1 ) \
92
do { if ( DebugTest( (level) ) ) \
93
ldap_log_printf( NULL, (level), fmt, arg1 ); \
94
} while ( 0 )
95
96
#define Debug2( level, fmt, arg1, arg2 ) \
97
do { if ( DebugTest( (level) ) ) \
98
ldap_log_printf( NULL, (level), fmt, arg1, arg2 ); \
99
} while ( 0 )
100
101
#define Debug3( level, fmt, arg1, arg2, arg3 ) \
102
do { if ( DebugTest( (level) ) ) \
103
ldap_log_printf( NULL, (level), fmt, arg1, arg2, arg3 ); \
104
} while ( 0 )
105
106
#else
107
108
#define DebugTest( level ) (0 == 1)
109
#define Debug0( level, fmt ) ((void)0)
110
#define Debug1( level, fmt, arg1 ) ((void)0)
111
#define Debug2( level, fmt, arg1, arg2 ) ((void)0)
112
#define Debug3( level, fmt, arg1, arg2, arg3 ) ((void)0)
113
114
#endif /* LDAP_DEBUG */
115
116
#define LDAP_DEPRECATED 1
117
#include "ldap.h"
118
119
#include "ldap_pvt.h"
120
121
LDAP_BEGIN_DECL
122
123
#define LDAP_URL_PREFIX "ldap://"
124
#define LDAP_URL_PREFIX_LEN STRLENOF(LDAP_URL_PREFIX)
125
#define PLDAP_URL_PREFIX "pldap://"
126
#define PLDAP_URL_PREFIX_LEN STRLENOF(PLDAP_URL_PREFIX)
127
#define LDAPS_URL_PREFIX "ldaps://"
128
#define LDAPS_URL_PREFIX_LEN STRLENOF(LDAPS_URL_PREFIX)
129
#define PLDAPS_URL_PREFIX "pldaps://"
130
#define PLDAPS_URL_PREFIX_LEN STRLENOF(PLDAPS_URL_PREFIX)
131
#define LDAPI_URL_PREFIX "ldapi://"
132
#define LDAPI_URL_PREFIX_LEN STRLENOF(LDAPI_URL_PREFIX)
133
#ifdef LDAP_CONNECTIONLESS
134
#define LDAPC_URL_PREFIX "cldap://"
135
#define LDAPC_URL_PREFIX_LEN STRLENOF(LDAPC_URL_PREFIX)
136
#endif
137
#define LDAP_URL_URLCOLON "URL:"
138
#define LDAP_URL_URLCOLON_LEN STRLENOF(LDAP_URL_URLCOLON)
139
140
#define LDAP_REF_STR "Referral:\n"
141
#define LDAP_REF_STR_LEN STRLENOF(LDAP_REF_STR)
142
#define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
143
#define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
144
145
#define LDAP_DEFAULT_REFHOPLIMIT 5
146
147
#define LDAP_BOOL_REFERRALS 0
148
#define LDAP_BOOL_RESTART 1
149
#define LDAP_BOOL_TLS 3
150
#define LDAP_BOOL_CONNECT_ASYNC 4
151
#define LDAP_BOOL_SASL_NOCANON 5
152
#define LDAP_BOOL_KEEPCONN 6
153
154
#define LDAP_BOOLEANS unsigned long
155
#define LDAP_BOOL(n) ((LDAP_BOOLEANS)1 << (n))
156
#define LDAP_BOOL_GET(lo, bool) \
157
((lo)->ldo_booleans & LDAP_BOOL(bool) ? -1 : 0)
158
#define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool))
159
#define LDAP_BOOL_CLR(lo, bool) ((lo)->ldo_booleans &= ~LDAP_BOOL(bool))
160
#define LDAP_BOOL_ZERO(lo) ((lo)->ldo_booleans = 0)
161
162
/*
163
* This structure represents both ldap messages and ldap responses.
164
* These are really the same, except in the case of search responses,
165
* where a response has multiple messages.
166
*/
167
168
struct ldapmsg {
169
ber_int_t lm_msgid; /* the message id */
170
ber_tag_t lm_msgtype; /* the message type */
171
BerElement *lm_ber; /* the ber encoded message contents */
172
struct ldapmsg *lm_chain; /* for search - next msg in the resp */
173
struct ldapmsg *lm_chain_tail;
174
struct ldapmsg *lm_next; /* next response */
175
time_t lm_time; /* used to maintain cache */
176
};
177
178
#ifdef HAVE_TLS
179
struct ldaptls {
180
char *lt_certfile;
181
char *lt_keyfile;
182
char *lt_dhfile;
183
char *lt_cacertfile;
184
char *lt_cacertdir;
185
char *lt_ciphersuite;
186
char *lt_crlfile;
187
char *lt_randfile; /* OpenSSL only */
188
char *lt_ecname; /* OpenSSL only */
189
int lt_protocol_min;
190
int lt_protocol_max;
191
struct berval lt_cacert;
192
struct berval lt_cert;
193
struct berval lt_key;
194
};
195
#endif
196
197
typedef struct ldaplist {
198
struct ldaplist *ll_next;
199
void *ll_data;
200
} ldaplist;
201
202
/*
203
* LDAP Client Source IP structure
204
*/
205
typedef struct ldapsourceip {
206
char *local_ip_addrs;
207
struct in_addr ip4_addr;
208
unsigned short has_ipv4;
209
#ifdef LDAP_PF_INET6
210
struct in6_addr ip6_addr;
211
unsigned short has_ipv6;
212
#endif
213
} ldapsourceip;
214
215
/*
216
* structure representing get/set'able options
217
* which have global defaults.
218
* Protect access to this struct with ldo_mutex
219
* ldap_log.h:ldapoptions_prefix must match the head of this struct.
220
*/
221
struct ldapoptions {
222
short ldo_valid;
223
#define LDAP_UNINITIALIZED 0x0
224
#define LDAP_INITIALIZED 0x1
225
#define LDAP_VALID_SESSION 0x2
226
#define LDAP_TRASHED_SESSION 0xFF
227
int ldo_debug;
228
229
ber_int_t ldo_version;
230
ber_int_t ldo_deref;
231
ber_int_t ldo_timelimit;
232
ber_int_t ldo_sizelimit;
233
234
/* per API call timeout */
235
struct timeval ldo_tm_api;
236
struct timeval ldo_tm_net;
237
238
LDAPURLDesc *ldo_defludp;
239
int ldo_defport;
240
char* ldo_defbase;
241
char* ldo_defbinddn; /* bind dn */
242
243
/*
244
* Per connection tcp-keepalive settings (Linux only,
245
* ignored where unsupported)
246
*/
247
ber_int_t ldo_keepalive_idle;
248
ber_int_t ldo_keepalive_probes;
249
ber_int_t ldo_keepalive_interval;
250
251
/*
252
* Per connection tcp user timeout (Linux >= 2.6.37 only,
253
* ignored where unsupported)
254
*/
255
ber_uint_t ldo_tcp_user_timeout;
256
257
int ldo_refhoplimit; /* limit on referral nesting */
258
259
/* LDAPv3 server and client controls */
260
LDAPControl **ldo_sctrls;
261
LDAPControl **ldo_cctrls;
262
263
/* LDAP rebind callback function */
264
LDAP_REBIND_PROC *ldo_rebind_proc;
265
void *ldo_rebind_params;
266
LDAP_NEXTREF_PROC *ldo_nextref_proc;
267
void *ldo_nextref_params;
268
LDAP_URLLIST_PROC *ldo_urllist_proc;
269
void *ldo_urllist_params;
270
271
/* LDAP connection callback stack */
272
ldaplist *ldo_conn_cbs;
273
274
LDAP_BOOLEANS ldo_booleans; /* boolean options */
275
276
#define LDAP_LDO_NULLARG ,0,0,0,0 ,{0},{0} ,0,0,0,0, 0,0,0,0,0, 0,0, 0,0,0,0,0,0, 0, 0
277
278
/* LDAP user configured bind IPs */
279
struct ldapsourceip ldo_local_ip_addrs;
280
281
#ifdef LDAP_PF_INET6
282
#define LDAP_LDO_SOURCEIP_NULLARG ,{0,0,0,0,0}
283
#else
284
#define LDAP_LDO_SOURCEIP_NULLARG ,{0,0,0}
285
#endif
286
287
#ifdef LDAP_CONNECTIONLESS
288
#define LDAP_IS_UDP(ld) ((ld)->ld_options.ldo_is_udp)
289
void* ldo_peer; /* struct sockaddr* */
290
char* ldo_cldapdn;
291
int ldo_is_udp;
292
#define LDAP_LDO_CONNECTIONLESS_NULLARG ,0,0,0
293
#else
294
#define LDAP_LDO_CONNECTIONLESS_NULLARG
295
#endif
296
297
#ifdef HAVE_TLS
298
/* tls context */
299
void *ldo_tls_ctx;
300
LDAP_TLS_CONNECT_CB *ldo_tls_connect_cb;
301
void* ldo_tls_connect_arg;
302
struct ldaptls ldo_tls_info;
303
#define ldo_tls_certfile ldo_tls_info.lt_certfile
304
#define ldo_tls_keyfile ldo_tls_info.lt_keyfile
305
#define ldo_tls_dhfile ldo_tls_info.lt_dhfile
306
#define ldo_tls_ecname ldo_tls_info.lt_ecname
307
#define ldo_tls_cacertfile ldo_tls_info.lt_cacertfile
308
#define ldo_tls_cacertdir ldo_tls_info.lt_cacertdir
309
#define ldo_tls_ciphersuite ldo_tls_info.lt_ciphersuite
310
#define ldo_tls_protocol_min ldo_tls_info.lt_protocol_min
311
#define ldo_tls_protocol_max ldo_tls_info.lt_protocol_max
312
#define ldo_tls_crlfile ldo_tls_info.lt_crlfile
313
#define ldo_tls_randfile ldo_tls_info.lt_randfile
314
#define ldo_tls_cacert ldo_tls_info.lt_cacert
315
#define ldo_tls_cert ldo_tls_info.lt_cert
316
#define ldo_tls_key ldo_tls_info.lt_key
317
int ldo_tls_mode;
318
int ldo_tls_require_cert;
319
int ldo_tls_impl;
320
int ldo_tls_crlcheck;
321
int ldo_tls_require_san;
322
char *ldo_tls_pin_hashalg;
323
struct berval ldo_tls_pin;
324
#define LDAP_LDO_TLS_NULLARG ,0,0,0,{0,0,0,0,0,0,0,0,0},0,0,0,0,0,0,{0,0}
325
#else
326
#define LDAP_LDO_TLS_NULLARG
327
#endif
328
329
#ifdef HAVE_CYRUS_SASL
330
char* ldo_def_sasl_mech; /* SASL Mechanism(s) */
331
char* ldo_def_sasl_realm; /* SASL realm */
332
char* ldo_def_sasl_authcid; /* SASL authentication identity */
333
char* ldo_def_sasl_authzid; /* SASL authorization identity */
334
335
/* SASL Security Properties */
336
struct sasl_security_properties ldo_sasl_secprops;
337
int ldo_sasl_cbinding;
338
#define LDAP_LDO_SASL_NULLARG ,0,0,0,0,{0},0
339
#else
340
#define LDAP_LDO_SASL_NULLARG
341
#endif
342
343
#ifdef LDAP_R_COMPILE
344
ldap_pvt_thread_mutex_t ldo_mutex;
345
#define LDAP_LDO_MUTEX_NULLARG , LDAP_PVT_MUTEX_NULL
346
#else
347
#define LDAP_LDO_MUTEX_NULLARG
348
#endif
349
};
350
351
352
/*
353
* structure for representing an LDAP server connection
354
*/
355
typedef struct ldap_conn {
356
Sockbuf *lconn_sb;
357
#ifdef HAVE_CYRUS_SASL
358
void *lconn_sasl_authctx; /* context for bind */
359
void *lconn_sasl_sockctx; /* for security layer */
360
void *lconn_sasl_cbind; /* for channel binding */
361
#endif
362
int lconn_refcnt;
363
time_t lconn_created; /* time */
364
time_t lconn_lastused; /* time */
365
int lconn_rebind_inprogress; /* set if rebind in progress */
366
char ***lconn_rebind_queue; /* used if rebind in progress */
367
int lconn_status;
368
#define LDAP_CONNST_NEEDSOCKET 1
369
#define LDAP_CONNST_CONNECTING 2
370
#define LDAP_CONNST_CONNECTED 3
371
LDAPURLDesc *lconn_server;
372
BerElement *lconn_ber; /* ber receiving on this conn. */
373
374
struct ldap_conn *lconn_next;
375
} LDAPConn;
376
377
378
/*
379
* structure used to track outstanding requests
380
*/
381
typedef struct ldapreq {
382
ber_int_t lr_msgid; /* the message id */
383
int lr_status; /* status of request */
384
#define LDAP_REQST_COMPLETED 0
385
#define LDAP_REQST_INPROGRESS 1
386
#define LDAP_REQST_CHASINGREFS 2
387
#define LDAP_REQST_NOTCONNECTED 3
388
#define LDAP_REQST_WRITING 4
389
int lr_refcnt; /* count of references */
390
int lr_outrefcnt; /* count of outstanding referrals */
391
int lr_abandoned; /* the request has been abandoned */
392
ber_int_t lr_origid; /* original request's message id */
393
int lr_parentcnt; /* count of parent requests */
394
ber_tag_t lr_res_msgtype; /* result message type */
395
ber_int_t lr_res_errno; /* result LDAP errno */
396
char *lr_res_error; /* result error string */
397
char *lr_res_matched;/* result matched DN string */
398
BerElement *lr_ber; /* ber encoded request contents */
399
LDAPConn *lr_conn; /* connection used to send request */
400
struct berval lr_dn; /* DN of request, in lr_ber */
401
struct ldapreq *lr_parent; /* request that spawned this referral */
402
struct ldapreq *lr_child; /* first child request */
403
struct ldapreq *lr_refnext; /* next referral spawned */
404
struct ldapreq *lr_prev; /* previous request */
405
struct ldapreq *lr_next; /* next request */
406
} LDAPRequest;
407
408
/*
409
* structure for client cache
410
*/
411
#define LDAP_CACHE_BUCKETS 31 /* cache hash table size */
412
typedef struct ldapcache {
413
LDAPMessage *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
414
LDAPMessage *lc_requests; /* unfulfilled reqs */
415
long lc_timeout; /* request timeout */
416
ber_len_t lc_maxmem; /* memory to use */
417
ber_len_t lc_memused; /* memory in use */
418
int lc_enabled; /* enabled? */
419
unsigned long lc_options; /* options */
420
#define LDAP_CACHE_OPT_CACHENOERRS 0x00000001
421
#define LDAP_CACHE_OPT_CACHEALLERRS 0x00000002
422
} LDAPCache;
423
424
/*
425
* structure containing referral request info for rebind procedure
426
*/
427
typedef struct ldapreqinfo {
428
ber_len_t ri_msgid;
429
int ri_request;
430
char *ri_url;
431
} LDAPreqinfo;
432
433
/*
434
* structure representing an ldap connection
435
*/
436
437
struct ldap_common {
438
Sockbuf *ldc_sb; /* socket descriptor & buffer */
439
#define ld_sb ldc->ldc_sb
440
441
unsigned short ldc_lberoptions;
442
#define ld_lberoptions ldc->ldc_lberoptions
443
444
/* protected by msgid_mutex */
445
ber_len_t ldc_msgid;
446
#define ld_msgid ldc->ldc_msgid
447
448
/* do not mess with these */
449
/* protected by req_mutex */
450
TAvlnode *ldc_requests; /* list of outstanding requests */
451
/* protected by res_mutex */
452
LDAPMessage *ldc_responses; /* list of outstanding responses */
453
#define ld_requests ldc->ldc_requests
454
#define ld_responses ldc->ldc_responses
455
456
/* protected by abandon_mutex */
457
ber_len_t ldc_nabandoned;
458
ber_int_t *ldc_abandoned; /* array of abandoned requests */
459
#define ld_nabandoned ldc->ldc_nabandoned
460
#define ld_abandoned ldc->ldc_abandoned
461
462
/* unused by libldap */
463
LDAPCache *ldc_cache; /* non-null if cache is initialized */
464
#define ld_cache ldc->ldc_cache
465
466
/* do not mess with the rest though */
467
468
/* protected by conn_mutex */
469
LDAPConn *ldc_defconn; /* default connection */
470
#define ld_defconn ldc->ldc_defconn
471
LDAPConn *ldc_conns; /* list of server connections */
472
#define ld_conns ldc->ldc_conns
473
void *ldc_selectinfo;/* platform specifics for select */
474
#define ld_selectinfo ldc->ldc_selectinfo
475
476
/* ldap_common refcnt - free only if 0 */
477
/* protected by ldc_mutex */
478
unsigned int ldc_refcnt;
479
#define ld_ldcrefcnt ldc->ldc_refcnt
480
481
/* protected by ldo_mutex */
482
struct ldapoptions ldc_options;
483
#define ld_options ldc->ldc_options
484
485
#define ld_valid ld_options.ldo_valid
486
#define ld_debug ld_options.ldo_debug
487
488
#define ld_deref ld_options.ldo_deref
489
#define ld_timelimit ld_options.ldo_timelimit
490
#define ld_sizelimit ld_options.ldo_sizelimit
491
492
#define ld_defbinddn ld_options.ldo_defbinddn
493
#define ld_defbase ld_options.ldo_defbase
494
#define ld_defhost ld_options.ldo_defhost
495
#define ld_defport ld_options.ldo_defport
496
497
#define ld_refhoplimit ld_options.ldo_refhoplimit
498
499
#define ld_sctrls ld_options.ldo_sctrls
500
#define ld_cctrls ld_options.ldo_cctrls
501
#define ld_rebind_proc ld_options.ldo_rebind_proc
502
#define ld_rebind_params ld_options.ldo_rebind_params
503
#define ld_nextref_proc ld_options.ldo_nextref_proc
504
#define ld_nextref_params ld_options.ldo_nextref_params
505
#define ld_urllist_proc ld_options.ldo_urllist_proc
506
#define ld_urllist_params ld_options.ldo_urllist_params
507
508
#define ld_version ld_options.ldo_version
509
510
#ifdef LDAP_R_COMPILE
511
ldap_pvt_thread_mutex_t ldc_mutex;
512
ldap_pvt_thread_mutex_t ldc_msgid_mutex;
513
ldap_pvt_thread_mutex_t ldc_conn_mutex;
514
ldap_pvt_thread_mutex_t ldc_req_mutex;
515
ldap_pvt_thread_mutex_t ldc_res_mutex;
516
ldap_pvt_thread_mutex_t ldc_abandon_mutex;
517
#define ld_ldopts_mutex ld_options.ldo_mutex
518
#define ld_ldcmutex ldc->ldc_mutex
519
#define ld_msgid_mutex ldc->ldc_msgid_mutex
520
#define ld_conn_mutex ldc->ldc_conn_mutex
521
#define ld_req_mutex ldc->ldc_req_mutex
522
#define ld_res_mutex ldc->ldc_res_mutex
523
#define ld_abandon_mutex ldc->ldc_abandon_mutex
524
#endif
525
};
526
527
struct ldap {
528
/* thread shared */
529
struct ldap_common *ldc;
530
531
/* thread specific */
532
ber_int_t ld_errno;
533
char *ld_error;
534
char *ld_matched;
535
char **ld_referrals;
536
};
537
538
#define LDAP_VALID(ld) ( (ld)->ld_valid == LDAP_VALID_SESSION )
539
#define LDAP_TRASHED(ld) ( (ld)->ld_valid == LDAP_TRASHED_SESSION )
540
#define LDAP_TRASH(ld) ( (ld)->ld_valid = LDAP_TRASHED_SESSION )
541
542
#ifdef LDAP_R_COMPILE
543
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
544
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_hostname_mutex;
545
LDAP_V ( int ) ldap_int_stackguard;
546
547
#endif
548
549
#ifdef LDAP_R_COMPILE
550
#define LDAP_MUTEX_LOCK(mutex) ldap_pvt_thread_mutex_lock( mutex )
551
#define LDAP_MUTEX_UNLOCK(mutex) ldap_pvt_thread_mutex_unlock( mutex )
552
#define LDAP_ASSERT_MUTEX_OWNER(mutex) \
553
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex)
554
#else
555
#define LDAP_MUTEX_LOCK(mutex) ((void) 0)
556
#define LDAP_MUTEX_UNLOCK(mutex) ((void) 0)
557
#define LDAP_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
558
#endif
559
560
#define LDAP_NEXT_MSGID(ld, id) do { \
561
LDAP_MUTEX_LOCK( &(ld)->ld_msgid_mutex ); \
562
(id) = ++(ld)->ld_msgid; \
563
LDAP_MUTEX_UNLOCK( &(ld)->ld_msgid_mutex ); \
564
} while (0)
565
566
/*
567
* in abandon.c
568
*/
569
570
LDAP_F (int)
571
ldap_int_bisect_find( ber_int_t *v, ber_len_t n, ber_int_t id, int *idxp );
572
LDAP_F (int)
573
ldap_int_bisect_insert( ber_int_t **vp, ber_len_t *np, int id, int idx );
574
LDAP_F (int)
575
ldap_int_bisect_delete( ber_int_t **vp, ber_len_t *np, int id, int idx );
576
577
/*
578
* in add.c
579
*/
580
581
LDAP_F (BerElement *) ldap_build_add_req LDAP_P((
582
LDAP *ld,
583
const char *dn,
584
LDAPMod **attrs,
585
LDAPControl **sctrls,
586
LDAPControl **cctrls,
587
ber_int_t *msgidp ));
588
589
/*
590
* in lbase64.c
591
*/
592
593
LDAP_F (int) ldap_int_decode_b64_inplace LDAP_P((
594
struct berval *value ));
595
596
/*
597
* in compare.c
598
*/
599
600
LDAP_F (BerElement *) ldap_build_compare_req LDAP_P((
601
LDAP *ld,
602
const char *dn,
603
const char *attr,
604
struct berval *bvalue,
605
LDAPControl **sctrls,
606
LDAPControl **cctrls,
607
ber_int_t *msgidp ));
608
609
/*
610
* in delete.c
611
*/
612
613
LDAP_F (BerElement *) ldap_build_delete_req LDAP_P((
614
LDAP *ld,
615
const char *dn,
616
LDAPControl **sctrls,
617
LDAPControl **cctrls,
618
ber_int_t *msgidp ));
619
620
/*
621
* in extended.c
622
*/
623
624
LDAP_F (BerElement *) ldap_build_extended_req LDAP_P((
625
LDAP *ld,
626
const char *reqoid,
627
struct berval *reqdata,
628
LDAPControl **sctrls,
629
LDAPControl **cctrls,
630
ber_int_t *msgidp ));
631
632
/*
633
* in init.c
634
*/
635
636
LDAP_V ( struct ldapoptions ) ldap_int_global_options;
637
638
LDAP_F ( void ) ldap_int_initialize LDAP_P((struct ldapoptions *, int *));
639
LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P((
640
struct ldapoptions *, int *));
641
642
/* memory.c */
643
/* simple macros to realloc for now */
644
#define LDAP_MALLOC(s) (ber_memalloc_x((s),NULL))
645
#define LDAP_CALLOC(n,s) (ber_memcalloc_x((n),(s),NULL))
646
#define LDAP_REALLOC(p,s) (ber_memrealloc_x((p),(s),NULL))
647
#define LDAP_FREE(p) (ber_memfree_x((p),NULL))
648
#define LDAP_VFREE(v) (ber_memvfree_x((void **)(v),NULL))
649
#define LDAP_STRDUP(s) (ber_strdup_x((s),NULL))
650
#define LDAP_STRNDUP(s,l) (ber_strndup_x((s),(l),NULL))
651
652
#define LDAP_MALLOCX(s,x) (ber_memalloc_x((s),(x)))
653
#define LDAP_CALLOCX(n,s,x) (ber_memcalloc_x((n),(s),(x)))
654
#define LDAP_REALLOCX(p,s,x) (ber_memrealloc_x((p),(s),(x)))
655
#define LDAP_FREEX(p,x) (ber_memfree_x((p),(x)))
656
#define LDAP_VFREEX(v,x) (ber_memvfree_x((void **)(v),(x)))
657
#define LDAP_STRDUPX(s,x) (ber_strdup_x((s),(x)))
658
#define LDAP_STRNDUPX(s,l,x) (ber_strndup_x((s),(l),(x)))
659
660
/*
661
* in error.c
662
*/
663
LDAP_F (void) ldap_int_error_init( void );
664
665
/*
666
* in modify.c
667
*/
668
669
LDAP_F (BerElement *) ldap_build_modify_req LDAP_P((
670
LDAP *ld,
671
const char *dn,
672
LDAPMod **mods,
673
LDAPControl **sctrls,
674
LDAPControl **cctrls,
675
ber_int_t *msgidp ));
676
677
/*
678
* in modrdn.c
679
*/
680
681
LDAP_F (BerElement *) ldap_build_moddn_req LDAP_P((
682
LDAP *ld,
683
const char *dn,
684
const char *newrdn,
685
const char *newSuperior,
686
int deleteoldrdn,
687
LDAPControl **sctrls,
688
LDAPControl **cctrls,
689
ber_int_t *msgidp ));
690
691
/*
692
* in unit-int.c
693
*/
694
LDAP_F (void) ldap_int_utils_init LDAP_P(( void ));
695
696
697
/*
698
* in print.c
699
*/
700
LDAP_F (int) ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...)) LDAP_GCCATTR((format(printf, 3, 4)));
701
702
/*
703
* in controls.c
704
*/
705
LDAP_F (int) ldap_int_put_controls LDAP_P((
706
LDAP *ld,
707
LDAPControl *const *ctrls,
708
BerElement *ber ));
709
710
LDAP_F (int) ldap_int_client_controls LDAP_P((
711
LDAP *ld,
712
LDAPControl **ctrlp ));
713
714
/*
715
* in dsparse.c
716
*/
717
LDAP_F (int) ldap_int_next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp ));
718
719
720
/*
721
* in open.c
722
*/
723
LDAP_F (int) ldap_open_defconn( LDAP *ld );
724
LDAP_F (int) ldap_int_open_connection( LDAP *ld,
725
LDAPConn *conn, LDAPURLDesc *srvlist, int async );
726
LDAP_F (int) ldap_int_check_async_open( LDAP *ld, ber_socket_t sd );
727
728
/*
729
* in os-ip.c
730
*/
731
#ifndef HAVE_POLL
732
LDAP_V (int) ldap_int_tblsize;
733
LDAP_F (void) ldap_int_ip_init( void );
734
#endif
735
736
LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest,
737
const struct timeval *tm );
738
LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb,
739
int proto, LDAPURLDesc *srv, int async );
740
LDAP_F (int) ldap_int_poll( LDAP *ld, ber_socket_t s,
741
struct timeval *tvp, int wr );
742
743
#if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
744
LDAP_V (char *) ldap_int_hostname;
745
LDAP_F (char *) ldap_host_connected_to( Sockbuf *sb,
746
const char *host );
747
#endif
748
749
LDAP_F (int) ldap_int_select( LDAP *ld, struct timeval *timeout );
750
LDAP_F (void *) ldap_new_select_info( void );
751
LDAP_F (void) ldap_free_select_info( void *sip );
752
LDAP_F (void) ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
753
LDAP_F (void) ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
754
LDAP_F (void) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
755
LDAP_F (void) ldap_clear_select_write( LDAP *ld, Sockbuf *sb );
756
LDAP_F (int) ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
757
LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
758
759
LDAP_F (int) ldap_validate_and_fill_sourceip ( char** source_ip_lst,
760
ldapsourceip* temp_source_ip );
761
762
LDAP_F (int) ldap_int_connect_cbs( LDAP *ld, Sockbuf *sb,
763
ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr );
764
765
/*
766
* in os-local.c
767
*/
768
#ifdef LDAP_PF_LOCAL
769
LDAP_F (int) ldap_connect_to_path( LDAP *ld, Sockbuf *sb,
770
LDAPURLDesc *srv, int async );
771
#endif /* LDAP_PF_LOCAL */
772
773
/*
774
* in request.c
775
*/
776
LDAP_F (ber_int_t) ldap_send_initial_request( LDAP *ld, ber_tag_t msgtype,
777
const char *dn, BerElement *ber, ber_int_t msgid );
778
LDAP_F (BerElement *) ldap_alloc_ber_with_options( LDAP *ld );
779
LDAP_F (void) ldap_set_ber_options( LDAP *ld, BerElement *ber );
780
781
LDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber,
782
ber_int_t msgid, LDAPRequest *parentreq, LDAPURLDesc **srvlist,
783
LDAPConn *lc, LDAPreqinfo *bind, int noconn, int m_res );
784
LDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist,
785
int use_ldsb, int connect, LDAPreqinfo *bind, int m_req, int m_res );
786
LDAP_F (LDAPRequest *) ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
787
LDAP_F (void) ldap_return_request( LDAP *ld, LDAPRequest *lr, int freeit );
788
LDAP_F (int) ldap_req_cmp( const void *l, const void *r );
789
LDAP_F (void) ldap_do_free_request( void *arg );
790
LDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
791
LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
792
LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
793
LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld );
794
LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
795
char **errstrp, int sref, int *hadrefp );
796
LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
797
char **refs, int sref, char **referralsp, int *hadrefp );
798
LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
799
LDAP_F (int) ldap_int_flush_request( LDAP *ld, LDAPRequest *lr );
800
801
/*
802
* in result.c:
803
*/
804
LDAP_F (const char *) ldap_int_msgtype2str( ber_tag_t tag );
805
806
/*
807
* in search.c
808
*/
809
LDAP_F (BerElement *) ldap_build_search_req LDAP_P((
810
LDAP *ld,
811
const char *base,
812
ber_int_t scope,
813
const char *filter,
814
char **attrs,
815
ber_int_t attrsonly,
816
LDAPControl **sctrls,
817
LDAPControl **cctrls,
818
ber_int_t timelimit,
819
ber_int_t sizelimit,
820
ber_int_t deref,
821
ber_int_t *msgidp));
822
823
824
/*
825
* in unbind.c
826
*/
827
LDAP_F (int) ldap_ld_free LDAP_P((
828
LDAP *ld,
829
int close,
830
LDAPControl **sctrls,
831
LDAPControl **cctrls ));
832
833
LDAP_F (int) ldap_send_unbind LDAP_P((
834
LDAP *ld,
835
Sockbuf *sb,
836
LDAPControl **sctrls,
837
LDAPControl **cctrls ));
838
839
/*
840
* in url.c
841
*/
842
LDAP_F (LDAPURLDesc *) ldap_url_dup LDAP_P((
843
LDAPURLDesc *ludp ));
844
845
LDAP_F (LDAPURLDesc *) ldap_url_duplist LDAP_P((
846
LDAPURLDesc *ludlist ));
847
848
LDAP_F (int) ldap_url_parsehosts LDAP_P((
849
LDAPURLDesc **ludlist,
850
const char *hosts,
851
int port ));
852
853
LDAP_F (char *) ldap_url_list2hosts LDAP_P((
854
LDAPURLDesc *ludlist ));
855
856
/*
857
* in cyrus.c
858
*/
859
860
LDAP_F (int) ldap_int_sasl_init LDAP_P(( void ));
861
862
LDAP_F (int) ldap_int_sasl_open LDAP_P((
863
LDAP *ld, LDAPConn *conn,
864
const char* host ));
865
LDAP_F (int) ldap_int_sasl_close LDAP_P(( LDAP *ld, LDAPConn *conn ));
866
867
LDAP_F (int) ldap_int_sasl_external LDAP_P((
868
LDAP *ld, LDAPConn *conn,
869
const char* authid, ber_len_t ssf ));
870
871
LDAP_F (int) ldap_int_sasl_get_option LDAP_P(( LDAP *ld,
872
int option, void *arg ));
873
LDAP_F (int) ldap_int_sasl_set_option LDAP_P(( LDAP *ld,
874
int option, void *arg ));
875
LDAP_F (int) ldap_int_sasl_config LDAP_P(( struct ldapoptions *lo,
876
int option, const char *arg ));
877
878
LDAP_F (int) ldap_int_sasl_bind LDAP_P((
879
LDAP *ld,
880
const char *,
881
const char *,
882
LDAPControl **, LDAPControl **,
883
884
/* should be passed in client controls */
885
unsigned flags,
886
LDAP_SASL_INTERACT_PROC *interact,
887
void *defaults,
888
LDAPMessage *result,
889
const char **rmech,
890
int *msgid ));
891
892
/* in sasl.c */
893
894
LDAP_F (BerElement *) ldap_build_bind_req LDAP_P((
895
LDAP *ld,
896
const char *dn,
897
const char *mech,
898
struct berval *cred,
899
LDAPControl **sctrls,
900
LDAPControl **cctrls,
901
ber_int_t *msgidp ));
902
903
/* in schema.c */
904
LDAP_F (char *) ldap_int_parse_numericoid LDAP_P((
905
const char **sp,
906
int *code,
907
const int flags ));
908
909
/*
910
* in tls.c
911
*/
912
LDAP_F (int) ldap_int_tls_start LDAP_P(( LDAP *ld,
913
LDAPConn *conn, LDAPURLDesc *srv ));
914
915
LDAP_F (void) ldap_int_tls_destroy LDAP_P(( struct ldapoptions *lo ));
916
917
/*
918
* in getvalues.c
919
*/
920
LDAP_F (char **) ldap_value_dup LDAP_P((
921
char *const *vals ));
922
923
LDAP_END_DECL
924
925
#endif /* _LDAP_INT_H */
926
927