![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Execute compiled unlang structures using an iterative interpret. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include "interpret_priv.h"
#include "module_priv.h"
#include "parallel_priv.h"
Go to the source code of this file.
Data Structures | |
struct | unlang_variable_ref_t |
Macros | |
#define | DUMP_STACK if (DEBUG_ENABLED5) stack_dump(request) |
#define | UNWIND_FLAG_DUMP(attrib) if (unwind & attrib) strcat(buf, #attrib" ") |
Functions | |
static int | _local_variables_free (unlang_variable_ref_t *ref) |
static void | frame_dump (request_t *request, unlang_stack_frame_t *frame) |
static unlang_frame_action_t | frame_eval (request_t *request, unlang_stack_frame_t *frame, rlm_rcode_t *result, int *priority) |
Evaluates all the unlang nodes in a section. | |
static void | instruction_dump (request_t *request, unlang_t const *instruction) |
static void | instruction_retry_handler (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *ctx) |
static void | instruction_timeout_handler (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *ctx) |
static unlang_frame_action_t | result_calculate (request_t *request, unlang_stack_frame_t *frame, rlm_rcode_t *result, int *priority) |
Update the current result after each instruction, and after popping each stack frame. | |
static void | stack_dump (request_t *request) |
static char * | stack_unwind_flag_dump (uint8_t unwind) |
static void | unlang_cancel_event (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx) |
Signal the request to stop executing. | |
static xlat_action_t | unlang_cancel_never_run (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in) |
static xlat_action_t | unlang_cancel_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args) |
Allows a request to dynamically alter its own lifetime. | |
void | unlang_frame_signal (request_t *request, fr_signal_t action, int limit) |
Send a signal (usually stop) to a request. | |
void | unlang_interpet_frame_discard (request_t *request) |
Discard the bottom most frame on the request's stack. | |
rlm_rcode_t | unlang_interpret (request_t *request, bool running) |
Run the interpreter for a current request. | |
fr_event_list_t * | unlang_interpret_event_list (request_t *request) |
Get the event list for the current interpreter. | |
TALLOC_CTX * | unlang_interpret_frame_talloc_ctx (request_t *request) |
Get a talloc_ctx which is valid only for this frame. | |
unlang_interpret_t * | unlang_interpret_get (request_t *request) |
Get the interpreter set for a request. | |
unlang_interpret_t * | unlang_interpret_get_thread_default (void) |
Get the default interpreter for this thread. | |
unlang_interpret_t * | unlang_interpret_init (TALLOC_CTX *ctx, fr_event_list_t *el, unlang_request_func_t *funcs, void *uctx) |
Initialize a unlang compiler / interpret. | |
int | unlang_interpret_init_global (TALLOC_CTX *ctx) |
bool | unlang_interpret_is_resumable (request_t *request) |
Check if a request as resumable. | |
void | unlang_interpret_mark_runnable (request_t *request) |
Mark a request as resumable. | |
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) |
Push the children of the current frame onto a new frame onto the stack. | |
int | unlang_interpret_push_instruction (request_t *request, void *instruction, rlm_rcode_t default_rcode, bool top_frame) |
Push an instruction onto the request stack for later interpretation. | |
int | unlang_interpret_push_section (request_t *request, CONF_SECTION *cs, rlm_rcode_t default_rcode, bool top_frame) |
Push a configuration section onto the request stack for later interpretation. | |
static void | unlang_interpret_request_detach (request_t *request) |
void | unlang_interpret_request_done (request_t *request) |
Indicate to the caller of the interpreter that this request is complete. | |
static void | unlang_interpret_request_stop (request_t *request) |
void | unlang_interpret_set (request_t *request, unlang_interpret_t *intp) |
Set a specific interpreter for a request. | |
void | unlang_interpret_set_thread_default (unlang_interpret_t *intp) |
Set the default interpreter for this thread. | |
int | unlang_interpret_set_timeout (request_t *request, fr_time_delta_t timeout) |
Set a timeout for a request. | |
void | unlang_interpret_signal (request_t *request, fr_signal_t action) |
Send a signal (usually stop) to a request. | |
void * | unlang_interpret_stack_alloc (TALLOC_CTX *ctx) |
Allocate a new unlang stack. | |
int | unlang_interpret_stack_depth (request_t *request) |
Return the depth of the request's stack. | |
rlm_rcode_t | unlang_interpret_stack_result (request_t *request) |
Get the current rcode for the frame. | |
void | unlang_interpret_stack_result_set (request_t *request, rlm_rcode_t rcode) |
Overwrite the current stack rcode. | |
static xlat_action_t | unlang_interpret_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Get information about the interpreter state. | |
bool | unlang_request_is_cancelled (request_t const *request) |
Return whether a request has been cancelled. | |
bool | unlang_request_is_done (request_t const *request) |
Return whether a request has been marked done. | |
bool | unlang_request_is_scheduled (request_t const *request) |
Return whether a request is currently scheduled. | |
Variables | |
static unlang_group_t | empty_group |
static _Thread_local unlang_interpret_t * | intp_thread_default |
The default interpreter instance for this thread. | |
static fr_table_num_ordered_t const | unlang_action_table [] |
static size_t | unlang_action_table_len = NUM_ELEMENTS(unlang_action_table) |
static xlat_arg_parser_t const | unlang_cancel_xlat_args [] |
static fr_table_num_ordered_t const | unlang_frame_action_table [] |
static size_t | unlang_frame_action_table_len = NUM_ELEMENTS(unlang_frame_action_table) |
static xlat_arg_parser_t const | unlang_interpret_xlat_args [] |
Execute compiled unlang structures using an iterative interpret.
Definition in file interpret.c.
struct unlang_variable_ref_t |
Definition at line 214 of file interpret.c.
Data Fields | ||
---|---|---|
fr_dict_t const * | old_dict | the previous dictionary for the request |
request_t * | request | the request |
#define DUMP_STACK if (DEBUG_ENABLED5) stack_dump(request) |
Definition at line 141 of file interpret.c.
#define UNWIND_FLAG_DUMP | ( | attrib | ) | if (unwind & attrib) strcat(buf, #attrib" ") |
|
static |
Definition at line 219 of file interpret.c.
|
static |
Definition at line 73 of file interpret.c.
|
inlinestatic |
Evaluates all the unlang nodes in a section.
[in] | request | The current request. |
[in] | frame | The current stack frame. |
[in,out] | result | The current section result. |
[in,out] | priority | The current section priority. |
Definition at line 539 of file interpret.c.
|
static |
Definition at line 1272 of file interpret.c.
|
static |
Definition at line 1288 of file interpret.c.
|
inlinestatic |
Update the current result after each instruction, and after popping each stack frame.
[in] | request | The current request. |
[in] | frame | The current stack frame. |
[in,out] | result | The current section result. |
[in,out] | priority | The current section priority. |
Definition at line 320 of file interpret.c.
|
static |
|
static |
Definition at line 104 of file interpret.c.
|
static |
Signal the request to stop executing.
The request can't be running at this point because we're in the event loop. This means the request is always in a consistent state when the timeout event fires, even if that's state is waiting on I/O.
Definition at line 1492 of file interpret.c.
|
static |
|
static |
Allows a request to dynamically alter its own lifetime.
cancel(<timeout>)
If timeout is 0, then the request is immediately cancelled.
Definition at line 1520 of file interpret.c.
void unlang_frame_signal | ( | request_t * | request, |
fr_signal_t | action, | ||
int | limit | ||
) |
Send a signal (usually stop) to a request.
This is typically called via an "async" action, i.e. an action outside of the normal processing of the request.
If there is no unlang_module_signal_t callback defined, the action is ignored.
The 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.
[in] | request | The current request. |
[in] | action | to signal. |
[in] | limit | the frame at which to stop signaling. |
Definition at line 1158 of file interpret.c.
void unlang_interpet_frame_discard | ( | request_t * | request | ) |
Discard the bottom most frame on the request's stack.
This is used for cleaning up after errors. i.e. the caller uses a push function, and experiences an error and needs to remove the frame that was just pushed.
Definition at line 1795 of file interpret.c.
rlm_rcode_t unlang_interpret | ( | request_t * | request, |
bool | running | ||
) |
Run the interpreter for a current request.
[in] | request | to run. If this is an internal request the request may be freed by the interpreter. |
[in] | running | Is the interpreter already running. |
Definition at line 784 of file interpret.c.
fr_event_list_t * unlang_interpret_event_list | ( | request_t * | request | ) |
Get the event list for the current interpreter.
Definition at line 1822 of file interpret.c.
TALLOC_CTX * unlang_interpret_frame_talloc_ctx | ( | request_t * | request | ) |
Get a talloc_ctx which is valid only for this frame.
[in] | request | The current request. |
Definition at line 1462 of file interpret.c.
unlang_interpret_t * unlang_interpret_get | ( | request_t * | request | ) |
Get the interpreter set for a request.
Definition at line 1812 of file interpret.c.
unlang_interpret_t * unlang_interpret_get_thread_default | ( | void | ) |
Get the default interpreter for this thread.
This allows detached requests to be executed asynchronously
Definition at line 1845 of file interpret.c.
unlang_interpret_t * unlang_interpret_init | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
unlang_request_func_t * | funcs, | ||
void * | uctx | ||
) |
Initialize a unlang compiler / interpret.
[in] | ctx | to bind lifetime of the interpret to. Shouldn't be any free order issues here as the interpret itself has no state. But event loop should be stopped before freeing the interpret. |
[in] | el | for any timer or I/O events. |
[in] | funcs | Callbacks to used to communicate request state to our owner. |
[in] | uctx | Data to pass to callbacks. |
Definition at line 1761 of file interpret.c.
int unlang_interpret_init_global | ( | TALLOC_CTX * | ctx | ) |
Definition at line 1852 of file interpret.c.
Check if a request as resumable.
[in] | request | The current request. |
Definition at line 1400 of file interpret.c.
void unlang_interpret_mark_runnable | ( | request_t * | request | ) |
Mark a request as resumable.
It's not called "unlang_interpret", because it doesn't actually resume the request, it just schedules it for resumption.
[in] | request | The current request. |
Definition at line 1418 of file interpret.c.
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.
[in] | request | to push the frame onto. |
[in] | instruction | One or more unlang_t nodes describing the operations to execute. |
[in] | default_rcode | The default result. |
[in] | do_next_sibling | Whether to only execute the first node in the unlang_t program or to execute subsequent nodes. |
[in] | top_frame | Return out of the unlang interpret when popping this frame. Hands execution back to whatever called the interpret. |
Definition at line 159 of file interpret.c.
unlang_action_t unlang_interpret_push_children | ( | rlm_rcode_t * | p_result, |
request_t * | request, | ||
rlm_rcode_t | default_rcode, | ||
bool | do_next_sibling | ||
) |
Push the children of the current frame onto a new frame onto the stack.
[out] | p_result | set to RLM_MOULDE_FAIL if pushing the children fails |
[in] | request | to push the frame onto. |
[in] | default_rcode | The default result. |
[in] | do_next_sibling | Whether to only execute the first node in the unlang_t program or to execute subsequent nodes. |
Definition at line 255 of file interpret.c.
int unlang_interpret_push_instruction | ( | request_t * | request, |
void * | instruction, | ||
rlm_rcode_t | default_rcode, | ||
bool | top_frame | ||
) |
Push an instruction onto the request stack for later interpretation.
Definition at line 1032 of file interpret.c.
int unlang_interpret_push_section | ( | request_t * | request, |
CONF_SECTION * | cs, | ||
rlm_rcode_t | default_rcode, | ||
bool | top_frame | ||
) |
Push a configuration section onto the request stack for later interpretation.
Definition at line 1009 of file interpret.c.
|
inlinestatic |
void unlang_interpret_request_done | ( | request_t * | request | ) |
Indicate to the caller of the interpreter that this request is complete.
Definition at line 1089 of file interpret.c.
|
inlinestatic |
void unlang_interpret_set | ( | request_t * | request, |
unlang_interpret_t * | intp | ||
) |
Set a specific interpreter for a request.
Definition at line 1803 of file interpret.c.
void unlang_interpret_set_thread_default | ( | unlang_interpret_t * | intp | ) |
Set the default interpreter for this thread.
Definition at line 1834 of file interpret.c.
int unlang_interpret_set_timeout | ( | request_t * | request, |
fr_time_delta_t | timeout | ||
) |
Set a timeout for a request.
The timeout is associated with the current stack frame.
Definition at line 1307 of file interpret.c.
void unlang_interpret_signal | ( | request_t * | request, |
fr_signal_t | action | ||
) |
Send a signal (usually stop) to a request.
This is typically called via an "async" action, i.e. an action outside of the normal processing of the request.
If there is no unlang_module_signal_t callback defined, the action is ignored.
[in] | request | The current request. |
[in] | action | to signal. |
Definition at line 1212 of file interpret.c.
void * unlang_interpret_stack_alloc | ( | TALLOC_CTX * | ctx | ) |
Allocate a new unlang stack.
[in] | ctx | to allocate stack in. |
Definition at line 1063 of file interpret.c.
int unlang_interpret_stack_depth | ( | request_t * | request | ) |
Return the depth of the request's stack.
Definition at line 1334 of file interpret.c.
rlm_rcode_t unlang_interpret_stack_result | ( | request_t * | request | ) |
Get the current rcode for the frame.
This can be useful for getting the result of unlang_function_t pushed onto the stack for evaluation.
[in] | request | The current request. |
Definition at line 1349 of file interpret.c.
void unlang_interpret_stack_result_set | ( | request_t * | request, |
rlm_rcode_t | rcode | ||
) |
Overwrite the current stack rcode.
[in] | request | The current request. |
[in] | rcode | to set. |
Definition at line 1361 of file interpret.c.
Return whether a request has been cancelled.
Definition at line 1381 of file interpret.c.
Return whether a request has been marked done.
Definition at line 1388 of file interpret.c.
Return whether a request is currently scheduled.
Definition at line 1371 of file interpret.c.
|
static |
Definition at line 985 of file interpret.c.
|
static |
The default interpreter instance for this thread.
Definition at line 38 of file interpret.c.
|
static |
Definition at line 40 of file interpret.c.
|
static |
Definition at line 48 of file interpret.c.
|
static |
Definition at line 1477 of file interpret.c.
|
static |
Definition at line 50 of file interpret.c.
|
static |
Definition at line 55 of file interpret.c.
|
static |
Definition at line 1593 of file interpret.c.