]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Define module_env_t
authorNick Porter <nick@portercomputing.co.uk>
Mon, 27 Feb 2023 15:50:53 +0000 (15:50 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 10 Mar 2023 17:18:33 +0000 (17:18 +0000)
To hold rules for parsing config items into call specific tmpls.

src/lib/server/module.h

index a11c1980092bd6b19a81a6cf76dfac2bd7a6ae8c..9292a0761eef875026b6f69b1ecd284f1c050b1e 100644 (file)
@@ -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,