31#include <freeradius-devel/server/cf_util.h>
32#include <freeradius-devel/server/request.h>
33#include <freeradius-devel/unlang/mod_action.h>
34#include <freeradius-devel/unlang/action.h>
36#define UNLANG_TOP_FRAME (true)
37#define UNLANG_SUB_FRAME (false)
39#define UNLANG_STACK_MAX (64)
40#define UNLANG_FRAME_PRE_ALLOC (128)
42#define UNLANG_REQUEST_RUNNING (true)
43#define UNLANG_REQUEST_RESUME (false)
153#define FRAME_CONF(_default_rcode, _top_frame) \
154 &(unlang_frame_conf_t){ \
155 .top_frame = (_top_frame), \
156 .default_rcode = (_default_rcode), \
157 .default_priority = MOD_ACTION_NOT_SET \
160#define FRAME_CONF_NO_RCODE(_default_rcode, _top_frame) \
161 &(unlang_frame_conf_t){ \
162 .top_frame = (_top_frame), \
163 .default_rcode = (_default_rcode), \
164 .default_priority = MOD_ACTION_NOT_SET \
170 CC_HINT(warn_unused_result);
174 CC_HINT(warn_unused_result);
A section grouping multiple CONF_PAIR.
void unlang_interpret_request_prioritise(request_t *request, uint32_t priority)
rlm_rcode_t unlang_interpret(request_t *request, bool running)
Run the interpreter for a current request.
bool unlang_request_is_done(request_t const *request)
Return whether a request has been marked done.
unlang_request_prioritise_t prioritise
Function to re-priotise a request in the runnable queue.
unlang_mod_action_t priority
The priority or action for that rcode.
unlang_result_t * unlang_interpret_result(request_t *request)
Get the last instruction result OR the last frame that was popped.
void unlang_interpet_frame_discard(request_t *request)
Discard the bottom most frame on the request's stack.
int unlang_interpret_set_timeout(request_t *request, fr_time_delta_t timeout)
Set a timeout for a request.
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.
unlang_mod_action_t default_priority
The default priority for the frame.
unlang_interpret_t * unlang_interpret_get(request_t *request)
Get the interpreter set for a request.
unlang_request_done_t done_internal
Function called when an internal request completes.
int unlang_interpret_stack_depth(request_t *request)
Return the depth of the request's stack.
void unlang_interpret_mark_runnable(request_t *request)
Mark a request as resumable.
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_init(TALLOC_CTX *ctx, fr_event_list_t *el, unlang_request_func_t *func, void *uctx)
Initialize a unlang compiler / interpret.
bool unlang_request_is_scheduled(request_t const *request)
Return whether a request is currently scheduled.
int unlang_interpret_init_global(TALLOC_CTX *ctx)
unlang_interpret_t * unlang_interpret_get_thread_default(void)
Get the default interpreter for this thread.
unlang_request_resume_t resume
Function called when a request is resumed.
void * unlang_interpret_stack_alloc(TALLOC_CTX *ctx)
Allocate a new unlang stack.
bool top_frame
Is this the top frame?
bool(* unlang_request_scheduled_t)(request_t const *request, void *uctx)
Signal the owner of the interpreter that a request is now runnable.
unlang_request_done_t done_external
Function called when a external request completes.
void unlang_interpret_set_thread_default(unlang_interpret_t *intp)
Set the default interpreter for this thread.
unlang_request_init_t detach
Function called when a request is detached.
unlang_mod_action_t unlang_interpret_priority(request_t *request)
Get the last instruction priority OR the last frame that was popped.
unlang_request_runnable_t mark_runnable
Function called when a request needs to be added back to the runnable queue.
rlm_rcode_t rcode
The current rcode, from executing the instruction or merging the result from a frame.
bool unlang_request_is_cancelled(request_t const *request)
Return whether a request has been cancelled.
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.
unlang_request_yield_t yield
Function called when a request yields.
void unlang_interpret_signal(request_t *request, fr_signal_t action)
Send a signal (usually stop) to a request.
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.
void(* unlang_request_prioritise_t)(request_t *request, void *uctx)
Re-priotise the request in the runnable queue.
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.
void(* unlang_request_resume_t)(request_t *request, void *uctx)
Signal the owner of the interpreter that a request is ready to be resumed.
unlang_request_done_t done_detached
Function called when a detached request completes.
void(* unlang_request_yield_t)(request_t *request, void *uctx)
Signal the owner of the interpreter that a request has yielded.
rlm_rcode_t default_rcode
The default return code for the frame.
bool unlang_interpret_is_resumable(request_t *request)
Check if a request as resumable.
rlm_rcode_t unlang_interpret_synchronous(fr_event_list_t *el, request_t *request)
Execute an unlang section synchronously.
void(* unlang_request_init_t)(request_t *request, void *uctx)
Signal the owner of the interpreter that this request should be initialised and executed.
unlang_request_scheduled_t scheduled
Function to check if a request is already scheduled.
void(* unlang_request_stop_t)(request_t *request, void *uctx)
Stop a request from running.
void(* unlang_request_runnable_t)(request_t *request, void *uctx)
Signal the owner of the interpreter that a request is now runnable.
rlm_rcode_t unlang_interpret_rcode(request_t *request)
Get the last instruction result OR the last frame that was popped.
unlang_request_init_t init_internal
Function called to initialise an internal request.
fr_event_list_t * unlang_interpret_event_list(request_t *request)
Get the event list for the current interpreter.
Configuration structure to make it easier to pass configuration options to initialise the frame with.
External functions provided by the owner of the interpret.
Stores all information relating to an event list.
rlm_rcode_t
Return codes indicating the result of the module call.
fr_signal_t
Signals that can be generated/processed by request signal handlers.
A time delta, a difference in time measured in nanoseconds.
static fr_event_list_t * el