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/action.h>
Go to the source code of this file.
Data Structures | |
struct | unlang_request_func_t |
External functions provided by the owner of the interpret. More... | |
Macros | |
#define | UNLANG_FRAME_PRE_ALLOC (128) |
How much memory we pre-alloc for each frame. | |
#define | UNLANG_STACK_MAX (64) |
The maximum depth of the 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_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. | |
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) |
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 *func, 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_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_action, bool top_frame) |
Push a configuration section onto the request stack for later interpretation. | |
void | unlang_interpret_request_done (request_t *request) |
Indicate to the caller of the interpreter that this request is complete. | |
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. | |
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 code) |
Overwrite the current stack rcode. | |
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_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 FeeRADIUS worker threads.
Definition at line 100 of file interpret.h.
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_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_stop_t | stop | function called when a request is signalled to stop. |
unlang_request_yield_t | yield | Function called when a request yields. |
#define UNLANG_FRAME_PRE_ALLOC (128) |
How much memory we pre-alloc for each frame.
Definition at line 39 of file interpret.h.
#define UNLANG_STACK_MAX (64) |
The maximum depth of the stack.
Definition at line 38 of file interpret.h.
#define UNLANG_SUB_FRAME (false) |
Definition at line 36 of file interpret.h.
#define UNLANG_TOP_FRAME (true) |
Definition at line 35 of file interpret.h.
typedef struct unlang_interpret_s unlang_interpret_t |
Interpreter handle.
Definition at line 44 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 56 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 50 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 74 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 80 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 86 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 62 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 68 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 1737 of file interpret.c.
rlm_rcode_t unlang_interpret | ( | request_t * | request | ) |
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. |
Definition at line 770 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 1764 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 1403 of file interpret.c.
unlang_interpret_t * unlang_interpret_get | ( | request_t * | request | ) |
Get the interpreter set for a request.
Definition at line 1754 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 1787 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 1703 of file interpret.c.
int unlang_interpret_init_global | ( | TALLOC_CTX * | ctx | ) |
Definition at line 1794 of file interpret.c.
Check if a request as resumable.
[in] | request | The current request. |
Definition at line 1341 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 1359 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 1015 of file interpret.c.
int unlang_interpret_push_section | ( | request_t * | request, |
CONF_SECTION * | cs, | ||
rlm_rcode_t | default_action, | ||
bool | top_frame | ||
) |
Push a configuration section onto the request stack for later interpretation.
Definition at line 992 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 1072 of file interpret.c.
void unlang_interpret_set | ( | request_t * | request, |
unlang_interpret_t * | intp | ||
) |
Set a specific interpreter for a request.
Definition at line 1745 of file interpret.c.
void unlang_interpret_set_thread_default | ( | unlang_interpret_t * | intp | ) |
Set the default interpreter for this thread.
Definition at line 1776 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 1196 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 1046 of file interpret.c.
int unlang_interpret_stack_depth | ( | request_t * | request | ) |
Return the depth of the request's stack.
Definition at line 1275 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 1290 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 1302 of file interpret.c.
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 212 of file interpret_synchronous.c.
Return whether a request has been cancelled.
Definition at line 1322 of file interpret.c.
Return whether a request has been marked done.
Definition at line 1329 of file interpret.c.
Return whether a request is currently scheduled.
Definition at line 1312 of file interpret.c.