From: Alan T. DeKok Date: Sun, 16 Feb 2025 20:10:25 +0000 (-0500) Subject: no need to say it's a tag "num". X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12b191f0ba78eeb0d8dcb4acddaf210d9cbe762a;p=thirdparty%2Ffreeradius-server.git no need to say it's a tag "num". it's an enum, and that's good enough --- diff --git a/src/protocols/der/base.c b/src/protocols/der/base.c index ef525a9947..c81f4ff8ab 100644 --- a/src/protocols/der/base.c +++ b/src/protocols/der/base.c @@ -134,7 +134,7 @@ static const bool *fr_type_to_der_tags[] = { * @param[in] tag The der tag to check. * @return true if the type can be encoded as the given tag. */ -bool fr_type_to_der_tag_valid(fr_type_t type, fr_der_tag_num_t tag) +bool fr_type_to_der_tag_valid(fr_type_t type, fr_der_tag_t tag) { return fr_type_to_der_tags[type][tag]; } @@ -223,7 +223,7 @@ static int dict_flag_has_default(fr_dict_attr_t **da_p, UNUSED char const *value static int dict_flag_der_type(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules) { fr_der_attr_flags_t *flags = fr_dict_attr_ext(*da_p, FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC); - fr_der_tag_num_t der_type; + fr_der_tag_t der_type; der_type = fr_table_value_by_str(tag_name_to_number, value, UINT8_MAX); if (der_type == UINT8_MAX) { @@ -239,7 +239,7 @@ static int dict_flag_der_type(fr_dict_attr_t **da_p, char const *value, UNUSED f static int dict_flag_sequence_of(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules) { fr_der_attr_flags_t *flags = fr_dict_attr_ext(*da_p, FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC); - fr_der_tag_num_t type; + fr_der_tag_t type; type = fr_table_value_by_str(tag_name_to_number, value, UINT8_MAX); if (type == UINT8_MAX) { @@ -256,7 +256,7 @@ static int dict_flag_sequence_of(fr_dict_attr_t **da_p, char const *value, UNUSE static int dict_flag_set_of(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules) { fr_der_attr_flags_t *flags = fr_dict_attr_ext(*da_p, FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC); - fr_der_tag_num_t type; + fr_der_tag_t type; type = fr_table_value_by_str(tag_name_to_number, value, UINT8_MAX); if (type == UINT8_MAX) { @@ -413,7 +413,7 @@ static bool type_parse(fr_type_t *type_p,fr_dict_attr_t **da_p, char const *name static size_t der_tag_table_len = NUM_ELEMENTS(der_tag_table); fr_der_attr_flags_t *flags = fr_dict_attr_ext(*da_p, FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC); - fr_der_tag_num_t der_type; + fr_der_tag_t der_type; fr_type_t fr_type; /* @@ -475,7 +475,7 @@ static bool type_parse(fr_type_t *type_p,fr_dict_attr_t **da_p, char const *name return true; } -static const fr_der_tag_num_t fr_type_to_der_tag_defaults[FR_TYPE_MAX + 1] = { +static const fr_der_tag_t fr_type_to_der_tag_defaults[FR_TYPE_MAX + 1] = { [FR_TYPE_BOOL] = FR_DER_TAG_BOOLEAN, [FR_TYPE_UINT8] = FR_DER_TAG_INTEGER, [FR_TYPE_UINT16] = FR_DER_TAG_INTEGER, @@ -493,7 +493,7 @@ static const fr_der_tag_num_t fr_type_to_der_tag_defaults[FR_TYPE_MAX + 1] = { [FR_TYPE_GROUP] = FR_DER_TAG_SEQUENCE, }; -fr_der_tag_num_t fr_type_to_der_tag_default(fr_type_t type) +fr_der_tag_t fr_type_to_der_tag_default(fr_type_t type) { return fr_type_to_der_tag_defaults[type]; } diff --git a/src/protocols/der/decode.c b/src/protocols/der/decode.c index 469ec96235..0d54e454b5 100644 --- a/src/protocols/der/decode.c +++ b/src/protocols/der/decode.c @@ -1108,7 +1108,7 @@ static ssize_t fr_der_decode_set(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_a /* * This is a set-of, meaning there are restrictions on the types which can be present */ - fr_der_tag_num_t restriction_type = fr_der_flag_set_of(parent); + fr_der_tag_t restriction_type = fr_der_flag_set_of(parent); while (fr_dbuff_remaining(&our_in) > 0) { fr_dbuff_marker_t current_value_marker; diff --git a/src/protocols/der/der.h b/src/protocols/der/der.h index a0a1a4d153..52e57b3c54 100644 --- a/src/protocols/der/der.h +++ b/src/protocols/der/der.h @@ -31,7 +31,7 @@ typedef enum { FR_DER_TAG_CHOICE = 0x23, //!< A choice of types. Techically not a DER tag, but used to represent a choice. FR_DER_TAG_MAX = UINT8_MAX -} fr_der_tag_num_t; +} fr_der_tag_t; typedef enum { FR_DER_TAG_PRIMITIVE = 0x00, //!< This is a leaf value, it contains no children. @@ -68,9 +68,9 @@ typedef enum { typedef struct { uint8_t tagnum; fr_der_tag_class_t class; - fr_der_tag_num_t der_type; - fr_der_tag_num_t sequence_of; - fr_der_tag_num_t set_of; + fr_der_tag_t der_type; + fr_der_tag_t sequence_of; + fr_der_tag_t set_of; int64_t max; bool is_sequence_of; bool is_set_of; @@ -105,8 +105,8 @@ static inline fr_der_attr_flags_t const *fr_der_attr_flags(fr_dict_attr_t const /* * base.c */ -fr_der_tag_num_t fr_type_to_der_tag_default(fr_type_t type); -bool fr_type_to_der_tag_valid(fr_type_t type, fr_der_tag_num_t tag); +fr_der_tag_t fr_type_to_der_tag_default(fr_type_t type); +bool fr_type_to_der_tag_valid(fr_type_t type, fr_der_tag_t tag); int fr_der_global_init(void); void fr_der_global_free(void); diff --git a/src/protocols/der/encode.c b/src/protocols/der/encode.c index fef74a9011..535f9b1e96 100644 --- a/src/protocols/der/encode.c +++ b/src/protocols/der/encode.c @@ -89,7 +89,7 @@ static ssize_t fr_der_encode_string(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, fr_ static ssize_t fr_der_encode_len(fr_dbuff_t *dbuff, fr_dbuff_marker_t *length_start) CC_HINT(nonnull); static inline CC_HINT(always_inline) ssize_t - fr_der_encode_tag(fr_dbuff_t *dbuff, fr_der_tag_num_t tag_num, fr_der_tag_class_t tag_class, + fr_der_encode_tag(fr_dbuff_t *dbuff, fr_der_tag_t tag_num, fr_der_tag_class_t tag_class, fr_der_tag_constructed_t constructed) CC_HINT(nonnull); static ssize_t encode_value(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx); @@ -1660,7 +1660,7 @@ static ssize_t fr_der_encode_len(fr_dbuff_t *dbuff, fr_dbuff_marker_t *length_st * @return The number of bytes written to the buffer */ static inline CC_HINT(always_inline) ssize_t - fr_der_encode_tag(fr_dbuff_t *dbuff, fr_der_tag_num_t tag_num, fr_der_tag_class_t tag_class, + fr_der_encode_tag(fr_dbuff_t *dbuff, fr_der_tag_t tag_num, fr_der_tag_class_t tag_class, fr_der_tag_constructed_t constructed) { fr_dbuff_t our_dbuff = FR_DBUFF(dbuff); @@ -1689,7 +1689,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, UNUSED fr_da_stack_t *da_stack, U fr_dbuff_t our_dbuff = FR_DBUFF(dbuff); fr_dbuff_marker_t marker; fr_der_tag_encode_t *tag_encode; - fr_der_tag_num_t tag_num; + fr_der_tag_t tag_num; fr_der_tag_class_t tag_class; fr_der_encode_ctx_t *uctx = encode_ctx; ssize_t slen = 0;