slap.h 67.6 KB
Newer Older
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1
/* slap.h - stand alone ldap server include file */
2
/* $OpenLDAP$ */
3
/*
Kurt Zeilenga's avatar
Kurt Zeilenga committed
4
 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5
6
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
7

Kurt Zeilenga's avatar
Kurt Zeilenga committed
8
9
#ifndef _SLAP_H_
#define _SLAP_H_
Kurt Zeilenga's avatar
Kurt Zeilenga committed
10

11
12
#include "ldap_defaults.h"

13
#include <stdio.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
14
#include <ac/stdlib.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
15

16
#include <sys/types.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
17
18
#include <ac/syslog.h>
#include <ac/regex.h>
Howard Chu's avatar
Howard Chu committed
19
#include <ac/signal.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
20
#include <ac/socket.h>
21
#include <ac/time.h>
22
#include <ac/param.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
23

Kurt Zeilenga's avatar
Kurt Zeilenga committed
24
#include "avl.h"
25
26
27
28
29
30
31

#ifndef ldap_debug
#define ldap_debug slap_debug
#endif

#include "ldap_log.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
32
33
#include <ldap.h>
#include <ldap_schema.h>
34

35
#include "lber_pvt.h"
36
#include "ldap_pvt_thread.h"
37
#include "ldap_queue.h"
38

Kurt Zeilenga's avatar
Kurt Zeilenga committed
39
40
#define SLAP_EXTENDED_SCHEMA 1

41
LDAP_BEGIN_DECL
Kurt Zeilenga's avatar
Kurt Zeilenga committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * SLAPD Memory allocation macros
 *
 * Unlike ch_*() routines, these routines do not assert() upon
 * allocation error.  They are intended to be used instead of
 * ch_*() routines where the caller has implemented proper
 * checking for and handling of allocation errors.
 *
 * Patches to convert ch_*() calls to SLAP_*() calls welcomed.
 */
#define SLAP_MALLOC(s)      ber_memalloc((s))
#define SLAP_CALLOC(n,s)    ber_memcalloc((n),(s))
#define SLAP_REALLOC(p,s)   ber_memrealloc((p),(s))
#define SLAP_FREE(p)        ber_memfree((p))
#define SLAP_VFREE(v)       ber_memvfree((void**)(v))
#define SLAP_STRDUP(s)      ber_strdup((s))
#define SLAP_STRNDUP(s,l)   ber_strndup((s),(l))
59

Hallvard Furuseth's avatar
Hallvard Furuseth committed
60
61
62
#ifdef f_next
#undef f_next /* name conflict between sys/file.h on SCO and struct filter */
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
63

Kurt Zeilenga's avatar
Kurt Zeilenga committed
64
65
66
#define SERVICE_NAME  OPENLDAP_PACKAGE "-slapd"
#define SLAPD_ANONYMOUS "cn=anonymous"

Juan Gomez's avatar
Juan Gomez committed
67
68
69
70
71
/* LDAPMod.mod_op value ===> Must be kept in sync with ldap.h!
 * This is a value used internally by the backends. It is needed to allow
 * adding values that already exist without getting an error as required by
 * modrdn when the new rdn was already an attribute value itself.
 */
72
#define SLAP_MOD_SOFTADD	0x1000
Juan Gomez's avatar
Juan Gomez committed
73

74
#define MAXREMATCHES (100)
75

76
#define SLAP_MAX_WORKER_THREADS		(16)
77

78
79
#define SLAP_MAX_SYNCREPL_THREADS	(8)

Kurt Zeilenga's avatar
Kurt Zeilenga committed
80
81
82
#define SLAP_SB_MAX_INCOMING_DEFAULT ((1<<18) - 1)
#define SLAP_SB_MAX_INCOMING_AUTH ((1<<24) - 1)

83
84
85
#define SLAP_CONN_MAX_PENDING_DEFAULT	100
#define SLAP_CONN_MAX_PENDING_AUTH	1000

86
#define SLAP_TEXT_BUFLEN (256)
87
88

/* psuedo error code indicating abandoned operation */
89
90
91
92
#define SLAPD_ABANDON (-1)

/* psuedo error code indicating disconnect */
#define SLAPD_DISCONNECT (-2)
93

94

95
96
/* We assume "C" locale, that is US-ASCII */
#define ASCII_SPACE(c)	( (c) == ' ' )
97
98
99
100
101
#define ASCII_LOWER(c)	( (c) >= 'a' && (c) <= 'z' )
#define ASCII_UPPER(c)	( (c) >= 'A' && (c) <= 'Z' )
#define ASCII_ALPHA(c)	( ASCII_LOWER(c) || ASCII_UPPER(c) )
#define ASCII_DIGIT(c)	( (c) >= '0' && (c) <= '9' )
#define ASCII_ALNUM(c)	( ASCII_ALPHA(c) || ASCII_DIGIT(c) )
102
#define ASCII_PRINTABLE(c) ( (c) >= ' ' && (c) <= '~' )
103
104
105
106
107
108
109
110

#define SLAP_NIBBLE(c) ((c)&0x0f)
#define SLAP_ESCAPE_CHAR ('\\')
#define SLAP_ESCAPE_LO(c) ( "0123456789ABCDEF"[SLAP_NIBBLE(c)] )
#define SLAP_ESCAPE_HI(c) ( SLAP_ESCAPE_LO((c)>>4) )

#define FILTER_ESCAPE(c) ( (c) == '*' || (c) == '\\' \
	|| (c) == '(' || (c) == ')' || !ASCII_PRINTABLE(c) )
111

112
#define DN_ESCAPE(c)	((c) == SLAP_ESCAPE_CHAR)
113
#define DN_SEPARATOR(c)	((c) == ',' || (c) == ';')
114
115
#define RDN_ATTRTYPEANDVALUE_SEPARATOR(c) ((c) == '+') /* RFC 2253 */
#define RDN_SEPARATOR(c) (DN_SEPARATOR(c) || RDN_ATTRTYPEANDVALUE_SEPARATOR(c))
116
117
118
119
120
#define RDN_NEEDSESCAPE(c)	((c) == '\\' || (c) == '"')

