From: Alan T. DeKok Date: Fri, 13 Aug 2021 15:08:19 +0000 (-0400) Subject: set "is_known_width" flag for DNS labels X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d0fbc38a9d8e6e229e5d0dbaa04f329e5b36fb8;p=thirdparty%2Ffreeradius-server.git set "is_known_width" flag for DNS labels which will let us encode DNS labels inside of structs, as that is used in DHCPv6 --- diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index 5d968e896de..ce949be38b7 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -84,6 +84,9 @@ typedef struct { unsigned int internal : 1; //!< Internal attribute, should not be received ///< in protocol packets, should not be encoded. unsigned int array : 1; //!< Pack multiples into 1 attr. + + unsigned int is_known_width : 1; //!< is treated as if it has a known width for structs + unsigned int has_value : 1; //!< Has a value. unsigned int virtual : 1; //!< for dynamic expansion diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 947c2d49995..99e5f1f08ef 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -262,6 +262,7 @@ static int dict_process_type_field(dict_tokenize_ctx_t *ctx, char const *name, f return -1; } + flags->is_known_width = true; flags->length = length; *type_p = type; return 0; @@ -983,7 +984,7 @@ static int dict_read_process_member(dict_tokenize_ctx_t *ctx, char **argv, int a * so, complain if we're adding a variable sized member. */ if (ctx->stack[ctx->stack_depth].da->flags.length && - ((type == FR_TYPE_TLV) || + ((type == FR_TYPE_TLV) || flags.is_known_width || ((type == FR_TYPE_STRING) && !flags.length) || ((type == FR_TYPE_OCTETS) && !flags.length))) { fr_strerror_printf("'struct' %s has fixed size %u, we cannot add a variable-sized member.", diff --git a/src/protocols/dhcpv6/base.c b/src/protocols/dhcpv6/base.c index 6dfaaaaa3d9..12537f83bac 100644 --- a/src/protocols/dhcpv6/base.c +++ b/src/protocols/dhcpv6/base.c @@ -1031,6 +1031,8 @@ static bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *pare return false; } + flags->is_known_width = true; + return true; }