]> git.sur5r.net Git - openldap/commitdiff
Update entryUUID to latest draft specification
authorKurt Zeilenga <kurt@openldap.org>
Fri, 31 Oct 2003 17:41:31 +0000 (17:41 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 31 Oct 2003 17:41:31 +0000 (17:41 +0000)
servers/slapd/modify.c
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/slap.h

index a120a3690a087a948967f469e41af3683dfc5c78..10298b5c781fa0348304b259835d08d097755ec0 100644 (file)
@@ -850,7 +850,7 @@ int slap_mods_opattrs(
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_entryUUID;
                        mod->sml_values =
-                       (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                               (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_values[0], &tmpval );
                        mod->sml_values[1].bv_len = 0;
                        mod->sml_values[1].bv_val = NULL;
@@ -863,7 +863,8 @@ int slap_mods_opattrs(
                        mod->sml_op = mop;
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_creatorsName;
-                       mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                       mod->sml_values =
+                               (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_values[0], &name );
                        mod->sml_values[1].bv_len = 0;
                        mod->sml_values[1].bv_val = NULL;
@@ -881,7 +882,8 @@ int slap_mods_opattrs(
                        mod->sml_op = mop;
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_createTimestamp;
-                       mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                       mod->sml_values =
+                               (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_values[0], &timestamp );
                        mod->sml_values[1].bv_len = 0;
                        mod->sml_values[1].bv_val = NULL;
index 0d64d5cbbc0e689c09f2b44f037d78a957b6be6b..a3cd70f295b0159d874af52bee4be9eb0581468a 100644 (file)
@@ -1770,6 +1770,86 @@ IA5StringNormalize(
        return LDAP_SUCCESS;
 }
 
+static int
+UUIDValidate(
+       Syntax *syntax,
+       struct berval *in )
+{
+       int i;
+       if( in->bv_len != 36 ) {
+               assert(0);
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       for( i=0; i<36; i++ ) {
+               switch(i) {
+                       case 8:
+                       case 13:
+                       case 18:
+                       case 23:
+                               if( in->bv_val[i] != '-' ) {
+                                       return LDAP_INVALID_SYNTAX;
+                               }
+                               break;
+                       default:
+                               if( !ASCII_HEX( in->bv_val[i]) ) {
+                                       return LDAP_INVALID_SYNTAX;
+                               }
+               }
+       }
+       
+       return LDAP_SUCCESS;
+}
+
+static int
+UUIDNormalize(
+       slap_mask_t usage,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *val,
+       struct berval *normalized,
+       void *ctx )
+{
+       unsigned char octet;
+       int i;
+       int j;
+       normalized->bv_len = 16;
+       normalized->bv_val = sl_malloc( normalized->bv_len+1, ctx );
+
+       for( i=0, j=0; i<36; i++ ) {
+               unsigned char nibble;
+               if( val->bv_val[i] == '-' ) {
+                       continue;
+
+               } else if( ASCII_DIGIT( val->bv_val[i] ) ) {
+                       nibble = val->bv_val[i] - '0';
+
+               } else if( ASCII_HEXLOWER( val->bv_val[i] ) ) {
+                       nibble = val->bv_val[i] - ('a'-10);
+
+               } else if( ASCII_HEXUPPER( val->bv_val[i] ) ) {
+                       nibble = val->bv_val[i] - ('A'-10);
+
+               } else {
+                       sl_free( normalized->bv_val, ctx );
+                       return LDAP_INVALID_SYNTAX;
+               }
+
+               if( j % 2 ) {
+                       octet = nibble << 4;
+               } else {
+                       octet |= nibble;
+                       normalized->bv_val[j>>1] = octet;
+               }
+               j++;
+       }
+
+       normalized->bv_val[normalized->bv_len] = 0;
+       return LDAP_SUCCESS;
+}
+
+
+
 static int
 numericStringValidate(
        Syntax *syntax,
@@ -2761,6 +2841,9 @@ static slap_syntax_defs_rec syntax_defs[] = {
                SLAP_SYNTAX_HIDE, NULL, NULL},
 #endif
 
+       {"( 1.3.6.1.4.1.4203.666.2.6 DESC 'UUID' )",
+               SLAP_SYNTAX_HIDE, UUIDValidate, NULL},
+
        /* OpenLDAP Void Syntax */
        {"( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' )" ,
                SLAP_SYNTAX_HIDE, inValidate, NULL},
@@ -3109,6 +3192,20 @@ static slap_mrule_defs_rec mrule_defs[] = {
                NULL, NULL,
                "integerMatch" },
 
+       {"( 1.3.6.1.4.1.4203.666.4.6 NAME 'UUIDMatch' "
+               "SYNTAX 1.3.6.1.4.1.4203.666.2.6 )",
+               SLAP_MR_HIDE | SLAP_MR_EQUALITY, NULL,
+               NULL, UUIDNormalize, octetStringMatch,
+               octetStringIndexer, octetStringFilter,
+               NULL},
+
+       {"( 1.3.6.1.4.1.4203.666.4.7 NAME 'UUIDOrderingMatch' "
+               "SYNTAX 1.3.6.1.4.1.4203.666.2.6 )",
+               SLAP_MR_HIDE | SLAP_MR_ORDERING, NULL,
+               NULL, UUIDNormalize, octetStringOrderingMatch,
+               octetStringIndexer, octetStringFilter,
+               "UUIDMatch"},
+
        {NULL, SLAP_MR_NONE, NULL,
                NULL, NULL, NULL, NULL, NULL,
                NULL }
index 0b43eea52403712669646f441a972394590caf46..306015eea6179eb8cdb444ecb0514c93cd184ba9 100644 (file)
@@ -368,8 +368,9 @@ static struct slap_schema_ad_map {
 
        { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "   
                        "DESC 'UUID of the entry' "
-                       "EQUALITY octetStringMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY UUIDMatch "
+                       "ORDERING UUIDOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.6 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
index 47e261373917af5a9546ce2fc4b9da2cf95d335c..5d4a5967b724bfef0323d202550fdff7541d891f 100644 (file)
@@ -96,6 +96,10 @@ LDAP_BEGIN_DECL
 #define ASCII_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' )
 #define ASCII_ALPHA(c) ( ASCII_LOWER(c) || ASCII_UPPER(c) )
 #define ASCII_DIGIT(c) ( (c) >= '0' && (c) <= '9' )
+#define ASCII_HEXLOWER(c)      ( (c) >= 'a' && (c) <= 'h' )
+#define ASCII_HEXUPPER(c)      ( (c) >= 'A' && (c) <= 'H' )
+#define ASCII_HEX(c)   ( ASCII_DIGIT(c) || \
+       ASCII_HEXLOWER(c) || ASCII_HEXUPPER(c) )
 #define ASCII_ALNUM(c) ( ASCII_ALPHA(c) || ASCII_DIGIT(c) )
 #define ASCII_PRINTABLE(c) ( (c) >= ' ' && (c) <= '~' )