#define DESC_LEADCHAR(c)	( ASCII_ALPHA(c) )
#define DESC_CHAR(c)	( ASCII_ALNUM(c) || (c) == '-' )
#define OID_LEADCHAR(c)	( ASCII_DIGIT(c) )
121
122
#define OID_SEPARATOR(c)	( (c) == '.' )
#define OID_CHAR(c)	( OID_LEADCHAR(c) || OID_SEPARATOR(c) )
123

124
125
#define ATTR_LEADCHAR(c)	( DESC_LEADCHAR(c) || OID_LEADCHAR(c) )
#define ATTR_CHAR(c)	( DESC_CHAR((c)) || (c) == '.' )
126

127
128
#define AD_LEADCHAR(c)	( ATTR_CHAR(c) )
#define AD_CHAR(c)		( ATTR_CHAR(c) || (c) == ';' )
129

130
131
#define SLAP_NUMERIC(c) ( ASCII_DIGIT(c) || ASCII_SPACE(c) )

132
133
134
#define SLAP_PRINTABLE(c)	( ASCII_ALNUM(c) || (c) == '\'' || \
	(c) == '(' || (c) == ')' || (c) == '+' || (c) == ',' || \
	(c) == '-' || (c) == '.' || (c) == '/' || (c) == ':' || \
135
	(c) == '?' || (c) == ' ' || (c) == '=' )
136
137
#define SLAP_PRINTABLES(c)	( SLAP_PRINTABLE(c) || (c) == '$' )

138
139
/* must match in schema_init.c */
#define SLAPD_DN_SYNTAX			"1.3.6.1.4.1.1466.115.121.1.12"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
140
#define SLAPD_NAMEUID_SYNTAX	"1.3.6.1.4.1.1466.115.121.1.34"
141
#define SLAPD_INTEGER_SYNTAX	"1.3.6.1.4.1.1466.115.121.1.27"
142
143
144
145
146
#define SLAPD_GROUP_ATTR		"member"
#define SLAPD_GROUP_CLASS		"groupOfNames"
#define SLAPD_ROLE_ATTR			"roleOccupant"
#define SLAPD_ROLE_CLASS		"organizationalRole"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
147
#ifdef SLAPD_ACI_ENABLED
148
#define SLAPD_ACI_SYNTAX		"1.3.6.1.4.1.4203.666.2.1"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
149
150
#endif

Mark Valence's avatar
Mark Valence committed
151
152
153
/* change this to "OpenLDAPset" */
#define SLAPD_ACI_SET_ATTR		"template"

154
155
#define SLAPD_TOP_OID			"2.5.6.0"

Howard Chu's avatar
Howard Chu committed
156
LDAP_SLAPD_V (int) slap_debug;
157

158
159
typedef unsigned long slap_mask_t;

160
161
162
163
164
165
166
167
168
169
170
171
/* Security Strength Factor */
typedef unsigned slap_ssf_t;

typedef struct slap_ssf_set {
	slap_ssf_t sss_ssf;
	slap_ssf_t sss_transport;
	slap_ssf_t sss_tls;
	slap_ssf_t sss_sasl;
	slap_ssf_t sss_update_ssf;
	slap_ssf_t sss_update_transport;
	slap_ssf_t sss_update_tls;
	slap_ssf_t sss_update_sasl;
172
	slap_ssf_t sss_simple_bind;
173
} slap_ssf_set_t;
174

175
176
177
178
/* Flags for telling slap_sasl_getdn() what type of identity is being passed */
#define SLAP_GETDN_AUTHCID 2
#define SLAP_GETDN_AUTHZID 4

179
180
181
/*
 * Index types
 */
182
183
184
185
186
187
188
189
190
191
#define SLAP_INDEX_TYPE           0x00FFUL
#define SLAP_INDEX_UNDEFINED      0x0001UL
#define SLAP_INDEX_PRESENT        0x0002UL
#define SLAP_INDEX_EQUALITY       0x0004UL
#define SLAP_INDEX_APPROX         0x0008UL
#define SLAP_INDEX_SUBSTR         0x0010UL
#define SLAP_INDEX_EXTENDED		  0x0020UL

#define SLAP_INDEX_DEFAULT        SLAP_INDEX_EQUALITY

192
#define IS_SLAP_INDEX(mask, type)	(((mask) & (type)) == (type))
193
194
195
196
197
198

#define SLAP_INDEX_SUBSTR_TYPE    0x0F00UL

#define SLAP_INDEX_SUBSTR_INITIAL ( SLAP_INDEX_SUBSTR | 0x0100UL ) 
#define SLAP_INDEX_SUBSTR_ANY     ( SLAP_INDEX_SUBSTR | 0x0200UL )
#define SLAP_INDEX_SUBSTR_FINAL   ( SLAP_INDEX_SUBSTR | 0x0400UL )
199
200
201
202
203
#define SLAP_INDEX_SUBSTR_DEFAULT \
	( SLAP_INDEX_SUBSTR \
	| SLAP_INDEX_SUBSTR_INITIAL \
	| SLAP_INDEX_SUBSTR_ANY \
	| SLAP_INDEX_SUBSTR_FINAL )
204

205
206
#define SLAP_INDEX_SUBSTR_MINLEN	2
#define SLAP_INDEX_SUBSTR_MAXLEN	4
207
#define SLAP_INDEX_SUBSTR_STEP	2
208

209
210
#define SLAP_INDEX_FLAGS         0xF000UL
#define SLAP_INDEX_NOSUBTYPES    0x1000UL /* don't use index w/ subtypes */
211
#define SLAP_INDEX_NOTAGS        0x2000UL /* don't use index w/ tags */
212
213
214
215
216
217
218
219

/*
 * there is a single index for each attribute.  these prefixes ensure
 * that there is no collision among keys.
 */
#define SLAP_INDEX_EQUALITY_PREFIX	'=' 	/* prefix for equality keys     */
#define SLAP_INDEX_APPROX_PREFIX	'~'		/* prefix for approx keys       */
#define SLAP_INDEX_SUBSTR_PREFIX	'*'		/* prefix for substring keys    */
220
221
#define SLAP_INDEX_SUBSTR_INITIAL_PREFIX '^'
#define SLAP_INDEX_SUBSTR_FINAL_PREFIX '$'
222
#define SLAP_INDEX_CONT_PREFIX		'.'		/* prefix for continuation keys */
223

