slap.h 63.8 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 "ldap_pvt_thread.h"
36
#include "ldap_queue.h"
37

38
#ifdef LDAP_DEVEL
39
/* #define SLAP_NVALUES 1 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
40
#define SLAP_EXTENDED_SCHEMA 1
41
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
42

43
LDAP_BEGIN_DECL
Kurt Zeilenga's avatar
Kurt Zeilenga committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * 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))
61

Hallvard Furuseth's avatar
Hallvard Furuseth committed
62
63
64
#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
65

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

Juan Gomez's avatar
Juan Gomez committed
69
70
71
72
73
/* 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.
 */
74
#define SLAP_MOD_SOFTADD	0x1000
Juan Gomez's avatar
Juan Gomez committed
75

76
#define MAXREMATCHES (100)
77

78
#define SLAP_MAX_WORKER_THREADS		(16)
79

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
#define SLAP_TEXT_BUFLEN (256)
84
85

/* psuedo error code indicating abandoned operation */
86
87
88
89
#define SLAPD_ABANDON (-1)

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

91

92
93
/* We assume "C" locale, that is US-ASCII */
#define ASCII_SPACE(c)	( (c) == ' ' )
94
95
96
97
98
#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) )
99
#define ASCII_PRINTABLE(c) ( (c) >= ' ' && (c) <= '~' )
100
101
102
103
104
105
106
107

#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) )
108

109
#define DN_ESCAPE(c)	((c) == SLAP_ESCAPE_CHAR)
110
#define DN_SEPARATOR(c)	((c) == ',' || (c) == ';')
111
112
#define RDN_ATTRTYPEANDVALUE_SEPARATOR(c) ((c) == '+') /* RFC 2253 */
#define RDN_SEPARATOR(c) (DN_SEPARATOR(c) || RDN_ATTRTYPEANDVALUE_SEPARATOR(c))
113
114
115
116
117
#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) )
118
119
#define OID_SEPARATOR(c)	( (c) == '.' )
#define OID_CHAR(c)	( OID_LEADCHAR(c) || OID_SEPARATOR(c) )
120

121
122
#define ATTR_LEADCHAR(c)	( DESC_LEADCHAR(c) || OID_LEADCHAR(c) )
#define ATTR_CHAR(c)	( DESC_CHAR((c)) || (c) == '.' )
123

124
125
#define AD_LEADCHAR(c)	( ATTR_CHAR(c) )
#define AD_CHAR(c)		( ATTR_CHAR(c) || (c) == ';' )
126

127
128
#define SLAP_NUMERIC(c) ( ASCII_DIGIT(c) || ASCII_SPACE(c) )

129
130
131
#define SLAP_PRINTABLE(c)	( ASCII_ALNUM(c) || (c) == '\'' || \
	(c) == '(' || (c) == ')' || (c) == '+' || (c) == ',' || \
	(c) == '-' || (c) == '.' || (c) == '/' || (c) == ':' || \
132
	(c) == '?' || (c) == ' ' || (c) == '=' )
133
134
#define SLAP_PRINTABLES(c)	( SLAP_PRINTABLE(c) || (c) == '$' )

135
136
/* 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
137
#define SLAPD_NAMEUID_SYNTAX	"1.3.6.1.4.1.1466.115.121.1.34"
138
139
140
141
142
#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
143
#ifdef SLAPD_ACI_ENABLED
144
#define SLAPD_ACI_SYNTAX		"1.3.6.1.4.1.4203.666.2.1"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
145
146
#endif

Mark Valence's avatar
Mark Valence committed
147
148
149
/* change this to "OpenLDAPset" */
#define SLAPD_ACI_SET_ATTR		"template"

150
151
#define SLAPD_TOP_OID			"2.5.6.0"

Howard Chu's avatar
Howard Chu committed
152
LDAP_SLAPD_V (int) slap_debug;
153

