]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add callback to parse protocol-specific data types
authorAlan T. DeKok <aland@freeradius.org>
Mon, 6 Jan 2025 23:44:47 +0000 (18:44 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 7 Jan 2025 00:31:40 +0000 (19:31 -0500)
src/lib/util/dict.h
src/lib/util/dict_tokenize.c

index 8d66cf258071b575e6d668245b5bb0723cc61cde..ca9b408efe23fb42e91b812f6ee782d5e37ac966 100644 (file)
@@ -304,6 +304,7 @@ typedef enum {
 } fr_dict_attr_err_t;
 
 typedef bool (*fr_dict_attr_valid_func_t)(fr_dict_attr_t *da);
+typedef bool (*fr_dict_attr_type_parse_t)(fr_type_t *type, fr_dict_attr_flags_t *flags, char const *name);
 
 /*
  *     Forward declarations to avoid circular references.
@@ -449,6 +450,7 @@ typedef struct {
                                                                                ///< Called when comparing attributes by their fields.
                } flags;
 
+               fr_dict_attr_type_parse_t       type_parse;             //!< parse unknown type names
                fr_dict_attr_valid_func_t       valid;                  //!< Validation function to ensure that
                                                                        ///< new attributes are valid.
        } attr;
index 03c2d4178f031a456c7050b3deda5f18a4d7df47..8501728dc3d0e8d63f0206b10833826bb320811b 100644 (file)
@@ -435,8 +435,16 @@ static int dict_process_type_field(dict_tokenize_ctx_t *dctx, char const *name,
         */
        type = fr_type_from_str(name);
        if (fr_type_is_null(type)) {
-               fr_strerror_printf("Unknown data type '%s'", name);
-               return -1;
+               fr_dict_attr_t *da = *da_p;
+
+               if (!da->dict->proto->attr.type_parse) {
+                       fr_strerror_printf("Unknown data type '%s'", name);
+                       return -1;
+               }
+
+               if (!da->dict->proto->attr.type_parse(&type, &da->flags, name)) {
+                       return -1;
+               }
        }
 
        return dict_attr_type_init(da_p, type);