224
225
226
227
228
#define SLAP_SYNTAX_MATCHINGRULES_OID	 "1.3.6.1.4.1.1466.115.121.1.30"
#define SLAP_SYNTAX_ATTRIBUTETYPES_OID	 "1.3.6.1.4.1.1466.115.121.1.3"
#define SLAP_SYNTAX_OBJECTCLASSES_OID	 "1.3.6.1.4.1.1466.115.121.1.37"
#define SLAP_SYNTAX_MATCHINGRULEUSES_OID "1.3.6.1.4.1.1466.115.121.1.31"
#define SLAP_SYNTAX_CONTENTRULE_OID		 "1.3.6.1.4.1.1466.115.121.1.16"
229

230
231
232
/*
 * represents schema information for a database
 */
233
234
235
236
237
238
#define SLAP_SCHERR_OUTOFMEM			1
#define SLAP_SCHERR_CLASS_NOT_FOUND		2
#define SLAP_SCHERR_CLASS_BAD_USAGE		3
#define SLAP_SCHERR_CLASS_BAD_SUP		4
#define SLAP_SCHERR_CLASS_DUP			5
#define SLAP_SCHERR_ATTR_NOT_FOUND		6
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#define SLAP_SCHERR_ATTR_BAD_MR			7
#define SLAP_SCHERR_ATTR_BAD_USAGE		8
#define SLAP_SCHERR_ATTR_BAD_SUP		9
#define SLAP_SCHERR_ATTR_INCOMPLETE		10
#define SLAP_SCHERR_ATTR_DUP			11
#define SLAP_SCHERR_MR_NOT_FOUND		12
#define SLAP_SCHERR_MR_INCOMPLETE		13
#define SLAP_SCHERR_MR_DUP				14
#define SLAP_SCHERR_SYN_NOT_FOUND		15
#define SLAP_SCHERR_SYN_DUP				16
#define SLAP_SCHERR_NO_NAME				17
#define SLAP_SCHERR_NOT_SUPPORTED		18
#define SLAP_SCHERR_BAD_DESCR			19
#define SLAP_SCHERR_OIDM				20
253
254
255
256
257
#define SLAP_SCHERR_CR_DUP				21
#define SLAP_SCHERR_CR_BAD_STRUCT		22
#define SLAP_SCHERR_CR_BAD_AUX			23
#define SLAP_SCHERR_CR_BAD_AT			24
#define SLAP_SCHERR_LAST				SLAP_SCHERR_CR_BAD_AT
Julio Sánchez Fernández's avatar
   
Julio Sánchez Fernández committed
258

259
260
261
262
typedef union slap_sockaddr {
	struct sockaddr sa_addr;
	struct sockaddr_in sa_in_addr;
#ifdef LDAP_PF_INET6
Kurt Zeilenga's avatar
Kurt Zeilenga committed
263
	struct sockaddr_storage sa_storage;
264
265
266
267
268
269
270
	struct sockaddr_in6 sa_in6_addr;
#endif
#ifdef LDAP_PF_LOCAL
	struct sockaddr_un sa_un_addr;
#endif
} Sockaddr;

271
272
273
274
#ifdef LDAP_PF_INET6
extern int slap_inet4or6;
#endif

275
typedef struct slap_oid_macro {
276
	struct berval som_oid;
277
	char **som_names;
278
	LDAP_SLIST_ENTRY(slap_oid_macro) som_next;
279
280
} OidMacro;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
281
282
283
284
/* forward declarations */
struct slap_syntax;
struct slap_matching_rule;

285
typedef int slap_syntax_validate_func LDAP_P((
Kurt Zeilenga's avatar
Kurt Zeilenga committed
286
	struct slap_syntax *syntax,
287
288
	struct berval * in));

Kurt Zeilenga's avatar
Kurt Zeilenga committed
289
290
typedef int slap_syntax_transform_func LDAP_P((
	struct slap_syntax *syntax,
291
	struct berval * in,
Howard Chu's avatar
Howard Chu committed
292
293
	struct berval * out,
	void *memctx));
294
295

typedef struct slap_syntax {
296
	LDAPSyntax			ssyn_syn;
297
298
#define ssyn_oid		ssyn_syn.syn_oid
#define ssyn_desc		ssyn_syn.syn_desc
Kurt Zeilenga's avatar
Kurt Zeilenga committed
299
#define ssyn_extensions	ssyn_syn.syn_extensions
300
301
	/*
	 * Note: the former
302
	ber_len_t	ssyn_oidlen;
303
304
305
306
307
308
309
	 * has been replaced by a struct berval that uses the value
	 * provided by ssyn_syn.syn_oid; a macro that expands to
	 * the bv_len field of the berval is provided for backward
	 * compatibility.  CAUTION: NEVER FREE THE BERVAL
	 */
	struct berval	ssyn_bvoid;
#define	ssyn_oidlen	ssyn_bvoid.bv_len
310

311
	unsigned int ssyn_flags;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
312

313
314
315
316
#define SLAP_SYNTAX_NONE	0x0000U
#define SLAP_SYNTAX_BLOB	0x0001U /* syntax treated as blob (audio) */
#define SLAP_SYNTAX_BINARY	0x0002U /* binary transfer required (certificate) */
#define SLAP_SYNTAX_BER		0x0004U /* stored in BER encoding (certificate) */
317
318
319
#ifdef LDAP_DEVEL
#define SLAP_SYNTAX_HIDE	0x0000U /* publish everything */
#else
320
#define SLAP_SYNTAX_HIDE	0x8000U /* hide (do not publish) */
321
#endif
322

323
	slap_syntax_validate_func	*ssyn_validate;
324
	slap_syntax_transform_func	*ssyn_pretty;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
325

326
#ifdef SLAPD_BINARY_CONVERSION
Kurt Zeilenga's avatar
Kurt Zeilenga committed
327
328
329
	/* convert to and from binary */
	slap_syntax_transform_func	*ssyn_ber2str;
	slap_syntax_transform_func	*ssyn_str2ber;
330
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
331

332
	LDAP_SLIST_ENTRY(slap_syntax) ssyn_next;
333
334
} Syntax;