154
155
typedef unsigned long slap_mask_t;

156
157
158
159
160
161
162
163
164
165
166
167
/* 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;
168
	slap_ssf_t sss_simple_bind;
169
} slap_ssf_set_t;
170

171
172
173
174
/* Flags for telling slap_sasl_getdn() what type of identity is being passed */
#define SLAP_GETDN_AUTHCID 2
#define SLAP_GETDN_AUTHZID 4

175
176
177
/*
 * Index types
 */
178
179
180
181
182
183
184
185
186
187
#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

188
#define IS_SLAP_INDEX(mask, type)	(((mask) & (type)) == (type))
189
190
191
192
193
194

#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 )
195
196
197
198
199
#define SLAP_INDEX_SUBSTR_DEFAULT \
	( SLAP_INDEX_SUBSTR \
	| SLAP_INDEX_SUBSTR_INITIAL \
	| SLAP_INDEX_SUBSTR_ANY \
	| SLAP_INDEX_SUBSTR_FINAL )
200

201
202
#define SLAP_INDEX_SUBSTR_MINLEN	2
#define SLAP_INDEX_SUBSTR_MAXLEN	4
203
#define SLAP_INDEX_SUBSTR_STEP	2
204

205
206
#define SLAP_INDEX_FLAGS         0xF000UL
#define SLAP_INDEX_NOSUBTYPES    0x1000UL /* don't use index w/ subtypes */
207
#define SLAP_INDEX_NOTAGS        0x2000UL /* don't use index w/ tags */
208
209
210
211
212
213
214
215

/*
 * 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    */
216
217
#define SLAP_INDEX_SUBSTR_INITIAL_PREFIX '^'
#define SLAP_INDEX_SUBSTR_FINAL_PREFIX '$'
218
#define SLAP_INDEX_CONT_PREFIX		'.'		/* prefix for continuation keys */
219

220
221
222
223
224
#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"
225

Jong Hyuk Choi's avatar
Jong Hyuk Choi committed
226
227
228
229
#ifdef LDAP_CLIENT_UPDATE
#define LCUP_COOKIE_OID "1.3.6.1.4.1.4203.666.10.1"
#endif /* LDAP_CLIENT_UPDATE */

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,
292
	struct berval * out));
293
294

typedef struct slap_syntax {
295
	LDAPSyntax			ssyn_syn;
296
297
#define ssyn_oid		ssyn_syn.syn_oid
#define ssyn_desc		ssyn_syn.syn_desc
298
#define ssyn_extensions		ssyn_syn.syn_extensions
299
300
	/*
	 * Note: the former
301
	ber_len_t	ssyn_oidlen;
302
303
304
305
306
307
308
	 * 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
309

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

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) */
#define SLAP_SYNTAX_HIDE	0x8000U /* hide (do not publish) */
317

318
	slap_syntax_validate_func	*ssyn_validate;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
319
#ifndef SLAP_NVALUES
320
	slap_syntax_transform_func	*ssyn_normalize;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
321
#endif
322
	slap_syntax_transform_func	*ssyn_pretty;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
323

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

330
	LDAP_SLIST_ENTRY(slap_syntax) ssyn_next;
331
332
} Syntax;

333
334
335
336
#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)
337
#define slap_syntax_is_hidden(s)	slap_syntax_is_flag((s),SLAP_SYNTAX_HIDE)
338

339
340
341
342
typedef struct slap_syntax_defs_rec {
	char *sd_desc;
	int sd_flags;
	slap_syntax_validate_func *sd_validate;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
343
344
345
#ifdef SLAP_NVALUES
	slap_syntax_transform_func *sd_normalizeXXX; /* to be deleted */
#else
346
	slap_syntax_transform_func *sd_normalize;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
347
#endif
348
349
350
351
352
353
354
	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
355
/* X -> Y Converter */
356
357
typedef int slap_mr_convert_func LDAP_P((
	struct berval * in,
358
	struct berval * out ));
Kurt Zeilenga's avatar
Kurt Zeilenga committed
359
360
361

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

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

377
378
/* Index generation function */
typedef int slap_mr_indexer_func LDAP_P((
379
380
	slap_mask_t use,
	slap_mask_t mask,
381
382
	struct slap_syntax *syntax,	/* syntax of stored value */
	struct slap_matching_rule *mr,
383
	struct berval *prefix,
384
385
	BerVarray values,
	BerVarray *keys ));
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,
395
	BerVarray *keys ));
