From: Arran Cudbard-Bell Date: Tue, 29 Oct 2024 11:20:08 +0000 (+0100) Subject: Move flags into their own struct within fr_dict_protocol_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d217a2a6c451cfcc4314d6e05df75c5ee72fa8cd;p=thirdparty%2Ffreeradius-server.git Move flags into their own struct within fr_dict_protocol_t --- diff --git a/src/lib/eap_aka_sim/base.c b/src/lib/eap_aka_sim/base.c index 3b17e4b1865..8fc2cb43c5c 100644 --- a/src/lib/eap_aka_sim/base.c +++ b/src/lib/eap_aka_sim/base.c @@ -329,8 +329,10 @@ fr_dict_protocol_t libfreeradius_eap_aka_sim_dict_protocol = { .default_type_size = 1, .default_type_length = 1, .attr = { - .flags_table = eap_aka_sim_flags, - .flags_table_len = NUM_ELEMENTS(eap_aka_sim_flags), - .flags_len = sizeof(fr_aka_sim_attr_flags_t) + .flags = { + .table = eap_aka_sim_flags, + .table_len = NUM_ELEMENTS(eap_aka_sim_flags), + .len = sizeof(fr_aka_sim_attr_flags_t) + } } }; diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index e324d2541ff..0f41171f987 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -401,13 +401,17 @@ typedef struct { * and can either be one of a set of fixed values or a generic type * like "string". */ - fr_dict_flag_parser_t const *flags_table; //!< Flags for this protocol, an array of - ///< fr_dict_flag_parser_t terminated - ///< by FR_DICT_PROTOCOL_FLAG_TERMINATOR. - size_t flags_table_len; //!< Length of protocol_flags table. + struct { + fr_dict_flag_parser_t const *table; //!< Flags for this protocol, an array of + ///< fr_dict_flag_parser_t terminated + ///< by FR_DICT_PROTOCOL_FLAG_TERMINATOR. + size_t table_len; //!< Length of protocol_flags table. - size_t flags_len; //!< Length of the flags field in the protocol - ///< specific structure. + size_t len; //!< Length of the flags field in the protocol + ///< specific structure. + + + } flags; fr_dict_attr_valid_func_t valid; //!< Validation function to ensure that ///< new attributes are valid. diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index cd7f8f63034..d215cde02bd 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -607,9 +607,9 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_dict * then the protocol flags table. */ if (!fr_dict_attr_flag_to_parser(&parser, dict_common_flags, dict_common_flags_len, key, NULL) && - (!ctx->dict->proto->attr.flags_table || - !fr_dict_attr_flag_to_parser(&parser, ctx->dict->proto->attr.flags_table, - ctx->dict->proto->attr.flags_table_len, key, NULL))) { + (!ctx->dict->proto->attr.flags.table || + !fr_dict_attr_flag_to_parser(&parser, ctx->dict->proto->attr.flags.table, + ctx->dict->proto->attr.flags.table_len, key, NULL))) { fr_strerror_printf("Unknown flag '%s'", key); return -1; } diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index 4d4db09c909..1691f1118c2 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -833,9 +833,9 @@ fr_dict_attr_t *dict_attr_alloc_null(TALLOC_CTX *ctx, fr_dict_protocol_t const * /* * Allocate room for the protocol specific flags */ - if (proto->attr.flags_len > 0) { + if (proto->attr.flags.len > 0) { if (unlikely(dict_attr_ext_alloc_size(&da, FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC, - proto->attr.flags_len) == NULL)) { + proto->attr.flags.len) == NULL)) { talloc_free(da); return NULL; } diff --git a/src/protocols/dhcpv4/base.c b/src/protocols/dhcpv4/base.c index 9c48b5e1e31..a20686cb624 100644 --- a/src/protocols/dhcpv4/base.c +++ b/src/protocols/dhcpv4/base.c @@ -756,9 +756,11 @@ fr_dict_protocol_t libfreeradius_dhcpv4_dict_protocol = { .default_type_size = 1, .default_type_length = 1, .attr = { - .flags_table = dhcpv4_flags, - .flags_table_len = NUM_ELEMENTS(dhcpv4_flags), - .flags_len = sizeof(fr_dhcpv4_attr_flags_t), + .flags = { + .table = dhcpv4_flags, + .table_len = NUM_ELEMENTS(dhcpv4_flags), + .len = sizeof(fr_dhcpv4_attr_flags_t) + }, .valid = attr_valid }, diff --git a/src/protocols/dhcpv6/base.c b/src/protocols/dhcpv6/base.c index 6a408193941..e2f2cfac4e9 100644 --- a/src/protocols/dhcpv6/base.c +++ b/src/protocols/dhcpv6/base.c @@ -991,9 +991,11 @@ fr_dict_protocol_t libfreeradius_dhcpv6_dict_protocol = { .attr = { .valid = attr_valid, - .flags_table = dhcpv6_flags, - .flags_table_len = NUM_ELEMENTS(dhcpv6_flags), - .flags_len = sizeof(fr_dhcpv6_attr_flags_t) + .flags = { + .table = dhcpv6_flags, + .table_len = NUM_ELEMENTS(dhcpv6_flags), + .len = sizeof(fr_dhcpv6_attr_flags_t) + } }, .init = fr_dhcpv6_global_init, diff --git a/src/protocols/dns/base.c b/src/protocols/dns/base.c index dc6ee368d2e..2e001e8fc86 100644 --- a/src/protocols/dns/base.c +++ b/src/protocols/dns/base.c @@ -467,9 +467,11 @@ fr_dict_protocol_t libfreeradius_dns_dict_protocol = { .default_type_size = 2, .default_type_length = 2, .attr = { - .flags_table = dns_flags, - .flags_table_len = NUM_ELEMENTS(dns_flags), - .flags_len = sizeof(fr_dns_attr_flags_t), + .flags = { + .table = dns_flags, + .table_len = NUM_ELEMENTS(dns_flags), + .len = sizeof(fr_dns_attr_flags_t) + }, .valid = attr_valid }, diff --git a/src/protocols/radius/base.c b/src/protocols/radius/base.c index 62b1a1db088..b381becb871 100644 --- a/src/protocols/radius/base.c +++ b/src/protocols/radius/base.c @@ -1391,9 +1391,11 @@ fr_dict_protocol_t libfreeradius_radius_dict_protocol = { .default_type_size = 1, .default_type_length = 1, .attr = { - .flags_table = radius_flags, - .flags_table_len = NUM_ELEMENTS(radius_flags), - .flags_len = sizeof(fr_radius_attr_flags_t), + .flags = { + .table = radius_flags, + .table_len = NUM_ELEMENTS(radius_flags), + .len = sizeof(fr_radius_attr_flags_t), + }, .valid = attr_valid, },