335
336
337
338
#define slap_syntax_is_flag(s,flag) ((int)((s)->ssyn_flags & (flag)) ? 1 : 0)
#define slap_syntax_is_blob(s)		slap_syntax_is_flag((s),SLAP_SYNTAX_BLOB)
#define slap_syntax_is_binary(s)	slap_syntax_is_flag((s),SLAP_SYNTAX_BINARY)
#define slap_syntax_is_ber(s)		slap_syntax_is_flag((s),SLAP_SYNTAX_BER)
339
#define slap_syntax_is_hidden(s)	slap_syntax_is_flag((s),SLAP_SYNTAX_HIDE)
340

341
342
343
344
345
346
347
348
349
350
351
typedef struct slap_syntax_defs_rec {
	char *sd_desc;
	int sd_flags;
	slap_syntax_validate_func *sd_validate;
	slap_syntax_transform_func *sd_pretty;
#ifdef SLAPD_BINARY_CONVERSION
	slap_syntax_transform_func *sd_ber2str;
	slap_syntax_transform_func *sd_str2ber;
#endif
} slap_syntax_defs_rec;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
352
/* X -> Y Converter */
353
354
typedef int slap_mr_convert_func LDAP_P((
	struct berval * in,
Howard Chu's avatar
Howard Chu committed
355
356
	struct berval * out,
	void *memctx ));
Kurt Zeilenga's avatar
Kurt Zeilenga committed
357
358
359

/* Normalizer */
typedef int slap_mr_normalize_func LDAP_P((
360
	slap_mask_t use,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
361
362
363
	struct slap_syntax *syntax, /* NULL if in is asserted value */
	struct slap_matching_rule *mr,
	struct berval * in,
Howard Chu's avatar
Howard Chu committed
364
365
	struct berval * out,
	void *memctx ));
Kurt Zeilenga's avatar
Kurt Zeilenga committed
366
367

/* Match (compare) function */
368
typedef int slap_mr_match_func LDAP_P((
369
	int *match,
370
	slap_mask_t use,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
371
372
373
	struct slap_syntax *syntax,	/* syntax of stored value */
	struct slap_matching_rule *mr,
	struct berval * value,
374
	void * assertValue ));
375

376
377
/* Index generation function */
typedef int slap_mr_indexer_func LDAP_P((
378
379
	slap_mask_t use,
	slap_mask_t mask,
380
381
	struct slap_syntax *syntax,	/* syntax of stored value */
	struct slap_matching_rule *mr,
382
	struct berval *prefix,
383
	BerVarray values,
Howard Chu's avatar
Howard Chu committed
384
385
	BerVarray *keys,
	void *memctx ));
386

387
388
/* Filter index function */
typedef int slap_mr_filter_func LDAP_P((
389
390
	slap_mask_t use,
	slap_mask_t mask,
391
392
	struct slap_syntax *syntax,	/* syntax of stored value */
	struct slap_matching_rule *mr,
393
394
	struct berval *prefix,
	void * assertValue,
Howard Chu's avatar
Howard Chu committed
395
396
	BerVarray *keys,
	void *memctx ));
397

398
399
typedef struct slap_matching_rule_use MatchingRuleUse;

