26RCSID(
"$Id: 261a4566384974a13aa8becc03a2c7e9732a261b $")
32#define FUNC(_state) *((void **)&state->func)
33#define REPEAT(_state) *((void **)&state->repeat)
64 .debug_name =
"function",
110#define STORE_CALLER \
111 char const *caller; \
112 caller = request->module; \
113 request->module = NULL
115#define RESTORE_CALLER \
116 request->module = caller;
133 RDEBUG4(
"Repeat function is NULL, likely due to previous yield, skipping call");
146 ua = func(p_result, request, state->
uctx);
180 ua = state->
func.wres(p_result, request, state->
uctx);
216 RDEBUG4(
"Repeat function is NULL, likely due to previous yield, skipping call");
229 ua = func(request, state->
uctx);
240 fr_assert_msg(0,
"Function %s (%p) is not allowed to indicate failure via UNLANG_ACTION_FAIL",
272 ua = state->
func.nres(request, state->
uctx);
286 fr_assert_msg(0,
"Function is not allowed to indicate failure via UNLANG_ACTION_FAIL");
317 RERROR(
"Can't clear function on non-function frame");
351 RERROR(
"Can't set repeat function on non-function frame");
390 RERROR(
"Can't set repeat function on non-function frame");
397 fr_assert_msg(0,
"Function type mismatch \"%s\"", repeat_name);
413static inline CC_HINT(always_inline)
417 char const *func_name,
419 char const *repeat_name,
429 if (!func && !repeat) {
430 fr_assert_msg(0,
"function push must push at least one function!");
447 state = frame->
state;
493 bool top_frame,
void *uctx)
502 signal, sigmask, signal_name,
508 if (!func && repeat) {
543 bool top_frame,
void *uctx)
552 signal, sigmask, signal_name,
558 if (!func && repeat) {
590 .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 *result_p, 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(int type, unlang_op_t *op)
Register an operation with the interpreter.
static char * stack[MAX_STACK]
@ RLM_MODULE_INVALID
The module considers the request invalid.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
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.
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.
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.