396

397
398
typedef struct slap_matching_rule_use MatchingRuleUse;

399
typedef struct slap_matching_rule {
400
	LDAPMatchingRule		smr_mrule;
401
402
403
404
405
	MatchingRuleUse			*smr_mru;
	/* RFC2252 string representation */
	struct berval			smr_str;
	/*
	 * Note: the former
406
	 *			ber_len_t	smr_oidlen;
407
408
409
410
411
412
413
414
	 * 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

415
	slap_mask_t				smr_usage;
416

417
418
#define SLAP_MR_HIDE			0x8000U

Kurt Zeilenga's avatar
Kurt Zeilenga committed
419
420
421
#define SLAP_MR_TYPE_MASK		0xF000U
#define SLAP_MR_SUBTYPE_MASK	0x0F00U
#define SLAP_MR_USAGE			0x00FFU
422
423

#define SLAP_MR_NONE			0x0000U
Kurt Zeilenga's avatar
Kurt Zeilenga committed
424
425
426
427
#define SLAP_MR_EQUALITY		0x1000U
#define SLAP_MR_ORDERING		0x2000U
#define SLAP_MR_SUBSTR			0x4000U
#define SLAP_MR_EXT				0x8000U /* implicitly extensible */
428

Kurt Zeilenga's avatar
Kurt Zeilenga committed
429
#define SLAP_MR_EQUALITY_APPROX	( SLAP_MR_EQUALITY | 0x0100U )
430

Kurt Zeilenga's avatar
Kurt Zeilenga committed
431
432
433
#define SLAP_MR_SUBSTR_INITIAL	( SLAP_MR_SUBSTR | 0x0100U )
#define SLAP_MR_SUBSTR_ANY		( SLAP_MR_SUBSTR | 0x0200U )
#define SLAP_MR_SUBSTR_FINAL	( SLAP_MR_SUBSTR | 0x0400U )
434

Kurt Zeilenga's avatar
Kurt Zeilenga committed
435
436
437
438
439
#ifndef SLAP_NVALUES
#define SLAP_MR_DN_FOLD			0x0080U
#endif

#ifndef SLAP_NVALUES
440
/*
441
 * normally the asserted value is expected to conform to
442
443
 * assertion syntax specified in the matching rule, however
 * at times (such as during individual value modification),
444
 * the asserted value is expected to conform to the
445
446
 * attribute's value syntax.
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
447
448
#define SLAP_MR_ASSERTION_SYNTAX_MATCH		0x0000U
#define SLAP_MR_ATTRIBUTE_SYNTAX_MATCH		0x0001U
449
450
451
452
453
454
455
456

/* For SLAP_MR_ATTRIBUTE_SYNTAX_MATCHes, this flag indicates
 * that the asserted value of the attribute syntax has been
 * converted to the assertion syntax.  (Not sure why we just
 * don't clear the SLAP_MR_ATTRIBUTE_SYNTAX_MATCH flag instead.)
 */
#define SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH	0x0002U

Kurt Zeilenga's avatar
Kurt Zeilenga committed
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#else
/*
 * 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

#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 )
#endif

478
479
480
/* either or both the asserted value or attribute value
 * may be provided in normalized form
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
481
482
#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH		0x0010U
#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH	0x0020U
483
484

#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
	(!((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 )
500

501
	Syntax					*smr_syntax;
502
	slap_mr_convert_func	*smr_convert;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
503
	slap_mr_normalize_func	*smr_normalize;
504
	slap_mr_match_func		*smr_match;
505
506
	slap_mr_indexer_func	*smr_indexer;
	slap_mr_filter_func		*smr_filter;
507

508
	/*
509
	 * null terminated array of syntaxes compatible with this syntax
510
	 * note: when MS_EXT is set, this MUST NOT contain the assertion
Kurt Zeilenga's avatar
Kurt Zeilenga committed
511
	 * syntax of the rule.  When MS_EXT is not set, it MAY.
512
513
514
	 */
	Syntax					**smr_compat_syntaxes;

515
	struct slap_matching_rule	*smr_associated;
516
	LDAP_SLIST_ENTRY(slap_matching_rule)smr_next;
517

518
519
520
#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
521
522
#define smr_obsolete		smr_mrule.mr_obsolete
#define smr_syntax_oid		smr_mrule.mr_syntax_oid
523
#define smr_extensions		smr_mrule.mr_extensions
524
525
} MatchingRule;

