26RCSID(
"$Id: 7c8dc1174b0cb1ccc14088ac2ed07cffc5aac71b $")
32#define FUNC(_state) *((void **)&state->func)
33#define REPEAT(_state) *((void **)&state->repeat)
64 .debug_name =
"function",
91 caller = request->module; \
92 request->module = NULL
94#define RESTORE_CALLER \
95 request->module = caller;
112 RDEBUG4(
"Repeat function is NULL, likely due to previous yield, skipping call");
125 ua = func(p_result, request, state->
uctx);
159 ua = state->
func.wres(p_result, request, state->
uctx);
195 RDEBUG4(
"Repeat function is NULL, likely due to previous yield, skipping call");
208 ua = func(request, state->
uctx);
219 fr_assert_msg(0,
"Function %s (%p) is not allowed to indicate failure via UNLANG_ACTION_FAIL",
251 ua = state->
func.nres(request, state->
uctx);
265 fr_assert_msg(0,
"Function is not allowed to indicate failure via UNLANG_ACTION_FAIL");
296 RERROR(
"Can't clear function on non-function frame");
330 RERROR(
"Can't set repeat function on non-function frame");
369 RERROR(
"Can't set repeat function on non-function frame");
376 fr_assert_msg(0,
"Function type mismatch \"%s\"", repeat_name);
392static inline CC_HINT(always_inline)
396 char const *func_name,
398 char const *repeat_name,
408 if (!func && !repeat) {
409 fr_assert_msg(0,
"function push must push at least one function!");
426 state = frame->
state;
472 bool top_frame,
void *uctx)
481 signal, sigmask, signal_name,
487 if (!func && repeat) {
522 bool top_frame,
void *uctx)
531 signal, sigmask, signal_name,
537 if (!func && repeat) {
571 .unlang_name =
"unlang_group_t",
574 .frame_state_type =
"unlang_frame_state_func_t",
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_PUSHED_CHILD
unlang_t pushed a new child onto the stack, execute it instead of continuing.
@ UNLANG_ACTION_STOP_PROCESSING
Break out of processing the current request (unwind).
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
static void unlang_function_dump(request_t *request, unlang_stack_frame_t *frame)
Custom frame state dumper.
char const * repeat_name
Debug name for the repeat function.
unlang_function_type_t type
Record whether we need to call the.
static unlang_action_t call_with_result(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
Call a generic function that produces a result.
int unlang_function_clear(request_t *request)
Clear pending repeat function calls, and remove the signal handler.
static unlang_action_t call_with_result_repeat(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
Call a generic function that produces a result.
static unlang_t function_instruction
Static instruction for allowing modules/xlats to call functions within themselves,...
unlang_function_signal_t signal
Signal function to call.
void * uctx
Uctx to pass to function.
union unlang_frame_state_func_t::@101 func
char const * func_name
Debug name for the function.
fr_signal_t sigmask
Signals to block.
static unlang_action_t call_no_result_repeat(UNUSED unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
Call a generic function that produces a result.
static unlang_action_t unlang_function_push_common(unlang_result_t *p_result, request_t *request, void *func, char const *func_name, void *repeat, char const *repeat_name, unlang_function_signal_t signal, fr_signal_t sigmask, char const *signal_name, unlang_function_type_t type, bool top_frame, void *uctx)
void unlang_function_init(void)
static void unlang_function_signal(request_t *request, unlang_stack_frame_t *frame, fr_signal_t action)
Generic signal handler.
static unlang_action_t call_no_result(UNUSED unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
Call a generic function that produces a result.
char const * signal_name
Debug name for the signal function.
Declarations for generic unlang functions.
@ UNLANG_FUNCTION_TYPE_NO_RESULT
Function without a result.
@ UNLANG_FUNCTION_TYPE_WITH_RESULT
Function with a result.
void(* unlang_function_signal_t)(request_t *request, fr_signal_t action, void *uctx)
Function to call if the request was signalled.
unlang_action_t(* unlang_function_no_result_t)(request_t *request, void *uctx)
A generic function pushed by a module or xlat to functions deeper in the C call stack to create resum...
unlang_action_t(* unlang_function_with_result_t)(unlang_result_t *p_result, request_t *request, void *uctx)
A generic function pushed by a module or xlat to functions deeper in the C call stack to create resum...
int unlang_interpret_push(unlang_result_t *p_result, request_t *request, unlang_t const *instruction, unlang_frame_conf_t const *conf, bool do_next_sibling)
Push a new frame onto the stack.
#define FRAME_CONF(_default_rcode, _top_frame)
void unlang_register(unlang_op_t *op)
Register an operation with the interpreter.
static char * stack[MAX_STACK]
#define DEFAULT_MOD_ACTIONS
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
fr_signal_t
Signals that can be generated/processed by request signal handlers.
fr_aka_sim_id_type_t type
Private interpreter structures and functions.
static void repeatable_clear(unlang_stack_frame_t *frame)
void * state
Stack frame specialisations.
static unlang_stack_frame_t * frame_current(request_t *request)
@ UNLANG_TYPE_FUNCTION
Internal call to a function or submodule.
static void frame_repeat(unlang_stack_frame_t *frame, unlang_process_t process)
Mark the current stack frame up for repeat, and set a new process function.
unlang_t const * instruction
The unlang node we're evaluating.
@ UNLANG_OP_FLAG_RETURN_POINT
Return point.
@ UNLANG_OP_FLAG_INTERNAL
it's not a real keyword
static void repeatable_set(unlang_stack_frame_t *frame)
unlang_process_t process
function to call for interpreting this stack frame
unlang_type_t type
The specialisation of this node.
Generic representation of a grouping.
A node in a graph of unlang_op_t (s) that we execute.
Our interpreter stack, as distinct from the C stack.
An unlang stack associated with a request.