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