400
typedef struct slap_matching_rule {
401
	LDAPMatchingRule		smr_mrule;
402
403
404
405
406
	MatchingRuleUse			*smr_mru;
	/* RFC2252 string representation */
	struct berval			smr_str;
	/*
	 * Note: the former
407
	 *			ber_len_t	smr_oidlen;
408
409
410
411
412
413
414
415
	 * has been replaced by a struct berval that uses the value
	 * provided by smr_mrule.mr_oid; a macro that expands to
	 * the bv_len field of the berval is provided for backward
	 * compatibility.  CAUTION: NEVER FREE THE BERVAL
	 */
	struct berval			smr_bvoid;
#define	smr_oidlen			smr_bvoid.bv_len

416
	slap_mask_t				smr_usage;
417

418
419
420
#ifdef LDAP_DEVEL
#define SLAP_MR_HIDE			0x0000U
#else
421
#define SLAP_MR_HIDE			0x8000U
422
#endif
423

Kurt Zeilenga's avatar
Kurt Zeilenga committed
424
425
426
#define SLAP_MR_TYPE_MASK		0x0F00U
#define SLAP_MR_SUBTYPE_MASK	0x00F0U
#define SLAP_MR_USAGE			0x000FU
427
428

#define SLAP_MR_NONE			0x0000U
Kurt Zeilenga's avatar
Kurt Zeilenga committed
429
430
431
432
#define SLAP_MR_EQUALITY		0x0100U
#define SLAP_MR_ORDERING		0x0200U
#define SLAP_MR_SUBSTR			0x0400U
#define SLAP_MR_EXT				0x0800U /* implicitly extensible */
433

Kurt Zeilenga's avatar
Kurt Zeilenga committed
434
#define SLAP_MR_EQUALITY_APPROX	( SLAP_MR_EQUALITY | 0x0010U )
435

Kurt Zeilenga's avatar
Kurt Zeilenga committed
436
437
438
#define SLAP_MR_SUBSTR_INITIAL	( SLAP_MR_SUBSTR | 0x0010U )
#define SLAP_MR_SUBSTR_ANY		( SLAP_MR_SUBSTR | 0x0020U )
#define SLAP_MR_SUBSTR_FINAL	( SLAP_MR_SUBSTR | 0x0040U )
439

Kurt Zeilenga's avatar
Kurt Zeilenga committed
440
441
442
443
444
445
446
447
448
449
450
451
452
453

/*
 * The asserted value, depending on the particular usage,
 * is expected to conform to either the assertion syntax
 * or the attribute syntax.   In some cases, the syntax of
 * the value is known.  If so, these flags indicate which
 * syntax the value is expected to conform to.  If not,
 * neither of these flags is set (until the syntax of the
 * provided value is determined).  If the value is of the
 * attribute syntax, the flag is changed once a value of
 * the assertion syntax is derived from the provided value.
 */
#define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX	0x0001U
#define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX	0x0002U
454
#define SLAP_MR_VALUE_OF_SYNTAX				0x0003U
Kurt Zeilenga's avatar
Kurt Zeilenga committed
455
456
457
458
459

#define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \
	((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX )
#define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \
	((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX )
460
461
462
463
464
465
#ifdef LDAP_DEBUG
#define SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) \
	((usage) & SLAP_MR_VALUE_OF_SYNTAX)
#else
#define SLAP_MR_IS_VALUE_OF_SYNTAX( usage )	(1)
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
466

467
468
469
/* either or both the asserted value or attribute value
 * may be provided in normalized form
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
470
471
#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH		0x0004U
#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH	0x0008U
472
473

#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
	(!((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_MATCH))
#define SLAP_IS_MR_ATTRIBUTE_SYNTAX_MATCH( usage ) \
	((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_MATCH)

#define SLAP_IS_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH( usage ) \
	(((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH) \
		== SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH)
#define SLAP_IS_MR_ATTRIBUTE_SYNTAX_NONCONVERTED_MATCH( usage ) \
	(((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH) \
		== SLAP_MR_ATTRIBUTE_SYNTAX_MATCH)

#define SLAP_IS_MR_ASSERTED_VALUE_NORMALIZED_MATCH( usage ) \
	((usage) & SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH )
#define SLAP_IS_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH( usage ) \
	((usage) & SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH )
489

490
	Syntax					*smr_syntax;
491
	slap_mr_convert_func	*smr_convert;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
492
	slap_mr_normalize_func	*smr_normalize;
493
	slap_mr_match_func		*smr_match;
494
495
	slap_mr_indexer_func	*smr_indexer;
	slap_mr_filter_func		*smr_filter;
496

497
	/*
498
	 * null terminated array of syntaxes compatible with this syntax
499
	 * note: when MS_EXT is set, this MUST NOT contain the assertion
Kurt Zeilenga's avatar
Kurt Zeilenga committed
500
	 * syntax of the rule.  When MS_EXT is not set, it MAY.
501
502
503
	 */
	Syntax					**smr_compat_syntaxes;

504
505
506
507
	/*
	 * For equality rules, refers to an associated approximate rule.
	 * For non-equality rules, refers to an associated equality rule.
	 */
508
	struct slap_matching_rule	*smr_associated;
509

510
511
512
#define SLAP_MR_ASSOCIATED(mr,amr)	(((mr) == (amr)) || \
	((mr)->smr_associated == (amr)))

513
	LDAP_SLIST_ENTRY(slap_matching_rule)smr_next;
514

515
516
517
#define smr_oid				smr_mrule.mr_oid
#define smr_names			smr_mrule.mr_names
#define smr_desc			smr_mrule.mr_desc
Kurt Zeilenga's avatar
Kurt Zeilenga committed
518
519
#define smr_obsolete		smr_mrule.mr_obsolete
#define smr_syntax_oid		smr_mrule.mr_syntax_oid
520
#define smr_extensions		smr_mrule.mr_extensions
521
522
} MatchingRule;

523
524
525
526
527
528
struct slap_matching_rule_use {
	LDAPMatchingRuleUse		smru_mruleuse;
	MatchingRule			*smru_mr;
	/* RFC2252 string representation */
	struct berval			smru_str;

529
	LDAP_SLIST_ENTRY(slap_matching_rule_use) smru_next;
530
531
532
533
534
535
536
537
538
539

#define smru_oid			smru_mruleuse.mru_oid
#define smru_names			smru_mruleuse.mru_names
#define smru_desc			smru_mruleuse.mru_desc
#define smru_obsolete			smru_mruleuse.mru_obsolete
#define smru_applies_oids		smru_mruleuse.mru_applies_oids

#define smru_usage			smru_mr->smr_usage
} /* MatchingRuleUse */ ;

540
541
542
typedef struct slap_mrule_defs_rec {
	char *						mrd_desc;
	slap_mask_t					mrd_usage;
543
	char **						mrd_compat_syntaxes;
544
545
546
547
548
549
	slap_mr_convert_func *		mrd_convert;
	slap_mr_normalize_func *	mrd_normalize;
	slap_mr_match_func *		mrd_match;
	slap_mr_indexer_func *		mrd_indexer;
	slap_mr_filter_func *		mrd_filter;

550
551
	/* For equality rule, this may refer to an associated approximate rule */
	/* For non-equality rule, this may refer to an associated equality rule */
552
553
554
	char *						mrd_associated;
} slap_mrule_defs_rec;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
555
struct slap_backend_db;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
556
557
struct slap_entry;
struct slap_attr;
558

559
typedef int (AttributeTypeSchemaCheckFN)(
560
	struct slap_backend_db *be,
561
562
563
564
565
	struct slap_entry *e,
	struct slap_attr *attr,
	const char** text,
	char *textbuf, size_t textlen );

566
typedef struct slap_attribute_type {
567
	LDAPAttributeType		sat_atype;
568
	struct berval			sat_cname;
569
570
571
	struct slap_attribute_type	*sat_sup;
	struct slap_attribute_type	**sat_subtypes;
	MatchingRule			*sat_equality;
572
	MatchingRule			*sat_approx;
573
574
	MatchingRule			*sat_ordering;
	MatchingRule			*sat_substr;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
575
576
	Syntax					*sat_syntax;

577
	AttributeTypeSchemaCheckFN	*sat_check;
578

579
580
581
#define SLAP_AT_NONE		0x0000U
#define SLAP_AT_ABSTRACT	0x0100U /* cannot be instantiated */
#define SLAP_AT_FINAL		0x0200U /* cannot be subtyped */
582
583
584
#ifdef LDAP_DEVEL
#define SLAP_AT_HIDE		0x0000U /* publish everything */
#else
585
#define SLAP_AT_HIDE		0x8000U /* hide attribute */
586
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
587
588
	slap_mask_t					sat_flags;

589
	LDAP_SLIST_ENTRY(slap_attribute_type) sat_next;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
590

591
592
593
#define sat_oid				sat_atype.at_oid
#define sat_names			sat_atype.at_names
#define sat_desc			sat_atype.at_desc
594
#define sat_obsolete		sat_atype.at_obsolete
595
#define sat_sup_oid			sat_atype.at_sup_oid
596
597
598
599
600
601
#define sat_equality_oid	sat_atype.at_equality_oid
#define sat_ordering_oid	sat_atype.at_ordering_oid
#define sat_substr_oid		sat_atype.at_substr_oid
#define sat_syntax_oid		sat_atype.at_syntax_oid
#define sat_single_value	sat_atype.at_single_value
#define sat_collective		sat_atype.at_collective
602
#define sat_no_user_mod		sat_atype.at_no_user_mod
603
#define sat_usage			sat_atype.at_usage
604
#define sat_extensions		sat_atype.at_extensions
Kurt Zeilenga's avatar
Kurt Zeilenga committed
605

Kurt Zeilenga's avatar
Kurt Zeilenga committed
606
607
	struct slap_attr_desc		*sat_ad;
	ldap_pvt_thread_mutex_t		sat_ad_mutex;
608
609
} AttributeType;

610
611
612
#define is_at_operational(at)	((at)->sat_usage)
#define is_at_single_value(at)	((at)->sat_single_value)
#define is_at_collective(at)	((at)->sat_collective)
613
#define is_at_obsolete(at)		((at)->sat_obsolete)
614
615
#define is_at_no_user_mod(at)	((at)->sat_no_user_mod)

Kurt Zeilenga's avatar
Kurt Zeilenga committed
616
617
struct slap_object_class;

618
typedef int (ObjectClassSchemaCheckFN)(
619
	struct slap_backend_db *be,
620
621
622
623
624
	struct slap_entry *e,
	struct slap_object_class *oc,
	const char** text,
	char *textbuf, size_t textlen );

625
typedef struct slap_object_class {
626
627
	LDAPObjectClass			soc_oclass;
	struct berval			soc_cname;
628
	struct slap_object_class	**soc_sups;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
629
630
	AttributeType				**soc_required;
	AttributeType				**soc_allowed;
631
632
	ObjectClassSchemaCheckFN	*soc_check;
	slap_mask_t					soc_flags;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
633
634
635
#define soc_oid				soc_oclass.oc_oid
#define soc_names			soc_oclass.oc_names
#define soc_desc			soc_oclass.oc_desc
636
637
#define soc_obsolete		soc_oclass.oc_obsolete
#define soc_sup_oids		soc_oclass.oc_sup_oids
Kurt Zeilenga's avatar
Kurt Zeilenga committed
638
#define soc_kind			soc_oclass.oc_kind
639
640
#define soc_at_oids_must	soc_oclass.oc_at_oids_must
#define soc_at_oids_may		soc_oclass.oc_at_oids_may
641
#define soc_extensions		soc_oclass.oc_extensions
Kurt Zeilenga's avatar
Kurt Zeilenga committed
642

643
	LDAP_SLIST_ENTRY(slap_object_class) soc_next;
644
} ObjectClass;
645

646
647
648
649
650
#define	SLAP_OC_ALIAS		0x0001
#define	SLAP_OC_REFERRAL	0x0002
#define	SLAP_OC_SUBENTRY	0x0004
#define	SLAP_OC_DYNAMICOBJECT	0x0008
#define	SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY	0x0010
651
#define SLAP_OC_GLUE		0x0020
652
653
654
655
#define SLAP_OC_SYNCPROVIDERSUBENTRY		0x0040
#define SLAP_OC_SYNCCONSUMERSUBENTRY		0x0080
#define	SLAP_OC__MASK		0x00FF
#define	SLAP_OC__END		0x0100
656
#define SLAP_OC_OPERATIONAL	0x4000
657
658
659
#ifdef LDAP_DEVEL
#define SLAP_OC_HIDE		0x0000
#else
660
#define SLAP_OC_HIDE		0x8000
661
#endif
662

663
664
665
666
667
668
669
670
671
672
/*
 * DIT content rule
 */
typedef struct slap_content_rule {
	LDAPContentRule		scr_crule;
	ObjectClass			*scr_sclass;
	ObjectClass			**scr_auxiliaries;	/* optional */
	AttributeType		**scr_required;		/* optional */
	AttributeType		**scr_allowed;		/* optional */
	AttributeType		**scr_precluded;	/* optional */
673
674
675
676
677
678
679
680
681
#define scr_oid				scr_crule.cr_oid
#define scr_names			scr_crule.cr_names
#define scr_desc			scr_crule.cr_desc
#define scr_obsolete		scr_crule.cr_obsolete
#define scr_oc_oids_aux		scr_crule.cr_oc_oids_aux
#define scr_at_oids_must	scr_crule.cr_at_oids_must
#define scr_at_oids_may		scr_crule.cr_at_oids_may
#define scr_at_oids_not		scr_crule.cr_at_oids_not

682
	LDAP_SLIST_ENTRY( slap_content_rule ) scr_next;
683
} ContentRule;
684

685
/* Represents a recognized attribute description ( type + options ). */
686
typedef struct slap_attr_desc {
687
	struct slap_attr_desc *ad_next;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
688
	AttributeType *ad_type;		/* attribute type, must be specified */
689
	struct berval ad_cname;		/* canonical name, must be specified */
690
	struct berval ad_tags;		/* empty if no tagging options */
691
	unsigned ad_flags;
692
693
#define SLAP_DESC_NONE			0x00U
#define SLAP_DESC_BINARY		0x01U
694
#define SLAP_DESC_TAG_RANGE		0x80U
695
696
} AttributeDescription;

697
698
699
typedef struct slap_attr_name {
	struct berval an_name;
	AttributeDescription *an_desc;
700
	ObjectClass *an_oc;
701
702
} AttributeName;

703
704
705
#define slap_ad_is_tagged(ad)			( (ad)->ad_tags.bv_len != 0 )
#define slap_ad_is_tag_range(ad)	\
	( ((ad)->ad_flags & SLAP_DESC_TAG_RANGE) ? 1 : 0 )
Kurt Zeilenga's avatar
Kurt Zeilenga committed
706
#define slap_ad_is_binary(ad)		\
707
	( ((ad)->ad_flags & SLAP_DESC_BINARY) ? 1 : 0 )
708

709
710
711
712
/*
 * pointers to schema elements used internally
 */
struct slap_internal_schema {
713
	/* objectClass */
714
	ObjectClass *si_oc_top;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
715
	ObjectClass *si_oc_extensibleObject;
716
717
	ObjectClass *si_oc_alias;
	ObjectClass *si_oc_referral;
718
	ObjectClass *si_oc_rootdse;
719
720
	ObjectClass *si_oc_subentry;
	ObjectClass *si_oc_subschema;
721
	ObjectClass *si_oc_collectiveAttributeSubentry;
722
	ObjectClass *si_oc_dynamicObject;
723

724
725
726
	ObjectClass *si_oc_glue;
	ObjectClass *si_oc_syncConsumerSubentry;
	ObjectClass *si_oc_syncProviderSubentry;
727

728
	/* objectClass attribute descriptions */
729
730
	AttributeDescription *si_ad_objectClass;

731
	/* operational attribute descriptions */
732
	AttributeDescription *si_ad_structuralObjectClass;
733
734
735
736
	AttributeDescription *si_ad_creatorsName;
	AttributeDescription *si_ad_createTimestamp;
	AttributeDescription *si_ad_modifiersName;
	AttributeDescription *si_ad_modifyTimestamp;
737
	AttributeDescription *si_ad_hasSubordinates;
738
	AttributeDescription *si_ad_subschemaSubentry;
739
	AttributeDescription *si_ad_collectiveSubentries;
740
741
742
	AttributeDescription *si_ad_collectiveExclusions;
	AttributeDescription *si_ad_entryUUID;
	AttributeDescription *si_ad_entryCSN;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
743
	AttributeDescription *si_ad_namingCSN;
744
	AttributeDescription *si_ad_superiorUUID;
745

746
747
748
	/* LDAP cache specific operational attribute */
	AttributeDescription *si_ad_queryid;

749
750
	AttributeDescription *si_ad_dseType;
	AttributeDescription *si_ad_syncreplCookie;
Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
751
	AttributeDescription *si_ad_contextCSN;
752

753
	/* root DSE attribute descriptions */
754
	AttributeDescription *si_ad_altServer;
755
756
757
758
759
	AttributeDescription *si_ad_namingContexts;
	AttributeDescription *si_ad_supportedControl;
	AttributeDescription *si_ad_supportedExtension;
	AttributeDescription *si_ad_supportedLDAPVersion;
	AttributeDescription *si_ad_supportedSASLMechanisms;
760
	AttributeDescription *si_ad_supportedFeatures;
761
	AttributeDescription *si_ad_monitorContext;
762
763
764
765
766
767
	AttributeDescription *si_ad_vendorName;
	AttributeDescription *si_ad_vendorVersion;

	/* subentry attribute descriptions */
	AttributeDescription *si_ad_administrativeRole;
	AttributeDescription *si_ad_subtreeSpecification;
768

769
	/* subschema subentry attribute descriptions */
770
771
772
	AttributeDescription *si_ad_ditStructureRules;
	AttributeDescription *si_ad_ditContentRules;
	AttributeDescription *si_ad_nameForms;
773
774
775
776
	AttributeDescription *si_ad_objectClasses;
	AttributeDescription *si_ad_attributeTypes;
	AttributeDescription *si_ad_ldapSyntaxes;
	AttributeDescription *si_ad_matchingRules;
777
	AttributeDescription *si_ad_matchingRuleUse;
778
779
780
781
782

	/* Aliases & Referrals */
	AttributeDescription *si_ad_aliasedObjectName;
	AttributeDescription *si_ad_ref;

783
	/* Access Control Internals */
784
785
	AttributeDescription *si_ad_entry;
	AttributeDescription *si_ad_children;
786
787
	AttributeDescription *si_ad_saslAuthzTo;
	AttributeDescription *si_ad_saslAuthzFrom;
788
789
790
#ifdef SLAPD_ACI_ENABLED
	AttributeDescription *si_ad_aci;
#endif
791

792
793
794
795
	/* dynamic entries */
	AttributeDescription *si_ad_entryTtl;
	AttributeDescription *si_ad_dynamicSubtrees;

796
	/* Other attributes descriptions */
797
	AttributeDescription *si_ad_distinguishedName;
798
799
	AttributeDescription *si_ad_name;
	AttributeDescription *si_ad_cn;
800
	AttributeDescription *si_ad_userPassword;
Howard Chu's avatar
Howard Chu committed
801
	AttributeDescription *si_ad_labeledURI;
802
#ifdef SLAPD_AUTHPASSWD
803
	AttributeDescription *si_ad_authPassword;
804
#endif
805
806
807
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
	AttributeDescription *si_ad_krbName;
#endif
808
        
809
810
	/* Undefined Attribute Type */
	AttributeType	*si_at_undefined;
811
812
813

	/* Matching Rules */
	MatchingRule	*si_mr_distinguishedNameMatch;
814
815
	MatchingRule    *si_mr_caseExactMatch;
	MatchingRule    *si_mr_caseExactSubstringsMatch;
816
	MatchingRule    *si_mr_caseExactIA5Match;
817
	MatchingRule	*si_mr_integerMatch;
818
	MatchingRule    *si_mr_integerFirstComponentMatch;
819
	MatchingRule    *si_mr_objectIdentifierFirstComponentMatch;
820
821

	/* Syntaxes */
822
	Syntax		*si_syn_directoryString;
823
824
	Syntax		*si_syn_distinguishedName;
	Syntax		*si_syn_integer;
825
	Syntax		*si_syn_octetString;
826
827
};

828
typedef struct slap_attr_assertion {
829
	AttributeDescription	*aa_desc;
830
	struct berval aa_value;
831
832
} AttributeAssertion;

833
834
typedef struct slap_ss_assertion {
	AttributeDescription	*sa_desc;
835
836
837
	struct berval		sa_initial;
	struct berval		*sa_any;
	struct berval		sa_final;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
838
} SubstringsAssertion;
839

840
typedef struct slap_mr_assertion {
841
842
	MatchingRule		*ma_rule;	/* optional */
	struct berval		ma_rule_text;  /* optional */
843
844
	AttributeDescription	*ma_desc;	/* optional */
	int						ma_dnattrs; /* boolean */
845
	struct berval		ma_value;	/* required */
846
} MatchingRuleAssertion;
847

Kurt Zeilenga's avatar
Kurt Zeilenga committed
848
849
850
/*
 * represents a search filter
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
851
typedef struct slap_filter {
852
	ber_tag_t	f_choice;	/* values taken from ldap.h, plus: */
853
854
855
856
#define SLAPD_FILTER_COMPUTED	((ber_tag_t) -1)
#define SLAPD_FILTER_DN_ONE		((ber_tag_t) -2)
#define SLAPD_FILTER_DN_SUBTREE	((ber_tag_t) -3)

Kurt Zeilenga's avatar
Kurt Zeilenga committed
857
	union f_un_u {
858
859
860
		/* precomputed result */
		ber_int_t f_un_result;

861
		/* DN */
862
		struct berval *f_un_dn;
863
864
865
866
867
868
869
870

		/* present */
		AttributeDescription *f_un_desc;

		/* simple value assertion */
		AttributeAssertion *f_un_ava;

		/* substring assertion */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
871
		SubstringsAssertion *f_un_ssa;
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887

		/* matching rule assertion */
		MatchingRuleAssertion *f_un_mra;

#define f_dn			f_un.f_un_dn
#define f_desc			f_un.f_un_desc
#define f_ava			f_un.f_un_ava
#define f_av_desc		f_un.f_un_ava->aa_desc
#define f_av_value		f_un.f_un_ava->aa_value
#define f_sub			f_un.f_un_ssa
#define f_sub_desc		f_un.f_un_ssa->sa_desc
#define f_sub_initial	f_un.f_un_ssa->sa_initial
#define f_sub_any		f_un.f_un_ssa->sa_any
#define f_sub_final		f_un.f_un_ssa->sa_final
#define f_mra			f_un.f_un_mra
#define f_mr_rule		f_un.f_un_mra->ma_rule
Kurt Zeilenga's avatar
Kurt Zeilenga committed
888
#define f_mr_rule_text	f_un.f_un_mra->ma_rule_text
889
890
#define f_mr_desc		f_un.f_un_mra->ma_desc
#define f_mr_value		f_un.f_un_mra->ma_value
891
#define	f_mr_dnattrs	f_un.f_un_mra->ma_dnattrs
892
893
894

		/* and, or, not */
		struct slap_filter *f_un_complex;
895
896
	} f_un;

897
#define f_result	f_un.f_un_result
898
899
900
901
#define f_and		f_un.f_un_complex
#define f_or		f_un.f_un_complex
#define f_not		f_un.f_un_complex
#define f_list		f_un.f_un_complex
Kurt Zeilenga's avatar
Kurt Zeilenga committed
902

Kurt Zeilenga's avatar
Kurt Zeilenga committed
903
	struct slap_filter	*f_next;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
904
905
} Filter;

