![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Declarations for the unlang interpreter. More...
#include <freeradius-devel/server/cf_util.h>#include <freeradius-devel/server/request.h>#include <freeradius-devel/unlang/mod_action.h>#include <freeradius-devel/unlang/action.h>
Include dependency graph for interpret.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | unlang_frame_conf_t |
| Configuration structure to make it easier to pass configuration options to initialise the frame with. More... | |
| struct | unlang_request_func_t |
| External functions provided by the owner of the interpret. More... | |
| struct | unlang_result_t |
Macros | |
| #define | FRAME_CONF(_default_rcode, _top_frame) |
| #define | UNLANG_FRAME_POOL_SIZE (UNLANG_STACK_MAX * UNLANG_FRAME_STATE) |
| total size of all frame states | |
| #define | UNLANG_FRAME_SIZE (152) |
| size of one stack frame, see radsizes | |
| #define | UNLANG_FRAME_STATE (128) |
| guess at per-frame state | |
| #define | UNLANG_REQUEST_RESUME (false) |
| #define | UNLANG_REQUEST_RUNNING (true) |
| #define | UNLANG_RESULT_NOT_SET ((unlang_result_t) { .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET }) |
| #define | UNLANG_RESULT_RCODE(_x) ((unlang_result_t) { .rcode = (_x), .priority = MOD_ACTION_NOT_SET }) |
| #define | UNLANG_STACK_MAX (64) |
| The maximum depth of the stack. | |
| #define | UNLANG_STACK_NUM_OBJECTS (1 + UNLANG_STACK_MAX) |
| number of stack-allocated objects, i.e. number of talloc headers | |
| #define | UNLANG_STACK_POOL_SIZE (UNLANG_STACK_SIZE + UNLANG_FRAME_POOL_SIZE) |
| total size of all stack objects | |
| #define | UNLANG_STACK_SIZE (9744) |
| size of the unlang stack | |
| #define | UNLANG_SUB_FRAME (false) |
| #define | UNLANG_TOP_FRAME (true) |
Typedefs | |
| typedef struct unlang_interpret_s | unlang_interpret_t |
| Interpreter handle. | |
| typedef void(* | unlang_request_done_t) (request_t *request, rlm_rcode_t rcode, void *uctx) |
| Signal the owner of the interpreter that this request completed processing. | |
| typedef void(* | unlang_request_init_t) (request_t *request, void *uctx) |
| Signal the owner of the interpreter that this request should be initialised and executed. | |
| typedef void(* | unlang_request_prioritise_t) (request_t *request, void *uctx) |
| Re-prioritise the request in the runnable queue. | |
| typedef void(* | unlang_request_resume_t) (request_t *request, void *uctx) |
| Signal the owner of the interpreter that a request is ready to be resumed. | |
| typedef void(* | unlang_request_runnable_t) (request_t *request, void *uctx) |
| Signal the owner of the interpreter that a request is now runnable. | |
| typedef bool(* | unlang_request_scheduled_t) (request_t const *request, void *uctx) |
| Signal the owner of the interpreter that a request is now runnable. | |
| typedef void(* | unlang_request_stop_t) (request_t *request, void *uctx) |
| Stop a request from running. | |
| typedef void(* | unlang_request_yield_t) (request_t *request, void *uctx) |
| Signal the owner of the interpreter that a request has yielded. | |
| typedef struct unlang_s | unlang_t |
Functions | |
| 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. | |
| int | unlang_interpret_force_result (unlang_t const *instruction, unlang_result_t *p_result, fr_timer_list_t *tl, fr_time_delta_t expire)) |
| Set (or clear) a forced result. | |
| 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 *func, void *uctx) |
| Initialize a unlang compiler / interpret. | |
| int | unlang_interpret_init_global (TALLOC_CTX *ctx) |
| unlang_t const * | unlang_interpret_instruction (request_t *request) |
| Get the current instruction. | |
| 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. | |
| unlang_mod_action_t | unlang_interpret_priority (request_t *request) |
| Get the last instruction priority OR the last frame that was popped. | |
| int | unlang_interpret_push_instruction (unlang_result_t *p_result, request_t *request, void *instruction, unlang_frame_conf_t const *conf) |
| Push an instruction onto the request stack for later interpretation. | |
| int | unlang_interpret_push_section (unlang_result_t *p_result, request_t *request, CONF_SECTION *cs, unlang_frame_conf_t const *conf) |
| Push a configuration section onto the request stack for later interpretation. | |
| rlm_rcode_t | unlang_interpret_rcode (request_t *request) |
| Get the last instruction result OR the last frame that was popped. | |
| void | unlang_interpret_request_cancel_retry (request_t *request) |
| Cancel any pending retry. | |
| void | unlang_interpret_request_done (request_t *request) |
| Indicate to the caller of the interpreter that this request is complete. | |
| void | unlang_interpret_request_prioritise (request_t *request, uint32_t priority) |
| unlang_result_t * | unlang_interpret_result (request_t *request) |
| Get the last instruction result OR the last frame that was popped. | |
| 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_synchronous (fr_event_list_t *el, request_t *request) |
| Execute an unlang section synchronously. | |
| 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. | |
Declarations for the unlang interpreter.
Definition in file interpret.h.
| struct unlang_frame_conf_t |
Configuration structure to make it easier to pass configuration options to initialise the frame with.
Definition at line 149 of file interpret.h.
Collaboration diagram for unlang_frame_conf_t:| Data Fields | ||
|---|---|---|
| unlang_result_t | default_result |
The default result for the frame. This needs to be specified separately from p_result, because we may be passing in NULL for p_result. |
| bool | top_frame | Is this the top frame? |
| struct unlang_request_func_t |
External functions provided by the owner of the interpret.
These functions allow the event loop to signal the caller when a given request is ready to run for the first time, and when it should be resumed and passed back to unlang_interpret to continue execution.
This is the cleanest way to separate the interpret and the code that's managing requests.
Test harnesses (for example) need to perform far less initialisation and request management than FreeRADIUS worker threads.
Definition at line 115 of file interpret.h.
Collaboration diagram for unlang_request_func_t:| Data Fields | ||
|---|---|---|
| unlang_request_init_t | detach | Function called when a request is detached. |
| unlang_request_done_t | done_detached | Function called when a detached request completes. |
| unlang_request_done_t | done_external | Function called when a external request completes. |
| unlang_request_done_t | done_internal | Function called when an internal request completes. |
| unlang_request_init_t | init_internal | Function called to initialise an internal request. |
| unlang_request_runnable_t | mark_runnable | Function called when a request needs to be added back to the runnable queue. |
| unlang_request_prioritise_t | prioritise | Function to re-prioritise a request in the runnable queue. |
| unlang_request_resume_t | resume | Function called when a request is resumed. |
| unlang_request_scheduled_t | scheduled | Function to check if a request is already scheduled. |
| unlang_request_yield_t | yield | Function called when a request yields. |
| struct unlang_result_t |
Definition at line 138 of file interpret.h.
| Data Fields | ||
|---|---|---|
| unlang_mod_action_t | priority | The priority or action for that rcode. |
| rlm_rcode_t | rcode | The current rcode, from executing the instruction or merging the result from a frame. |
| #define FRAME_CONF | ( | _default_rcode, | |
| _top_frame | |||
| ) |
Definition at line 157 of file interpret.h.
| #define UNLANG_FRAME_POOL_SIZE (UNLANG_STACK_MAX * UNLANG_FRAME_STATE) |
total size of all frame states
Definition at line 43 of file interpret.h.
| #define UNLANG_FRAME_SIZE (152) |
size of one stack frame, see radsizes
Definition at line 39 of file interpret.h.
| #define UNLANG_FRAME_STATE (128) |
guess at per-frame state
Definition at line 42 of file interpret.h.
| #define UNLANG_REQUEST_RESUME (false) |
Definition at line 48 of file interpret.h.
| #define UNLANG_REQUEST_RUNNING (true) |
Definition at line 47 of file interpret.h.
| #define UNLANG_RESULT_NOT_SET ((unlang_result_t) { .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET }) |
Definition at line 144 of file interpret.h.
| #define UNLANG_RESULT_RCODE | ( | _x | ) | ((unlang_result_t) { .rcode = (_x), .priority = MOD_ACTION_NOT_SET }) |
Definition at line 145 of file interpret.h.
| #define UNLANG_STACK_MAX (64) |
The maximum depth of the stack.
Definition at line 40 of file interpret.h.
| #define UNLANG_STACK_NUM_OBJECTS (1 + UNLANG_STACK_MAX) |
number of stack-allocated objects, i.e. number of talloc headers
Definition at line 45 of file interpret.h.
| #define UNLANG_STACK_POOL_SIZE (UNLANG_STACK_SIZE + UNLANG_FRAME_POOL_SIZE) |
total size of all stack objects
Definition at line 44 of file interpret.h.
| #define UNLANG_STACK_SIZE (9744) |
size of the unlang stack
Definition at line 41 of file interpret.h.
| #define UNLANG_SUB_FRAME (false) |
Definition at line 37 of file interpret.h.
| #define UNLANG_TOP_FRAME (true) |
Definition at line 36 of file interpret.h.
| typedef struct unlang_interpret_s unlang_interpret_t |
Interpreter handle.
Definition at line 53 of file interpret.h.
| typedef void(* unlang_request_done_t) (request_t *request, rlm_rcode_t rcode, void *uctx) |
Signal the owner of the interpreter that this request completed processing.
This is called once per request, when the interpret is about to stop processing it.
Definition at line 65 of file interpret.h.
| typedef void(* unlang_request_init_t) (request_t *request, void *uctx) |
Signal the owner of the interpreter that this request should be initialised and executed.
This is called once per request, when it's about to start executing.
Definition at line 59 of file interpret.h.
| typedef void(* unlang_request_prioritise_t) (request_t *request, void *uctx) |
Re-prioritise the request in the runnable queue.
The new priority will be available in request->async->priority.
Definition at line 101 of file interpret.h.
| typedef void(* unlang_request_resume_t) (request_t *request, void *uctx) |
Signal the owner of the interpreter that a request is ready to be resumed.
This is called any time a yielded request has resumed.
Definition at line 83 of file interpret.h.
| typedef void(* unlang_request_runnable_t) (request_t *request, void *uctx) |
Signal the owner of the interpreter that a request is now runnable.
This is called any time a yielded request has been marked runnable.
Definition at line 89 of file interpret.h.
Signal the owner of the interpreter that a request is now runnable.
This is called any time a yielded request has been marked runnable.
Definition at line 95 of file interpret.h.
| typedef void(* unlang_request_stop_t) (request_t *request, void *uctx) |
Stop a request from running.
This is called whenever a request has been signalled to stop
Definition at line 71 of file interpret.h.
| typedef void(* unlang_request_yield_t) (request_t *request, void *uctx) |
Signal the owner of the interpreter that a request has yielded.
This is called whenever a request has given control back to the interpreter.
Definition at line 77 of file interpret.h.
Definition at line 166 of file interpret.h.
| 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 2382 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| rlm_rcode_t unlang_interpret | ( | request_t * | request, |
| bool | running | ||
| ) |
Run the interpreter for a current request.
This function runs the interpreter for a request. It deals with popping stack frames, and calculating the final result for the frame.
| [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 1289 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| fr_event_list_t * unlang_interpret_event_list | ( | request_t * | request | ) |
Get the event list for the current interpreter.
Definition at line 2409 of file interpret.c.
Here is the caller graph for this function:| int unlang_interpret_force_result | ( | unlang_t const * | instruction, |
| unlang_result_t * | p_result, | ||
| fr_timer_list_t * | tl, | ||
| fr_time_delta_t | expire | ||
| ) |
Set (or clear) a forced result.
If timer list is passed, and a future expiry time, the function will set a timer that removes the forced result at that time.
Definition at line 344 of file interpret.c.
Here is the call graph for this function:| 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 2033 of file interpret.c.
Here is the caller graph for this function:| unlang_interpret_t * unlang_interpret_get | ( | request_t * | request | ) |
Get the interpreter set for a request.
Definition at line 2399 of file interpret.c.
Here is the caller graph for this function:| 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 2432 of file interpret.c.
Here is the caller graph for this function:| 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 2349 of file interpret.c.
Here is the caller graph for this function:| int unlang_interpret_init_global | ( | TALLOC_CTX * | ctx | ) |
Definition at line 2439 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:Get the current instruction.
Definition at line 321 of file interpret.c.
Check if a request as resumable.
| [in] | request | The current request. |
Definition at line 1970 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 1988 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| unlang_mod_action_t unlang_interpret_priority | ( | request_t * | request | ) |
Get the last instruction priority OR the last frame that was popped.
| [in] | request | The current request. |
Definition at line 1923 of file interpret.c.
Here is the call graph for this function:| int unlang_interpret_push_instruction | ( | unlang_result_t * | p_result, |
| request_t * | request, | ||
| void * | instruction, | ||
| unlang_frame_conf_t const * | conf | ||
| ) |
Push an instruction onto the request stack for later interpretation.
Definition at line 1545 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int unlang_interpret_push_section | ( | unlang_result_t * | p_result, |
| request_t * | request, | ||
| CONF_SECTION * | cs, | ||
| unlang_frame_conf_t const * | conf | ||
| ) |
Push a configuration section onto the request stack for later interpretation.
Definition at line 1522 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| rlm_rcode_t unlang_interpret_rcode | ( | request_t * | request | ) |
Get the last instruction result OR the last frame that was popped.
| [in] | request | The current request. |
Definition at line 1913 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void unlang_interpret_request_cancel_retry | ( | request_t * | request | ) |
Cancel any pending retry.
| [in] | request | The current request. |
Definition at line 1673 of file interpret.c.
| void unlang_interpret_request_done | ( | request_t * | request | ) |
Indicate to the caller of the interpreter that this request is complete.
Definition at line 1610 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| unlang_result_t * unlang_interpret_result | ( | request_t * | request | ) |
Get the last instruction result OR the last frame that was popped.
| [in] | request | The current request. |
Definition at line 1933 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void unlang_interpret_set | ( | request_t * | request, |
| unlang_interpret_t * | intp | ||
| ) |
Set a specific interpreter for a request.
Definition at line 2390 of file interpret.c.
Here is the caller graph for this function:| void unlang_interpret_set_thread_default | ( | unlang_interpret_t * | intp | ) |
Set the default interpreter for this thread.
Definition at line 2421 of file interpret.c.
Here is the caller graph for this function:| 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 1876 of file interpret.c.
Here is the call graph for this function:| 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.
| [in] | request | The current request. |
| [in] | action | to signal. |
Definition at line 1769 of file interpret.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void * unlang_interpret_stack_alloc | ( | TALLOC_CTX * | ctx | ) |
Allocate a new unlang stack.
| [in] | ctx | to allocate stack in. |
Definition at line 1573 of file interpret.c.
Here is the caller graph for this function:| int unlang_interpret_stack_depth | ( | request_t * | request | ) |
Return the depth of the request's stack.
Definition at line 1901 of file interpret.c.
Here is the caller graph for this function:| rlm_rcode_t unlang_interpret_synchronous | ( | fr_event_list_t * | el, |
| request_t * | request | ||
| ) |
Execute an unlang section synchronously.
Create a temporary event loop and swap it out for the one in the request. Execute unlang operations until we receive a non-yield return code then return.
| [in] | el | Event list for the temporary interpreter. If NULL a temporary list will be allocated. |
| [in] | request | The current request. |
Definition at line 193 of file interpret_synchronous.c.
Here is the call graph for this function:
Here is the caller graph for this function:Return whether a request has been cancelled.
Definition at line 1951 of file interpret.c.
Here is the caller graph for this function:Return whether a request has been marked done.
Definition at line 1958 of file interpret.c.
Here is the caller graph for this function:Return whether a request is currently scheduled.
Definition at line 1941 of file interpret.c.
Here is the caller graph for this function:
1.9.8