1 /*	$NetBSD: componentlib.h,v 1.1.1.2 2010/03/08 02:14:20 lukem Exp $	*/
2 
3 /* Copyright 2004 IBM Corporation
4  * All rights reserved.
5  * Redisribution and use in source and binary forms, with or without
6  * modification, are permitted only as  authorizd by the OpenLADP
7  * Public License.
8  */
9 /* ACKNOWLEDGEMENTS
10  * This work originally developed by Sang Seok Lim
11  * 2004/06/18	03:20:00	slim@OpenLDAP.org
12  */
13 
14 #ifndef _H_COMPONENT_MODULE
15 #define _H_COMPONENT_MODULE
16 
17 #include "portable.h"
18 #include <ac/string.h>
19 #include <ac/socket.h>
20 #include <ldap_pvt.h>
21 #include "lutil.h"
22 #include <ldap.h>
23 #include <slap.h>
24 #include <component.h>
25 
26 #include <asn-incl.h>
27 #include "asn.h"
28 #include <asn-gser.h>
29 #include <string.h>
30 
31 #define MAX_IDENTIFIER_LEN	32
32 #define COMPONENTNOT_NULL(ptr)  ((ptr) != NULL)
33 
34 typedef struct slap_component_type {
35         /*
36          * Don't change the order of following fields
37          * They are identical the first 9 fields of
38          * AttributeType
39          */
40         LDAPAttributeType               ct_atype;
41         struct berval                   ct_cname;
42         struct slap_attribute_type      *ct_sup;
43         struct slap_attribute_type      **ct_subtypes;
44         MatchingRule                    *ct_equality;
45         MatchingRule                    *ct_approx;
46         MatchingRule                    *ct_ordering;
47         MatchingRule                    *ct_substr;
48         Syntax                          *ct_syntax;
49 } ComponentType;
50 
51 
52 /*
53  * BIT STRING
54  */
55 typedef struct ComponentBits {
56 	void* syntax;
57 	ComponentDesc* comp_desc;
58 	struct berval identifier;
59 	char id_buf[MAX_IDENTIFIER_LEN];
60 	AsnBits value;
61 } ComponentBits;
62 
63 #define GASNBITS_PRESENT(abits) ((abits)->value.bits != NULL)
64 #define COMPONENTBITS_PRESENT(abits) ((abits)->value.bits != NULL)
65 int GEncComponentBits (GenBuf *b, ComponentBits* bits);
66 int GDecComponentBits (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
67 int BDecComponentBits (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
68 int MatchingComponentBits (char* oid, ComponentSyntaxInfo *bits1 , ComponentSyntaxInfo* bits2);
69 #define ExtractingComponentBits( mem_op, cr,data ) NULL
70 
71 /*
72  * BMP String
73  */
74 typedef struct ComponentBMPString {
75 	void* syntax;
76 	ComponentDesc* comp_desc;
77 	struct berval identifier;
78 	char id_buf[MAX_IDENTIFIER_LEN];
79 	BMPString value;
80 } ComponentBMPString;
81 
82 int GEncComponentBMPString (GenBuf *b, ComponentBMPString* bmp);
83 int GDecComponentBMPString (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
84 int BDecComponentBMPString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
85 #define MatchingComponentBMPString MatchingComponentOcts
86 #define ExtractingComponentBMPString( mem_op, cr, data ) NULL
87 #define FreeComponentBMPString FreeComponentOcts
88 
89 /*
90  * BOOLEAN
91  */
92 typedef struct ComponentBool {
93 	void* syntax;
94 	ComponentDesc* comp_desc;
95 	struct berval identifier;
96 	char id_buf[MAX_IDENTIFIER_LEN];
97 	AsnBool value;
98 } ComponentBool;
99 
100 int GEncComponentBool (GenBuf *b, ComponentBool * bool );
101 int GDecComponentBool ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
102 int BDecComponentBool ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
103 int MatchingComponentBool (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
104 #define ExtractingComponentBool( mem_op, cr, data ) NULL
105 #define FreeComponentBool(v) NULL
106 
107 /*
108  * ENUMERTED
109  */
110 typedef struct ComponentEnum {
111 	void* syntax;
112 	ComponentDesc* comp_desc;
113 	struct berval identifier;
114 	char id_buf[MAX_IDENTIFIER_LEN];
115 	AsnEnum value;
116 	struct berval value_identifier;/*Why this value is defined here?*/
117 } ComponentEnum;
118 
119 int GEncComponentEnum (GenBuf *b, ComponentEnum* comp_enum);
120 int GDecComponentEnum ( void* mem_op, GenBuf *a, void *result, AsnLen *bytesDecoded,int mode);
121 int BDecComponentEnum ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
122 int MatchingComponentEnum (char *oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo * b);
123 #define ExtractingComponentEnum( mem_op, cr, data ) NULL
124 #define FreeComponentEnum FreeComponentInt
125 
126 /*
127  * IA5 String
128  */
129 typedef struct ComponentIA5String {
130 	void* syntax;
131 	ComponentDesc* comp_desc;
132 	struct berval identifier;
133 	char id_buf[MAX_IDENTIFIER_LEN];
134 	IA5String value;
135 } ComponentIA5String;
136 
137 #define GEncComponentIA5String GEncComponentUTF8String
138 #define GDecComponentIA5String GDecComponentUTF8String
139 int
140 BDecComponentIA5StringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
141 int BDecComponentIA5String ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
142 #define MatchingComponentIA5String MatchingComponentOcts
143 #define ExtractingComponentIA5String(mem_op, cr,data)	NULL
144 #define FreeComponentIA5String FreeComponentOcts
145 
146 
147 /*
148  * INTEGER
149  */
150 typedef struct ComponentInt {
151 	void* syntax;
152 	ComponentDesc* comp_desc;
153 	struct berval identifier;
154 	char id_buf[MAX_IDENTIFIER_LEN];
155 	int value;
156 } ComponentInt;
157 
158 #define GNOT_NULL(ptr) ((ptr) != NULL)
159 int GEncComponentInt (GenBuf *b, ComponentInt *comp_int);
160 int GDecComponentInt ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
161 int BDecComponentInt ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
162 int MatchingComponentInt (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
163 #define ExtractingComponentInt(mem_op, cr,data)	NULL
164 #define FreeComponentInt(v) NULL
165 
166 /*
167  * LIST Data Structure for C_LIST
168  */
169 typedef struct ComponentList {
170 	void* syntax;
171 	ComponentDesc* comp_desc;
172 	struct berval identifier;
173 	char id_buf[MAX_IDENTIFIER_LEN];
174 	AsnList comp_list;
175 } ComponentList;
176 
177 /*
178  * NULL
179  */
180 typedef struct ComponentNull {
181 	void* syntax;
182 	ComponentDesc* comp_desc;
183 	struct berval identifier;
184 	char id_buf[MAX_IDENTIFIER_LEN];
185 	AsnNull value;
186 } ComponentNull;
187 
188 int GEncComponentNull (GenBuf *b, ComponentNull* comp_null);
189 int GDecComponentNull ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
190 int BDecComponentNull ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
191 int BDecComponentNullTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
192 int MatchingComponentNull (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
193 #define ExtractingComponentNull(mem_op, cr, data)	NULL
194 #define FreeComponentNull NULL
195 
196 /*
197  * Numeric String
198  */
199 typedef struct ComponentNumericString {
200 	void* syntax;
201 	ComponentDesc* comp_desc;
202 	struct berval identifier;
203 	char id_buf[MAX_IDENTIFIER_LEN];
204 	NumericString value;
205 } ComponentNumericString;
206 
207 #define GEncComponentNumericString GEncComponentUTF8String
208 #define GDecComponentNumericString GDecComponentUTF8String
209 int BDecComponentNumericString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
210 #define MatchingComponentNumericString MatchingComponentOcts
211 #define ExtractingComponentNumericString(mem_op, cr,data)	NULL
212 #define FreeComponentNumericString FreeComponentOcts
213 
214 /*
215  * OCTETS STRING
216  */
217 typedef struct ComponentOcts {
218 	void* syntax;
219 	ComponentDesc* comp_desc;
220 	struct berval identifier;
221 	char id_buf[MAX_IDENTIFIER_LEN];
222 	AsnOcts value;
223 } ComponentOcts;
224 
225 #define GASNOCTS_PRESENT(aocts) ((aocts)->value.octs != NULL)
226 int GEncComponentOcts (GenBuf *b, ComponentOcts *octs);
227 int GDecComponentOcts (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
228 int BDecComponentOctsTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
229 int BDecComponentOcts (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
230 int MatchingComponentOcts (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
231 #define ExtractingComponentOcts(mem_op,cr,data)	NULL
232 void FreeComponentOcts( ComponentOcts* octs );
233 
234 /*
235  * OID (Object Identifier)
236  */
237 typedef struct ComponentOid {
238 	void* syntax;
239 	ComponentDesc* comp_desc;
240 	struct berval identifier;
241 	char id_buf[MAX_IDENTIFIER_LEN];
242 	AsnOid value;
243 } ComponentOid;
244 
245 #define GASNOID_PRESENT(aoid) ASNOCTS_PRESENT(aoid)
246 int GEncComponentOid (GenBuf *b, ComponentOid *oid);
247 int GDecComponentOid (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
248 int BDecComponentOid (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
249 int MatchingComponentOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
250 #define ExtractingComponentOid(mem_op, cr, data)	NULL
251 #define FreeComponentOid FreeComponentOcts
252 
253 /*
254  * Printable String
255  */
256 typedef struct ComponentPrintableString{
257 	void* syntax;
258 	ComponentDesc* comp_desc;
259 	struct berval identifier;
260 	char id_buf[MAX_IDENTIFIER_LEN];
261 	PrintableString value;
262 } ComponentPrintableString;
263 #define GEncComponentPrintableString GEncComponentUTF8String
264 #define GDecComponentPrintableString GDecComponentUTF8String
265 int BDecComponentPrintableString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
266 int BDecComponentPrintableStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
267 #define MatchingComponentPrintableString MatchingComponentOcts
268 #define ExtractingComponentPrintableString(mem_op, cr, data)	NULL
269 #define FreeComponentPrintableString FreeComponentOcts
270 
271 /*
272  * REAL
273  */
274 typedef struct ComponentReal{
275 	void* syntax;
276 	ComponentDesc* comp_desc;
277 	struct berval identifier;
278 	char id_buf[MAX_IDENTIFIER_LEN];
279 	AsnReal value;
280 } ComponentReal;
281 
282 int GEncComponentReal (GenBuf *b, ComponentReal* comp_real);
283 int GDecComponentReal (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
284 int BDecComponentReal (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
285 int MatchingComponentReal (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
286 #define ExtractingComponentReal( mem_op, cr, data )	NULL
287 #define FreeComponentReal(v) NULL
288 
289 /*
290  * Relative OID
291  */
292 
293 typedef struct ComponentRelativeOid {
294 	void* syntax;
295 	ComponentDesc* comp_desc;
296 	struct berval identifier;
297 	char id_buf[MAX_IDENTIFIER_LEN];
298 	AsnRelativeOid value;
299 } ComponentRelativeOid;
300 
301 int GEncComponentRelativeOid (GenBuf *b, ComponentRelativeOid *r_oid);
302 int GDecComponentRelativeOid ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
303 int BDecComponentRelativeOid ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
304 int MatchingComponentRelativeOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
305 #define ExtractingComponentRelativeOid( mem_op, cr, data ) NULL
306 #define FreeComponentRelativeOid FreeComponentOid
307 
308 /*
309  * Teletex String
310  */
311 typedef struct ComponentTeletexString {
312 	void* syntax;
313 	ComponentDesc* comp_desc;
314 	struct berval identifier;
315 	char id_buf[MAX_IDENTIFIER_LEN];
316 	TeletexString value;
317 } ComponentTeletexString;
318 
319 int GEncComponentTeletexString (GenBuf *b, ComponentTeletexString * tel_str);
320 int GDecComponentTeletexString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
321 int BDecComponentTeletexStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
322 int BDecComponentTeletexString( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode );
323 #define MatchingComponentTeletexString MatchingComponentOcts
324 #define ExtractingComponentTeletexString(mem_op,cr,data)
325 #define FreeComponentTeletexString FreeComponentOcts
326 
327 
328 /*
329  * Universal String
330  */
331 typedef struct ComponentUniversalString{
332 	void* syntax;
333 	ComponentDesc* comp_desc;
334 	struct berval identifier;
335 	char id_buf[MAX_IDENTIFIER_LEN];
336 	UniversalString value;
337 } ComponentUniversalString;
338 
339 int GEncComponentUniversalString (GenBuf *b, ComponentUniversalString* uni_str);
340 int GDecComponentUniversalString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
341 int BDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
342 #define MatchingComponentUniversalString MatchingComponentOcts
343 #define ExtractingComponentUniversalString(mem_op,cr,data)
344 #define FreeComponentUniversalString FreeComponentOcts
345 
346 /*
347  * UTF8 String
348  */
349 typedef struct ComponentUTF8String{
350 	void* syntax;
351 	ComponentDesc* comp_desc;
352 	struct berval identifier;
353 	char id_buf[MAX_IDENTIFIER_LEN];
354 	UTF8String value;
355 } ComponentUTF8String;
356 
357 int GEncComponentUTF8String (GenBuf *b, ComponentUTF8String * utf_str);
358 int GDecComponentUTF8String (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
359 int BDecComponentUTF8String (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
360 #define MatchingComponentUTF8String MatchingComponentOcts
361 #define ExtractingComponentUTF8String(mem_op,cr,data)
362 #define FreeComponentUTF8String FreeComponentOcts
363 
364 /*
365  * Visible String
366  */
367 typedef struct ComponentVisibleString{
368 	void* syntax;
369 	ComponentDesc* comp_desc;
370 	struct berval identifier;
371 	char id_buf[MAX_IDENTIFIER_LEN];
372 	VisibleString value;
373 } ComponentVisibleString;
374 
375 #define GEncComponentVisibleString GEncComponentUTF8String
376 #define GDecComponentVisibleString GDecComponentUTF8String
377 int BDecComponentVisibleString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
378 #define MatchingComponentVisibleString MatchingComponentOcts
379 #define ExtractingComponentVisibleString(mem_op,cr,data)
380 #define FreeComponentVisibleString FreeComponentOcts
381 
382 /*
383  * ANY and ANY DEFINED BY
384  */
385 
386 typedef int (*MatchFcn) (char*, void*, void*);
387 typedef void* (*ExtractFcn) (void*, ComponentReference*, void * );
388 
389 typedef struct ComponentAnyInfo
390 {
391 	int		anyId;
392 	AsnOid		oid;
393 	ComponentInt	intId;
394 	unsigned int	size;
395 	EncodeFcn	Encode;
396 	gser_decoder_func* GSER_Decode;
397 	ber_tag_decoder_func* BER_Decode;
398 	ExtractFcn	Extract;
399 	MatchFcn	Match;
400 	FreeFcn		Free;
401 	PrintFcn	Print;
402 } ComponentAnyInfo;
403 
404 typedef struct ComponentAnyInfo OidDecoderMapping ;
405 
406 typedef struct ComponentAny{
407 	void*		syntax;
408 	ComponentDesc	*comp_desc;
409 	struct berval	identifier;
410 	char id_buf[MAX_IDENTIFIER_LEN];
411 	ComponentAnyInfo	*cai;
412 	void		*value;
413 } ComponentAny;
414 
415 typedef ComponentAny ComponentAnyDefinedBy;
416 
417 #define BDecComponentAnyDefinedBy BDecComponentAny
418 #define GDecComponentAnyDefinedBy GDecComponentAny
419 #define MatchingComponentAnyDefinedBy MatchingComponentAny
420 #define FreeComponentAnyDefinedBy FreeComponentAny
421 
422 int GEncComponentAny (GenBuf *b, ComponentAny *comp_any);
423 int BDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
424 int GDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
425 int MatchingComponentAny (char* oid, ComponentAny *a, ComponentAny *b);
426 void FreeComponentAny ( ComponentAny*);
427 
428 void InstallAnyByComponentInt (int anyId, ComponentInt intId, unsigned int size, EncodeFcn encode, gser_decoder_func* G_decode, ber_tag_decoder_func B_decode, ExtractFcn extract, MatchFcn match, FreeFcn free, PrintFcn print);
429 
430 void InstallAnyByComponentOid (int anyId, AsnOid *oid, unsigned int size, EncodeFcn encode, gser_decoder_func* G_decode, ber_tag_decoder_func* B_decode, ExtractFcn extract, MatchFcn match, FreeFcn free, PrintFcn print);
431 
432 int CheckSelectTypeCorrect ( void* mem_op, ComponentAnyInfo *v, struct berval* select );
433 
434 OidDecoderMapping* RetrieveOidDecoderMappingbyBV( struct berval* in );
435 OidDecoderMapping* RetrieveOidDecoderMappingbyOid( char* ch_oid, int oid_len );
436 OidDecoderMapping* RetrieveOidDecoderMappingbyDesc( char* desc, int desc_len );
437 /*
438  * UTCTime
439  */
440 typedef ComponentVisibleString ComponentUTCTime;
441 #define GEncComponentUTCTime GEncComponentUTF8String
442 #define GDecComponentUTCTime GDecComponentVisibleString
443 #define BDecComponentUTCTime BDecComponentOcts
444 #define MatchingComponentUTCTime MatchingComponentOcts
445 #define ExtractingComponentUTCTime(mem_op,cr,data) NULL
446 #define FreeComponentUTCTime FreeComponentOcts
447 
448 /*
449  * GeneralizedTime
450  */
451 typedef ComponentVisibleString ComponentGeneralizedTime;
452 int GEncComponentGeneralizedTime (GenBuf *b, ComponentGeneralizedTime *gen_time);
453 #define GDecComponentGeneralizedTime GDecComponentVisibleString
454 #define BDecComponentGeneralizedTime BDecComponentOcts
455 #define MatchingComponentGeneralizedTime MatchingComponentOcts
456 #define ExtractingComponentGeneralizedTime(mem_op,cr,data) NULL
457 #define FreeComponentGeneralizedTime FreeComponentOcts
458 
459 typedef int converter_func LDAP_P ((
460 	struct berval* in ));
461 
462 typedef struct asntype_to_syntax {
463 	AsnTypeId	ats_typeId;
464 	/* Syntax Descriptor */
465 	char		*ats_syn_name;
466 	/* Syntax OID */
467 	char		*ats_syn_oid;
468 	Syntax		*ats_syn;
469 } AsnTypetoSyntax;
470 
471 typedef struct asntype_to_comp_matchingrule {
472 	AsnTypeId	atc_typeId;
473 	char*	atc_equality;
474 	char*	atc_approx;
475 	char*	atc_ordering;
476 	char*	atc_substr;
477 } AsnTypetoCompMatchingRule;
478 
479 typedef struct asntype_to_comp_desc {
480 	AsnTypeId	atcd_typeId;
481 	ComponentDesc	atcd_cd;
482 } AsnTypetoCompDesc;
483 
484 typedef struct asntype_to_comp_type {
485 	AsnTypeId	ac_asn_id;
486 	ComponentType   ac_comp_type;
487 } AsnTypetoCompType;
488 
489 /* refined matching purpose */
490 typedef struct asntype_to_matchingrule {
491 	AsnTypeId	atmr_typeId;
492 	char*		atmr_mr_name;
493 	/*Implicitly corresponding LDAP syntax OID*/
494 	char*		atmr_syn_oid;
495 	MatchingRule	*atmr_mr;
496 } AsnTypetoMatchingRule;
497 
498 typedef struct asntype_to_matchingrule_table {
499 	char*	atmr_oid;
500 	struct asntype_to_matchingrule atmr_table[ASNTYPE_END];
501 	struct asntype_to_matchingrule_table* atmr_table_next;
502 } AsnTypetoMatchingRuleTable;
503 
504 #define MAX_OID_LEN 256
505 #define MAX_OD_ENTRY 8
506 
507 /*
508  * Object Identifier and corresponding Syntax Decoder Table
509  */
510 typedef struct OID_Decoder_entry {
511         char            oe_oid[MAX_OID_LEN];
512         gser_decoder_func*   oe_gser_decoder;
513         ber_decoder_func*   oe_ber_decoder;
514 	converter_func* oe_converter;
515         struct OID_Decoder_entry*       oe_next;
516         struct OID_Decoder_entry*       oe_prev;
517 } OD_entry;
518 
519 void
520 m_convert_asn_to_ldap ( ComponentSyntaxInfo* csi, struct berval* bv);
521 int
522 m_convert_assert_to_comp ( gser_decoder_func* decoder, struct berval* bv,
523                         ComponentSyntaxInfo** csi, int len, int mode );
524 void*
525 m_convert_attr_to_comp ( Attribute* a, struct berval* bv );
526 
527 /*
528  * Decoder Modes
529  * Different operation is required to handle Decoding(2), Extracted Component
530  * decoding(0), ANY DEFINED TYPe(2)
531  * b0 : Component Alloc(yes)
532  *	Constructed type : Component Alloc (Yes)
533  *	Primitive type : Component Alloc (Yes)
534  * 	set to mode 2 in inner decoders
535  * b1 : Component Alloc (No)
536  *	Constructed type : Component Alloc (No)
537  *	Primitive type : Component Alloc (No)
538  *	set to mode 2 in inner decoders
539  * b2 : Default Mode
540  *	Constructed type : Component Alloc (Yes)
541  *	Primitive type : Component Alloc (No)
542  * in addition to above modes, the 4th bit has special meaning,
543  * b4 : if the 4th bit is clear, DecxxxContent is called
544  * b4 : if the 4th bit is set, Decxxx is called, then it is cleared.
545  */
546 #define DEC_ALLOC_MODE_0	0x01
547 #define DEC_ALLOC_MODE_1	0x02
548 #define DEC_ALLOC_MODE_2	0x04
549 #define CALL_TAG_DECODER	0x08
550 #define CALL_CONTENT_DECODER	~0x08
551 
552 #define OID_ALL_COMP_MATCH "1.2.36.79672281.1.13.6"
553 #define OID_COMP_FILTER_MATCH "1.2.36.79672281.1.13.2"
554 #define MAX_LDAP_STR_LEN 128
555 
556 MatchingRule*
557 retrieve_matching_rule( char* mr_oid, AsnTypeId type );
558 
559 #define INITIAL_DN_SIZE 128
560 #define INITIAL_ATTR_SIZE 256
561 #define INCREMENT_SIZE 32
562 /*
563  * Followings are for conversion from ASN.1 RDN and DN to
564  * LDAP encodings
565  */
566 #define MAX_ALIASING_ENTRY 128
567 int increment_bv_mem ( struct berval* in );
568 int intToAscii ( int value, char* buf );
569 typedef ComponentList irRDNSequence;
570 typedef ComponentList irRelativeDistinguishedName;
571 typedef ComponentOid irAttributeType;
572 typedef struct comp_irAttributeTypeAndValue /* SEQUENCE */
573 {
574 	Syntax* syntax;
575 	ComponentDesc* comp_desc;
576 	struct berval identifier;
577 	char id_buf[MAX_IDENTIFIER_LEN];
578 	irAttributeType type; /* AttributeType */
579 	ComponentAnyDefinedBy value; /* ANY DEFINED BY type */
580 } irAttributeTypeAndValue;
581 #define RDN_MATCH_OID "1.2.36.79672281.1.13.3"
582 #define DN_MATCH_OID "2.5.13.1"
583 
584 extern AsnTypetoSyntax asn_to_syntax_mapping_tbl[];
585 extern AsnTypetoCompMatchingRule asntype_to_compMR_mapping_tbl[];
586 extern AsnTypetoCompType asntype_to_compType_mapping_tbl[];
587 extern AsnTypetoCompDesc asntype_to_compdesc_mapping_tbl[];
588 
589 int ConvertRDN2RFC2253 ( irRelativeDistinguishedName* in, struct berval *out );
590 int ConvertRDNSequence2RFC2253( irRDNSequence *in, struct berval* out );
591 
592 void* comp_nibble_memory_allocator ( int init_mem, int inc_mem );
593 
594 ComponentDesc* get_ComponentDesc( int id );
595 #endif
596