The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
unlang_priv.h File Reference

Private interpreter structures and functions. More...

#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/map_proc.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/server/time_tracking.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/unlang/base.h>
#include <freeradius-devel/io/listen.h>
+ Include dependency graph for unlang_priv.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  unlang_ext_t
 Describes how to allocate an unlang_group_t with additional memory keyword specific data. More...
 
struct  unlang_group_t
 Generic representation of a grouping. More...
 
struct  unlang_op_t
 An unlang operation. More...
 
struct  unlang_retry_t
 
struct  unlang_s
 A node in a graph of unlang_op_t (s) that we execute. More...
 
struct  unlang_stack_frame_s
 Our interpreter stack, as distinct from the C stack. More...
 
struct  unlang_stack_t
 An unlang stack associated with a request. More...
 
struct  unlang_thread_t
 
struct  unlang_tmpl_t
 A naked xlat. More...
 
struct  unlang_variable_t
 

Macros

#define has_debug_braces(_thing)
 
#define MOD_NUM_TYPES   (UNLANG_TYPE_XLAT + 1)
 
#define UNLANG_DETACHABLE   (true)
 
#define unlang_frame_perf_cleanup(_x)
 
#define unlang_frame_perf_init(_x)
 
#define unlang_frame_perf_resume(_x)
 
#define unlang_frame_perf_yield(_x)
 
#define UNLANG_NEXT_SIBLING   (true)
 
#define UNLANG_NEXT_STOP   (false)
 
#define UNLANG_NORMAL_CHILD   (false)
 

Typedefs

typedef void(* unlang_dump_t) (request_t *request, unlang_stack_frame_t *frame)
 Custom callback for dumping information about frame state.
 