906
/* compare routines can return undefined */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
907
#define SLAPD_COMPARE_UNDEFINED	((ber_int_t) -1)
908

909
typedef struct slap_valuesreturnfilter {
910
	ber_tag_t	vrf_choice;
911
912
913

	union vrf_un_u {
		/* precomputed result */
914
		ber_int_t vrf_un_result;
915
916

		/* DN */
917
		char *vrf_un_dn;
918
919

		/* present */
920
		AttributeDescription *vrf_un_desc;
921
922

		/* simple value assertion */
923
		AttributeAssertion *vrf_un_ava;
924
925

		/* substring assertion */
926
		SubstringsAssertion *vrf_un_ssa;
927
928

		/* matching rule assertion */
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
		MatchingRuleAssertion *vrf_un_mra;

#define vrf_result		vrf_un.vrf_un_result
#define vrf_dn			vrf_un.vrf_un_dn
#define vrf_desc		vrf_un.vrf_un_desc
#define vrf_ava			vrf_un.vrf_un_ava
#define vrf_av_desc		vrf_un.vrf_un_ava->aa_desc
#define vrf_av_value	vrf_un.vrf_un_ava->aa_value
#define vrf_ssa			vrf_un.vrf_un_ssa
#define vrf_sub			vrf_un.vrf_un_ssa
#define vrf_sub_desc	vrf_un.vrf_un_ssa->sa_desc
#define vrf_sub_initial	vrf_un.vrf_un_ssa->sa_initial
#define vrf_sub_any		vrf_un.vrf_un_ssa->sa_any
#define vrf_sub_final	vrf_un.vrf_un_ssa->sa_final
#define vrf_mra			vrf_un.vrf_un_mra
#define vrf_mr_rule		vrf_un.vrf_un_mra->ma_rule
#define vrf_mr_rule_text	vrf_un.vrf_un_mra->ma_rule_text
#define vrf_mr_desc		vrf_un.vrf_un_mra->ma_desc
#define vrf_mr_value		vrf_un.vrf_un_mra->ma_value
#define	vrf_mr_dnattrs	vrf_un.vrf_un_mra->ma_dnattrs


	} vrf_un;

	struct slap_valuesreturnfilter	*vrf_next;
954
955
} ValuesReturnFilter;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
956
/*
957
 * represents an attribute (description + values)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
958
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
959
typedef struct slap_attr {
960
	AttributeDescription *a_desc;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
961
962
	BerVarray	a_vals;		/* preserved values */
	BerVarray	a_nvals;	/* normalized values */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
