Back to index

openldap  2.4.31
componentlib.h
Go to the documentation of this file.
00001 /* Copyright 2004 IBM Corporation
00002  * All rights reserved.
00003  * Redisribution and use in source and binary forms, with or without
00004  * modification, are permitted only as  authorizd by the OpenLADP
00005  * Public License.
00006  */
00007 /* ACKNOWLEDGEMENTS
00008  * This work originally developed by Sang Seok Lim
00009  * 2004/06/18 03:20:00      slim@OpenLDAP.org
00010  */
00011 
00012 #ifndef _H_COMPONENT_MODULE
00013 #define _H_COMPONENT_MODULE
00014 
00015 #include "portable.h"
00016 #include <ac/string.h>
00017 #include <ac/socket.h>
00018 #include <ldap_pvt.h>
00019 #include "lutil.h"
00020 #include <ldap.h>
00021 #include <slap.h>
00022 #include <component.h>
00023 
00024 #include <asn-incl.h>
00025 #include "asn.h"
00026 #include <asn-gser.h>
00027 #include <string.h>
00028 
00029 #define MAX_IDENTIFIER_LEN  32
00030 #define COMPONENTNOT_NULL(ptr)  ((ptr) != NULL)
00031 
00032 typedef struct slap_component_type {
00033         /*
00034          * Don't change the order of following fields
00035          * They are identical the first 9 fields of
00036          * AttributeType
00037          */
00038         LDAPAttributeType               ct_atype;
00039         struct berval                   ct_cname;
00040         struct slap_attribute_type      *ct_sup;
00041         struct slap_attribute_type      **ct_subtypes;
00042         MatchingRule                    *ct_equality;
00043         MatchingRule                    *ct_approx;
00044         MatchingRule                    *ct_ordering;
00045         MatchingRule                    *ct_substr;
00046         Syntax                          *ct_syntax;
00047 } ComponentType;
00048 
00049 
00050 /*
00051  * BIT STRING
00052  */
00053 typedef struct ComponentBits {
00054        void* syntax;
00055        ComponentDesc* comp_desc;
00056        struct berval identifier;
00057        char id_buf[MAX_IDENTIFIER_LEN];
00058        AsnBits value;
00059 } ComponentBits;
00060 
00061 #define GASNBITS_PRESENT(abits) ((abits)->value.bits != NULL)
00062 #define COMPONENTBITS_PRESENT(abits) ((abits)->value.bits != NULL)
00063 int GEncComponentBits (GenBuf *b, ComponentBits* bits);
00064 int GDecComponentBits (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00065 int BDecComponentBits (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00066 int MatchingComponentBits (char* oid, ComponentSyntaxInfo *bits1 , ComponentSyntaxInfo* bits2);
00067 #define ExtractingComponentBits( mem_op, cr,data ) NULL
00068 
00069 /*
00070  * BMP String
00071  */
00072 typedef struct ComponentBMPString {
00073        void* syntax;
00074        ComponentDesc* comp_desc;
00075        struct berval identifier;
00076        char id_buf[MAX_IDENTIFIER_LEN];
00077        BMPString value;
00078 } ComponentBMPString;
00079 
00080 int GEncComponentBMPString (GenBuf *b, ComponentBMPString* bmp);
00081 int GDecComponentBMPString (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00082 int BDecComponentBMPString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00083 #define MatchingComponentBMPString MatchingComponentOcts
00084 #define ExtractingComponentBMPString( mem_op, cr, data ) NULL
00085 #define FreeComponentBMPString FreeComponentOcts
00086 
00087 /*
00088  * BOOLEAN
00089  */
00090 typedef struct ComponentBool {
00091        void* syntax;
00092        ComponentDesc* comp_desc;
00093        struct berval identifier;
00094        char id_buf[MAX_IDENTIFIER_LEN];
00095        AsnBool value;
00096 } ComponentBool;
00097 
00098 int GEncComponentBool (GenBuf *b, ComponentBool * bool );
00099 int GDecComponentBool ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00100 int BDecComponentBool ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00101 int MatchingComponentBool (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00102 #define ExtractingComponentBool( mem_op, cr, data ) NULL
00103 #define FreeComponentBool(v) NULL
00104 
00105 /*
00106  * ENUMERTED
00107  */
00108 typedef struct ComponentEnum {
00109        void* syntax;
00110        ComponentDesc* comp_desc;
00111        struct berval identifier;
00112        char id_buf[MAX_IDENTIFIER_LEN];
00113        AsnEnum value;
00114        struct berval value_identifier;/*Why this value is defined here?*/
00115 } ComponentEnum;
00116 
00117 int GEncComponentEnum (GenBuf *b, ComponentEnum* comp_enum);
00118 int GDecComponentEnum ( void* mem_op, GenBuf *a, void *result, AsnLen *bytesDecoded,int mode);
00119 int BDecComponentEnum ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00120 int MatchingComponentEnum (char *oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo * b);
00121 #define ExtractingComponentEnum( mem_op, cr, data ) NULL
00122 #define FreeComponentEnum FreeComponentInt
00123 
00124 /*
00125  * IA5 String
00126  */
00127 typedef struct ComponentIA5String {
00128        void* syntax;
00129        ComponentDesc* comp_desc;
00130        struct berval identifier;
00131        char id_buf[MAX_IDENTIFIER_LEN];
00132        IA5String value;
00133 } ComponentIA5String;
00134 
00135 #define GEncComponentIA5String GEncComponentUTF8String
00136 #define GDecComponentIA5String GDecComponentUTF8String
00137 int
00138 BDecComponentIA5StringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
00139 int BDecComponentIA5String ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00140 #define MatchingComponentIA5String MatchingComponentOcts
00141 #define ExtractingComponentIA5String(mem_op, cr,data)   NULL
00142 #define FreeComponentIA5String FreeComponentOcts
00143 
00144 
00145 /*
00146  * INTEGER
00147  */
00148 typedef struct ComponentInt {
00149        void* syntax;
00150        ComponentDesc* comp_desc;
00151        struct berval identifier;
00152        char id_buf[MAX_IDENTIFIER_LEN];
00153        int value;
00154 } ComponentInt;
00155 
00156 #define GNOT_NULL(ptr) ((ptr) != NULL)
00157 int GEncComponentInt (GenBuf *b, ComponentInt *comp_int);
00158 int GDecComponentInt ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
00159 int BDecComponentInt ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00160 int MatchingComponentInt (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00161 #define ExtractingComponentInt(mem_op, cr,data)  NULL
00162 #define FreeComponentInt(v) NULL
00163 
00164 /*
00165  * LIST Data Structure for C_LIST
00166  */
00167 typedef struct ComponentList {
00168        void* syntax;
00169        ComponentDesc* comp_desc;
00170        struct berval identifier;
00171        char id_buf[MAX_IDENTIFIER_LEN];
00172        AsnList comp_list;
00173 } ComponentList;
00174 
00175 /*
00176  * NULL
00177  */
00178 typedef struct ComponentNull {
00179        void* syntax;
00180        ComponentDesc* comp_desc;
00181        struct berval identifier;
00182        char id_buf[MAX_IDENTIFIER_LEN];
00183        AsnNull value;
00184 } ComponentNull;
00185 
00186 int GEncComponentNull (GenBuf *b, ComponentNull* comp_null);
00187 int GDecComponentNull ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00188 int BDecComponentNull ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00189 int BDecComponentNullTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
00190 int MatchingComponentNull (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00191 #define ExtractingComponentNull(mem_op, cr, data)       NULL
00192 #define FreeComponentNull NULL
00193 
00194 /*
00195  * Numeric String
00196  */
00197 typedef struct ComponentNumericString {
00198        void* syntax;
00199        ComponentDesc* comp_desc;
00200        struct berval identifier;
00201        char id_buf[MAX_IDENTIFIER_LEN];
00202        NumericString value;
00203 } ComponentNumericString;
00204 
00205 #define GEncComponentNumericString GEncComponentUTF8String
00206 #define GDecComponentNumericString GDecComponentUTF8String
00207 int BDecComponentNumericString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00208 #define MatchingComponentNumericString MatchingComponentOcts
00209 #define ExtractingComponentNumericString(mem_op, cr,data)      NULL
00210 #define FreeComponentNumericString FreeComponentOcts
00211 
00212 /*
00213  * OCTETS STRING
00214  */
00215 typedef struct ComponentOcts {
00216        void* syntax;
00217        ComponentDesc* comp_desc;
00218        struct berval identifier;
00219        char id_buf[MAX_IDENTIFIER_LEN];
00220        AsnOcts value;
00221 } ComponentOcts;
00222 
00223 #define GASNOCTS_PRESENT(aocts) ((aocts)->value.octs != NULL)
00224 int GEncComponentOcts (GenBuf *b, ComponentOcts *octs);
00225 int GDecComponentOcts (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00226 int BDecComponentOctsTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
00227 int BDecComponentOcts (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00228 int MatchingComponentOcts (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00229 #define ExtractingComponentOcts(mem_op,cr,data)  NULL
00230 void FreeComponentOcts( ComponentOcts* octs );
00231 
00232 /*
00233  * OID (Object Identifier)
00234  */
00235 typedef struct ComponentOid {
00236        void* syntax;
00237        ComponentDesc* comp_desc;
00238        struct berval identifier;
00239        char id_buf[MAX_IDENTIFIER_LEN];
00240        AsnOid value;
00241 } ComponentOid;
00242 
00243 #define GASNOID_PRESENT(aoid) ASNOCTS_PRESENT(aoid)
00244 int GEncComponentOid (GenBuf *b, ComponentOid *oid);
00245 int GDecComponentOid (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00246 int BDecComponentOid (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00247 int MatchingComponentOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00248 #define ExtractingComponentOid(mem_op, cr, data) NULL
00249 #define FreeComponentOid FreeComponentOcts
00250 
00251 /*
00252  * Printable String
00253  */
00254 typedef struct ComponentPrintableString{
00255        void* syntax;
00256        ComponentDesc* comp_desc;
00257        struct berval identifier;
00258        char id_buf[MAX_IDENTIFIER_LEN];
00259        PrintableString value;
00260 } ComponentPrintableString;
00261 #define GEncComponentPrintableString GEncComponentUTF8String
00262 #define GDecComponentPrintableString GDecComponentUTF8String
00263 int BDecComponentPrintableString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00264 int BDecComponentPrintableStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
00265 #define MatchingComponentPrintableString MatchingComponentOcts
00266 #define ExtractingComponentPrintableString(mem_op, cr, data)   NULL
00267 #define FreeComponentPrintableString FreeComponentOcts
00268 
00269 /*
00270  * REAL
00271  */
00272 typedef struct ComponentReal{
00273        void* syntax;
00274        ComponentDesc* comp_desc;
00275        struct berval identifier;
00276        char id_buf[MAX_IDENTIFIER_LEN];
00277        AsnReal value;
00278 } ComponentReal;
00279 
00280 int GEncComponentReal (GenBuf *b, ComponentReal* comp_real);
00281 int GDecComponentReal (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00282 int BDecComponentReal (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00283 int MatchingComponentReal (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00284 #define ExtractingComponentReal( mem_op, cr, data )     NULL
00285 #define FreeComponentReal(v) NULL
00286 
00287 /*
00288  * Relative OID
00289  */
00290 
00291 typedef struct ComponentRelativeOid {
00292        void* syntax;
00293        ComponentDesc* comp_desc;
00294        struct berval identifier;
00295        char id_buf[MAX_IDENTIFIER_LEN];
00296        AsnRelativeOid value;
00297 } ComponentRelativeOid;
00298 
00299 int GEncComponentRelativeOid (GenBuf *b, ComponentRelativeOid *r_oid);
00300 int GDecComponentRelativeOid ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00301 int BDecComponentRelativeOid ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00302 int MatchingComponentRelativeOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
00303 #define ExtractingComponentRelativeOid( mem_op, cr, data ) NULL
00304 #define FreeComponentRelativeOid FreeComponentOid
00305 
00306 /*
00307  * Teletex String
00308  */
00309 typedef struct ComponentTeletexString {
00310        void* syntax;
00311        ComponentDesc* comp_desc;
00312        struct berval identifier;
00313        char id_buf[MAX_IDENTIFIER_LEN];
00314        TeletexString value;
00315 } ComponentTeletexString;
00316 
00317 int GEncComponentTeletexString (GenBuf *b, ComponentTeletexString * tel_str);
00318 int GDecComponentTeletexString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
00319 int BDecComponentTeletexStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
00320 int BDecComponentTeletexString( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode );
00321 #define MatchingComponentTeletexString MatchingComponentOcts
00322 #define ExtractingComponentTeletexString(mem_op,cr,data)
00323 #define FreeComponentTeletexString FreeComponentOcts
00324 
00325 
00326 /*
00327  * Universal String
00328  */
00329 typedef struct ComponentUniversalString{
00330        void* syntax;
00331        ComponentDesc* comp_desc;
00332        struct berval identifier;
00333        char id_buf[MAX_IDENTIFIER_LEN];
00334        UniversalString value;
00335 } ComponentUniversalString;
00336 
00337 int GEncComponentUniversalString (GenBuf *b, ComponentUniversalString* uni_str);
00338 int GDecComponentUniversalString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00339 int BDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00340 #define MatchingComponentUniversalString MatchingComponentOcts
00341 #define ExtractingComponentUniversalString(mem_op,cr,data)
00342 #define FreeComponentUniversalString FreeComponentOcts
00343 
00344 /*
00345  * UTF8 String
00346  */
00347 typedef struct ComponentUTF8String{
00348        void* syntax;
00349        ComponentDesc* comp_desc;
00350        struct berval identifier;
00351        char id_buf[MAX_IDENTIFIER_LEN];
00352        UTF8String value;
00353 } ComponentUTF8String;
00354 
00355 int GEncComponentUTF8String (GenBuf *b, ComponentUTF8String * utf_str);
00356 int GDecComponentUTF8String (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
00357 int BDecComponentUTF8String (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00358 #define MatchingComponentUTF8String MatchingComponentOcts
00359 #define ExtractingComponentUTF8String(mem_op,cr,data)
00360 #define FreeComponentUTF8String FreeComponentOcts
00361 
00362 /*
00363  * Visible String
00364  */
00365 typedef struct ComponentVisibleString{
00366        void* syntax;
00367        ComponentDesc* comp_desc;
00368        struct berval identifier;
00369        char id_buf[MAX_IDENTIFIER_LEN];
00370        VisibleString value;
00371 } ComponentVisibleString;
00372 
00373 #define GEncComponentVisibleString GEncComponentUTF8String
00374 #define GDecComponentVisibleString GDecComponentUTF8String
00375 int BDecComponentVisibleString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
00376 #define MatchingComponentVisibleString MatchingComponentOcts
00377 #define ExtractingComponentVisibleString(mem_op,cr,data)
00378 #define FreeComponentVisibleString FreeComponentOcts
00379 
00380 /*
00381  * ANY and ANY DEFINED BY
00382  */
00383 
00384 typedef int (*MatchFcn) (char*, void*, void*);
00385 typedef void* (*ExtractFcn) (void*, ComponentReference*, void * );
00386 
00387 typedef struct ComponentAnyInfo
00388 {
00389        int           anyId;
00390        AsnOid        oid;
00391        ComponentInt  intId;
00392        unsigned int  size;
00393        EncodeFcn     Encode;
00394        gser_decoder_func* GSER_Decode;
00395        ber_tag_decoder_func* BER_Decode;
00396        ExtractFcn    Extract;
00397        MatchFcn      Match;
00398        FreeFcn              Free;
00399        PrintFcn      Print;
00400 } ComponentAnyInfo;
00401 
00402 typedef struct ComponentAnyInfo OidDecoderMapping ;
00403 
00404 typedef struct ComponentAny{
00405        void*         syntax;
00406        ComponentDesc *comp_desc;
00407        struct berval identifier;
00408        char id_buf[MAX_IDENTIFIER_LEN];
00409        ComponentAnyInfo     *cai;
00410        void          *value;
00411 } ComponentAny;
00412 
00413 typedef ComponentAny ComponentAnyDefinedBy;
00414 
00415 #define BDecComponentAnyDefinedBy BDecComponentAny
00416 #define GDecComponentAnyDefinedBy GDecComponentAny
00417 #define MatchingComponentAnyDefinedBy MatchingComponentAny
00418 #define FreeComponentAnyDefinedBy FreeComponentAny
00419 
00420 int GEncComponentAny (GenBuf *b, ComponentAny *comp_any);
00421 int BDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
00422 int GDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
00423 int MatchingComponentAny (char* oid, ComponentAny *a, ComponentAny *b);
00424 void FreeComponentAny ( ComponentAny*);
00425 
00426 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);
00427 
00428 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);
00429 
00430 int CheckSelectTypeCorrect ( void* mem_op, ComponentAnyInfo *v, struct berval* select );
00431 
00432 OidDecoderMapping* RetrieveOidDecoderMappingbyBV( struct berval* in );
00433 OidDecoderMapping* RetrieveOidDecoderMappingbyOid( char* ch_oid, int oid_len );
00434 OidDecoderMapping* RetrieveOidDecoderMappingbyDesc( char* desc, int desc_len );
00435 /*
00436  * UTCTime
00437  */
00438 typedef ComponentVisibleString ComponentUTCTime;
00439 #define GEncComponentUTCTime GEncComponentUTF8String 
00440 #define GDecComponentUTCTime GDecComponentVisibleString
00441 #define BDecComponentUTCTime BDecComponentOcts
00442 #define MatchingComponentUTCTime MatchingComponentOcts
00443 #define ExtractingComponentUTCTime(mem_op,cr,data) NULL
00444 #define FreeComponentUTCTime FreeComponentOcts
00445 
00446 /*
00447  * GeneralizedTime
00448  */
00449 typedef ComponentVisibleString ComponentGeneralizedTime;
00450 int GEncComponentGeneralizedTime (GenBuf *b, ComponentGeneralizedTime *gen_time);
00451 #define GDecComponentGeneralizedTime GDecComponentVisibleString
00452 #define BDecComponentGeneralizedTime BDecComponentOcts
00453 #define MatchingComponentGeneralizedTime MatchingComponentOcts
00454 #define ExtractingComponentGeneralizedTime(mem_op,cr,data) NULL
00455 #define FreeComponentGeneralizedTime FreeComponentOcts
00456 
00457 typedef int converter_func LDAP_P ((
00458        struct berval* in ));
00459 
00460 typedef struct asntype_to_syntax {
00461        AsnTypeId     ats_typeId;
00462        /* Syntax Descriptor */
00463        char          *ats_syn_name;
00464        /* Syntax OID */
00465        char          *ats_syn_oid;
00466        Syntax        *ats_syn;
00467 } AsnTypetoSyntax;
00468 
00469 typedef struct asntype_to_comp_matchingrule {
00470        AsnTypeId     atc_typeId;
00471        char*  atc_equality;
00472        char*  atc_approx;
00473        char*  atc_ordering;
00474        char*  atc_substr;
00475 } AsnTypetoCompMatchingRule;
00476 
00477 typedef struct asntype_to_comp_desc {
00478        AsnTypeId     atcd_typeId;
00479        ComponentDesc atcd_cd;
00480 } AsnTypetoCompDesc;
00481 
00482 typedef struct asntype_to_comp_type {
00483        AsnTypeId     ac_asn_id;
00484        ComponentType   ac_comp_type;
00485 } AsnTypetoCompType;
00486 
00487 /* refined matching purpose */
00488 typedef struct asntype_to_matchingrule {
00489        AsnTypeId     atmr_typeId;
00490        char*         atmr_mr_name;
00491        /*Implicitly corresponding LDAP syntax OID*/
00492        char*         atmr_syn_oid;
00493        MatchingRule  *atmr_mr;
00494 } AsnTypetoMatchingRule;
00495 
00496 typedef struct asntype_to_matchingrule_table {
00497        char*  atmr_oid;
00498        struct asntype_to_matchingrule atmr_table[ASNTYPE_END];
00499        struct asntype_to_matchingrule_table* atmr_table_next;
00500 } AsnTypetoMatchingRuleTable;
00501 
00502 #define MAX_OID_LEN 256
00503 #define MAX_OD_ENTRY 8
00504 
00505 /*
00506  * Object Identifier and corresponding Syntax Decoder Table
00507  */
00508 typedef struct OID_Decoder_entry {
00509         char            oe_oid[MAX_OID_LEN];
00510         gser_decoder_func*   oe_gser_decoder;
00511         ber_decoder_func*   oe_ber_decoder;
00512        converter_func* oe_converter;
00513         struct OID_Decoder_entry*       oe_next;
00514         struct OID_Decoder_entry*       oe_prev;
00515 } OD_entry;
00516 
00517 void
00518 m_convert_asn_to_ldap ( ComponentSyntaxInfo* csi, struct berval* bv);
00519 int
00520 m_convert_assert_to_comp ( gser_decoder_func* decoder, struct berval* bv,
00521                         ComponentSyntaxInfo** csi, int len, int mode );
00522 void*
00523 m_convert_attr_to_comp ( Attribute* a, struct berval* bv );
00524 
00525 /*
00526  * Decoder Modes
00527  * Different operation is required to handle Decoding(2), Extracted Component
00528  * decoding(0), ANY DEFINED TYPe(2)
00529  * b0 : Component Alloc(yes)
00530  *     Constructed type : Component Alloc (Yes)
00531  *     Primitive type : Component Alloc (Yes)
00532  *     set to mode 2 in inner decoders
00533  * b1 : Component Alloc (No)
00534  *     Constructed type : Component Alloc (No)
00535  *     Primitive type : Component Alloc (No)
00536  *     set to mode 2 in inner decoders
00537  * b2 : Default Mode
00538  *     Constructed type : Component Alloc (Yes)
00539  *     Primitive type : Component Alloc (No)
00540  * in addition to above modes, the 4th bit has special meaning,
00541  * b4 : if the 4th bit is clear, DecxxxContent is called
00542  * b4 : if the 4th bit is set, Decxxx is called, then it is cleared.
00543  */
00544 #define DEC_ALLOC_MODE_0    0x01
00545 #define DEC_ALLOC_MODE_1    0x02
00546 #define DEC_ALLOC_MODE_2    0x04
00547 #define CALL_TAG_DECODER    0x08
00548 #define CALL_CONTENT_DECODER       ~0x08
00549 
00550 #define OID_ALL_COMP_MATCH "1.2.36.79672281.1.13.6"
00551 #define OID_COMP_FILTER_MATCH "1.2.36.79672281.1.13.2"
00552 #define MAX_LDAP_STR_LEN 128
00553 
00554 MatchingRule*
00555 retrieve_matching_rule( char* mr_oid, AsnTypeId type );
00556 
00557 #define INITIAL_DN_SIZE 128
00558 #define INITIAL_ATTR_SIZE 256
00559 #define INCREMENT_SIZE 32
00560 /*
00561  * Followings are for conversion from ASN.1 RDN and DN to
00562  * LDAP encodings
00563  */
00564 #define MAX_ALIASING_ENTRY 128
00565 int increment_bv_mem ( struct berval* in );
00566 int intToAscii ( int value, char* buf );
00567 typedef ComponentList irRDNSequence;
00568 typedef ComponentList irRelativeDistinguishedName;
00569 typedef ComponentOid irAttributeType;
00570 typedef struct comp_irAttributeTypeAndValue /* SEQUENCE */
00571 {
00572        Syntax* syntax;
00573        ComponentDesc* comp_desc;
00574        struct berval identifier;
00575        char id_buf[MAX_IDENTIFIER_LEN];
00576        irAttributeType type; /* AttributeType */
00577        ComponentAnyDefinedBy value; /* ANY DEFINED BY type */
00578 } irAttributeTypeAndValue;
00579 #define RDN_MATCH_OID "1.2.36.79672281.1.13.3"
00580 #define DN_MATCH_OID "2.5.13.1"
00581 
00582 extern AsnTypetoSyntax asn_to_syntax_mapping_tbl[];
00583 extern AsnTypetoCompMatchingRule asntype_to_compMR_mapping_tbl[];
00584 extern AsnTypetoCompType asntype_to_compType_mapping_tbl[];
00585 extern AsnTypetoCompDesc asntype_to_compdesc_mapping_tbl[];
00586 
00587 int ConvertRDN2RFC2253 ( irRelativeDistinguishedName* in, struct berval *out );
00588 int ConvertRDNSequence2RFC2253( irRDNSequence *in, struct berval* out );
00589        
00590 void* comp_nibble_memory_allocator ( int init_mem, int inc_mem );
00591 
00592 ComponentDesc* get_ComponentDesc( int id );
00593 #endif