From: Nick Porter Date: Mon, 27 Feb 2023 15:50:53 +0000 (+0000) Subject: Define module_env_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08ac580182721e47641d901317c10ae0484aba75;p=thirdparty%2Ffreeradius-server.git Define module_env_t To hold rules for parsing config items into call specific tmpls. --- diff --git a/src/lib/server/module.h b/src/lib/server/module.h index a11c1980092..9292a0761ee 100644 --- a/src/lib/server/module.h +++ b/src/lib/server/module.h @@ -41,6 +41,7 @@ typedef struct module_s module_t; typedef struct module_method_name_s module_method_name_t; typedef struct module_instance_s module_instance_t; typedef struct module_thread_instance_s module_thread_instance_t; +typedef struct module_env_s module_env_t; typedef struct module_list_t module_list_t; #define MODULE_TYPE_THREAD_SAFE (0 << 0) //!< Module is threadsafe. @@ -222,6 +223,49 @@ struct module_thread_instance_s { uint64_t active_callers; //! number of active callers. i.e. number of current yields }; +typedef enum { + MOD_ENV_TYPE_VALUE_BOX = 1, + MOD_ENV_TYPE_VALUE_BOX_LIST +} mod_env_dest_t; + +/** Per method module config + * + * Similar to a CONF_PARSER used to hold details of conf pairs + * which are evaluated per call for each module method. + * + * This allows the conf pairs to be evaluated within the appropriate context + * and use the appropriate dictionaries for where the module is in use. + */ +struct module_env_s { + char const *name; //!< Of conf pair to pass to tmpl_tokenizer. + char const *dflt; //!< Default string to pass to the tmpl_tokenizer if no CONF_PAIR found. + fr_token_t dflt_quote; //!< Default quoting for the default string. + + uint32_t type; //!< To cast boxes to. Also contains flags controlling parser behaviour. + + size_t offset; //!< Where to write results in the output structure when the tmpls are evaluated. + + union { + struct { + bool required; //!< Tmpl must produce output + bool concat; //!< If the tmpl produced multiple boxes they should be concatenated. + bool single; //!< If the tmpl produces more than one box this is an error. + bool multi; //!< Multiple instances of the conf pairs are allowed. Resulting + ///< boxes are stored in an array - one entry per conf pair. + mod_env_dest_t type; //!< Type of structure boxes will be written to. + size_t size; //!< Size of structure boxes will be written to. + char const *type_name; //!< Name of structure type boxes will be written to. + } pair; + + struct { + char const *ident2; //!< Second identifier for a section + module_env_t const *subcs; //!< Nested definitions for subsection. + } section; + }; +}; + +#define MODULE_ENV_TERMINATOR { NULL } + /** A list of modules * * This allows modules to be instantiated and freed in phases,