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 GEncComponentBits (GenBuf *b, ComponentBits* bits);
45 int GDecComponentBits (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
46 int BDecComponentBits (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
47 int MatchingComponentBits (char* oid, ComponentSyntaxInfo *bits1 , ComponentSyntaxInfo* bits2);
48 #define ExtractingComponentBits( mem_op, cr,data ) NULL
53 typedef struct ComponentBMPString {
55 ComponentDesc* comp_desc;
56 struct berval identifier;
57 char id_buf[MAX_IDENTIFIER_LEN];
61 int GEncComponentBMPString (GenBuf *b, ComponentBMPString* bmp);
62 int GDecComponentBMPString (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
63 int BDecComponentBMPString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
64 #define MatchingComponentBMPString MatchingComponentOcts
65 #define ExtractingComponentBMPString( mem_op, cr, data ) NULL
66 #define FreeComponentBMPString FreeComponentOcts
71 typedef struct ComponentBool {
73 ComponentDesc* comp_desc;
74 struct berval identifier;
75 char id_buf[MAX_IDENTIFIER_LEN];
79 int GEncComponentBool (GenBuf *b, ComponentBool * bool );
80 int GDecComponentBool ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
81 int BDecComponentBool ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
82 int MatchingComponentBool (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
83 #define ExtractingComponentBool( mem_op, cr, data ) NULL
84 #define FreeComponentBool(v) NULL
89 typedef struct ComponentEnum {
91 ComponentDesc* comp_desc;
92 struct berval identifier;
93 char id_buf[MAX_IDENTIFIER_LEN];
95 struct berval value_identifier;/*Why this value is defined here?*/
98 int GEncComponentEnum (GenBuf *b, ComponentEnum* comp_enum);
99 int GDecComponentEnum ( void* mem_op, GenBuf *a, void *result, AsnLen *bytesDecoded,int mode);
100 int BDecComponentEnum ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
101 int MatchingComponentEnum (char *oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo * b);
102 #define ExtractingComponentEnum( mem_op, cr, data ) NULL
103 #define FreeComponentEnum FreeComponentInt
108 typedef struct ComponentIA5String {
110 ComponentDesc* comp_desc;
111 struct berval identifier;
112 char id_buf[MAX_IDENTIFIER_LEN];
114 } ComponentIA5String;
116 #define GEncComponentIA5String GEncComponentUTF8String
117 #define GDecComponentIA5String GDecComponentUTF8String
118 int BDecComponentIA5String ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
119 #define MatchingComponentIA5String MatchingComponentOcts
120 #define ExtractingComponentIA5String(mem_op, cr,data) NULL
121 #define FreeComponentIA5String FreeComponentOcts
127 typedef struct ComponentInt {
129 ComponentDesc* comp_desc;
130 struct berval identifier;
131 char id_buf[MAX_IDENTIFIER_LEN];
135 #define GNOT_NULL(ptr) ((ptr) != NULL)
136 int GEncComponentInt (GenBuf *b, ComponentInt *comp_int);
137 int GDecComponentInt ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
138 int BDecComponentInt ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
139 int MatchingComponentInt (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
140 #define ExtractingComponentInt(mem_op, cr,data) NULL
141 #define FreeComponentInt(v) NULL
144 * LIST Data Structure for C_LIST
146 typedef struct ComponentList {
148 ComponentDesc* comp_desc;
149 struct berval identifier;
150 char id_buf[MAX_IDENTIFIER_LEN];
157 typedef struct ComponentNull {
159 ComponentDesc* comp_desc;
160 struct berval identifier;
161 char id_buf[MAX_IDENTIFIER_LEN];
165 int GEncComponentNull (GenBuf *b, ComponentNull* comp_null);
166 int GDecComponentNull ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
167 int BDecComponentNull ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
168 int BDecComponentNullTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
169 int MatchingComponentNull (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
170 #define ExtractingComponentNull(mem_op, cr, data) NULL
171 #define FreeComponentNull NULL
176 typedef struct ComponentNumericString {
178 ComponentDesc* comp_desc;
179 struct berval identifier;
180 char id_buf[MAX_IDENTIFIER_LEN];
182 } ComponentNumericString;
184 #define GEncComponentNumericString GEncComponentUTF8String
185 #define GDecComponentNumericString GDecComponentUTF8String
186 int BDecComponentNumericString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
187 #define MatchingComponentNumericString MatchingComponentOcts
188 #define ExtractingComponentNumericString(mem_op, cr,data) NULL
189 #define FreeComponentNumericString FreeComponentOcts
194 typedef struct ComponentOcts {
196 ComponentDesc* comp_desc;
197 struct berval identifier;
198 char id_buf[MAX_IDENTIFIER_LEN];
202 #define GASNOCTS_PRESENT(aocts) ((aocts)->value.octs != NULL)
203 int GEncComponentOcts (GenBuf *b, ComponentOcts *octs);
204 int GDecComponentOcts (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
205 int BDecComponentOcts (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
206 int MatchingComponentOcts (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
207 #define ExtractingComponentOcts(mem_op,cr,data) NULL
208 void FreeComponentOcts( ComponentOcts* octs );
211 * OID (Object Identifier)
213 typedef struct ComponentOid {
215 ComponentDesc* comp_desc;
216 struct berval identifier;
217 char id_buf[MAX_IDENTIFIER_LEN];
221 #define GASNOID_PRESENT(aoid) ASNOCTS_PRESENT(aoid)
222 int GEncComponentOid (GenBuf *b, ComponentOid *oid);
223 int GDecComponentOid (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
224 int BDecComponentOid (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
225 int MatchingComponentOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
226 #define ExtractingComponentOid(mem_op, cr, data) NULL
227 #define FreeComponentOid FreeComponentOcts
232 typedef struct ComponentPrintableString{
234 ComponentDesc* comp_desc;
235 struct berval identifier;
236 char id_buf[MAX_IDENTIFIER_LEN];
237 PrintableString value;
238 } ComponentPrintableString;
239 #define GEncComponentPrintableString GEncComponentUTF8String
240 #define GDecComponentPrintableString GDecComponentUTF8String
241 int BDecComponentPrintableString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
242 int BDecComponentPrintableStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
243 #define MatchingComponentPrintableString MatchingComponentOcts
244 #define ExtractingComponentPrintableString(mem_op, cr, data) NULL
245 #define FreeComponentPrintableString FreeComponentOcts
250 typedef struct ComponentReal{
252 ComponentDesc* comp_desc;
253 struct berval identifier;
254 char id_buf[MAX_IDENTIFIER_LEN];
258 int GEncComponentReal (GenBuf *b, ComponentReal* comp_real);
259 int GDecComponentReal (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
260 int BDecComponentReal (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
261 int MatchingComponentReal (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
262 #define ExtractingComponentReal( mem_op, cr, data ) NULL
263 #define FreeComponentReal(v) NULL
269 typedef struct ComponentRelativeOid {
271 ComponentDesc* comp_desc;
272 struct berval identifier;
273 char id_buf[MAX_IDENTIFIER_LEN];
274 AsnRelativeOid value;
275 } ComponentRelativeOid;
277 int GEncComponentRelativeOid (GenBuf *b, ComponentRelativeOid *r_oid);
278 int GDecComponentRelativeOid ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
279 int BDecComponentRelativeOid ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
280 int MatchingComponentRelativeOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
281 #define ExtractingComponentRelativeOid( mem_op, cr, data ) NULL
282 #define FreeComponentRelativeOid FreeComponentOid
287 typedef struct ComponentTeletexString {
289 ComponentDesc* comp_desc;
290 struct berval identifier;
291 char id_buf[MAX_IDENTIFIER_LEN];
293 } ComponentTeletexString;
295 int GEncComponentTeletexString (GenBuf *b, ComponentTeletexString * tel_str);
296 int GDecComponentTeletexString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
297 #define BDecComponentTeletexString BDecComponentOcts
298 #define MatchingComponentTeletexString MatchingComponentOcts
299 #define ExtractingComponentTeletexString(mem_op,cr,data)
300 #define FreeComponentTeletexString FreeComponentOcts
306 typedef struct ComponentUniversalString{
308 ComponentDesc* comp_desc;
309 struct berval identifier;
310 char id_buf[MAX_IDENTIFIER_LEN];
311 UniversalString value;
312 } ComponentUniversalString;
314 int GEncComponentUniversalString (GenBuf *b, ComponentUniversalString* uni_str);
315 int GDecComponentUniversalString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
316 int BDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
317 #define MatchingComponentUniversalString MatchingComponentOcts
318 #define ExtractingComponentUniversalString(mem_op,cr,data)
319 #define FreeComponentUniversalString FreeComponentOcts
324 typedef struct ComponentUTF8String{
326 ComponentDesc* comp_desc;
327 struct berval identifier;
328 char id_buf[MAX_IDENTIFIER_LEN];
330 } ComponentUTF8String;
332 int GEncComponentUTF8String (GenBuf *b, ComponentUTF8String * utf_str);
333 int GDecComponentUTF8String (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
334 int BDecComponentUTF8String (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
335 #define MatchingComponentUTF8String MatchingComponentOcts
336 #define ExtractingComponentUTF8String(mem_op,cr,data)
337 #define FreeComponentUTF8String FreeComponentOcts
342 typedef struct ComponentVisibleString{
344 ComponentDesc* comp_desc;
345 struct berval identifier;
346 char id_buf[MAX_IDENTIFIER_LEN];
348 } ComponentVisibleString;
350 #define GEncComponentVisibleString GEncComponentUTF8String
351 #define GDecComponentVisibleString GDecComponentUTF8String
352 int BDecComponentVisibleString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
353 #define MatchingComponentVisibleString MatchingComponentOcts
354 #define ExtractingComponentVisibleString(mem_op,cr,data)
355 #define FreeComponentVisibleString FreeComponentOcts
358 * ANY and ANY DEFINED BY
361 typedef int (*MatchFcn) (char*, void*, void*);
362 typedef void* (*ExtractFcn) (void*, ComponentReference*, void * );
364 typedef struct ComponentAnyInfo
371 gser_decoder_func* GSER_Decode;
372 ber_tag_decoder_func* BER_Decode;
379 typedef struct ComponentAny{
381 ComponentDesc *comp_desc;
382 struct berval identifier;
383 char id_buf[MAX_IDENTIFIER_LEN];
384 ComponentAnyInfo *cai;
388 typedef ComponentAny ComponentAnyDefinedBy;
390 #define BDecComponentAnyDefinedBy BDecComponentAny
391 #define GDecComponentAnyDefinedBy GDecComponentAny
392 #define MatchingComponentAnyDefinedBy MatchingComponentAny
393 #define FreeComponentAnyDefinedBy FreeComponentAny
395 int GEncComponentAny (GenBuf *b, ComponentAny *comp_any);
396 int BDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
397 int GDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
398 int MatchingComponentAny (char* oid, ComponentAny *a, ComponentAny *b);
399 void FreeComponentAny ( ComponentAny*);
401 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);
403 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);
409 typedef ComponentVisibleString ComponentUTCTime;
410 int GEncComponentUTCTime( GenBuf* b, ComponentUTCTime* utc_time);
411 #define GDecComponentUTCTime GDecComponentVisibleString
412 #define BDecComponentUTCTime BDecComponentOcts
413 #define MatchingComponentUTCTime MatchingComponentOcts
414 #define ExtractingComponentUTCTime(mem_op,cr,data) NULL
415 #define FreeComponentUTCTime FreeComponentOcts
420 typedef ComponentVisibleString ComponentGeneralizedTime;
421 int GEncComponentGeneralizedTime (GenBuf *b, ComponentGeneralizedTime *gen_time);
422 #define GDecComponentGeneralizedTime GDecComponentVisibleString
423 #define BDecComponentGeneralizedTime BDecComponentOcts
424 #define MatchingComponentGeneralizedTime MatchingComponentOcts
425 #define ExtractingComponentGeneralizedTime(mem_op,cr,data) NULL
426 #define FreeComponentGeneralizedTime FreeComponentOcts
428 typedef int converter_func LDAP_P ((
429 struct berval* in ));
431 typedef struct asntype_to_syntax {
432 AsnTypeId ats_typeId;
433 /* Syntax Descriptor */
440 typedef struct asntype_to_matchingrule {
441 AsnTypeId atmr_typeId;
443 /*Implicitly corresponding LDAP syntax OID*/
445 MatchingRule *atmr_mr;
446 } AsnTypetoMatchingRule;
448 typedef struct asntype_to_matchingrule_table {
450 struct asntype_to_matchingrule atmr_table[ASNTYPE_END];
451 struct asntype_to_matchingrule_table* atmr_table_next;
452 } AsnTypetoMatchingRuleTable;
454 extern AsnTypetoSyntax asn_to_syntax_mapping_tbl[];
456 #define MAX_OID_LEN 256
457 #define MAX_OD_ENTRY 8
460 * Object Identifier and corresponding Syntax Decoder Table
462 typedef struct OID_Decoder_entry {
463 char oe_oid[MAX_OID_LEN];
464 gser_decoder_func* oe_gser_decoder;
465 ber_decoder_func* oe_ber_decoder;
466 converter_func* oe_converter;
467 struct OID_Decoder_entry* oe_next;
468 struct OID_Decoder_entry* oe_prev;
472 m_convert_asn_to_ldap ( ComponentSyntaxInfo* csi, struct berval* bv);
474 m_convert_assert_to_comp ( gser_decoder_func* decoder, struct berval* bv,
475 ComponentSyntaxInfo** csi, int len, int mode );
477 m_convert_attr_to_comp ( Attribute* a, struct berval* bv );
481 * Different operation is required to handle Decoding(2), Extracted Component
482 * decoding(0), ANY DEFINED TYPe(2)
483 * b0 : Component Alloc(yes)
484 * Constructed type : Component Alloc (Yes)
485 * Primitive type : Component Alloc (Yes)
486 * set to mode 2 in inner decoders
487 * b1 : Component Alloc (No)
488 * Constructed type : Component Alloc (No)
489 * Primitive type : Component Alloc (No)
490 * set to mode 2 in inner decoders
492 * Constructed type : Component Alloc (Yes)
493 * Primitive type : Component Alloc (No)
494 * in addition to above modes, the 4th bit has special meaning,
495 * b4 : if the 4th bit is clear, DecxxxContent is called
496 * b4 : if the 4th bit is set, Decxxx is called, then it is cleared.
498 #define DEC_ALLOC_MODE_0 0x01
499 #define DEC_ALLOC_MODE_1 0x02
500 #define DEC_ALLOC_MODE_2 0x04
501 #define CALL_TAG_DECODER 0x08
502 #define CALL_CONTENT_DECODER ~0x08
504 #define OID_ALL_COMP_MATCH "1.2.36.79672281.1.13.6"
505 #define OID_COMP_FILTER_MATCH "1.2.36.79672281.1.13.2"
506 #define MAX_LDAP_STR_LEN 128
509 retrieve_matching_rule( char* mr_oid, AsnTypeId type );