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: cf86e6f38452907e4ca79eb0cc95edac6425397e $
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: cf86e6f38452907e4ca79eb0cc95edac6425397e $")
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.
92 CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE = (1 << 11), //!< bare words are treated as an attribute, but strings may
93 ///< be xlats. Should not be used with CALL_ENV_FLAG_ATTRIBUTE.
94 ///< as that flag _always_ parses it as an attribute.
96DIAG_ON(attributes)
97
98/** @name #conf_parser_t flags checks
99 *
100 * @{
101 */
102/** Evaluates to true if flags are valid for a pair
103 *
104 * @param[in] _flags to evaluate
105 */
106#define call_env_pair_flags(_flags) (((_flags) & (CALL_ENV_FLAG_SUBSECTION)) == 0)
107
108/** Evaluates to true if flags are valid for a subsection
109 *
110 * @param[in] _flags to evaluate
111 */
112#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)
113
114#define call_env_required(_flags) ((_flags) & CALL_ENV_FLAG_REQUIRED)
115
116#define call_env_concat(_flags) ((_flags) & CALL_ENV_FLAG_CONCAT)
117
118#define call_env_single(_flags) ((_flags) & CALL_ENV_FLAG_SINGLE)
119
120#define call_env_multi(_flags) ((_flags) & CALL_ENV_FLAG_MULTI)
121
122#define call_env_nullable(_flags) ((_flags) & CALL_ENV_FLAG_NULLABLE)
123
124#define call_env_force_quote(_flags) ((_flags) & CALL_ENV_FLAG_FORCE_QUOTE)
125
126#define call_env_parse_only(_flags) ((_flags) & CALL_ENV_FLAG_PARSE_ONLY)
127
128#define call_env_attribute(_flags) ((_flags) & CALL_ENV_FLAG_ATTRIBUTE)
129
130#define call_env_is_subsection(_flags) ((_flags) & CALL_ENV_FLAG_SUBSECTION)
131
132#define call_env_parse_missing(_flags) ((_flags) & CALL_ENV_FLAG_PARSE_MISSING)
133
134#define call_env_secret(_flags) ((_flags) & CALL_ENV_FLAG_SECRET)
135
136#define call_env_bare_word_attribute(_flags) ((_flags) & CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE)
137/** @} */
138
139/** Callback for performing custom parsing of a #CONF_PAIR
140 *
141 * @param[in] ctx to allocate any data in.
142 * @param[out] out Where to write the result of parsing.
143 * @param[in] t_rules we're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
144 * @param[in] ci The #CONF_SECTION or #CONF_PAIR to parse.
145 * @param[in] cec information about how the call env is being used.
146 * @param[in] rule Parse rules - How the #CONF_PAIR or #CONF_SECTION should be converted.
147 * @return
148 * - 0 on success.
149 * - -1 on failure.
150 */
151typedef 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);
152
153/** Callback for performing custom parsing of a #CONF_SECTION
154 *
155 * The callback function is expected to call call_env_parsed_add to allocate a new
156 * call_env_parsed_t, and either call_env_parsed_set_tmpl, or call_env_parsed_set_data to populate
157 * the call env_parsed_t structure.
158 *
159 * @param[in] ctx to allocate any data in.
160 * @param[out] out Where to write the result of parsing.
161 * @param[in] t_rules we're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
162 * @param[in] ci The #CONF_SECTION or #CONF_PAIR to parse.
163 * @param[in] cec information about how the call env is being used.
164 * @param[in] rule Parse rules - How the #CONF_PAIR or #CONF_SECTION should be converted.
165 * @return
166 * - 0 on success.
167 * - -1 on failure.
168 */
169typedef int (*call_env_parse_section_t)(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci,
170 call_env_ctx_t const *cec, call_env_parser_t const *rule);
171
172/** Per method call config
173 *
174 * Similar to a conf_parser_t used to hold details of conf pairs
175 * which are evaluated per call for each module method / xlat.
176 *
177 * This allows the conf pairs to be evaluated within the appropriate context
178 * and use the appropriate dictionaries for where the module is in use.
179 */
181 char const *name; //!< Of conf pair to pass to tmpl_tokenizer.
182 call_env_flags_t flags; //!< Flags controlling parser behaviour.
183
184 union {
185 struct {
186 fr_type_t cast_type; //!< To cast boxes to. Also contains flags controlling parser behaviour.
187
188 call_env_result_type_t type; //!< Type of structure boxes will be written to.
189 size_t size; //!< Size of structure boxes will be written to.
190 char const *type_name; //!< Name of structure type boxes will be written to.
191 size_t offset; //!< Where to write the result of evaluating the tmpl_t produced in the parsing phase.
192
193 char const *dflt; //!< Default string to pass to the tmpl_tokenizer if no CONF_PAIR found.
194 fr_token_t dflt_quote; //!< Quoting for the default string.
195
196 call_env_parse_pair_t func; //!< Callback for parsing a CONF_PAIR
197
198 struct {
199 ssize_t offset; //!< Where to write the result of the parsing phase.
200 ///< This is usually a tmpl_t, but could be other things when a callback
201 ///< function is used to parse the CONF_SECTION or CONF_PAIR.
202
203 call_env_parse_type_t type; //!< What type of output the parsing phase is expected to produce.
204 } parsed;
205
206 fr_value_box_safe_for_t literals_safe_for; //!< What safe_for value to assign any literals that are arguments to the tmpl_t.
207 tmpl_escape_t escape; //!< Escape method to use when evaluating tmpl_t.
208 } pair;
209
210 struct {
211 char const *name2; //!< Second identifier for a section
212 call_env_parser_t const *subcs; //!< Nested definitions for subsection.
213
214 call_env_parse_section_t func; //!< Callback for parsing CONF_SECTION.
215 } section;
216 };
217
218 void const *uctx; //!< User context for callback functions.
219};
220
221typedef enum {
222 CALL_ENV_CTX_TYPE_MODULE = 1, //!< The callenv is registered to a module method.
223 CALL_ENV_CTX_TYPE_XLAT //!< The callenv is registered to an xlat.
225
227 call_env_ctx_type_t type; //!< Type of callenv ctx.
228
229 module_instance_t const *mi; //!< Module instance that the callenv is registered to.
230 ///< Available for both module methods, and xlats.
231
232 section_name_t const *asked; //!< The actual name1/name2 that resolved to a
233 ///< module_method_binding_t.
234};
235
236#define CALL_ENV_TERMINATOR { NULL }
237
238/** Helper macro for populating the size/type fields of a #call_env_method_t from the output structure type
239 */
240#define FR_CALL_ENV_METHOD_OUT(_inst) \
241 .inst_size = sizeof(_inst), \
242 .inst_type = STRINGIFY(_inst) \
243
245 size_t inst_size; //!< Size of per call env.
246 char const *inst_type; //!< Type of per call env.
247 call_env_parser_t const *env; //!< Parsing rules for call method env.
248};
249
250/** Structure containing both a talloc pool, a list of parsed call_env_pairs
251 */
253 call_env_parsed_head_t parsed; //!< The per call parsed call environment.
254 call_env_method_t const *method; //!< The method this call env is for.
255};
256
257/** Where we're specifying a parsing phase output field, determine its type
258 */
259#define CALL_ENV_PARSE_TYPE(_s, _f) \
260_Generic((((_s *)NULL)->_f), \
261 tmpl_t const * : CALL_ENV_PARSE_TYPE_TMPL, \
262 tmpl_t * : CALL_ENV_PARSE_TYPE_TMPL, \
263 fr_value_box_t const * : CALL_ENV_PARSE_TYPE_VALUE_BOX, \
264 fr_value_box_t * : CALL_ENV_PARSE_TYPE_VALUE_BOX, \
265 default : CALL_ENV_PARSE_TYPE_VOID \
266)
267
268/** Derive whether tmpl can only emit a single box.
269 */
270#define FR_CALL_ENV_SINGLE(_s, _f, _c) \
271_Generic((((_s *)NULL)->_f), \
272 fr_value_box_t : __builtin_choose_expr(_c, CALL_ENV_FLAG_NONE, CALL_ENV_FLAG_SINGLE), \
273 fr_value_box_t * : __builtin_choose_expr(_c, CALL_ENV_FLAG_NONE, CALL_ENV_FLAG_SINGLE), \
274 fr_value_box_list_t : CALL_ENV_FLAG_NONE, \
275 fr_value_box_list_t * : CALL_ENV_FLAG_NONE, \
276 default : CALL_ENV_FLAG_NONE \
277)
278
279/** Derive whether multi conf pairs are allowed from target field type.
280 */
281#define FR_CALL_ENV_MULTI(_s, _f) \
282_Generic((((_s *)NULL)->_f), \
283 fr_value_box_t : CALL_ENV_FLAG_NONE, \
284 fr_value_box_t * : CALL_ENV_FLAG_MULTI, \
285 fr_value_box_list_t : CALL_ENV_FLAG_NONE, \
286 fr_value_box_list_t * : CALL_ENV_FLAG_MULTI \
287)
288
289/** Only FR_TYPE_STRING and FR_TYPE_OCTETS can be concatenated.
290 */
291#define FR_CALL_ENV_CONCAT(_c, _ct) \
292__builtin_choose_expr(_ct == FR_TYPE_STRING, _c, \
293__builtin_choose_expr(_ct == FR_TYPE_OCTETS, _c, \
294__builtin_choose_expr(_c, (void)0, false)))
295
296/** Mapping from field types to destination type enum
297 */
298#define FR_CALL_ENV_DST_TYPE(_s, _f) \
299_Generic((((_s *)NULL)->_f), \
300 fr_value_box_t : CALL_ENV_RESULT_TYPE_VALUE_BOX, \
301 fr_value_box_t * : CALL_ENV_RESULT_TYPE_VALUE_BOX, \
302 fr_value_box_list_t : CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST, \
303 fr_value_box_list_t * : CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST \
304)
305
306#define FR_CALL_ENV_DST_SIZE(_s, _f) \
307_Generic((((_s *)NULL)->_f), \
308 fr_value_box_t : sizeof(fr_value_box_t), \
309 fr_value_box_t * : sizeof(fr_value_box_t), \
310 fr_value_box_list_t : sizeof(fr_value_box_list_t), \
311 fr_value_box_list_t * : sizeof(fr_value_box_list_t), \
312 default : 0 \
313)
314
315#define FR_CALL_ENV_RESULT_TYPE_NAME(_s, _f) \
316_Generic((((_s *)NULL)->_f), \
317 fr_value_box_t : "fr_value_box_t", \
318 fr_value_box_t * : "fr_value_box_t", \
319 fr_value_box_list_t : "fr_value_box_list_t", \
320 fr_value_box_list_t * : "fr_value_box_list_t", \
321 default : NULL \
322)
323
324typedef void _mismatch_flags; //!< Dummy type used to indicate bad flags.
325
326#define CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field) \
327 (FR_CALL_ENV_CONCAT(((_flags) & CALL_ENV_FLAG_CONCAT), _cast_type) | \
328 FR_CALL_ENV_SINGLE(_struct, _field, ((_flags) & CALL_ENV_FLAG_CONCAT)) | \
329 FR_CALL_ENV_MULTI(_struct, _field) |\
330 ((_flags) & ~CALL_ENV_FLAG_CONCAT)) \
331
332/** Specify a call_env_parser_t which writes out runtime results to the specified field
333 *
334 * @param[in] _name of the conf pair to parse.
335 * @param[in] _cast_type Cast any value boxes produced to this type.
336 * @param[in] _flags controlling parser behaviour.
337 * @param[in] _struct which contains the field to write the result of the evaluation phase to.
338 * @param[in] _field where to write the result.
339 */
340#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field) \
341 .name = _name, \
342 .flags = CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field), \
343 .pair = { \
344 .cast_type = _cast_type, \
345 .type = FR_CALL_ENV_DST_TYPE(_struct, _field), \
346 .size = FR_CALL_ENV_DST_SIZE(_struct, _field), \
347 .type_name = FR_CALL_ENV_RESULT_TYPE_NAME(_struct, _field), \
348 .offset = offsetof(_struct, _field), \
349 .parsed = { \
350 .offset = -1, \
351 .type = CALL_ENV_PARSE_TYPE_TMPL \
352 } \
353 }
354
355/** Specify a call_env_parser_t which writes out runtime results and the result of the parsing phase to the fields specified
356 *
357 * @param[in] _name of the conf pair to parse.
358 * @param[in] _cast_type Cast any value boxes produced to this type.
359 * @param[in] _flags controlling parser behaviour.
360 * @param[in] _struct which contains the field to write the result of the evaluation phase to.
361 * @param[in] _field where to write the result.
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_OFFSET(_name, _cast_type, _flags, _struct, _field, _parse_field) \
366 .name = _name, \
367 .flags = CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field), \
368 .pair = { \
369 .cast_type = _cast_type, \
370 .type = FR_CALL_ENV_DST_TYPE(_struct, _field), \
371 .size = FR_CALL_ENV_DST_SIZE(_struct, _field), \
372 .type_name = FR_CALL_ENV_RESULT_TYPE_NAME(_struct, _field), \
373 .offset = offsetof(_struct, _field), \
374 .parsed = { \
375 .offset = offsetof(_struct, _parse_field), \
376 .type = CALL_ENV_PARSE_TYPE(_struct, _parse_field) \
377 } \
378 }
379
380/** Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified
381 *
382 * @param[in] _name of the conf pair to parse.
383 * @param[in] _cast_type Sets the cast used by the tmpl.
384 * @param[in] _flags controlling parser behaviour.
385 * @param[in] _struct which contains the field to write the result of the evaluation phase to.
386 * @param[in] _parse_field where to write the result of the parsing phase.
387 * This must be a field in the specified _struct.
388 */
389#define FR_CALL_ENV_PARSE_ONLY_OFFSET(_name, _cast_type, _flags, _struct, _parse_field) \
390 .name = _name, \
391 .flags = (_flags) | CALL_ENV_FLAG_PARSE_ONLY, \
392 .pair = { \
393 .cast_type = _cast_type, \
394 .parsed = { \
395 .offset = offsetof(_struct, _parse_field), \
396 .type = CALL_ENV_PARSE_TYPE(_struct, _parse_field) \
397 } \
398 }
399
400/** Specify a call_env_parser_t which defines a nested subsection
401 */
402#define FR_CALL_ENV_SUBSECTION(_name, _name2, _flags, _subcs ) \
403 .name = _name, \
404 .flags = CALL_ENV_FLAG_SUBSECTION | (_flags), \
405 .section = { \
406 .name2 = _name2, \
407 .subcs = _subcs, \
408 }
409
410/** Specify a call_env_parser_t which parses a subsection using a callback function
411 */
412#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _name2, _flags, _func) \
413 .name = _name, \
414 .flags = CALL_ENV_FLAG_SUBSECTION | (_flags), \
415 .section = { \
416 .name2 = _name2, \
417 .func = _func \
418 }
419
420/** @name Expand a call_env_t
421 * @{
422 */
423unlang_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);
424/** @} */
425
426/** @name Functions that implement standard parsing behaviour which can be called by callbacks
427 * @{
428 */
429int call_env_parse_pair(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci,
430 call_env_ctx_t const *cec, call_env_parser_t const *rule);
431/** @} */
432
433/** @name Functions to be used by the section callbacks to add parsed data.
434 * @{
435 */
436call_env_parsed_t *call_env_parsed_add(TALLOC_CTX *ctx, call_env_parsed_head_t *head, call_env_parser_t const *rule);
437
438void call_env_parsed_set_tmpl(call_env_parsed_t *parsed, tmpl_t const *tmpl);
439
441
442void call_env_parsed_set_data(call_env_parsed_t *parsed, void const *data);
443
444void call_env_parsed_set_multi_index(call_env_parsed_t *parsed, size_t count, size_t index);
445
446void call_env_parsed_free(call_env_parsed_head_t *parsed, call_env_parsed_t *ptr);
447/** @} */
448
449/** @name Allocate a new call env
450 * @{
451 */
452call_env_t *call_env_alloc(TALLOC_CTX *ctx, char const *name, call_env_method_t const *call_env_method,
453 tmpl_rules_t const *rules, CONF_SECTION *cs, call_env_ctx_t const *cec) CC_HINT(nonnull(3,4,5));
454/** @} */
455
456#ifdef __cplusplus
457}
458#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:182
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:169
call_env_ctx_type_t type
Type of callenv ctx.
Definition call_env.h:227
call_env_ctx_type_t
Definition call_env.h:221
@ CALL_ENV_CTX_TYPE_XLAT
The callenv is registered to an xlat.
Definition call_env.h:223
@ CALL_ENV_CTX_TYPE_MODULE
The callenv is registered to a module method.
Definition call_env.h:222
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:732
char const * name
Of conf pair to pass to tmpl_tokenizer.
Definition call_env.h:181
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:245
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:247
section_name_t const * asked
The actual name1/name2 that resolved to a module_method_binding_t.
Definition call_env.h:232
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:750
void const * uctx
User context for callback functions.
Definition call_env.h:218
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:645
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:717
char const * inst_type
Type of per call env.
Definition call_env.h:246
void _mismatch_flags
Dummy type used to indicate bad flags.
Definition call_env.h:324
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_BARE_WORD_ATTRIBUTE
bare words are treated as an attribute, but strings may be xlats.
Definition call_env.h:92
@ 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:702
call_env_parsed_head_t parsed
The per call parsed call environment.
Definition call_env.h:253
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:688
module_instance_t const * mi
Module instance that the callenv is registered to.
Definition call_env.h:229
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:254
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:151
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:674
Per method call config.
Definition call_env.h:180
Structure containing both a talloc pool, a list of parsed call_env_pairs.
Definition call_env.h:252
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:347
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