]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
let's use unique names
authorAlan T. DeKok <aland@freeradius.org>
Fri, 18 Oct 2019 11:10:18 +0000 (07:10 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 18 Oct 2019 11:38:36 +0000 (07:38 -0400)
and update process STRUCT so that it adds the struct name to
the global namespace.  This lets us check for duplicate names,
and also address the struct by name.

share/dictionary/dhcpv6/dictionary.rfc6355
src/lib/util/dict_tokenize.c

index 14a2b849d21e3103b1fdd94c9f223f84b8928880..7dd9743f913d018281defe10d842e03d28476cc4 100644 (file)
 ##############################################################################
 
 STRUCT Client-ID-DUID-UUID                     Client-ID-DUID  4
-MEMBER         Client-ID-DUID-UUID                     octets[16]
+MEMBER         Client-ID-DUID-UUID-Value               octets[16]
 
 #
 #  Duplicate sub-struct as the server cannot (yet) reference structs
 #
 STRUCT Server-ID-DUID-UUID                     Server-ID-DUID  4
-MEMBER         Server-ID-DUID-UUID                     octets[16]
+MEMBER         Server-ID-DUID-UUID-Value               octets[16]
index 8cf16945d68648e72b31423bac9ac4bb843af926..26af6e00c3e45484352bfd5a5efba609186fb24f 100644 (file)
@@ -922,7 +922,7 @@ static int dict_read_process_flags(UNUSED fr_dict_t *dict, char **argv, int argc
  */
 static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int argc)
 {
-       fr_dict_attr_t                  *da, *mutable;
+       fr_dict_attr_t const            *da;
        fr_dict_attr_t const            *parent, *previous;
        fr_value_box_t                  value;
        fr_type_t                       type;
@@ -1058,17 +1058,14 @@ get_value:
        fr_value_box_clear(&value);
 
        memset(&flags, 0, sizeof(flags));
-       da = dict_attr_alloc(ctx->dict->pool, parent, key_attr, attr, FR_TYPE_STRUCT, &flags);
-       if (!da) {
-               fr_strerror_printf("Failed allocating memory for STRUCT");
-               return -1;
-       }
 
-       memcpy(&mutable, &parent, sizeof(parent)); /* const issues */
-       if (dict_attr_child_add(mutable, da) < 0) {
-               talloc_free(da);
-               return -1;
-       }
+       /*
+        *      Add the keyed STRUCT to the global namespace, and as a child of "parent".
+        */
+       if (fr_dict_attr_add(ctx->dict, parent, argv[1], attr, FR_TYPE_STRUCT, &flags) < 0) return -1;
+
+       da = fr_dict_attr_by_name(ctx->dict, argv[1]);
+       if (!da) return -1;
 
        /*
         *      A STRUCT definition is an implicit BEGIN-STRUCT.