1 /* Copyright 2004 IBM Corporation
3 * Redisribution and use in source and binary forms, with or without
4 * modification, are permitted only as authorizd by the OpenLADP
8 * This work originally developed by Sang Seok Lim
9 * 2004/06/18 03:20:00 slim@OpenLDAP.org
12 #ifndef _H_COMPONENT_MODULE
13 #define _H_COMPONENT_MODULE
16 #include <ac/string.h>
17 #include <ac/socket.h>
28 #define MAX_IDENTIFIER_LEN 128
29 #define COMPONENTNOT_NULL(ptr) ((ptr) != NULL)
34 typedef struct ComponentBits {
36 ComponentDesc* comp_desc;
37 struct berval identifier;
38 char id_buf[MAX_IDENTIFIER_LEN];
42 #define GASNBITS_PRESENT(abits) ((abits)->value.bits != NULL)
43 #define COMPONENTBITS_PRESENT(abits) ((abits)->value.bits != NULL)
44 int GDecComponentBits (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
45 int BDecComponentBits (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
46 int MatchingComponentBits (char* oid, ComponentSyntaxInfo *bits1 , ComponentSyntaxInfo* bits2);
47 #define ExtractingComponentBits( mem_op, cr,data ) NULL
52 typedef struct ComponentBMPString {
54 ComponentDesc* comp_desc;
55 struct berval identifier;
56 char id_buf[MAX_IDENTIFIER_LEN];
60 int GDecComponentBMPString (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
61 int BDecComponentBMPString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
62 #define MatchingComponentBMPString MatchingComponentOcts
63 #define ExtractingComponentBMPString( mem_op, cr, data ) NULL
64 #define FreeComponentBMPString FreeComponentOcts
69 typedef struct ComponentBool {
71 ComponentDesc* comp_desc;
72 struct berval identifier;
73 char id_buf[MAX_IDENTIFIER_LEN];
77 int GDecComponentBool ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
78 int BDecComponentBool ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
79 int MatchingComponentBool (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
80 #define ExtractingComponentBool( mem_op, cr, data ) NULL
81 #define FreeComponentBool(v) NULL
86 typedef struct ComponentEnum {
88 ComponentDesc* comp_desc;
89 struct berval identifier;
90 char id_buf[MAX_IDENTIFIER_LEN];
92 struct berval value_identifier;/*Why this value is defined here?*/
95 int GDecComponentEnum ( void* mem_op, GenBuf *a, void *result, AsnLen *bytesDecoded,int mode);
96 int BDecComponentEnum ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
97 int MatchingComponentEnum (char *oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo * b);
98 #define ExtractingComponentEnum( mem_op, cr, data ) NULL
99 #define FreeComponentEnum FreeComponentInt
104 typedef struct ComponentIA5String {
106 ComponentDesc* comp_desc;
107 struct berval identifier;
108 char id_buf[MAX_IDENTIFIER_LEN];
110 } ComponentIA5String;
112 #define GDecComponentIA5String GDecComponentUTF8String
113 int BDecComponentIA5String ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
114 #define MatchingComponentIA5String MatchingComponentOcts
115 #define ExtractingComponentIA5String(mem_op, cr,data) NULL
116 #define FreeComponentIA5String FreeComponentOcts
122 typedef struct ComponentInt {
124 ComponentDesc* comp_desc;
125 struct berval identifier;
126 char id_buf[MAX_IDENTIFIER_LEN];
130 #define GNOT_NULL(ptr) ((ptr) != NULL)
132 int GDecComponentInt ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
133 int BDecComponentInt ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
134 int MatchingComponentInt (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
135 #define ExtractingComponentInt(mem_op, cr,data) NULL
136 #define FreeComponentInt(v) NULL
139 * LIST Data Structure for C_LIST
141 typedef struct ComponentList {
143 ComponentDesc* comp_desc;
144 struct berval identifier;
145 char id_buf[MAX_IDENTIFIER_LEN];
152 typedef struct ComponentNull {
154 ComponentDesc* comp_desc;
155 struct berval identifier;
156 char id_buf[MAX_IDENTIFIER_LEN];
160 int GDecComponentNull ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
161 int BDecComponentNull ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
162 int BDecComponentNullTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
163 int MatchingComponentNull (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
164 #define ExtractingComponentNull(mem_op, cr, data) NULL
165 #define FreeComponentNull NULL
170 typedef struct ComponentNumericString {
172 ComponentDesc* comp_desc;
173 struct berval identifier;
174 char id_buf[MAX_IDENTIFIER_LEN];
176 } ComponentNumericString;
178 #define GDecComponentNumericString GDecComponentUTF8String
179 int BDecComponentNumericString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
180 #define MatchingComponentNumericString MatchingComponentOcts
181 #define ExtractingComponentNumericString(mem_op, cr,data) NULL
182 #define FreeComponentNumericString FreeComponentOcts
187 typedef struct ComponentOcts {
189 ComponentDesc* comp_desc;
190 struct berval identifier;
191 char id_buf[MAX_IDENTIFIER_LEN];
195 #define GASNOCTS_PRESENT(aocts) ((aocts)->value.octs != NULL)
197 int GDecComponentOcts (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
198 int BDecComponentOcts (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
199 int MatchingComponentOcts (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
200 #define ExtractingComponentOcts(mem_op,cr,data) NULL
201 void FreeComponentOcts( ComponentOcts* octs );
204 * OID (Object Identifier)
206 typedef struct ComponentOid {
208 ComponentDesc* comp_desc;
209 struct berval identifier;
210 char id_buf[MAX_IDENTIFIER_LEN];
214 #define GASNOID_PRESENT(aoid) ASNOCTS_PRESENT(aoid)
216 int GDecComponentOid (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
217 int BDecComponentOid (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
218 int MatchingComponentOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
219 #define ExtractingComponentOid(mem_op, cr, data) NULL
220 #define FreeComponentOid FreeComponentOcts
225 typedef struct ComponentPrintableString{
227 ComponentDesc* comp_desc;
228 struct berval identifier;
229 char id_buf[MAX_IDENTIFIER_LEN];
230 PrintableString value;
231 } ComponentPrintableString;
233 #define GDecComponentPrintableString GDecComponentUTF8String
234 int BDecComponentPrintableString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
235 int BDecComponentPrintableStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
236 #define MatchingComponentPrintableString MatchingComponentOcts
237 #define ExtractingComponentPrintableString(mem_op, cr, data) NULL
238 #define FreeComponentPrintableString FreeComponentOcts
243 typedef struct ComponentReal{
245 ComponentDesc* comp_desc;
246 struct berval identifier;
247 char id_buf[MAX_IDENTIFIER_LEN];
251 int GDecComponentReal (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
252 int BDecComponentReal (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
253 int MatchingComponentReal (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
254 #define ExtractingComponentReal( mem_op, cr, data ) NULL
255 #define FreeComponentReal(v) NULL
261 typedef struct ComponentRelativeOid {
263 ComponentDesc* comp_desc;
264 struct berval identifier;
265 char id_buf[MAX_IDENTIFIER_LEN];
266 AsnRelativeOid value;
267 } ComponentRelativeOid;
269 int GDecComponentRelativeOid ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
270 int BDecComponentRelativeOid ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
271 int MatchingComponentRelativeOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
272 #define ExtractingComponentRelativeOid( mem_op, cr, data ) NULL
273 #define FreeComponentRelativeOid FreeComponentOid
278 typedef struct ComponentTeletexString {
280 ComponentDesc* comp_desc;
281 struct berval identifier;
282 char id_buf[MAX_IDENTIFIER_LEN];
284 } ComponentTeletexString;
286 int GDecComponentTeletexString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
287 #define BDecComponentTeletexString BDecComponentOcts
288 #define MatchingComponentTeletexString MatchingComponentOcts
289 #define ExtractingComponentTeletexString(mem_op,cr,data)
290 #define FreeComponentTeletexString FreeComponentOcts
296 typedef struct ComponentUniversalString{
298 ComponentDesc* comp_desc;
299 struct berval identifier;
300 char id_buf[MAX_IDENTIFIER_LEN];
301 UniversalString value;
302 } ComponentUniversalString;
304 int GDecComponentUniversalString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
305 int BDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
306 #define MatchingComponentUniversalString MatchingComponentOcts
307 #define ExtractingComponentUniversalString(mem_op,cr,data)
308 #define FreeComponentUniversalString FreeComponentOcts
313 typedef struct ComponentUTF8String{
315 ComponentDesc* comp_desc;
316 struct berval identifier;
317 char id_buf[MAX_IDENTIFIER_LEN];
319 } ComponentUTF8String;
321 int GDecComponentUTF8String (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
322 int BDecComponentUTF8String (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
323 #define MatchingComponentUTF8String MatchingComponentOcts
324 #define ExtractingComponentUTF8String(mem_op,cr,data)
325 #define FreeComponentUTF8String FreeComponentOcts
330 typedef struct ComponentVisibleString{
332 ComponentDesc* comp_desc;
333 struct berval identifier;
334 char id_buf[MAX_IDENTIFIER_LEN];
336 } ComponentVisibleString;
338 #define GDecComponentVisibleString GDecComponentUTF8String
339 int BDecComponentVisibleString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
340 #define MatchingComponentVisibleString MatchingComponentOcts
341 #define ExtractingComponentVisibleString(mem_op,cr,data)
342 #define FreeComponentVisibleString FreeComponentOcts
345 * ANY and ANY DEFINED BY
348 typedef int (*MatchFcn) (char*, void*, void*);
349 typedef void* (*ExtractFcn) (void*, ComponentReference*, void * );
351 typedef struct ComponentAnyInfo
358 gser_decoder_func* GSER_Decode;
359 ber_tag_decoder_func* BER_Decode;
366 typedef struct ComponentAny{
368 ComponentDesc *comp_desc;
369 struct berval identifier;
370 char id_buf[MAX_IDENTIFIER_LEN];
371 ComponentAnyInfo *cai;
375 typedef ComponentAny ComponentAnyDefinedBy;
377 #define BDecComponentAnyDefinedBy BDecComponentAny
378 #define GDecComponentAnyDefinedBy GDecComponentAny
379 #define MatchingComponentAnyDefinedBy MatchingComponentAny
380 #define FreeComponentAnyDefinedBy FreeComponentAny
382 int BDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
383 int GDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
384 int MatchingComponentAny (char* oid, ComponentAny *a, ComponentAny *b);
385 void FreeComponentAny ( ComponentAny*);
387 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);
389 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);
395 typedef ComponentVisibleString ComponentUTCTime;
396 #define GDecComponentUTCTime GDecComponentVisibleString
397 #define BDecComponentUTCTime BDecComponentOcts
398 #define MatchingComponentUTCTime MatchingComponentOcts
399 #define ExtractingComponentUTCTime(mem_op,cr,data) NULL
400 #define FreeComponentUTCTime FreeComponentOcts
405 typedef ComponentVisibleString ComponentGeneralizedTime;
406 #define GDecComponentGeneralizedTime GDecComponentVisibleString
407 #define BDecComponentGeneralizedTime BDecComponentOcts
408 #define MatchingComponentGeneralizedTime MatchingComponentOcts
409 #define ExtractingComponentGeneralizedTime(mem_op,cr,data) NULL
410 #define FreeComponentGeneralizedTime FreeComponentOcts
412 typedef int converter_func LDAP_P ((
413 struct berval* in ));
415 typedef struct asntype_to_syntax {
416 AsnTypeId ats_typeId;
417 /* Syntax Descriptor */
424 typedef struct asntype_to_matchingrule {
425 AsnTypeId atmr_typeId;
427 /*Implicitly corresponding LDAP syntax OID*/
429 MatchingRule *atmr_mr;
430 } AsnTypetoMatchingRule;
432 typedef struct asntype_to_matchingrule_table {
434 struct asntype_to_matchingrule atmr_table[ASNTYPE_END];
435 struct asntype_to_matchingrule_table* atmr_table_next;
436 } AsnTypetoMatchingRuleTable;
438 extern AsnTypetoSyntax asn_to_syntax_mapping_tbl[];
440 #define MAX_OID_LEN 256
441 #define MAX_OD_ENTRY 8
444 * Object Identifier and corresponding Syntax Decoder Table
446 typedef struct OID_Decoder_entry {
447 char oe_oid[MAX_OID_LEN];
448 gser_decoder_func* oe_gser_decoder;
449 ber_decoder_func* oe_ber_decoder;
450 converter_func* oe_converter;
451 struct OID_Decoder_entry* oe_next;
452 struct OID_Decoder_entry* oe_prev;
456 m_convert_asn_to_ldap ( ComponentSyntaxInfo* csi, struct berval* bv);
458 m_convert_assert_to_comp ( gser_decoder_func* decoder, struct berval* bv,
459 ComponentSyntaxInfo** csi, int len, int mode );
461 m_convert_attr_to_comp ( Attribute* a, struct berval* bv );
465 * Different operation is required to handle Decoding(2), Extracted Component
466 * decoding(0), ANY DEFINED TYPe(2)
467 * b0 : Component Alloc(yes)
468 * Constructed type : Component Alloc (Yes)
469 * Primitive type : Component Alloc (Yes)
470 * set to mode 2 in inner decoders
471 * b1 : Component Alloc (No)
472 * Constructed type : Component Alloc (No)
473 * Primitive type : Component Alloc (No)
474 * set to mode 2 in inner decoders
476 * Constructed type : Component Alloc (Yes)
477 * Primitive type : Component Alloc (No)
478 * in addition to above modes, the 4th bit has special meaning,
479 * b4 : if the 4th bit is clear, DecxxxContent is called
480 * b4 : if the 4th bit is set, Decxxx is called, then it is cleared.
482 #define DEC_ALLOC_MODE_0 0x01
483 #define DEC_ALLOC_MODE_1 0x02
484 #define DEC_ALLOC_MODE_2 0x04
485 #define CALL_TAG_DECODER 0x08
486 #define CALL_CONTENT_DECODER ~0x08
488 #define OID_ALL_COMP_MATCH "1.2.36.79672281.1.13.6"
489 #define OID_COMP_FILTER_MATCH "1.2.36.79672281.1.13.2"
490 #define MAX_LDAP_STR_LEN 128
493 retrieve_matching_rule( char* mr_oid, AsnTypeId type );