963
	struct slap_attr *a_next;
964
965
966
	unsigned a_flags;
#define SLAP_ATTR_IXADD		0x1U
#define SLAP_ATTR_IXDEL		0x2U
Kurt Zeilenga's avatar
Kurt Zeilenga committed
967
968
969
970
971
972
973
} Attribute;


/*
 * the id used in the indexes to refer to an entry
 */
typedef unsigned long	ID;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
974
#define NOID	((ID)~0)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
975
976
977
978

/*
 * represents an entry in core
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
979
typedef struct slap_entry {
980
981
982
983
984
	/*
	 * The ID field should only be changed before entry is
	 * inserted into a cache.  The ID value is backend
	 * specific.
	 */
985
	ID		e_id;
986

987
988
989
990
991
	struct berval e_name;	/* name (DN) of this entry */
	struct berval e_nname;	/* normalized name (DN) of this entry */

	/* for migration purposes */
#define e_dn e_name.bv_val
Howard Chu's avatar
Howard Chu committed
992
#define e_ndn e_nname.bv_val
993

994
	Attribute	*e_attrs;	/* list of attributes + values */
995

996
997
	slap_mask_t	e_ocflags;

998
999
	struct berval	e_bv;		/* For entry_encode/entry_decode */

1000
1001
	/* for use by the backend for any purpose */
	void*	e_private;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1002
1003
} Entry;

1004
1005
1006
1007
1008
/*
 * A list of LDAPMods
 */
typedef struct slap_mod {
	int sm_op;
1009
	AttributeDescription *sm_desc;