From: Alan T. DeKok Date: Fri, 18 Oct 2019 11:10:18 +0000 (-0400) Subject: let's use unique names X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=858ca40cd3477355ae00a545d51c6757ec3689f8;p=thirdparty%2Ffreeradius-server.git let's use unique names 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. --- diff --git a/share/dictionary/dhcpv6/dictionary.rfc6355 b/share/dictionary/dhcpv6/dictionary.rfc6355 index 14a2b849d21..7dd9743f913 100644 --- a/share/dictionary/dhcpv6/dictionary.rfc6355 +++ b/share/dictionary/dhcpv6/dictionary.rfc6355 @@ -11,10 +11,10 @@ ############################################################################## 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] diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 8cf16945d68..26af6e00c3e 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -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.