typedef unlang_action_t(* unlang_process_t) (rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Function to call when interpreting a frame.
 
typedef void(* unlang_signal_t) (request_t *request, unlang_stack_frame_t *frame, fr_signal_t action)
 Function to call if the request was signalled.
 
typedef struct unlang_stack_frame_s unlang_stack_frame_t
 
typedef struct unlang_s unlang_t
 
typedef int(* unlang_thread_instantiate_t) (unlang_t const *instruction, void *thread_inst)
 

Enumerations

enum  unlang_frame_action_t {
  UNLANG_FRAME_ACTION_POP = 1 ,
  UNLANG_FRAME_ACTION_RETRY ,
  UNLANG_FRAME_ACTION_NEXT ,
  UNLANG_FRAME_ACTION_YIELD
}
 Allows the frame evaluator to signal the interpreter. More...
 
enum  unlang_frame_flag_t {
  UNLANG_FRAME_FLAG_NONE = 0x00 ,
  UNLANG_FRAME_FLAG_REPEAT = 0x01 ,
  UNLANG_FRAME_FLAG_TOP_FRAME = 0x02 ,
  UNLANG_FRAME_FLAG_YIELDED = 0x04 ,
  UNLANG_FRAME_FLAG_UNWIND = 0x08
}
 
enum  unlang_op_flag_t {
  UNLANG_OP_FLAG_NONE = 0x00 ,
  UNLANG_OP_FLAG_DEBUG_BRACES = 0x01 ,
  UNLANG_OP_FLAG_RCODE_SET = 0x02 ,
  UNLANG_OP_FLAG_NO_CANCEL = 0x04 ,
  UNLANG_OP_FLAG_BREAK_POINT = 0x08 ,
  UNLANG_OP_FLAG_RETURN_POINT = 0x10 ,
  UNLANG_OP_FLAG_CONTINUE_POINT = 0x20
}
 
enum  unlang_type_t {
  UNLANG_TYPE_NULL = 0 ,
  UNLANG_TYPE_MODULE = 1 ,
  UNLANG_TYPE_FUNCTION ,
  UNLANG_TYPE_GROUP ,
  UNLANG_TYPE_REDUNDANT ,
  UNLANG_TYPE_LOAD_BALANCE ,
  UNLANG_TYPE_REDUNDANT_LOAD_BALANCE ,
  UNLANG_TYPE_PARALLEL ,
  UNLANG_TYPE_IF ,
  UNLANG_TYPE_ELSE ,
  UNLANG_TYPE_ELSIF ,
  UNLANG_TYPE_UPDATE ,
  UNLANG_TYPE_SWITCH ,
  UNLANG_TYPE_CASE ,
  UNLANG_TYPE_FOREACH ,
  UNLANG_TYPE_BREAK ,
  UNLANG_TYPE_CONTINUE ,
  UNLANG_TYPE_RETURN ,
  UNLANG_TYPE_MAP ,
  UNLANG_TYPE_SUBREQUEST ,
  UNLANG_TYPE_CHILD_REQUEST ,
  UNLANG_TYPE_DETACH ,
  UNLANG_TYPE_CALL ,
  UNLANG_TYPE_CALLER ,
  UNLANG_TYPE_TIMEOUT ,
  UNLANG_TYPE_LIMIT ,
  UNLANG_TYPE_TRANSACTION ,
  UNLANG_TYPE_TRY ,
  UNLANG_TYPE_CATCH ,
  UNLANG_TYPE_FINALLY ,
  UNLANG_TYPE_POLICY ,
  UNLANG_TYPE_XLAT ,
  UNLANG_TYPE_TMPL ,
  UNLANG_TYPE_EDIT ,
  UNLANG_TYPE_MAX
}
 Types of unlang_t nodes. More...
 

Functions

static bool _frame_has_debug_braces (unlang_stack_frame_t const *frame)
 
static bool _instruction_has_debug_braces (unlang_t const *instruction)
 
static void frame_cleanup (unlang_stack_frame_t *frame)
 Cleanup any lingering frame state.
 
static unlang_stack_frame_tframe_current (request_t *request)
 
static void frame_next (unlang_stack_t *stack, unlang_stack_frame_t *frame)
 Advance to the next sibling instruction.
 
static void frame_pop (request_t *request, unlang_stack_t *stack)
 Pop a stack frame, removing any associated dynamically allocated state.
 
static void frame_repeat (unlang_stack_frame_t *frame, unlang_process_t process)
 Mark the current stack frame up for repeat, and set a new process function.
 
static unlang_action_t frame_set_next (unlang_stack_frame_t *frame, unlang_t *unlang)
 
static void frame_state_init (unlang_stack_t *stack, unlang_stack_frame_t *frame)
 
static bool is_break_point (unlang_stack_frame_t const *frame)
 
static bool is_cancellable (unlang_stack_frame_t const *frame)
 
static bool is_continue_point (unlang_stack_frame_t const *frame)
 
static bool is_rcode_set (unlang_stack_frame_t const *frame)
 
static bool is_repeatable (unlang_stack_frame_t const *frame)
 
static bool is_return_point (unlang_stack_frame_t const *frame)
 
static bool is_top_frame (unlang_stack_frame_t const *frame)
 
static bool is_unwinding (unlang_stack_frame_t const *frame)
 
static bool is_yielded (unlang_stack_frame_t const *frame)
 
static void repeatable_clear (unlang_stack_frame_t *frame)
 
static void repeatable_set (unlang_stack_frame_t *frame)
 
static int stack_depth_current (request_t *request)
 
static void top_frame_clear (unlang_stack_frame_t *frame)
 
static void top_frame_set (unlang_stack_frame_t *frame)
 
static unsigned int unlang_frame_by_flag (unlang_stack_t *stack, unlang_frame_flag_t flag)
 Find the first frame with a given flag.
 
static unsigned int unlang_frame_by_op_flag (unlang_stack_t *stack, unlang_op_flag_t flag)
 Find the first frame with a given flag.
 
void unlang_stack_signal (request_t *request, fr_signal_t action, int limit)
 Delivers a frame to one or more frames in the stack.
 
void * unlang_thread_instance (unlang_t const *instruction)
 Get the thread-instance data for an instruction.
 
static void unwind_clear (unlang_stack_frame_t *frame)
 
static void unwind_set (unlang_stack_frame_t *frame)
 
static unlang_action_t unwind_to_depth (unlang_stack_t *stack, unsigned int to_depth)
 Mark up frames as cancelled so they're immediately popped by the interpreter.
 
static unlang_action_t unwind_to_op_flag (unsigned int *depth_p, unlang_stack_t *stack, unlang_op_flag_t flag)
 Mark the entire stack as cancelled.
 
static void yielded_clear (unlang_stack_frame_t *frame)
 
static void yielded_set (unlang_stack_frame_t *frame)
 

Variables

fr_table_num_sorted_t const mod_rcode_table []
 
size_t mod_rcode_table_len
 
unlang_op_t unlang_ops []
 Different operations the interpreter can execute.
 

Conversion functions for converting #unlang_t to its specialisations

Simple conversions: unlang_module_t and unlang_group_t are subclasses of unlang_t, so we often want to go back and forth between them.

static unlang_group_tunlang_generic_to_group (unlang_t const *p)
 
static unlang_tmpl_tunlang_generic_to_tmpl (unlang_t const *p)
 
static unlang_tunlang_group_to_generic (unlang_group_t const *p)
 
static unlang_tunlang_tmpl_to_generic (unlang_tmpl_t const *p)
 

Internal interpreter functions needed by ops

int unlang_interpret_push (request_t *request, unlang_t const *instruction, rlm_rcode_t default_rcode, bool do_next_sibling, bool top_frame)
 Push a new frame onto the stack.
 
unlang_action_t unlang_interpret_push_children (rlm_rcode_t *p_result, request_t *request, rlm_rcode_t default_rcode, bool do_next_sibling)
 
void unlang_op_free (void)
 
int unlang_op_init (void)
 

io shims

Functions to simulate a 'proto' module when we're running 'fake' requests.

i.e. those created by parallel and subrequest.

request_tunlang_io_subrequest_alloc (request_t *parent, fr_dict_t const *namespace, bool detachable)
 Allocate a child request based on the parent.
 

op init functions

Functions to trigger registration of the various unlang ops.

void unlang_call_init (void)
 
void unlang_caller_init (void)
 
void unlang_catch_init (void)
 
void unlang_condition_init (void)
 
void unlang_detach_init (void)
 Initialise subrequest ops.
 
void unlang_edit_init (void)
 
void unlang_finally_init (void)
 
void unlang_foreach_init (void)
 
void unlang_function_init (void)
 
void unlang_group_init (void)
 
void unlang_limit_init (void)
 
void unlang_load_balance_init (void)
 
void unlang_map_init (void)
 
void unlang_module_init (void)
 
void unlang_parallel_init (void)
 
void unlang_register (int type, unlang_op_t *op)
 Register an operation with the interpreter.
 
void unlang_return_init (void)
 
int unlang_subrequest_op_init (void)
 Initialise subrequest ops.
 
void unlang_switch_init (void)
 
void unlang_timeout_init (void)
 
void unlang_tmpl_init (void)
 
void unlang_transaction_init (void)
 
void unlang_try_init (void)
 

Detailed Description

Private interpreter structures and functions.

Id
3812bc4deb5ceb592db9e7b524afb1f130479f62
Author
Alan DeKok (aland.nosp@m.@fre.nosp@m.eradi.nosp@m.us.o.nosp@m.rg)

Definition in file unlang_priv.h.


Data Structure Documentation

◆ unlang_ext_t

struct unlang_ext_t

Describes how to allocate an unlang_group_t with additional memory keyword specific data.

Definition at line 145 of file unlang_priv.h.

Data Fields
size_t len Total length of the unlang_group_t + specialisation struct.
unsigned pool_headers How much additional space to allocate for chunk headers.
size_t pool_len How much additional space to allocate for extensions.
unlang_type_t type Keyword.
char const * type_name Talloc type name.

◆ unlang_group_t

struct unlang_group_t

Generic representation of a grouping.

Can represent IF statements, maps, update sections etc...

Definition at line 163 of file unlang_priv.h.

+ Collaboration diagram for unlang_group_t:
Data Fields
unlang_t * children Children beneath this group.

The body of an if section for example.

CONF_SECTION * cs
int num_children
unlang_t self
unlang_t ** tail pointer to the tail which gets updated
unlang_variable_t * variables rarely used, so we don't usually need it

◆ unlang_op_t

struct unlang_op_t

An unlang operation.

These are like the opcodes in other interpreters. Each operation, when executed will return an unlang_action_t, which determines what the interpreter does next.

Definition at line 239 of file unlang_priv.h.

+ Collaboration diagram for unlang_op_t:
Data Fields
unlang_dump_t dump Dump additional information about the frame state.
unlang_op_flag_t flag Flags for this operation.
size_t frame_state_pool_objects How many sub-allocations we expect.
size_t frame_state_pool_size The total size of the pool to alloc.
size_t frame_state_size size of instance data in the stack frame
char const * frame_state_type talloc name of the frame instance data
unlang_process_t interpret Function to interpret the keyword.
char const * name Name of the operation.
unlang_signal_t signal Function to signal stop / dup / whatever.
size_t thread_inst_size
char const * thread_inst_type
unlang_thread_instantiate_t thread_instantiate per-thread instantiation function

◆ unlang_retry_t

struct unlang_retry_t

Definition at line 290 of file unlang_priv.h.

+ Collaboration diagram for unlang_retry_t:
Data Fields
uint32_t count
int depth of this retry structure
fr_timer_t * ev
request_t * request
fr_retry_state_t state

◆ unlang_s

struct unlang_s

A node in a graph of unlang_op_t (s) that we execute.

The interpreter acts like a turing machine, with unlang_t nodes forming the tape and the unlang_action_t the instructions.

This is the parent 'class' for multiple unlang_t node specialisations. The unlang_t struct is listed first in the specialisation so that we can cast between parent/child classes without knowledge of the layout of the structures.

The specialisations of the nodes describe additional details of the operation to be performed.

Definition at line 130 of file unlang_priv.h.

+ Collaboration diagram for unlang_s:
Data Fields
unlang_mod_actions_t actions Priorities, etc. for the various return codes.
CONF_ITEM * ci used to generate this item
bool closed whether or not this section is closed to new statements
char const * debug_name Printed in log messages when the node is executed.
char const * name Unknown...
unlang_t * next Next node (executed on UNLANG_ACTION_EXECUTE_NEXT et al).
unsigned int number unique node number
unlang_t * parent Previous node.
unlang_type_t type The specialisation of this node.

◆ unlang_stack_frame_s

struct unlang_stack_frame_s

Our interpreter stack, as distinct from the C stack.

We don't call the modules recursively. Instead we iterate over a list of unlang_t and and manage the call stack ourselves.

After looking at various green thread implementations, it was decided that using the existing unlang interpreter stack was the best way to perform async I/O.

Each request as an unlang interpreter stack associated with it, which represents its progress through the server. Because the interpreter stack is distinct from the C stack, we can have a single system thread with many thousands of pending requests.

Definition at line 310 of file unlang_priv.h.

+ Collaboration diagram for unlang_stack_frame_s:
Data Fields
unlang_frame_flag_t flag Unwind flags.
rindent_t indent Indent level of the request when the frame was created.

This is used to restore the indent level when the stack is being forcefully unwound.

unlang_t const * instruction The unlang node we're evaluating.
unlang_t const * next The next unlang node we will evaluate.
int priority Result priority.

When we pop this stack frame this priority will be compared with the one of the frame lower in the stack to determine if the result stored in the lower stack frame should

unlang_process_t process function to call for interpreting this stack frame
rlm_rcode_t result The result from executing the instruction.
unlang_retry_t * retry if the frame is being retried.
unlang_signal_t signal function to call when signalling this stack frame
void * state Stack frame specialisations.

These store extra (mutable) state data, for the immutable (unlang_t) instruction. Instructions can't be used to store data because they might be shared between multiple threads.

Which stack_entry specialisation to use is determined by the instruction->type.

◆ unlang_stack_t

struct unlang_stack_t

An unlang stack associated with a request.

Definition at line 348 of file unlang_priv.h.

+ Collaboration diagram for unlang_stack_t:
Data Fields
int depth Current depth we're executing at.
unlang_stack_frame_t frame[UNLANG_STACK_MAX] The stack...
unlang_interpret_t * intp Interpreter that the request is currently associated with.
int priority Current priority.
rlm_rcode_t result The current stack rcode.
uint8_t unwind Unwind to this frame if it exists.

This is used for break and return.

◆ unlang_thread_t

struct unlang_thread_t

Definition at line 263 of file unlang_priv.h.

+ Collaboration diagram for unlang_thread_t:
Data Fields
unlang_t const * instruction instruction which we're executing
void * thread_inst thread-specific instance data

◆ unlang_tmpl_t

struct unlang_tmpl_t

A naked xlat.

Note
These are vestigial and may be removed in future.

Definition at line 178 of file unlang_priv.h.

+ Collaboration diagram for unlang_tmpl_t:
Data Fields
unlang_t self
tmpl_t const * tmpl

◆ unlang_variable_t

struct unlang_variable_t

Definition at line 153 of file unlang_priv.h.

+ Collaboration diagram for unlang_variable_t:
Data Fields
fr_dict_t * dict our dictionary
int max_attr 1..N local attributes have been defined
fr_dict_attr_t const * root the root of our dictionary

Macro Definition Documentation

◆ has_debug_braces

#define has_debug_braces (   _thing)
Value:
_Generic((_thing), \
unlang_t const *: _instruction_has_debug_braces((unlang_t const *)(_thing)), \
)
static bool _instruction_has_debug_braces(unlang_t const *instruction)
static bool _frame_has_debug_braces(unlang_stack_frame_t const *frame)
A node in a graph of unlang_op_t (s) that we execute.
Our interpreter stack, as distinct from the C stack.

Definition at line 385 of file unlang_priv.h.

◆ MOD_NUM_TYPES

#define MOD_NUM_TYPES   (UNLANG_TYPE_XLAT + 1)

Definition at line 363 of file unlang_priv.h.

◆ UNLANG_DETACHABLE

#define UNLANG_DETACHABLE   (true)

Definition at line 100 of file unlang_priv.h.

◆ unlang_frame_perf_cleanup

#define unlang_frame_perf_cleanup (   _x)

Definition at line 285 of file unlang_priv.h.

◆ unlang_frame_perf_init

#define unlang_frame_perf_init (   _x)

Definition at line 282 of file unlang_priv.h.

◆ unlang_frame_perf_resume

#define unlang_frame_perf_resume (   _x)

Definition at line 284 of file unlang_priv.h.

◆ unlang_frame_perf_yield

#define unlang_frame_perf_yield (   _x)

Definition at line 283 of file unlang_priv.h.

◆ UNLANG_NEXT_SIBLING

#define UNLANG_NEXT_SIBLING   (true)

Definition at line 98 of file unlang_priv.h.

◆ UNLANG_NEXT_STOP

#define UNLANG_NEXT_STOP   (false)

Definition at line 97 of file unlang_priv.h.

◆ UNLANG_NORMAL_CHILD

#define UNLANG_NORMAL_CHILD   (false)

Definition at line 101 of file unlang_priv.h.

Typedef Documentation

◆ unlang_dump_t

typedef void(* unlang_dump_t) (request_t *request, unlang_stack_frame_t *frame)

Custom callback for dumping information about frame state.

Parameters
[in]requestThe current request.
[in]frameto provide additional information for.

Definition at line 213 of file unlang_priv.h.

◆ unlang_process_t

typedef unlang_action_t(* unlang_process_t) (rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)

Function to call when interpreting a frame.

Parameters
[in,out]p_resultPointer to the current rcode, may be modified by the function.
[in]requestThe current request.
[in]framebeing executed.
Returns
an action for the interpreter to perform.

Definition at line 191 of file unlang_priv.h.

◆ unlang_signal_t

typedef void(* unlang_signal_t) (request_t *request, unlang_stack_frame_t *frame, fr_signal_t action)

Function to call if the request was signalled.

This is the instruction specific cancellation function. This function will usually either call a more specialised cancellation function set when something like a module yielded, or just cleanup the state of the original unlang_process_t.

Parameters
[in]requestThe current request.
[in]framebeing signalled.
[in]actionWe're being signalled with.

Definition at line 205 of file unlang_priv.h.

◆ unlang_stack_frame_t

Definition at line 117 of file unlang_priv.h.

◆ unlang_t

typedef struct unlang_s unlang_t

Definition at line 116 of file unlang_priv.h.

◆ unlang_thread_instantiate_t

typedef int(* unlang_thread_instantiate_t) (unlang_t const *instruction, void *thread_inst)

Definition at line 215 of file unlang_priv.h.

Enumeration Type Documentation

◆ unlang_frame_action_t

Allows the frame evaluator to signal the interpreter.

Enumerator
UNLANG_FRAME_ACTION_POP 

Pop the current frame, and check the next one further up in the stack for what to do next.

UNLANG_FRAME_ACTION_RETRY 

retry the current frame

UNLANG_FRAME_ACTION_NEXT 

Process the next instruction at this level.

UNLANG_FRAME_ACTION_YIELD 

Temporarily return control back to the caller on the C stack.

Definition at line 88 of file unlang_priv.h.

◆ unlang_frame_flag_t

Enumerator
UNLANG_FRAME_FLAG_NONE 

No flags.

UNLANG_FRAME_FLAG_REPEAT 

Repeat the frame on the way up the stack.

UNLANG_FRAME_FLAG_TOP_FRAME 

are we the top frame of the stack? If true, causes the interpreter to stop interpreting and return, control then passes to whatever called the interpreter.

UNLANG_FRAME_FLAG_YIELDED 

frame has yielded

UNLANG_FRAME_FLAG_UNWIND 

This frame should be unwound without evaluation.

Definition at line 104 of file unlang_priv.h.

◆ unlang_op_flag_t

Enumerator
UNLANG_OP_FLAG_NONE 

No flags.

UNLANG_OP_FLAG_DEBUG_BRACES 

Print debug braces.

UNLANG_OP_FLAG_RCODE_SET 

Set request->rcode to the result of this operation.

UNLANG_OP_FLAG_NO_CANCEL 

Must not be cancelled.

@Note Slightly confusingly, a cancellation signal can still be delivered to a frame that is not cancellable, but the frame won't be automatically unwound. This lets the frame know that cancellation is desired, but can be ignored.

UNLANG_OP_FLAG_BREAK_POINT 

Break point.

UNLANG_OP_FLAG_RETURN_POINT 

Return point.

UNLANG_OP_FLAG_CONTINUE_POINT 

Continue point.

Definition at line 218 of file unlang_priv.h.

◆ unlang_type_t

Types of unlang_t nodes.

Here are our basic types: unlang_t, unlang_group_t, and unlang_module_t. For an explanation of what they are all about, see doc/unlang/configurable_failover.adoc

Enumerator
UNLANG_TYPE_NULL 

unlang type not set.

UNLANG_TYPE_MODULE 

Module method.

UNLANG_TYPE_FUNCTION 

Internal call to a function or submodule.

UNLANG_TYPE_GROUP 

Grouping section.

UNLANG_TYPE_REDUNDANT 

exactly like group, but with different default return codes

UNLANG_TYPE_LOAD_BALANCE 

Load balance section.

UNLANG_TYPE_REDUNDANT_LOAD_BALANCE 

Redundant load balance section.

UNLANG_TYPE_PARALLEL 

execute statements in parallel

UNLANG_TYPE_IF 

Condition.

UNLANG_TYPE_ELSE 

!Condition.

UNLANG_TYPE_ELSIF 

!Condition && Condition.

UNLANG_TYPE_UPDATE 

Update block.

UNLANG_TYPE_SWITCH 

Switch section.

UNLANG_TYPE_CASE 

Case section (within a UNLANG_TYPE_SWITCH).

UNLANG_TYPE_FOREACH 

Foreach section.

UNLANG_TYPE_BREAK 

Break statement (within a UNLANG_TYPE_FOREACH or UNLANG_TYPE_CASE).

UNLANG_TYPE_CONTINUE 

Break statement (within a UNLANG_TYPE_FOREACH).

UNLANG_TYPE_RETURN 

Return statement.

UNLANG_TYPE_MAP 

Mapping section (like UNLANG_TYPE_UPDATE, but uses values from a map_proc_t call).

UNLANG_TYPE_SUBREQUEST 

create a child subrequest

UNLANG_TYPE_CHILD_REQUEST 

a frame at the top of a child's request stack used to signal the parent when the child is complete.

UNLANG_TYPE_DETACH 

detach a child

UNLANG_TYPE_CALL 

call another virtual server

UNLANG_TYPE_CALLER 

conditionally check parent dictionary type

UNLANG_TYPE_TIMEOUT 

time-based timeouts.

UNLANG_TYPE_LIMIT 

limit number of requests in a section

UNLANG_TYPE_TRANSACTION 

transactions for editing lists

UNLANG_TYPE_TRY 

try / catch blocks

UNLANG_TYPE_CATCH 

catch a previous try

UNLANG_TYPE_FINALLY 

run at the end of a virtual server.

UNLANG_TYPE_POLICY 

Policy section.

UNLANG_TYPE_XLAT 

Represents one level of an xlat expansion.

UNLANG_TYPE_TMPL 

asynchronously expand a tmpl_t

UNLANG_TYPE_EDIT 

edit VPs in place. After 20 years!

UNLANG_TYPE_MAX 

Definition at line 45 of file unlang_priv.h.

Function Documentation

◆ _frame_has_debug_braces()

static bool _frame_has_debug_braces ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 384 of file unlang_priv.h.

◆ _instruction_has_debug_braces()

static bool _instruction_has_debug_braces ( unlang_t const *  instruction)
inlinestatic

Definition at line 383 of file unlang_priv.h.

◆ frame_cleanup()

static void frame_cleanup ( unlang_stack_frame_t frame)
inlinestatic

Cleanup any lingering frame state.

Definition at line 551 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ frame_current()

static unlang_stack_frame_t * frame_current ( request_t request)
inlinestatic

Definition at line 489 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ frame_next()

static void frame_next ( unlang_stack_t stack,
unlang_stack_frame_t frame 
)
inlinestatic

Advance to the next sibling instruction.

Definition at line 568 of file unlang_priv.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frame_pop()

static void frame_pop ( request_t request,
unlang_stack_t stack 
)
inlinestatic

Pop a stack frame, removing any associated dynamically allocated state.

Parameters
[in]requestThe current request.
[in]stackframe to pop.

Definition at line 585 of file unlang_priv.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frame_repeat()

static void frame_repeat ( unlang_stack_frame_t frame,
unlang_process_t  process 
)
inlinestatic

Mark the current stack frame up for repeat, and set a new process function.

Definition at line 629 of file unlang_priv.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frame_set_next()

static unlang_action_t frame_set_next ( unlang_stack_frame_t frame,
unlang_t unlang 
)
inlinestatic

Definition at line 635 of file unlang_priv.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frame_state_init()

static void frame_state_init ( unlang_stack_t stack,
unlang_stack_frame_t frame 
)
inlinestatic

Definition at line 503 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_break_point()

static bool is_break_point ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 394 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_cancellable()

static bool is_cancellable ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 393 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_continue_point()

static bool is_continue_point ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 396 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_rcode_set()

static bool is_rcode_set ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 392 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_repeatable()

static bool is_repeatable ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 378 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_return_point()

static bool is_return_point ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 395 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_top_frame()

static bool is_top_frame ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 379 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_unwinding()

static bool is_unwinding ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 381 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ is_yielded()

static bool is_yielded ( unlang_stack_frame_t const *  frame)
inlinestatic

Definition at line 380 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ repeatable_clear()

static void repeatable_clear ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 373 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ repeatable_set()

static void repeatable_set ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 368 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ stack_depth_current()

static int stack_depth_current ( request_t request)
inlinestatic

Definition at line 496 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ top_frame_clear()

static void top_frame_clear ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 374 of file unlang_priv.h.

◆ top_frame_set()

static void top_frame_set ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 369 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unlang_call_init()

void unlang_call_init ( void  )

Definition at line 249 of file call.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_caller_init()

void unlang_caller_init ( void  )

Definition at line 55 of file caller.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_catch_init()

void unlang_catch_init ( void  )

Definition at line 98 of file catch.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_condition_init()

void unlang_condition_init ( void  )

Definition at line 103 of file condition.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_detach_init()

void unlang_detach_init ( void  )

Initialise subrequest ops.

Definition at line 54 of file detach.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_edit_init()

void unlang_edit_init ( void  )

Definition at line 1746 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_finally_init()

void unlang_finally_init ( void  )

Definition at line 159 of file finally.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_foreach_init()

void unlang_foreach_init ( void  )

Definition at line 558 of file foreach.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_frame_by_flag()

static unsigned int unlang_frame_by_flag ( unlang_stack_t stack,
unlang_frame_flag_t  flag 
)
inlinestatic

Find the first frame with a given flag.

Returns
  • 0 if no frame has the flag.
  • The index of the first frame with the flag.

Definition at line 405 of file unlang_priv.h.

◆ unlang_frame_by_op_flag()

static unsigned int unlang_frame_by_op_flag ( unlang_stack_t stack,
unlang_op_flag_t  flag 
)
inlinestatic

Find the first frame with a given flag.

Returns
  • 0 if no frame has the flag.
  • The index of the first frame with the flag.

Definition at line 423 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unlang_function_init()

void unlang_function_init ( void  )

Definition at line 337 of file function.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_generic_to_group()

static unlang_group_t * unlang_generic_to_group ( unlang_t const *  p)
inlinestatic

Definition at line 674 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unlang_generic_to_tmpl()

static unlang_tmpl_t * unlang_generic_to_tmpl ( unlang_t const *  p)
inlinestatic

Definition at line 686 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unlang_group_init()

void unlang_group_init ( void  )

Definition at line 41 of file group.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_group_to_generic()

static unlang_t * unlang_group_to_generic ( unlang_group_t const *  p)
inlinestatic

Definition at line 681 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unlang_interpret_push()

int unlang_interpret_push ( request_t request,
unlang_t const *  instruction,
rlm_rcode_t  default_rcode,
bool  do_next_sibling,
bool  top_frame 
)

Push a new frame onto the stack.

Parameters
[in]requestto push the frame onto.
[in]instructionOne or more unlang_t nodes describing the operations to execute.
[in]default_rcodeThe default result.
[in]do_next_siblingWhether to only execute the first node in the unlang_t program or to execute subsequent nodes.
[in]top_frameReturn out of the unlang interpret when popping this frame. Hands execution back to whatever called the interpret.
Returns
  • 0 on success.
  • -1 on call stack too deep.

Definition at line 143 of file interpret.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_interpret_push_children()

unlang_action_t unlang_interpret_push_children ( rlm_rcode_t p_result,
request_t request,
rlm_rcode_t  default_rcode,
bool  do_next_sibling 
)

◆ unlang_io_subrequest_alloc()

request_t * unlang_io_subrequest_alloc ( request_t parent,
fr_dict_t const *  namespace,
bool  detachable 
)

Allocate a child request based on the parent.

Parameters
[in]parentspawning the child request.
[in]namespacethe child request operates in. If NULL the parent's namespace is used.
[in]detachableAllow/disallow the child to be detached.
Returns
  • The new child request.
  • NULL on error.

Definition at line 39 of file io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_limit_init()

void unlang_limit_init ( void  )

Definition at line 124 of file limit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_load_balance_init()

void unlang_load_balance_init ( void  )

Definition at line 248 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_map_init()

void unlang_map_init ( void  )

Definition at line 374 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_module_init()

void unlang_module_init ( void  )

Definition at line 956 of file module.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_op_free()

void unlang_op_free ( void  )

◆ unlang_op_init()

int unlang_op_init ( void  )

◆ unlang_parallel_init()

void unlang_parallel_init ( void  )

Definition at line 386 of file parallel.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_register()

void unlang_register ( int  type,
unlang_op_t op 
)

Register an operation with the interpreter.

The main purpose of this registration API is to avoid intermixing the xlat, condition, map APIs with the interpreter, i.e. the callbacks needed for that functionality can be in their own source files, and we don't need to include supporting types and function declarations in the interpreter.

Later, this could potentially be used to register custom operations for modules.

The reason why there's a function instead of accessing the unlang_op array directly, is because 'type' really needs to go away, as needing to add ops to the unlang_type_t enum breaks the pluggable module model. If there's no explicit/consistent type values we need to enumerate the operations ourselves.

Parameters
[in]typeOperation identifier. Used to map compiled unlang code to operations.
[in]opunlang_op to register.

Definition at line 63 of file base.c.

+ Here is the caller graph for this function:

◆ unlang_return_init()

void unlang_return_init ( void  )

Definition at line 43 of file return.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_stack_signal()

void unlang_stack_signal ( request_t request,
fr_signal_t  action,
int  limit 
)

Delivers a frame to one or more frames in the stack.

This is typically called via an "async" action, i.e. an action outside of the normal processing of the request.

For FR_SIGNAL_CANCEL all frames are marked up for cancellation, but the cancellation is handled by the interpret.

Other signal types are delivered immediately, inrrespecitve of whether the request is currently being processed or not.

Signaling stops at the "limit" frame. This is so that keywords such as "timeout" and "limit" can signal frames lower than theirs to stop, but then continue with their own work.

Note
It's better (clearer) to use one of the unwind_* functions unless the entire request is being cancelled.
Parameters
[in]requestThe current request.
[in]actionto signal.
[in]limitthe frame at which to stop signaling.

Definition at line 1087 of file interpret.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_op_init()

int unlang_subrequest_op_init ( void  )

Initialise subrequest ops.

Definition at line 516 of file subrequest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_switch_init()

void unlang_switch_init ( void  )

Definition at line 133 of file switch.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_thread_instance()

void * unlang_thread_instance ( unlang_t const *  instruction)

Get the thread-instance data for an instruction.

Parameters
[in]instructionthe instruction to use
Returns
a pointer to thread-local data

Definition at line 5248 of file compile.c.

+ Here is the caller graph for this function:

◆ unlang_timeout_init()

void unlang_timeout_init ( void  )

Definition at line 267 of file timeout.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_tmpl_init()

void unlang_tmpl_init ( void  )

Definition at line 328 of file tmpl.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_tmpl_to_generic()

static unlang_t * unlang_tmpl_to_generic ( unlang_tmpl_t const *  p)
inlinestatic

Definition at line 692 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unlang_transaction_init()

void unlang_transaction_init ( void  )

Definition at line 123 of file transaction.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_try_init()

void unlang_try_init ( void  )

Definition at line 42 of file try.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unwind_clear()

static void unwind_clear ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 376 of file unlang_priv.h.

◆ unwind_set()

static void unwind_set ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 371 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ unwind_to_depth()

static unlang_action_t unwind_to_depth ( unlang_stack_t stack,
unsigned int  to_depth 
)
inlinestatic

Mark up frames as cancelled so they're immediately popped by the interpreter.

Note
We used to do this asynchronously, but now we may need to execute timeout sections which means it's not enough to pop and cleanup the stack, we need continue executing the request.
Parameters
[in]stackThe current stack.
[in]to_depthmark all frames below this depth as cancelled.

Definition at line 444 of file unlang_priv.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unwind_to_op_flag()

static unlang_action_t unwind_to_op_flag ( unsigned int *  depth_p,
unlang_stack_t stack,
unlang_op_flag_t  flag 
)
inlinestatic

Mark the entire stack as cancelled.

This cancels all frames up to the next "break" frame.

Parameters
[out]depth_pDepth of the break || return || continue point.
[in]stackThe current stack.
[in]flagFlag to search for. One of:
  • UNLANG_OP_FLAG_BREAK_POINT
  • UNLANG_OP_FLAG_RETURN_POINT
  • UNLANG_OP_FLAG_CONTINUE_POINT
Returns
UNLANG_ACTION_CALCULATE_RESULT

Definition at line 472 of file unlang_priv.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ yielded_clear()

static void yielded_clear ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 375 of file unlang_priv.h.

+ Here is the caller graph for this function:

◆ yielded_set()

static void yielded_set ( unlang_stack_frame_t frame)
inlinestatic

Definition at line 370 of file unlang_priv.h.

+ Here is the caller graph for this function:

Variable Documentation

◆ mod_rcode_table

fr_table_num_sorted_t const mod_rcode_table[]
extern

Definition at line 78 of file compile.c.

◆ mod_rcode_table_len

size_t mod_rcode_table_len
extern

Definition at line 91 of file compile.c.

◆ unlang_ops

unlang_op_t unlang_ops[]
extern

Different operations the interpreter can execute.

Definition at line 31 of file base.c.