The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations
tmpl_escape.h File Reference
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/server/request.h>
+ Include dependency graph for tmpl_escape.h:

Go to the source code of this file.

Data Structures

struct  tmpl_escape_t
 Escaping rules for tmpls. More...
 
struct  tmpl_escape_t.uctx
 
union  tmpl_escape_t.uctx.__unnamed76__
 
struct  tmpl_escape_t.uctx.__unnamed76__.__unnamed78__
 
struct  tmpl_escape_t.uctx.__unnamed76__.func
 

Macros

#define tmpl_escape_post_concat(_tmpl)   ((_tmpl)->rules.escape.func && ((_tmpl)->rules.escape.mode == TMPL_ESCAPE_POST_CONCAT))
 See if we should perform output escaping after concatenation. More...
 
#define tmpl_escape_pre_concat(_tmpl)   ((_tmpl)->rules.escape.func && ((_tmpl)->rules.escape.mode == TMPL_ESCAPE_PRE_CONCAT))
 See if we should perform output escaping before concatenation. More...
 

Typedefs

typedef void *(* tmpl_escape_uctx_alloc_t) (request_t *request, void const *uctx)
 Function to allocate a user context for escaping. More...
 
typedef void(* tmpl_escape_uctx_free_t) (void *uctx)
 Free a previously allocated used ctx. More...
 

Enumerations

enum  tmpl_escape_mode_t {
  TMPL_ESCAPE_NONE = 0 ,
  TMPL_ESCAPE_PRE_CONCAT ,
  TMPL_ESCAPE_POST_CONCAT
}
 When to apply escaping. More...
 
enum  tmpl_escape_uctx_type_t {
  TMPL_ESCAPE_UCTX_STATIC = 0 ,
  TMPL_ESCAPE_UCTX_ALLOC ,
  TMPL_ESCAPE_UCTX_ALLOC_FUNC
}
 Different modes for creating a user context for escaping. More...
 

Data Structure Documentation

◆ tmpl_escape_t

struct tmpl_escape_t

Escaping rules for tmpls.

Definition at line 80 of file tmpl_escape.h.

+ Collaboration diagram for tmpl_escape_t:
Data Fields
fr_value_box_escape_t func How to escape when returned from evaluation.

Currently only used for async evaluation.

tmpl_escape_mode_t mode Whether to apply escape function after concatenation, i.e.

to the final output of the tmpl. If false, then the escaping is performed on each value box individually prior to concatenation and prior to casting. If no concatenation is performed, then the escaping is performed on each box individually.

fr_value_box_safe_for_t safe_for Value to set on boxes which have been escaped by the fr_value_box_escape_t function.
struct tmpl_escape_t uctx

◆ tmpl_escape_t.uctx

struct tmpl_escape_t.uctx

Definition at line 95 of file tmpl_escape.h.

Data Fields
uctx __unnamed__
tmpl_escape_uctx_type_t type Type of uctx to use for this escape operation.

default is TMPL_ESCAPE_UCTX_STATIC.

◆ tmpl_escape_t.uctx.__unnamed76__

union tmpl_escape_t.uctx.__unnamed76__

Definition at line 96 of file tmpl_escape.h.

Data Fields
__unnamed76__ __unnamed__
__unnamed76__ func
void const * ptr User context for escape function.

◆ tmpl_escape_t.uctx.__unnamed76__.__unnamed78__

struct tmpl_escape_t.uctx.__unnamed76__.__unnamed78__

Definition at line 99 of file tmpl_escape.h.

Data Fields
size_t size Size of the uctx to allocate.
char const * talloc_type Talloc type to assign to the uctx.

◆ tmpl_escape_t.uctx.__unnamed76__.func

struct tmpl_escape_t.uctx.__unnamed76__.func

Definition at line 104 of file tmpl_escape.h.

Data Fields
tmpl_escape_uctx_alloc_t alloc Function to call to allocate the uctx.
tmpl_escape_uctx_free_t free Function to call to free the uctx.
void const * uctx User context to pass to allocation func.

Macro Definition Documentation

◆ tmpl_escape_post_concat

#define tmpl_escape_post_concat (   _tmpl)    ((_tmpl)->rules.escape.func && ((_tmpl)->rules.escape.mode == TMPL_ESCAPE_POST_CONCAT))

See if we should perform output escaping after concatenation.

Definition at line 123 of file tmpl_escape.h.

◆ tmpl_escape_pre_concat

#define tmpl_escape_pre_concat (   _tmpl)    ((_tmpl)->rules.escape.func && ((_tmpl)->rules.escape.mode == TMPL_ESCAPE_PRE_CONCAT))

See if we should perform output escaping before concatenation.

Definition at line 118 of file tmpl_escape.h.

Typedef Documentation

◆ tmpl_escape_uctx_alloc_t

typedef void*(* tmpl_escape_uctx_alloc_t) (request_t *request, void const *uctx)

Function to allocate a user context for escaping.

Parameters
[in]requestRequest that the tmpl is being evaluated for.
[in]uctxThe user context that was passed via the tmpl_escape_t.
Returns
  • A pointer to the allocated user context on success.
  • NULL on failure.

Definition at line 48 of file tmpl_escape.h.

◆ tmpl_escape_uctx_free_t

typedef void(* tmpl_escape_uctx_free_t) (void *uctx)

Free a previously allocated used ctx.

Parameters
[in]uctxto free.

Definition at line 54 of file tmpl_escape.h.

Enumeration Type Documentation

◆ tmpl_escape_mode_t

When to apply escaping.

Enumerator
TMPL_ESCAPE_NONE 

No escaping is performed.

TMPL_ESCAPE_PRE_CONCAT 

Pre-concatenation escaping is useful for DSLs where elements of the expansion are static, specified by the user, and other parts are dynamic, which may or may not need to be escaped based on which "safe" flags are applied to the box.

When using this mode, the escape function must be able to handle boxes of a type other than the cast type, possibly performing a cast itself if necessary.

TMPL_ESCAPE_POST_CONCAT 

Post-concatenation escaping is useful for when we don't want to allow the user to bypass escaping for any part of the value.

Here all boxes are guaranteed to be of the cast type.

Definition at line 58 of file tmpl_escape.h.

◆ tmpl_escape_uctx_type_t

Different modes for creating a user context for escaping.

Enumerator
TMPL_ESCAPE_UCTX_STATIC 

A static (to us) is provided by whatever is initialising the tmpl_escape_t.

This is the default.

TMPL_ESCAPE_UCTX_ALLOC 

A new uctx of the specified size and type is allocated and freed when escaping is complete.

TMPL_ESCAPE_UCTX_ALLOC_FUNC 

A new uctx of the specified size and type is allocated and pre-populated by memcpying uctx.size bytes from uctx.ptr.

Definition at line 30 of file tmpl_escape.h.