526
527
528
529
530
531
struct slap_matching_rule_use {
	LDAPMatchingRuleUse		smru_mruleuse;
	MatchingRule			*smru_mr;
	/* RFC2252 string representation */
	struct berval			smru_str;

532
	LDAP_SLIST_ENTRY(slap_matching_rule_use) smru_next;
533
534
535
536
537
538
539
540
541
542

#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 */ ;

543
544
545
typedef struct slap_mrule_defs_rec {
	char *						mrd_desc;
	slap_mask_t					mrd_usage;
546
	char **						mrd_compat_syntaxes;
547
548
549
550
551
552
	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;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
553
	/* For equality rule, this may refer to an appropriate approximate rule */
554
555
556
	char *						mrd_associated;
} slap_mrule_defs_rec;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
557
struct slap_backend_db;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
558
559
struct slap_entry;
struct slap_attr;
560

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

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

579
	AttributeTypeSchemaCheckFN	*sat_check;
580

581
582
583
584
#define SLAP_AT_NONE		0x0000U
#define SLAP_AT_ABSTRACT	0x0100U /* cannot be instantiated */
#define SLAP_AT_FINAL		0x0200U /* cannot be subtyped */
#define SLAP_AT_HIDE		0x8000U /* hide attribute */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
585
586
	slap_mask_t					sat_flags;

587
	LDAP_SLIST_ENTRY(slap_attribute_type) sat_next;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
588

589
590
591
#define sat_oid				sat_atype.at_oid
#define sat_names			sat_atype.at_names
#define sat_desc			sat_atype.at_desc
592
#define sat_obsolete		sat_atype.at_obsolete
593
#define sat_sup_oid			sat_atype.at_sup_oid
594
595
596
597
598
599
#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
600
#define sat_no_user_mod		sat_atype.at_no_user_mod
601
#define sat_usage			sat_atype.at_usage
602
#define sat_extensions		sat_atype.at_extensions
Kurt Zeilenga's avatar
Kurt Zeilenga committed
603

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

608
609
610
#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)
611
#define is_at_obsolete(at)		((at)->sat_obsolete)
612
613
#define is_at_no_user_mod(at)	((at)->sat_no_user_mod)

Kurt Zeilenga's avatar
Kurt Zeilenga committed
614
615
struct slap_object_class;

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

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

641
	LDAP_SLIST_ENTRY(slap_object_class) soc_next;
642
} ObjectClass;
643

644
645
646
647
648
649
650
651
652
#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
#define	SLAP_OC__MASK		0x001F
#define	SLAP_OC__END		0x0020
#define SLAP_OC_OPERATIONAL	0x4000
#define SLAP_OC_HIDE		0x8000
653

654
655
656
657
658
659
660
661
662
663
/*
 * 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 */
664
665
666
667
668
669
670
671
672
#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

