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.
+ size_t tmpl_offset; //!< Where to write pointer to tmpl in the output structure. Optional.
} pair;
struct {
.size = FR_MODULE_ENV_DST_SIZE(_struct, _field), \
.type_name = FR_MODULE_ENV_DST_TYPE_NAME(_struct, _field) }
+/** Version of the above which sets optional field for pointer to tmpl
+ */
+#define FR_MODULE_ENV_TMPL_OFFSET(_name, _cast_type, _struct, _field, _tmpl_field, _dflt, _dflt_quote, _required, _concat) \
+ .name = _name, \
+ .type = _cast_type, \
+ .offset = offsetof(_struct, _field), \
+ .dflt = _dflt, \
+ .dflt_quote = _dflt_quote, \
+ .pair = { .required = _required, \
+ .concat = FR_MODULE_ENV_CONCAT(_concat, _cast_type), \
+ .single = FR_MODULE_ENV_SINGLE(_struct, _field, _concat), \
+ .multi = FR_MODULE_ENV_MULTI(_struct, _field), \
+ .type = FR_MODULE_ENV_DST_TYPE(_struct, _field), \
+ .size = FR_MODULE_ENV_DST_SIZE(_struct, _field), \
+ .type_name = FR_MODULE_ENV_DST_TYPE_NAME(_struct, _field), \
+ .tmpl_offset = offsetof(_struct, _tmpl_field) }
+
/** A list of modules
*
* This allows modules to be instantiated and freed in phases,
/** Parse the result of module_env tmpl expansion
*/
-static inline CC_HINT(always_inline) int module_env_value_parse(request_t *request, void * out, unlang_frame_state_module_t *state) {
+static inline CC_HINT(always_inline) int module_env_value_parse(request_t *request, void *out, void **tmpl_out,
+ unlang_frame_state_module_t *state) {
fr_value_box_t *vb;
module_env_parsed_t const *env = state->last_expanded;
}
}
+ if (tmpl_out) *tmpl_out = env->tmpl;
+
return 0;
}
}
if (mc->method_env) {
- void *out, **array;
+ void *out, **array, *tmpl_out = NULL;
module_env_parsed_t const *env;
TALLOC_CTX *ctx;
out = ((uint8_t *)array) + env->rule->pair.size * env->multi_index;
}
- if (module_env_value_parse(request, out, state) < 0) {
+ if (env->rule->pair.tmpl_offset) tmpl_out = ((uint8_t *)state->env_data) + env->rule->pair.tmpl_offset;
+
+ if (module_env_value_parse(request, out, tmpl_out, state) < 0) {
ua = UNLANG_ACTION_FAIL;
goto fail;
}