All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tmpl.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_TMPL_H
17 #define _FR_TMPL_H
18 /**
19  * $Id: 08919e8f543e7776b19edbb797a9d95b7c90105d $
20  *
21  * @file include/tmpl.h
22  * @brief Structures and prototypes for templates
23  *
24  * These functions are used to work with #vp_tmpl_t structs.
25  *
26  * #vp_tmpl_t (VPTs) specify either a data source, or a data sink.
27  *
28  * Examples of sources are #TMPL_TYPE_XLAT, #TMPL_TYPE_EXEC and #TMPL_TYPE_ATTR.
29  * Examples of sinks are #TMPL_TYPE_ATTR, #TMPL_TYPE_LIST.
30  *
31  * VPTs are used to gather values or attributes for evaluation, or copying, and to specify
32  * where values or #VALUE_PAIR should be copied to.
33  *
34  * To create new #vp_tmpl_t use one of the tmpl_*from_* functions. These parse
35  * strings into VPTs. The main parsing function is #tmpl_afrom_str, which can produce
36  * most types of VPTs. It uses the type of quoting (passed as an #FR_TOKEN) to determine
37  * what type of VPT to parse the string as. For example a #T_DOUBLE_QUOTED_STRING will
38  * produce either a #TMPL_TYPE_XLAT or a #TMPL_TYPE_UNPARSED (depending if the string
39  * contained a non-literal expansion).
40  *
41  * @see tmpl_afrom_str
42  * @see tmpl_afrom_attr_str
43  * @see tmpl_from_attr_str
44  * @see tmpl_from_attr_substr
45  *
46  * In the case of #TMPL_TYPE_ATTR and #TMPL_TYPE_LIST, there are special cursor overlay
47  * functions which can be used to iterate over only the #VALUE_PAIR that match a
48  * vp_tmpl_t in a given list.
49  *
50  * @see tmpl_cursor_init
51  * @see tmpl_cursor_next
52  *
53  * Or for simplicity, there are functions which wrap the cursor functions, to copy or
54  * return the #VALUE_PAIR that match the VPT.
55  *
56  * @see tmpl_copy_vps
57  * @see tmpl_find_vp
58  *
59  * If you just need the string value of whatever the VPT refers to, the tmpl_*expand
60  * functions may be used. These functions evaluate the VPT, execing, and xlat expanding
61  * as necessary. In the case of #TMPL_TYPE_ATTR, and #PW_TYPE_STRING or #PW_TYPE_OCTETS
62  * #tmpl_expand will return a pointer to the raw #VALUE_PAIR buffer. This can be very
63  * useful when using the #PW_TYPE_TMPL type in #CONF_PARSER structs, as it allows the
64  * user to determine whether they want the module to sanitise the value using presentation
65  * format specific #xlat_escape_t function, or to operate on the raw value.
66  *
67  * @see tmpl_expand
68  * @see tmpl_aexpand
69  *
70  * @copyright 2014-2015 The FreeRADIUS server project
71  */
72 RCSIDH(tmpl_h, "$Id: 08919e8f543e7776b19edbb797a9d95b7c90105d $")
73 
74 #include <freeradius-devel/xlat.h>
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 typedef enum pair_lists {
81  PAIR_LIST_UNKNOWN = 0, //!< Unknown list.
82  PAIR_LIST_REQUEST, //!< Attributes in incoming or internally proxied
83  ///< request.
84  PAIR_LIST_REPLY, //!< Attributes to send in the response.
85  PAIR_LIST_CONTROL, //!< Attributes that change the behaviour of
86  ///< modules.
87  PAIR_LIST_STATE, //!< Attributes to store multiple rounds of
88  ///< challenges/responses.
89 #ifdef WITH_PROXY
90  PAIR_LIST_PROXY_REQUEST, //!< A copy of attributes in the request list
91  ///< that may be modified in pre-proxy before
92  //!< proxying the request.
93  PAIR_LIST_PROXY_REPLY, //!< Attributes sent in response to the proxied
94  ///< request.
95 #endif
96 #ifdef WITH_COA
97  PAIR_LIST_COA, //!< Attributes to send in a forked CoA-Request.
98  PAIR_LIST_COA_REPLY, //!< Attributes sent in response to the forked
99  ///< CoA-Request.
100  PAIR_LIST_DM, //!< Attributes to send in a forked Disconnect-Request.
101  PAIR_LIST_DM_REPLY //!< Attributes sent in response to the forked
102  //!< Disconnect-Request.
103 #endif
104 } pair_lists_t;
105 
106 extern const FR_NAME_NUMBER pair_lists[];
107 
108 typedef enum requests {
109  REQUEST_UNKNOWN = 0, //!< Unknown request.
110  REQUEST_OUTER, //!< #REQUEST containing the outer layer of the EAP
111  //!< conversation. Usually the RADIUS request sent
112  //!< by the NAS.
113  REQUEST_CURRENT, //!< The current request.
114  REQUEST_PARENT //!< Not currently used.
116 
117 extern const FR_NAME_NUMBER request_refs[];
118 
119 typedef struct pair_list {
120  char const *name;
123  int lineno;
124  struct pair_list *next;
125 } PAIR_LIST;
126 
127 /** Types of #vp_tmpl_t
128  */
129 typedef enum tmpl_type {
130  TMPL_TYPE_UNKNOWN = 0, //!< Uninitialised.
131  TMPL_TYPE_UNPARSED, //!< Unparsed literal string.
132  TMPL_TYPE_XLAT, //!< XLAT expansion.
133  TMPL_TYPE_ATTR, //!< Dictionary attribute.
134  TMPL_TYPE_ATTR_UNDEFINED, //!< Attribute not found in the global dictionary.
135  TMPL_TYPE_LIST, //!< Attribute list.
136  TMPL_TYPE_REGEX, //!< Regular expression.
137  TMPL_TYPE_EXEC, //!< Callout to an external script or program.
138  TMPL_TYPE_DATA, //!< Value in native format.
139  TMPL_TYPE_XLAT_STRUCT, //!< Pre-parsed XLAT expansion.
140  TMPL_TYPE_REGEX_STRUCT, //!< Pre-parsed regular expression.
141  TMPL_TYPE_NULL //!< Has no value.
142 } tmpl_type_t;
143 
144 extern const FR_NAME_NUMBER tmpl_names[];
145 
146 /** Describes a #TMPL_TYPE_ATTR, #TMPL_TYPE_ATTR_UNDEFINED or #TMPL_TYPE_LIST
147  */
148 typedef struct {
149  request_refs_t request; //!< Request to search or insert in.
150  pair_lists_t list; //!< List to search or insert in.
151 
152  fr_dict_attr_t const *da; //!< Resolved dictionary attribute.
153  union {
154  uint8_t da[FR_DICT_ATTR_SIZE]; //!< Unknown dictionary attribute buffer.
155  uint8_t vendor[FR_DICT_ATTR_SIZE]; //!< Unknown dictionary attribute buffer.
156  char name[FR_DICT_ATTR_SIZE]; //!< Raw unknown dictionary name.
157  } unknown;
158  int num; //!< For array references.
159  int8_t tag; //!< For tag references.
161 
162 /** A source or sink of value data.
163  *
164  * Is used as both the RHS and LHS of a map (both update, and conditional types)
165  *
166  * @section update_maps Use in update vp_map_t
167  * When used on the LHS it describes an attribute to create and should be one of these types:
168  * - #TMPL_TYPE_ATTR
169  * - #TMPL_TYPE_LIST
170  *
171  * When used on the RHS it describes the value to assign to the attribute being created and
172  * should be one of these types:
173  * - #TMPL_TYPE_UNPARSED
174  * - #TMPL_TYPE_XLAT
175  * - #TMPL_TYPE_ATTR
176  * - #TMPL_TYPE_LIST
177  * - #TMPL_TYPE_EXEC
178  * - #TMPL_TYPE_DATA
179  * - #TMPL_TYPE_XLAT_STRUCT (pre-parsed xlat)
180  *
181  * @section conditional_maps Use in conditional vp_map_t
182  * When used as part of a condition it may be any of the RHS side types, as well as:
183  * - #TMPL_TYPE_REGEX_STRUCT (pre-parsed regex)
184  *
185  * @see vp_map_t
186  */
187 typedef struct vp_tmpl_t {
188  tmpl_type_t type; //!< What type of value tmpl refers to.
189 
190  char const *name; //!< Raw string used to create the template.
191  size_t len; //!< Length of the raw string used to create the template.
192  FR_TOKEN quote; //!< What type of quoting was around the raw string.
193 
194  bool auto_converted; //!< Attr-26.9.1 --> Cisco-AVPair
195 
196 #ifdef HAVE_REGEX
197  bool iflag; //!< regex - case insensitive (if operand is used in regex comparison)
198  bool mflag; //!< regex - multiline flags (controls $ matching)
199 #endif
200 
201  union {
202  /*
203  * Attribute reference. Either an attribute currently in the request
204  * or an attribute to create.
205  */
206  value_pair_tmpl_attr_t attribute;
207 
208  /*
209  * Attribute value. Typically used as the RHS of an update map.
210  */
211  struct {
212  PW_TYPE type; //!< Type of data.
213  value_data_t data; //!< Value data.
214  } literal;
215 
216  xlat_exp_t *xlat; //!< pre-parsed xlat_exp_t
217 
218 #ifdef HAVE_REGEX
219  regex_t *preg; //!< pre-parsed regex_t
220 #endif
221  } data;
222 } vp_tmpl_t;
223 
224 /** @name Field accessors for #TMPL_TYPE_ATTR, #TMPL_TYPE_ATTR_UNDEFINED, #TMPL_TYPE_LIST
225  *
226  * @{
227  */
228 #define tmpl_request data.attribute.request
229 #define tmpl_list data.attribute.list
230 #define tmpl_da data.attribute.da
231 #define tmpl_unknown data.attribute.unknown.da
232 #define tmpl_unknown_name data.attribute.unknown.name
233 #define tmpl_num data.attribute.num
234 #define tmpl_tag data.attribute.tag
235 /* @} **/
236 
237 /** @name Field accessors for #TMPL_TYPE_XLAT_STRUCT
238  *
239  * @{
240  */
241 #define tmpl_xlat data.xlat
242 /* @} **/
243 
244 /** @name Field accessors for #TMPL_TYPE_DATA
245  *
246  * @{
247  */
248 #define tmpl_data data.literal
249 #define tmpl_data_type data.literal.type
250 #define tmpl_data_length data.literal.data.length
251 #define tmpl_data_value data.literal.data
252 /* @} **/
253 
254 /** @name Field accessors for #TMPL_TYPE_REGEX_STRUCT and #TMPL_TYPE_REGEX
255  *
256  * @{
257  */
258 #ifdef HAVE_REGEX
259 # define tmpl_preg data.preg //!< #TMPL_TYPE_REGEX_STRUCT only.
260 # define tmpl_iflag iflag
261 # define tmpl_mflag mflag
262 #endif
263 /* @} **/
264 
265 #ifndef WITH_VERIFY_PTR
266 # define VERIFY_TMPL(_x)
267 #else
268 # define VERIFY_TMPL(_x) tmpl_verify(__FILE__, __LINE__, _x)
269 void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt);
270 #endif
271 
272 /** Produces an initialiser for static #TMPL_TYPE_LIST type #vp_tmpl_t
273  *
274  * Example:
275  @code{.c}
276  static vp_tmpl_t list = tmpl_initialiser_list(CURRENT_REQUEST, PAIR_LIST_REQUEST);
277  vp_cursor_t cursor;
278  VALUE_PAIR *vp;
279 
280  // Iterate over all pairs in the request list
281  for (vp = tmpl_cursor_init(NULL, &cursor, request, &list);
282  vp;
283  vp = tmpl_cursor_next(&cursor, &list)) {
284  // Do something
285  }
286  @endcode
287  *
288  * @param _request to locate the list in.
289  * @param _list to set as the target for the template.
290  * @see tmpl_cursor_init
291  * @see tmpl_cursor_next
292  */
293 #define tmpl_initialiser_list(_request, _list)\
294 { \
295  .name = "static", \
296  .len = sizeof("static"), \
297  .type = TMPL_TYPE_LIST, \
298  .quote = T_SINGLE_QUOTED_STRING, \
299  .data = { \
300  .attribute = { \
301  .request = _request, \
302  .list = _list \
303  } \
304  } \
305 }
306 
307 /** Determine the correct context and list head
308  *
309  * Used in conjunction with the fr_cursor functions to determine the correct list
310  * and TALLOC_CTX for inserting VALUE_PAIRs.
311  *
312  * Example:
313  @code{.c}
314  TALLOC_CTX *ctx;
315  VALUE_PAIR **head;
316  value_data_t value;
317 
318  RADIUS_LIST_AND_CTX(ctx, head, request, CURRENT_REQUEST, PAIR_LIST_REQUEST);
319  if (!list) return -1; // error
320 
321  value.strvalue = talloc_strdup(NULL, "my new username");
322  value.length = talloc_array_length(value.strvalue) - 1;
323 
324  if (fr_pair_update_by_num(ctx, head, PW_USERNAME, 0, TAG_ANY, PW_TYPE_STRING, &value) < 0) return -1; // error
325  @endcode
326  *
327  * @param _ctx new #VALUE_PAIR s should be allocated in for the specified list.
328  * @param _head of the #VALUE_PAIR list.
329  * @param _request The current request.
330  * @param _ref to resolve.
331  * @param _list to resolve.
332  */
333 #define RADIUS_LIST_AND_CTX(_ctx, _head, _request, _ref, _list) \
334 do {\
335  REQUEST *_rctx = _request; \
336  if ((radius_request(&_rctx, _ref) < 0) || \
337  !(_head = radius_list(_rctx, _list)) || \
338  !(_ctx = radius_list_ctx(_rctx, _list))) {\
339  _ctx = NULL; \
340  _head = NULL; \
341  }\
342 } while (0)
343 
344 VALUE_PAIR **radius_list(REQUEST *request, pair_lists_t list);
345 
346 RADIUS_PACKET *radius_packet(REQUEST *request, pair_lists_t list_name);
347 
348 TALLOC_CTX *radius_list_ctx(REQUEST *request, pair_lists_t list_name);
349 
350 size_t radius_list_name(pair_lists_t *out, char const *name, pair_lists_t default_list);
351 
352 int radius_request(REQUEST **request, request_refs_t name);
353 
354 size_t radius_request_name(request_refs_t *out, char const *name, request_refs_t unknown);
355 
357  char const *name, ssize_t len, FR_TOKEN quote);
358 
359 vp_tmpl_t *tmpl_alloc(TALLOC_CTX *ctx, tmpl_type_t type, char const *name,
360  ssize_t len, FR_TOKEN quote);
361 
362 void tmpl_from_da(vp_tmpl_t *vpt, fr_dict_attr_t const *da, int8_t tag, int num,
363  request_refs_t request, pair_lists_t list);
364 
365 int tmpl_afrom_value_data(TALLOC_CTX *ctx, vp_tmpl_t **out, value_data_t *data,
366  PW_TYPE type, fr_dict_attr_t const *enumv, bool steal);
367 
368 ssize_t tmpl_from_attr_substr(vp_tmpl_t *vpt, char const *name,
369  request_refs_t request_def, pair_lists_t list_def,
370  bool allow_unknown, bool allow_undefined);
371 
372 ssize_t tmpl_from_attr_str(vp_tmpl_t *vpt, char const *name,
373  request_refs_t request_def,
374  pair_lists_t list_def,
375  bool allow_unknown, bool allow_undefined);
376 
377 ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name,
378  request_refs_t request_def, pair_lists_t list_def,
379  bool allow_unknown, bool allow_undefined);
380 
381 ssize_t tmpl_afrom_attr_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name,
382  request_refs_t request_def,
383  pair_lists_t list_def,
384  bool allow_unknown, bool allow_undefined);
385 
386 ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name, size_t inlen,
387  FR_TOKEN type, request_refs_t request_def, pair_lists_t list_def, bool do_escape);
388 
389 int tmpl_cast_in_place(vp_tmpl_t *vpt, PW_TYPE type, fr_dict_attr_t const *enumv);
390 
392 
393 int tmpl_cast_to_vp(VALUE_PAIR **out, REQUEST *request,
394  vp_tmpl_t const *vpt, fr_dict_attr_t const *cast);
395 
396 size_t tmpl_snprint(char *buffer, size_t bufsize, vp_tmpl_t const *vpt,
397  fr_dict_attr_t const *values);
398 
399 ssize_t tmpl_expand(char const **out, char *buff, size_t outlen, REQUEST *request,
400  vp_tmpl_t const *vpt, xlat_escape_t escape, void *escape_ctx);
401 
402 ssize_t tmpl_aexpand(TALLOC_CTX *ctx, char **out, REQUEST *request, vp_tmpl_t const *vpt,
403  xlat_escape_t escape, void *escape_ctx);
404 
405 VALUE_PAIR *tmpl_cursor_init(int *err, vp_cursor_t *cursor, REQUEST *request,
406  vp_tmpl_t const *vpt);
407 
408 VALUE_PAIR *tmpl_cursor_next(vp_cursor_t *cursor, vp_tmpl_t const *vpt);
409 
410 int tmpl_copy_vps(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request,
411  vp_tmpl_t const *vpt);
412 
413 int tmpl_find_vp(VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt);
414 
415 int tmpl_find_or_add_vp(VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt);
416 
418 
420 
421 #ifdef __cplusplus
422 }
423 #endif
424 #endif /* _FR_TMPL_H */
void tmpl_from_da(vp_tmpl_t *vpt, fr_dict_attr_t const *da, int8_t tag, int num, request_refs_t request, pair_lists_t list)
Initialise a vp_tmpl_t to search for, or create attributes.
Definition: tmpl.c:567
ssize_t tmpl_expand(char const **out, char *buff, size_t outlen, REQUEST *request, vp_tmpl_t const *vpt, xlat_escape_t escape, void *escape_ctx)
Expand a vp_tmpl_t to a string writing the result to a buffer.
Definition: tmpl.c:1479
#define RCSIDH(h, id)
Definition: build.h:136
ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name, size_t inlen, FR_TOKEN type, request_refs_t request_def, pair_lists_t list_def, bool do_escape)
Convert an arbitrary string into a vp_tmpl_t.
Definition: tmpl.c:1022
struct vp_tmpl_t vp_tmpl_t
A source or sink of value data.
char const * name
Definition: tmpl.h:120
VALUE_PAIR * check
Definition: tmpl.h:121
Dictionary attribute.
Definition: dict.h:77
REQUEST containing the outer layer of the EAP conversation.
Definition: tmpl.h:110
RADIUS_PACKET * radius_packet(REQUEST *request, pair_lists_t list_name)
Resolve a list to the RADIUS_PACKET holding the HEAD pointer for a VALUE_PAIR list.
Definition: tmpl.c:279
char const * name
Raw string used to create the template.
Definition: tmpl.h:190
int tmpl_afrom_value_data(TALLOC_CTX *ctx, vp_tmpl_t **out, value_data_t *data, PW_TYPE type, fr_dict_attr_t const *enumv, bool steal)
Create a vp_tmpl_t from a value_data_t.
Definition: tmpl.c:595
TALLOC_CTX * radius_list_ctx(REQUEST *request, pair_lists_t list_name)
Return the correct TALLOC_CTX to alloc VALUE_PAIR in, for a list.
Definition: tmpl.c:331
VALUE_PAIR ** radius_list(REQUEST *request, pair_lists_t list)
Resolve attribute pair_lists_t value to an attribute list.
Definition: tmpl.c:195
bool auto_converted
Attr-26.9.1 –> Cisco-AVPair.
Definition: tmpl.h:194
Dictionary attribute.
Definition: tmpl.h:133
static char const * name
Attributes sent in response to the forked Disconnect-Request.
Definition: tmpl.h:101
Pre-parsed XLAT expansion.
Definition: tmpl.h:139
Attributes to send in a forked CoA-Request.
Definition: tmpl.h:97
ssize_t tmpl_from_attr_substr(vp_tmpl_t *vpt, char const *name, request_refs_t request_def, pair_lists_t list_def, bool allow_unknown, bool allow_undefined)
Parse a string into a TMPL_TYPE_ATTR_* or TMPL_TYPE_LIST type vp_tmpl_t.
Definition: tmpl.c:661
ssize_t tmpl_afrom_attr_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name, request_refs_t request_def, pair_lists_t list_def, bool allow_unknown, bool allow_undefined)
Parse a string into a TMPL_TYPE_ATTR_* or TMPL_TYPE_LIST type vp_tmpl_t.
Definition: tmpl.c:956
Unparsed literal string.
Definition: tmpl.h:131
Unknown request.
Definition: tmpl.h:109
Values of the encryption flags.
Definition: dict.h:40
A copy of attributes in the request list that may be modified in pre-proxy before proxying the reques...
Definition: tmpl.h:90
tmpl_type
Types of vp_tmpl_t.
Definition: tmpl.h:129
size_t(* xlat_escape_t)(REQUEST *request, char *out, size_t outlen, char const *in, void *arg)
Definition: xlat.h:36
pair_lists_t list
List to search or insert in.
Definition: tmpl.h:150
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
Definition: pair.h:144
Attributes to send in a forked Disconnect-Request.
Definition: tmpl.h:100
pair_lists
Definition: tmpl.h:80
Attribute not found in the global dictionary.
Definition: tmpl.h:134
Pre-parsed regular expression.
Definition: tmpl.h:140
Definition: xlat.c:60
int tmpl_define_unknown_attr(vp_tmpl_t *vpt)
Add an unknown fr_dict_attr_t specified by a vp_tmpl_t to the main dictionary.
Definition: tmpl.c:1360
const FR_NAME_NUMBER request_refs[]
Map keywords to request_refs_t values.
Definition: tmpl.c:74
VALUE_PAIR * tmpl_cursor_init(int *err, vp_cursor_t *cursor, REQUEST *request, vp_tmpl_t const *vpt)
Initialise a vp_cursor_t to the VALUE_PAIR specified by a vp_tmpl_t.
Definition: tmpl.c:1990
struct pair_list * next
Definition: tmpl.h:124
requests
Definition: tmpl.h:108
Value in native format.
Definition: tmpl.h:138
int tmpl_find_vp(VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt)
Returns the first VP matching a vp_tmpl_t.
Definition: tmpl.c:2224
ssize_t tmpl_from_attr_str(vp_tmpl_t *vpt, char const *name, request_refs_t request_def, pair_lists_t list_def, bool allow_unknown, bool allow_undefined)
Parse a string into a TMPL_TYPE_ATTR_* or TMPL_TYPE_LIST type vp_tmpl_t.
Definition: tmpl.c:877
Regular expression.
Definition: tmpl.h:136
Attributes sent in response to the forked CoA-Request.
Definition: tmpl.h:98
Attributes in incoming or internally proxied request.
Definition: tmpl.h:82
int radius_request(REQUEST **request, request_refs_t name)
Resolve a request_refs_t to a REQUEST.
Definition: tmpl.c:451
Attribute list.
Definition: tmpl.h:135
int tmpl_find_or_add_vp(VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt)
Returns the first VP matching a vp_tmpl_t, or if no VPs match, creates a new one. ...
Definition: tmpl.c:2251
Stores an attribute, a value and various bits of other data.
Definition: pair.h:112
ssize_t tmpl_aexpand(TALLOC_CTX *ctx, char **out, REQUEST *request, vp_tmpl_t const *vpt, xlat_escape_t escape, void *escape_ctx)
Expand a template to a string, allocing a new buffer to hold the string.
Definition: tmpl.c:1653
#define FR_DICT_ATTR_SIZE
Maximum dictionary attribute size.
Definition: dict.h:127
int num
For array references.
Definition: tmpl.h:158
int tmpl_define_undefined_attr(vp_tmpl_t *vpt, PW_TYPE type, fr_dict_attr_flags_t const *flags)
Add an undefined fr_dict_attr_t specified by a vp_tmpl_t to the main dictionary.
Definition: tmpl.c:1396
The current request.
Definition: tmpl.h:113
tmpl_type_t type
What type of value tmpl refers to.
Definition: tmpl.h:188
enum tmpl_type tmpl_type_t
Types of vp_tmpl_t.
size_t len
Length of the raw string used to create the template.
Definition: tmpl.h:191
int tmpl_copy_vps(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt)
Copy pairs matching a vp_tmpl_t in the current REQUEST.
Definition: tmpl.c:2181
int tmpl_cast_to_vp(VALUE_PAIR **out, REQUEST *request, vp_tmpl_t const *vpt, fr_dict_attr_t const *cast)
Expand a vp_tmpl_t to a string, parse it as an attribute of type cast, create a VALUE_PAIR from the r...
Definition: tmpl.c:1304
vp_tmpl_t * tmpl_init(vp_tmpl_t *vpt, tmpl_type_t type, char const *name, ssize_t len, FR_TOKEN quote)
Initialise stack allocated vp_tmpl_t.
Definition: tmpl.c:497
void tmpl_cast_in_place_str(vp_tmpl_t *vpt)
Convert vp_tmpl_t of type TMPL_TYPE_UNPARSED to TMPL_TYPE_DATA of type PW_TYPE_STRING.
Definition: tmpl.c:1273
Callout to an external script or program.
Definition: tmpl.h:137
uint8_t data[]
Definition: eap_pwd.h:625
request_refs_t request
Request to search or insert in.
Definition: tmpl.h:149
int lineno
Definition: tmpl.h:123
size_t radius_list_name(pair_lists_t *out, char const *name, pair_lists_t default_list)
Resolve attribute name to a pair_lists_t value.
Definition: tmpl.c:120
Describes a TMPL_TYPE_ATTR, TMPL_TYPE_ATTR_UNDEFINED or TMPL_TYPE_LIST.
Definition: tmpl.h:148
Unknown list.
Definition: tmpl.h:81
size_t tmpl_snprint(char *buffer, size_t bufsize, vp_tmpl_t const *vpt, fr_dict_attr_t const *values)
Print a vp_tmpl_t to a string.
Definition: tmpl.c:1822
Attributes to send in the response.
Definition: tmpl.h:84
enum pair_lists pair_lists_t
Not currently used.
Definition: tmpl.h:114
fr_dict_attr_t const * da
Resolved dictionary attribute.
Definition: tmpl.h:152
enum fr_token FR_TOKEN
size_t radius_request_name(request_refs_t *out, char const *name, request_refs_t unknown)
Resolve attribute name to a request_refs_t value.
Definition: tmpl.c:413
Uninitialised.
Definition: tmpl.h:130
XLAT expansion.
Definition: tmpl.h:132
Attributes to store multiple rounds of challenges/responses.
Definition: tmpl.h:87
Attributes that change the behaviour of modules.
Definition: tmpl.h:85
FR_TOKEN quote
What type of quoting was around the raw string.
Definition: tmpl.h:192
VALUE_PAIR * tmpl_cursor_next(vp_cursor_t *cursor, vp_tmpl_t const *vpt)
Returns the next VALUE_PAIR specified by vpt.
Definition: tmpl.c:2128
Attributes sent in response to the proxied request.
Definition: tmpl.h:93
int tmpl_cast_in_place(vp_tmpl_t *vpt, PW_TYPE type, fr_dict_attr_t const *enumv)
Convert vp_tmpl_t of type TMPL_TYPE_UNPARSED or TMPL_TYPE_DATA to TMPL_TYPE_DATA of type specified...
Definition: tmpl.c:1212
union vp_tmpl_t::@11 data
VALUE_PAIR * reply
Definition: tmpl.h:122
ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name, request_refs_t request_def, pair_lists_t list_def, bool allow_unknown, bool allow_undefined)
Parse a string into a TMPL_TYPE_ATTR_* or TMPL_TYPE_LIST type vp_tmpl_t.
Definition: tmpl.c:926
A source or sink of value data.
Definition: tmpl.h:187
enum requests request_refs_t
const FR_NAME_NUMBER tmpl_names[]
Map tmpl_type_t values to descriptive strings.
Definition: tmpl.c:36
vp_tmpl_t * tmpl_alloc(TALLOC_CTX *ctx, tmpl_type_t type, char const *name, ssize_t len, FR_TOKEN quote)
Create a new heap allocated vp_tmpl_t.
Definition: tmpl.c:526
Has no value.
Definition: tmpl.h:141
int8_t tag
For tag references.
Definition: tmpl.h:159
PW_TYPE
Internal data types used within libfreeradius.
Definition: radius.h:31
struct pair_list PAIR_LIST