673
	LDAP_SLIST_ENTRY( slap_content_rule ) scr_next;
674
} ContentRule;
675

676
/* Represents a recognized attribute description ( type + options ). */
677
typedef struct slap_attr_desc {
678
	struct slap_attr_desc *ad_next;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
679
	AttributeType *ad_type;		/* attribute type, must be specified */
680
	struct berval ad_cname;		/* canonical name, must be specified */
681
	struct berval ad_tags;		/* empty if no tagging options */
682
	unsigned ad_flags;
683
684
#define SLAP_DESC_NONE			0x00U
#define SLAP_DESC_BINARY		0x01U
685
#define SLAP_DESC_TAG_RANGE		0x80U
686
687
} AttributeDescription;

688
689
690
typedef struct slap_attr_name {
	struct berval an_name;
	AttributeDescription *an_desc;
691
	ObjectClass *an_oc;
692
693
} AttributeName;

694
695
696
#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
697
#define slap_ad_is_binary(ad)		\
698
	( ((ad)->ad_flags & SLAP_DESC_BINARY) ? 1 : 0 )
699

700
701
702
703
/*
 * pointers to schema elements used internally
 */
struct slap_internal_schema {
704
	/* objectClass */
705
	ObjectClass *si_oc_top;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
706
	ObjectClass *si_oc_extensibleObject;
707
708
	ObjectClass *si_oc_alias;
	ObjectClass *si_oc_referral;
709
	ObjectClass *si_oc_rootdse;
710
711
	ObjectClass *si_oc_subentry;
	ObjectClass *si_oc_subschema;
712
	ObjectClass *si_oc_monitor;
713
	ObjectClass *si_oc_collectiveAttributeSubentry;
714
	ObjectClass *si_oc_dynamicObject;
715

716
	/* objectClass attribute descriptions */
717
718
	AttributeDescription *si_ad_objectClass;

719
	/* operational attribute descriptions */
720
	AttributeDescription *si_ad_structuralObjectClass;
721
722
723
724
	AttributeDescription *si_ad_creatorsName;
	AttributeDescription *si_ad_createTimestamp;
	AttributeDescription *si_ad_modifiersName;
	AttributeDescription *si_ad_modifyTimestamp;
725
	AttributeDescription *si_ad_hasSubordinates;
726
	AttributeDescription *si_ad_subschemaSubentry;
727
	AttributeDescription *si_ad_collectiveSubentries;
728
729
730
	AttributeDescription *si_ad_collectiveExclusions;
	AttributeDescription *si_ad_entryUUID;
	AttributeDescription *si_ad_entryCSN;
731
	AttributeDescription *si_ad_superiorUUID;
732

733
	/* root DSE attribute descriptions */
734
	AttributeDescription *si_ad_altServer;
735
736
737
738
739
	AttributeDescription *si_ad_namingContexts;
	AttributeDescription *si_ad_supportedControl;
	AttributeDescription *si_ad_supportedExtension;
	AttributeDescription *si_ad_supportedLDAPVersion;
	AttributeDescription *si_ad_supportedSASLMechanisms;
740
	AttributeDescription *si_ad_supportedFeatures;
741
	AttributeDescription *si_ad_monitorContext;
742
743
744
745
746
747
	AttributeDescription *si_ad_vendorName;
	AttributeDescription *si_ad_vendorVersion;

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

749
	/* subschema subentry attribute descriptions */
750
751
752
	AttributeDescription *si_ad_ditStructureRules;
	AttributeDescription *si_ad_ditContentRules;
	AttributeDescription *si_ad_nameForms;
753
754
755
756
	AttributeDescription *si_ad_objectClasses;
	AttributeDescription *si_ad_attributeTypes;
	AttributeDescription *si_ad_ldapSyntaxes;
	AttributeDescription *si_ad_matchingRules;
757
	AttributeDescription *si_ad_matchingRuleUse;
758
759
760
761
762

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

763
	/* Access Control Internals */
764
765
	AttributeDescription *si_ad_entry;
	AttributeDescription *si_ad_children;
766
767
	AttributeDescription *si_ad_saslAuthzTo;
	AttributeDescription *si_ad_saslAuthzFrom;
768
769
770
#ifdef SLAPD_ACI_ENABLED
	AttributeDescription *si_ad_aci;
#endif
771

772
773
774
775
	/* dynamic entries */
	AttributeDescription *si_ad_entryTtl;
	AttributeDescription *si_ad_dynamicSubtrees;

776
	/* Other attributes descriptions */
777
	AttributeDescription *si_ad_distinguishedName;
778
779
	AttributeDescription *si_ad_name;
	AttributeDescription *si_ad_cn;
780
	AttributeDescription *si_ad_userPassword;
781
#ifdef SLAPD_AUTHPASSWD
782
	AttributeDescription *si_ad_authPassword;
783
#endif
784
785
786
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
	AttributeDescription *si_ad_krbName;
#endif
787
788
789

