The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
call_env.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18/**
19 * $Id: 750c489514607c999a99c7757b277b38dd985872 $
20 *
21 * @file unlang/call_env.h
22 * @brief Structures and functions for handling call environments.
23 *
24 * @copyright 2023 Network RADIUS SAS (legal@networkradius.com)
25 */
26RCSIDH(call_env_h, "$Id: 750c489514607c999a99c7757b277b38dd985872 $")
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <freeradius-devel/util/dlist.h>
33
38typedef struct call_env_s call_env_t;
39
40FR_DLIST_TYPES(call_env_parsed)
41FR_DLIST_TYPEDEFS(call_env_parsed, call_env_parsed_head_t, call_env_parsed_entry_t)
42
43#include <freeradius-devel/util/value.h>
44#include <freeradius-devel/unlang/action.h>
45#include <freeradius-devel/server/cf_parse.h>
46#include <freeradius-devel/server/dl_module.h>
47#include <freeradius-devel/server/module.h>
48#include <freeradius-devel/server/request.h>
49#include <freeradius-devel/server/tmpl.h>
50
56
57/** What type of structure is produced by the parsing phase
58 */
59typedef enum {
60 CALL_ENV_PARSE_TYPE_TMPL = 1, //!< Output of the parsing phase is a tmpl_t.
61 CALL_ENV_PARSE_TYPE_VALUE_BOX, //!< Output of the parsing phase is a single value box (static data).
62 CALL_ENV_PARSE_TYPE_VOID //!< Output of the parsing phase is undefined (a custom structure).
64
65/** What type of structure is produced by the evaluation phase
66 */
67typedef enum {
68 CALL_ENV_RESULT_TYPE_VALUE_BOX = 1, //!< Output of the evaluation phase is a single value box.
69 CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST, //!< Output of the evaluation phase is a list of value boxes.
71
72DIAG_OFF(attributes)
73typedef enum CC_HINT(flag_enum) {
75 CALL_ENV_FLAG_REQUIRED = 1, //!< Associated conf pair or section is required.
76 CALL_ENV_FLAG_CONCAT = (1 << 1), //!< If the tmpl produced multiple boxes they should be concatenated.
77 CALL_ENV_FLAG_SINGLE = (1 << 2), //!< If the tmpl produces more than one box this is an error.
78 CALL_ENV_FLAG_MULTI = (1 << 3), //!< Multiple instances of the conf pairs are allowed. Resulting
79 ///< boxes are stored in an array - one entry per conf pair.
80 CALL_ENV_FLAG_NULLABLE = (1 << 4), //!< Tmpl expansions are allowed to produce no output.
81 CALL_ENV_FLAG_FORCE_QUOTE = (1 << 5), //!< Force quote method when parsing tmpl. This is for corner cases
82 ///< where tmpls should always be parsed with a particular quoting
83 ///< regardless of how they are in the config file. E.g. the `program`
84 ///< option of `rlm_exec` should always be parsed as T_BACK_QUOTED_STRING.
85 CALL_ENV_FLAG_PARSE_ONLY = (1 << 6), //!< The result of parsing will not be evaluated at runtime.
86 CALL_ENV_FLAG_ATTRIBUTE = (1 << 7), //!< Tmpl must contain an attribute reference.
87 CALL_ENV_FLAG_SUBSECTION = (1 << 8), //!< This is a subsection.
88 CALL_ENV_FLAG_PARSE_MISSING = (1 << 9), //!< If this subsection is missing, still parse it. Useful for cases where
89 ///< there is a callback which always needs to be run to set up required
90 ///< data structures.
91 CALL_ENV_FLAG_SECRET = (1 << 10), //!< The value is a secret, and should not be logged.
93DIAG_ON(attributes)
94
95/** @name #conf_parser_t flags checks
96 *
97 * @{
98 */
99/** Evaluates to true if flags are valid for a pair
100 *
101 * @param[in] _flags to evaluate
102 */
103#define call_env_pair_flags(_flags) (((_flags) & (CALL_ENV_FLAG_SUBSECTION)) == 0)
104
105/** Evaluates to true if flags are valid for a subsection
106 *
107 * @param[in] _flags to evaluate
108 */
109#define call_env_subsection_flags(_flags) (((_flags) & (CALL_ENV_FLAG_CONCAT | CALL_ENV_FLAG_SINGLE | CALL_ENV_FLAG_MULTI | CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_FORCE_QUOTE | CALL_ENV_FLAG_ATTRIBUTE | CALL_ENV_FLAG_PARSE_MISSING)) == 0)
110
111#define call_env_required(_flags) ((_flags) & CALL_ENV_FLAG_REQUIRED)
112
113#define call_env_concat(_flags) ((_flags) & CALL_ENV_FLAG_CONCAT)
114
115#define call_env_single(_flags) ((_flags) & CALL_ENV_FLAG_SINGLE)
116
117#define call_env_multi(_flags) ((_flags) & CALL_ENV_FLAG_MULTI)
118
119#define call_env_nullable(_flags) ((_flags) & CALL_ENV_FLAG_NULLABLE)
120
121#define call_env_force_quote(_flags) ((_flags) & CALL_ENV_FLAG_FORCE_QUOTE)
122
123#define call_env_parse_only(_flags) ((_flags) & CALL_ENV_FLAG_PARSE_ONLY)
124
125#define call_env_attribute(_flags) ((_flags) & CALL_ENV_FLAG_ATTRIBUTE)
126
127#define call_env_is_subsection(_flags) ((_flags) & CALL_ENV_FLAG_SUBSECTION)
128
129#define call_env_parse_missing(_flags) ((_flags) & CALL_ENV_FLAG_PARSE_MISSING)
130
131#define call_env_secret(_flags) ((_flags) & CALL_ENV_FLAG_SECRET)
132/** @} */
133
134/** Callback for performing custom parsing of a #CONF_PAIR
135 *
136 * @param[in] ctx to allocate any data in.
137 * @param[out] out Where to write the result of parsing.
138 * @param[in] t_rules we're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
139 * @param[in] ci The #CONF_SECTION or #CONF_PAIR to parse.
140 * @param[in] cec information about how the call env is being used.
141 * @param[in] rule Parse rules - How the #CONF_PAIR or #CONF_SECTION should be converted.
142 * @return
143 * - 0 on success.
144 * - -1 on failure.
145 */
146typedef int (*call_env_parse_pair_t)(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, call_env_parser_t const *rule);
147
148/** Callback for performing custom parsing of a #CONF_SECTION
149 *
150 * The callback function is expected to call call_env_parsed_add to allocate a new
151 * call_env_parsed_t, and either call_env_parsed_set_tmpl, or call_env_parsed_set_data to populate
152 * the call env_parsed_t structure.
153 *
154 * @param[in] ctx to allocate any data in.
155 * @param[out] out Where to write the result of parsing.
156 * @param[in] t_rules we're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
157 * @param[in] ci The #CONF_SECTION or #CONF_PAIR to parse.
158 * @param[in] cec information about how the call env is being used.
159 * @param[in] rule Parse rules - How the #CONF_PAIR or #CONF_SECTION should be converted.
160 * @return
161 * - 0 on success.
162 * - -1 on failure.
163 */
164typedef int (*call_env_parse_section_t)(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci,
165 call_env_ctx_t const *cec, call_env_parser_t const *rule);
166
167/** Per method call config
168 *
169 * Similar to a conf_parser_t used to hold details of conf pairs
170 * which are evaluated per call for each module method / xlat.
171 *
172 * This allows the conf pairs to be evaluated within the appropriate context
173 * and use the appropriate dictionaries for where the module is in use.
174 */
176 char const *name; //!< Of conf pair to pass to tmpl_tokenizer.
177 call_env_flags_t flags; //!< Flags controlling parser behaviour.
178
179 union {
180 struct {
181 fr_type_t cast_type; //!< To cast boxes to. Also contains flags controlling parser behaviour.
182
183 call_env_result_type_t type; //!< Type of structure boxes will be written to.
184 size_t size; //!< Size of structure boxes will be written to.
185 char const *type_name; //!< Name of structure type boxes will be written to.
186 size_t offset; //!< Where to write the result of evaluating the tmpl_t produced in the parsing phase.
187
188 char const *dflt; //!< Default string to pass to the tmpl_tokenizer if no CONF_PAIR found.
189 fr_token_t dflt_quote; //!< Quoting for the default string.
190
191 call_env_parse_pair_t func; //!< Callback for parsing a CONF_PAIR
192
193 struct {
194 ssize_t offset; //!< Where to write the result of the parsing phase.
195 ///< This is usually a tmpl_t, but could be other things when a callback
196 ///< function is used to parse the CONF_SECTION or CONF_PAIR.
197
198 call_env_parse_type_t type; //!< What type of output the parsing phase is expected to produce.
199 } parsed;
200
201 fr_value_box_safe_for_t literals_safe_for; //!< What safe_for value to assign any literals that are arguments to the tmpl_t.
202 tmpl_escape_t escape; //!< Escape method to use when evaluating tmpl_t.
203 } pair;
204
205 struct {
206 char const *name2; //!< Second identifier for a section
207 call_env_parser_t const *subcs; //!< Nested definitions for subsection.
208
209 call_env_parse_section_t func; //!< Callback for parsing CONF_SECTION.
210 } section;
211 };
212
213 void const *uctx; //!< User context for callback functions.
214};
215
216typedef enum {
217 CALL_ENV_CTX_TYPE_MODULE = 1, //!< The callenv is registered to a module method.
218 CALL_ENV_CTX_TYPE_XLAT //!< The callenv is registered to an xlat.
220
222 call_env_ctx_type_t type; //!< Type of callenv ctx.
223
224 module_instance_t const *mi; //!< Module instance that the callenv is registered to.
225 ///< Available for both module methods, and xlats.
226
227 section_name_t const *asked; //!< The actual name1/name2 that resolved to a
228 ///< module_method_binding_t.
229};
230
231#define CALL_ENV_TERMINATOR { NULL }
232
233/** Helper macro for populating the size/type fields of a #call_env_method_t from the output structure type
234 */
235#define FR_CALL_ENV_METHOD_OUT(_inst) \
236 .inst_size = sizeof(_inst), \
237 .inst_type = STRINGIFY(_inst) \
238
240 size_t inst_size; //!< Size of per call env.
241 char const *inst_type; //!< Type of per call env.
242 call_env_parser_t const *env; //!< Parsing rules for call method env.
243};
244
245/** Structure containing both a talloc pool, a list of parsed call_env_pairs
246 */
248 call_env_parsed_head_t parsed; //!< The per call parsed call environment.
249 call_env_method_t const *method; //!< The method this call env is for.
250};
251
252/** Where we're specifying a parsing phase output field, determine its type
253 */
254#define CALL_ENV_PARSE_TYPE(_s, _f) \
255_Generic((((_s *)NULL)->_f), \
256 tmpl_t const * : CALL_ENV_PARSE_TYPE_TMPL, \
257 tmpl_t * : CALL_ENV_PARSE_TYPE_TMPL, \
258 fr_value_box_t const * : CALL_ENV_PARSE_TYPE_VALUE_BOX, \
259 fr_value_box_t * : CALL_ENV_PARSE_TYPE_VALUE_BOX, \
260 default : CALL_ENV_PARSE_TYPE_VOID \
261)
262
263/** Derive whether tmpl can only emit a single box.
264 */
265#define FR_CALL_ENV_SINGLE(_s, _f, _c) \
266_Generic((((_s *)NULL)->_f), \
267 fr_value_box_t : __builtin_choose_expr(_c, CALL_ENV_FLAG_NONE, CALL_ENV_FLAG_SINGLE), \
268 fr_value_box_t * : __builtin_choose_expr(_c, CALL_ENV_FLAG_NONE, CALL_ENV_FLAG_SINGLE), \
269 fr_value_box_list_t : CALL_ENV_FLAG_NONE, \
270 fr_value_box_list_t * : CALL_ENV_FLAG_NONE, \
271 default : CALL_ENV_FLAG_NONE \
272)
273
274/** Derive whether multi conf pairs are allowed from target field type.
275 */
276#define FR_CALL_ENV_MULTI(_s, _f) \
277_Generic((((_s *)NULL)->_f), \
278 fr_value_box_t : CALL_ENV_FLAG_NONE, \
279 fr_value_box_t * : CALL_ENV_FLAG_MULTI, \
280 fr_value_box_list_t : CALL_ENV_FLAG_NONE, \
281 fr_value_box_list_t * : CALL_ENV_FLAG_MULTI \
282)
283
284/** Only FR_TYPE_STRING and FR_TYPE_OCTETS can be concatenated.
285 */
286#define FR_CALL_ENV_CONCAT(_c, _ct) \
287__builtin_choose_expr(_ct == FR_TYPE_STRING, _c, \
288__builtin_choose_expr(_ct == FR_TYPE_OCTETS, _c, \
289__builtin_choose_expr(_c, (void)0, false)))
290
291/** Mapping from field types to destination type enum
292 */
293#define FR_CALL_ENV_DST_TYPE(_s, _f) \
294_Generic((((_s *)NULL)->_f), \
295 fr_value_box_t : CALL_ENV_RESULT_TYPE_VALUE_BOX, \
296 fr_value_box_t * : CALL_ENV_RESULT_TYPE_VALUE_BOX, \
297 fr_value_box_list_t : CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST, \
298 fr_value_box_list_t * : CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST \
299)
300
301#define FR_CALL_ENV_DST_SIZE(_s, _f) \
302_Generic((((_s *)NULL)->_f), \
303 fr_value_box_t : sizeof(fr_value_box_t), \
304 fr_value_box_t * : sizeof(fr_value_box_t), \
305 fr_value_box_list_t : sizeof(fr_value_box_list_t), \
306 fr_value_box_list_t * : sizeof(fr_value_box_list_t), \
307 default : 0 \
308)
309
310#define FR_CALL_ENV_RESULT_TYPE_NAME(_s, _f) \
311_Generic((((_s *)NULL)->_f), \
312 fr_value_box_t : "fr_value_box_t", \
313 fr_value_box_t * : "fr_value_box_t", \
314 fr_value_box_list_t : "fr_value_box_list_t", \
315 fr_value_box_list_t * : "fr_value_box_list_t", \
316 default : NULL \
317)
318
319typedef void _mismatch_flags; //!< Dummy type used to indicate bad flags.
320
321#define CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field) \
322 (FR_CALL_ENV_CONCAT(((_flags) & CALL_ENV_FLAG_CONCAT), _cast_type) | \
323 FR_CALL_ENV_SINGLE(_struct, _field, ((_flags) & CALL_ENV_FLAG_CONCAT)) | \
324 FR_CALL_ENV_MULTI(_struct, _field) |\
325 ((_flags) & ~CALL_ENV_FLAG_CONCAT)) \
326
327/** Specify a call_env_parser_t which writes out runtime results to the specified field
328 *
329 * @param[in] _name of the conf pair to parse.
330 * @param[in] _cast_type Cast any value boxes produced to this type.
331 * @param[in] _flags controlling parser behaviour.
332 * @param[in] _struct which contains the field to write the result of the evaluation phase to.
333 * @param[in] _field where to write the result.
334 */
335#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field) \
336 .name = _name, \
337 .flags = CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field), \
338 .pair = { \
339 .cast_type = _cast_type, \
340 .type = FR_CALL_ENV_DST_TYPE(_struct, _field), \
341 .size = FR_CALL_ENV_DST_SIZE(_struct, _field), \
342 .type_name = FR_CALL_ENV_RESULT_TYPE_NAME(_struct, _field), \
343 .offset = offsetof(_struct, _field), \
344 .parsed = { \
345 .offset = -1, \
346 .type = CALL_ENV_PARSE_TYPE_TMPL \
347 } \
348 }
349
350/** Specify a call_env_parser_t which writes out runtime results and the result of the parsing phase to the fields specified
351 *
352 * @param[in] _name of the conf pair to parse.
353 * @param[in] _cast_type Cast any value boxes produced to this type.
354 * @param[in] _flags controlling parser behaviour.
355 * @param[in] _struct which contains the field to write the result of the evaluation phase to.
356 * @param[in] _field where to write the result.
357 * @param[in] _parse_field where to write the result of the parsing phase.
358 * This must be a field in the specified _struct.
359 */
360#define FR_CALL_ENV_PARSE_OFFSET(_name, _cast_type, _flags, _struct, _field, _parse_field) \
361 .name = _name, \
362 .flags = CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field), \
363 .pair = { \
364 .cast_type = _cast_type, \
365 .type = FR_CALL_ENV_DST_TYPE(_struct, _field), \
366 .size = FR_CALL_ENV_DST_SIZE(_struct, _field), \
367 .type_name = FR_CALL_ENV_RESULT_TYPE_NAME(_struct, _field), \
368 .offset = offsetof(_struct, _field), \
369 .parsed = { \
370 .offset = offsetof(_struct, _parse_field), \
371 .type = CALL_ENV_PARSE_TYPE(_struct, _parse_field) \
372 } \
373 }
374
375/** Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified
376 *
377 * @param[in] _name of the conf pair to parse.
378 * @param[in] _cast_type Sets the cast used by the tmpl.
379 * @param[in] _flags controlling parser behaviour.
380 * @param[in] _struct which contains the field to write the result of the evaluation phase to.
381 * @param[in] _parse_field where to write the result of the parsing phase.
382 * This must be a field in the specified _struct.
383 */
384#define FR_CALL_ENV_PARSE_ONLY_OFFSET(_name, _cast_type, _flags, _struct, _parse_field) \
385 .name = _name, \
386 .flags = (_flags) | CALL_ENV_FLAG_PARSE_ONLY, \
387 .pair = { \
388 .cast_type = _cast_type, \
389 .parsed = { \
390 .offset = offsetof(_struct, _parse_field), \
391 .type = CALL_ENV_PARSE_TYPE(_struct, _parse_field) \
392 } \
393 }
394
395/** Specify a call_env_parser_t which defines a nested subsection
396 */
397#define FR_CALL_ENV_SUBSECTION(_name, _name2, _flags, _subcs ) \
398 .name = _name, \
399 .flags = CALL_ENV_FLAG_SUBSECTION | (_flags), \
400 .section = { \
401 .name2 = _name2, \
402 .subcs = _subcs, \
403 }
404
405/** Specify a call_env_parser_t which parses a subsection using a callback function
406 */
407#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _name2, _flags, _func) \
408 .name = _name, \
409 .flags = CALL_ENV_FLAG_SUBSECTION | (_flags), \
410 .section = { \
411 .name2 = _name2, \
412 .func = _func \
413 }
414
415/** @name Expand a call_env_t
416 * @{
417 */
418unlang_action_t call_env_expand(TALLOC_CTX *ctx, request_t *request, call_env_result_t *result, void **env_data, call_env_t const *call_env);
419/** @} */
420
421/** @name Functions that implement standard parsing behaviour which can be called by callbacks
422 * @{
423 */
424int call_env_parse_pair(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci,
425 call_env_ctx_t const *cec, call_env_parser_t const *rule);
426/** @} */
427
428/** @name Functions to be used by the section callbacks to add parsed data.
429 * @{
430 */
431call_env_parsed_t *call_env_parsed_add(TALLOC_CTX *ctx, call_env_parsed_head_t *head, call_env_parser_t const *rule);
432
433void call_env_parsed_set_tmpl(call_env_parsed_t *parsed, tmpl_t const *tmpl);
434
436
437void call_env_parsed_set_data(call_env_parsed_t *parsed, void const *data);
438
439void call_env_parsed_set_multi_index(call_env_parsed_t *parsed, size_t count, size_t index);
440
441void call_env_parsed_free(call_env_parsed_head_t *parsed, call_env_parsed_t *ptr);
442/** @} */
443
444/** @name Allocate a new call env
445 * @{
446 */
447call_env_t *call_env_alloc(TALLOC_CTX *ctx, char const *name, call_env_method_t const *call_env_method,
448 tmpl_rules_t const *rules, CONF_SECTION *cs, call_env_ctx_t const *cec) CC_HINT(nonnull(3,4,5));
449/** @} */
450
451#ifdef __cplusplus
452}
453#endif
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
#define DIAG_ON(_x)
Definition build.h:458
#define RCSIDH(h, id)
Definition build.h:484
#define DIAG_OFF(_x)
Definition build.h:457
call_env_flags_t flags
Flags controlling parser behaviour.
Definition call_env.h:177
int(* call_env_parse_section_t)(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, call_env_parser_t const *rule)
Callback for performing custom parsing of a CONF_SECTION.
Definition call_env.h:164
call_env_ctx_type_t type
Type of callenv ctx.
Definition call_env.h:222
call_env_ctx_type_t
Definition call_env.h:216
@ CALL_ENV_CTX_TYPE_XLAT
The callenv is registered to an xlat.
Definition call_env.h:218
@ CALL_ENV_CTX_TYPE_MODULE
The callenv is registered to a module method.
Definition call_env.h:217
void call_env_parsed_free(call_env_parsed_head_t *parsed, call_env_parsed_t *ptr)
Remove a call_env_parsed_t from the list of parsed call envs.
Definition call_env.c:718
char const * name
Of conf pair to pass to tmpl_tokenizer.
Definition call_env.h:176
unlang_action_t call_env_expand(TALLOC_CTX *ctx, request_t *request, call_env_result_t *result, void **env_data, call_env_t const *call_env)
Initialise the expansion of a call environment.
Definition call_env.c:295
call_env_result_type_t
What type of structure is produced by the evaluation phase.
Definition call_env.h:67
@ CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST
Output of the evaluation phase is a list of value boxes.
Definition call_env.h:69
@ CALL_ENV_RESULT_TYPE_VALUE_BOX
Output of the evaluation phase is a single value box.
Definition call_env.h:68
size_t inst_size
Size of per call env.
Definition call_env.h:240
call_env_result_t
Definition call_env.h:51
@ CALL_ENV_INVALID
Definition call_env.h:54
@ CALL_ENV_MISSING
Definition call_env.h:53
@ CALL_ENV_SUCCESS
Definition call_env.h:52
call_env_parser_t const * env
Parsing rules for call method env.
Definition call_env.h:242
section_name_t const * asked
The actual name1/name2 that resolved to a module_method_binding_t.
Definition call_env.h:227
call_env_t * call_env_alloc(TALLOC_CTX *ctx, char const *name, call_env_method_t const *call_env_method, tmpl_rules_t const *rules, CONF_SECTION *cs, call_env_ctx_t const *cec))
Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or mo...
Definition call_env.c:736
void const * uctx
User context for callback functions.
Definition call_env.h:213
call_env_parsed_t * call_env_parsed_add(TALLOC_CTX *ctx, call_env_parsed_head_t *head, call_env_parser_t const *rule)
Allocate a new call_env_parsed_t structure and add it to the list of parsed call envs.
Definition call_env.c:631
void call_env_parsed_set_multi_index(call_env_parsed_t *parsed, size_t count, size_t index)
Assign a count and index to a call_env_parsed_t.
Definition call_env.c:703
char const * inst_type
Type of per call env.
Definition call_env.h:241
void _mismatch_flags
Dummy type used to indicate bad flags.
Definition call_env.h:319
call_env_flags_t
Definition call_env.h:73
@ CALL_ENV_FLAG_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition call_env.h:76
@ CALL_ENV_FLAG_SUBSECTION
This is a subsection.
Definition call_env.h:87
@ CALL_ENV_FLAG_SINGLE
If the tmpl produces more than one box this is an error.
Definition call_env.h:77
@ CALL_ENV_FLAG_ATTRIBUTE
Tmpl must contain an attribute reference.
Definition call_env.h:86
@ CALL_ENV_FLAG_FORCE_QUOTE
Force quote method when parsing tmpl.
Definition call_env.h:81
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
Definition call_env.h:85
@ CALL_ENV_FLAG_SECRET
The value is a secret, and should not be logged.
Definition call_env.h:91
@ CALL_ENV_FLAG_NONE
Definition call_env.h:74
@ CALL_ENV_FLAG_MULTI
Multiple instances of the conf pairs are allowed.
Definition call_env.h:78
@ CALL_ENV_FLAG_REQUIRED
Associated conf pair or section is required.
Definition call_env.h:75
@ CALL_ENV_FLAG_PARSE_MISSING
If this subsection is missing, still parse it.
Definition call_env.h:88
@ CALL_ENV_FLAG_NULLABLE
Tmpl expansions are allowed to produce no output.
Definition call_env.h:80
void call_env_parsed_set_data(call_env_parsed_t *parsed, void const *data)
Assign data to a call_env_parsed_t.
Definition call_env.c:688
call_env_parsed_head_t parsed
The per call parsed call environment.
Definition call_env.h:248
call_env_parse_type_t
What type of structure is produced by the parsing phase.
Definition call_env.h:59
@ CALL_ENV_PARSE_TYPE_VALUE_BOX
Output of the parsing phase is a single value box (static data).
Definition call_env.h:61
@ CALL_ENV_PARSE_TYPE_TMPL
Output of the parsing phase is a tmpl_t.
Definition call_env.h:60
@ CALL_ENV_PARSE_TYPE_VOID
Output of the parsing phase is undefined (a custom structure).
Definition call_env.h:62
void call_env_parsed_set_value(call_env_parsed_t *parsed, fr_value_box_t const *vb)
Assign a value box to a call_env_parsed_t.
Definition call_env.c:674
module_instance_t const * mi
Module instance that the callenv is registered to.
Definition call_env.h:224
int call_env_parse_pair(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, call_env_parser_t const *rule)
call_env_method_t const * method
The method this call env is for.
Definition call_env.h:249
int(* call_env_parse_pair_t)(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, call_env_parser_t const *rule)
Callback for performing custom parsing of a CONF_PAIR.
Definition call_env.h:146
void call_env_parsed_set_tmpl(call_env_parsed_t *parsed, tmpl_t const *tmpl)
Assign a tmpl to a call_env_parsed_t.
Definition call_env.c:660
Per method call config.
Definition call_env.h:175
Structure containing both a talloc pool, a list of parsed call_env_pairs.
Definition call_env.h:247
Common header for all CONF_* types.
Definition cf_priv.h:49
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
#define FR_DLIST_TYPES(_name)
Define type specific wrapper structs for dlists.
Definition dlist.h:1129
#define FR_DLIST_TYPEDEFS(_name, _head, _entry)
Define friendly names for type specific dlist head and entry structures.
Definition dlist.h:1139
fr_type_t
long int ssize_t
static char const * name
Section name identifier.
Definition section.h:44
Module instance data.
Definition module.h:265
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:341
return count
Definition module.c:163
fr_aka_sim_id_type_t type
Escaping rules for tmpls.
Definition tmpl_escape.h:80
enum fr_token fr_token_t
static fr_slen_t head
Definition xlat.h:422
static fr_slen_t data
Definition value.h:1265
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
Definition value.h:155
int nonnull(2, 5))
static size_t char ** out
Definition value.h:997