![]() |
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>
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 | FRAME_CONF_NO_RCODE(_default_rcode, _top_frame) |
#define | UNLANG_FRAME_PRE_ALLOC (128) |
How much memory we pre-alloc for each frame. | |
#define | UNLANG_REQUEST_RESUME (false) |
#define | UNLANG_REQUEST_RUNNING (true) |
#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_prioritise_t) (request_t *request, void *uctx) |
Re-priotise 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. | |
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. | |
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. | |
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_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 141 of file interpret.h.
Data Fields | ||
---|---|---|
unlang_mod_action_t | default_priority |
The default priority for the frame. This needs to be specified separately from p_result, because we may be passing in NULL for p_result. |
rlm_rcode_t | default_rcode |
The default return code 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 FeeRADIUS worker threads.
Definition at line 110 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_prioritise_t | prioritise | Function to re-priotise 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 133 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 153 of file interpret.h.
#define FRAME_CONF_NO_RCODE | ( | _default_rcode, | |
_top_frame | |||
) |
Definition at line 160 of file interpret.h.
#define UNLANG_FRAME_PRE_ALLOC (128) |
How much memory we pre-alloc for each frame.
Definition at line 40 of file interpret.h.
#define UNLANG_REQUEST_RESUME (false) |
Definition at line 43 of file interpret.h.
#define UNLANG_REQUEST_RUNNING (true) |
Definition at line 42 of file interpret.h.
#define UNLANG_STACK_MAX (64) |
The maximum depth of the stack.
Definition at line 39 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 48 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 60 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 54 of file interpret.h.
typedef void(* unlang_request_prioritise_t) (request_t *request, void *uctx) |
Re-priotise the request in the runnable queue.
The new priority will be available in request->async->priority.
Definition at line 96 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 78 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 84 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 90 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 66 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 72 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 1986 of file interpret.c.
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 calaculating 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 941 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 2013 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 1661 of file interpret.c.
unlang_interpret_t * unlang_interpret_get | ( | request_t * | request | ) |
Get the interpreter set for a request.
Definition at line 2003 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 2036 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 1953 of file interpret.c.
int unlang_interpret_init_global | ( | TALLOC_CTX * | ctx | ) |
Definition at line 2043 of file interpret.c.
Check if a request as resumable.
[in] | request | The current request. |
Definition at line 1598 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 1616 of file interpret.c.
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 1551 of file interpret.c.
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 1166 of file interpret.c.
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 1143 of file interpret.c.
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 1541 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 1255 of file interpret.c.
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 1561 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 1994 of file interpret.c.
void unlang_interpret_set_thread_default | ( | unlang_interpret_t * | intp | ) |
Set the default interpreter for this thread.
Definition at line 2025 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 1504 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.
[in] | request | The current request. |
[in] | action | to signal. |
Definition at line 1396 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 1194 of file interpret.c.
int unlang_interpret_stack_depth | ( | request_t * | request | ) |
Return the depth of the request's stack.
Definition at line 1529 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 193 of file interpret_synchronous.c.
Return whether a request has been cancelled.
Definition at line 1579 of file interpret.c.
Return whether a request has been marked done.
Definition at line 1586 of file interpret.c.
Return whether a request is currently scheduled.
Definition at line 1569 of file interpret.c.