	/* Undefined Attribute Type */
	AttributeType	*si_at_undefined;
790
791
792

	/* Matching Rules */
	MatchingRule	*si_mr_distinguishedNameMatch;
793
794
	MatchingRule    *si_mr_caseExactMatch;
	MatchingRule    *si_mr_caseExactSubstringsMatch;
795
	MatchingRule    *si_mr_caseExactIA5Match;
796
	MatchingRule	*si_mr_integerMatch;
797
	MatchingRule    *si_mr_integerFirstComponentMatch;
798
799

	/* Syntaxes */
800
	Syntax		*si_syn_directoryString;
801
802
	Syntax		*si_syn_distinguishedName;
	Syntax		*si_syn_integer;
803
	Syntax		*si_syn_octetString;
804
805
};

806
typedef struct slap_attr_assertion {
807
	AttributeDescription	*aa_desc;
808
	struct berval aa_value;
809
810
} AttributeAssertion;

811
812
typedef struct slap_ss_assertion {
	AttributeDescription	*sa_desc;
813
814
815
	struct berval		sa_initial;
	struct berval		*sa_any;
	struct berval		sa_final;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
816
} SubstringsAssertion;
817

818
typedef struct slap_mr_assertion {
819
820
	MatchingRule		*ma_rule;	/* optional */
	struct berval		ma_rule_text;  /* optional */
821
822
	AttributeDescription	*ma_desc;	/* optional */
	int						ma_dnattrs; /* boolean */
823
	struct berval		ma_value;	/* required */
824
} MatchingRuleAssertion;
825

Kurt Zeilenga's avatar
Kurt Zeilenga committed
826
827
828
/*
 * represents a search filter
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
829
typedef struct slap_filter {
830
	ber_tag_t	f_choice;	/* values taken from ldap.h, plus: */
831
832
833
834
#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
835
	union f_un_u {
836
837
838
		/* precomputed result */
		ber_int_t f_un_result;

839
		/* DN */
840
		struct berval *f_un_dn;
841
842
843
844
845
846
847
848

		/* present */
		AttributeDescription *f_un_desc;

		/* simple value assertion */
		AttributeAssertion *f_un_ava;

		/* substring assertion */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
849
		SubstringsAssertion *f_un_ssa;
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865

		/* 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
866
#define f_mr_rule_text	f_un.f_un_mra->ma_rule_text
867
868
#define f_mr_desc		f_un.f_un_mra->ma_desc
#define f_mr_value		f_un.f_un_mra->ma_value
869
#define	f_mr_dnattrs	f_un.f_un_mra->ma_dnattrs
870
871
872

		/* and, or, not */
		struct slap_filter *f_un_complex;
873
874
	} f_un;

875
#define f_result	f_un.f_un_result
876
877
878
879
#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
880

