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