Kurt Zeilenga's avatar
Kurt Zeilenga committed
881
	struct slap_filter	*f_next;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
882
883
} Filter;

884
/* compare routines can return undefined */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
885
#define SLAPD_COMPARE_UNDEFINED	((ber_int_t) -1)
886

887
typedef struct slap_valuesreturnfilter {
888
	ber_tag_t	vrf_choice;
889
890
891

	union vrf_un_u {
		/* precomputed result */
892
		ber_int_t vrf_un_result;
893
894

		/* DN */
895
		char *vrf_un_dn;
896
897

		/* present */
898
		AttributeDescription *vrf_un_desc;
899
900

		/* simple value assertion */
901
		AttributeAssertion *vrf_un_ava;
902
903

		/* substring assertion */
904
		SubstringsAssertion *vrf_un_ssa;
905
906

		/* matching rule assertion */
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
		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;
932
933
} ValuesReturnFilter;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
934
/*
935
 * represents an attribute (description + values)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
936
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
937
typedef struct slap_attr {
938
	AttributeDescription *a_desc;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
939
940
941
942
	BerVarray	a_vals;		/* preserved values */
#ifdef SLAP_NVALUES
	BerVarray	a_nvals;	/* normalized values */
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
943
	struct slap_attr *a_next;
944
945
946
	unsigned a_flags;
#define SLAP_ATTR_IXADD		0x1U
#define SLAP_ATTR_IXDEL		0x2U
Kurt Zeilenga's avatar
Kurt Zeilenga committed
947
948
949
950
951
952
953
} Attribute;


/*
 * the id used in the indexes to refer to an entry
 */
typedef unsigned long	ID;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
954
#define NOID	((ID)~0)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
955
956
957
958

/*
 * represents an entry in core
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
959
typedef struct slap_entry {
960
961
962
963
964
	/*
	 * The ID field should only be changed before entry is
	 * inserted into a cache.  The ID value is backend
	 * specific.
	 */
965
	ID		e_id;
966

967
968
969
970
971
	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
972
#define e_ndn e_nname.bv_val
973

974
	Attribute	*e_attrs;	/* list of attributes + values */
975

976
977
	slap_mask_t	e_ocflags;

978
979
	struct berval	e_bv;		/* For entry_encode/entry_decode */

980
981
	/* for use by the backend for any purpose */
	void*	e_private;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
982
983
} Entry;

984
985
986
987
988
/*
 * A list of LDAPMods
 */
typedef struct slap_mod {
	int sm_op;
989
	AttributeDescription *sm_desc;
990
	struct berval sm_type;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
991
	BerVarray sm_values;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
992
#define sm_bvalues sm_values
Kurt Zeilenga's avatar
Kurt Zeilenga committed
993
994
995
#ifdef SLAP_NVALUES
	BerVarray sm_nvalues;
#endif
996
997
998
} Modification;

typedef struct slap_mod_list {
999
1000
1001
	Modification sml_mod;
#define sml_op		sml_mod.sm_op
#define sml_desc	sml_mod.sm_desc
1002
#define	sml_type	sml_mod.sm_type
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1003
1004
1005
#define sml_bvalues	sml_mod.sm_values
#define sml_values	sml_mod.sm_values
#define sml_nvalues	sml_mod.sm_nvalues
1006
1007
1008
1009
1010
1011
	struct slap_mod_list *sml_next;
} Modifications;

typedef struct slap_ldap_modlist {
	LDAPMod ml_mod;
	struct slap_ldap_modlist *ml_next;
1012
1013
1014
#define ml_op		ml_mod.mod_op
#define ml_type		ml_mod.mod_type
#define ml_values	ml_mod.mod_values
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1015
#define ml_bvalues	ml_mod.mod_values
1016
} LDAPModList;
1017

Kurt Zeilenga's avatar
Kurt Zeilenga committed
1018
1019
1020
/*
 * represents an access control list
 */
1021
1022
1023