* Push a new call frame onto the stack
*/
if (unlang_interpret_push(request, unlang_call_to_generic(c),
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, top_frame) < 0) {
+ FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) {
talloc_free(c);
return UNLANG_ACTION_FAIL;
}
};
/* Sets up the frame for us to use immediately */
- if (unlikely(unlang_interpret_push_instruction(child, &inform_parent, RLM_MODULE_NOOP, true) < 0)) {
+ if (unlikely(unlang_interpret_push_instruction(child, &inform_parent,
+ FRAME_CONF(RLM_MODULE_NOOP, true)) < 0)) {
return -1;
}
* Push a new edit frame onto the stack
*/
if (unlang_interpret_push(request, unlang_edit_to_generic(edit),
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, false) < 0) return -1;
+ FRAME_CONF(RLM_MODULE_NOT_SET, UNLANG_SUB_FRAME), UNLANG_NEXT_STOP) < 0) return -1;
frame = &stack->frame[stack->depth];
state = talloc_get_type_abort(frame->state, unlang_frame_state_edit_t);
}
}
- if (unlikely(unlang_interpret_push_instruction(request, state->instruction, RLM_MODULE_NOOP, UNLANG_SUB_FRAME) < 0)) {
+ if (unlikely(unlang_interpret_push_instruction(request, state->instruction,
+ FRAME_CONF(RLM_MODULE_NOOP, UNLANG_SUB_FRAME)) < 0)) {
unlang_interpret_signal(request, FR_SIGNAL_CANCEL); /* also stops the request and does cleanups */
}
* timer expires.
*/
if (unlang_interpret_push(request, &finally_instruction,
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, top_frame) < 0) return -1;
+ FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) return -1;
frame = &stack->frame[stack->depth];
/*
* Push module's function
*/
if (unlang_interpret_push(request, &function_instruction,
- RLM_MODULE_NOOP, UNLANG_NEXT_STOP, top_frame) < 0) return UNLANG_ACTION_FAIL;
+ FRAME_CONF(RLM_MODULE_NOOP, top_frame), UNLANG_NEXT_STOP) < 0) return UNLANG_ACTION_FAIL;
frame = &stack->frame[stack->depth];
return UNLANG_ACTION_EXECUTE_NEXT;
}
- if (unlang_interpret_push(request, g->children, default_rcode, do_next_sibling, UNLANG_SUB_FRAME) < 0) {
+ if (unlang_interpret_push(request, g->children, FRAME_CONF(default_rcode, UNLANG_SUB_FRAME), do_next_sibling) < 0) {
return UNLANG_ACTION_STOP_PROCESSING;
}
/** Push a configuration section onto the request stack for later interpretation.
*
*/
-int unlang_interpret_push_section(request_t *request, CONF_SECTION *cs, rlm_rcode_t default_rcode, bool top_frame)
+int unlang_interpret_push_section(request_t *request, CONF_SECTION *cs, unlang_frame_conf_t const *conf)
{
unlang_t *instruction = NULL;
}
}
- return unlang_interpret_push_instruction(request, instruction, default_rcode, top_frame);
+ return unlang_interpret_push_instruction(request, instruction, conf);
}
/** Push an instruction onto the request stack for later interpretation.
*
*/
-int unlang_interpret_push_instruction(request_t *request, void *instruction, rlm_rcode_t default_rcode, bool top_frame)
+int unlang_interpret_push_instruction(request_t *request, void *instruction, unlang_frame_conf_t const *conf)
{
unlang_stack_t *stack = request->stack;
* Push the default action, and the instruction which has
* no action.
*/
- if (unlang_interpret_push(request,
- instruction, default_rcode, UNLANG_NEXT_SIBLING, top_frame) < 0) {
+ if (unlang_interpret_push(request, instruction, conf, UNLANG_NEXT_SIBLING) < 0) {
return -1;
}
///< runnable queue.
} unlang_request_func_t;
-int unlang_interpret_push_section(request_t *request, CONF_SECTION *cs,
- rlm_rcode_t default_action, bool top_frame)
+/** Configuration structure to make it easier to pass configuration options to initialise the frame with
+ */
+typedef struct {
+ bool top_frame; //!< Is this the top frame?
+ bool no_rcode; //!< Don't set the rcode when the frame is popped.
+ rlm_rcode_t default_rcode; //!< The default return code for the frame.
+ unlang_mod_action_t default_priority; //!< The default priority for the frame.
+} unlang_frame_conf_t;
+
+#define FRAME_CONF(_default_rcode, _top_frame) \
+ &(unlang_frame_conf_t){ \
+ .top_frame = (_top_frame), \
+ .no_rcode = false, \
+ .default_rcode = (_default_rcode), \
+ .default_priority = MOD_ACTION_NOT_SET \
+ }
+
+int unlang_interpret_push_section(request_t *request, CONF_SECTION *cs, unlang_frame_conf_t const *conf)
CC_HINT(warn_unused_result);
-int unlang_interpret_push_instruction(request_t *request, void *instruction,
- rlm_rcode_t default_rcode, bool top_frame)
+int unlang_interpret_push_instruction(request_t *request, void *instruction, unlang_frame_conf_t const *conf)
CC_HINT(warn_unused_result);
unlang_interpret_t *unlang_interpret_init(TALLOC_CTX *ctx,
/*
* Push the child, and yield for a later return.
*/
- if (unlang_interpret_push(request, redundant->child, RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, UNLANG_SUB_FRAME) < 0) {
+ if (unlang_interpret_push(request, redundant->child, FRAME_CONF(RLM_MODULE_NOT_SET, UNLANG_SUB_FRAME), UNLANG_NEXT_STOP) < 0) {
return UNLANG_ACTION_STOP_PROCESSING;
}
*/
if (frame->instruction->type == UNLANG_TYPE_LOAD_BALANCE) {
if (unlang_interpret_push(request, redundant->found,
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, UNLANG_SUB_FRAME) < 0) {
+ FRAME_CONF(RLM_MODULE_NOT_SET, UNLANG_SUB_FRAME), UNLANG_NEXT_STOP) < 0) {
return UNLANG_ACTION_STOP_PROCESSING;
}
return UNLANG_ACTION_PUSHED_CHILD;
* Push a new module frame onto the stack
*/
if (unlang_interpret_push(request, unlang_module_to_generic(mc),
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, top_frame) < 0) {
+ FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) {
return -1;
}
(void) unlang_module_yield(request, resume, signal, sigmask, rctx);
if (unlang_interpret_push_section(request, subcs,
- default_rcode, UNLANG_SUB_FRAME) < 0) return UNLANG_ACTION_STOP_PROCESSING;
+ FRAME_CONF(default_rcode, UNLANG_SUB_FRAME)) < 0) return UNLANG_ACTION_STOP_PROCESSING;
return UNLANG_ACTION_PUSHED_CHILD;
}
* subsection within the parallel block.
*/
if (unlang_interpret_push(child,
- instruction, RLM_MODULE_FAIL,
- UNLANG_NEXT_STOP,
- state->detach ? UNLANG_TOP_FRAME : UNLANG_SUB_FRAME) < 0) goto error;
+ instruction,
+ FRAME_CONF(RLM_MODULE_FAIL, state->detach ? UNLANG_TOP_FRAME : UNLANG_SUB_FRAME),
+ UNLANG_NEXT_STOP) < 0) goto error;
}
/*
* Push the first instruction the child's
* going to run.
*/
- if (unlang_interpret_push(child, g->children, RLM_MODULE_NOT_SET,
- UNLANG_NEXT_SIBLING, UNLANG_SUB_FRAME) < 0) goto fail;
+ if (unlang_interpret_push(child, g->children,
+ FRAME_CONF(RLM_MODULE_NOT_SET, UNLANG_SUB_FRAME),
+ UNLANG_NEXT_SIBLING) < 0) goto fail;
/*
* Finally, setup the function that will be
* completed.
*/
if (unlang_interpret_push(child->parent, &subrequest_instruction,
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, top_frame) < 0) {
+ FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) {
return -1;
}
*/
if (!found) return UNLANG_ACTION_EXECUTE_NEXT;
- if (unlang_interpret_push(request, found, RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, UNLANG_SUB_FRAME) < 0) {
+ if (unlang_interpret_push(request, found, FRAME_CONF(RLM_MODULE_NOT_SET, UNLANG_SUB_FRAME), UNLANG_NEXT_STOP) < 0) {
return UNLANG_ACTION_STOP_PROCESSING;
}
/*
* Push something else onto the stack to execute.
*/
- if (unlikely(unlang_interpret_push_instruction(request, state->instruction, RLM_MODULE_TIMEOUT, true) < 0)) {
+ if (unlikely(unlang_interpret_push_instruction(request, state->instruction,
+ FRAME_CONF(RLM_MODULE_TIMEOUT, true)) < 0)) {
unlang_interpret_signal(request, FR_SIGNAL_CANCEL); /* also stops the request and does cleanups */
}
}
* Push a new timeout frame onto the stack
*/
if (unlang_interpret_push(request, &timeout_instruction,
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, top_frame) < 0) return -1;
+ FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) return -1;
frame = &stack->frame[stack->depth];
/*
* Push a new tmpl frame onto the stack
*/
if (unlang_interpret_push(request, unlang_tmpl_to_generic(ut),
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, false) < 0) return -1;
+ FRAME_CONF(RLM_MODULE_NOT_SET, false), UNLANG_NEXT_STOP) < 0) return -1;
frame = &stack->frame[stack->depth];
state = talloc_get_type_abort(frame->state, unlang_frame_state_tmpl_t);
* @{
*/
int unlang_interpret_push(request_t *request, unlang_t const *instruction,
- rlm_rcode_t default_rcode, bool do_next_sibling, bool top_frame)
+ unlang_frame_conf_t const *conf, bool do_next_sibling)
CC_HINT(warn_unused_result);
unlang_action_t unlang_interpret_push_children(rlm_rcode_t *p_result, request_t *request,
* Push a new xlat eval frame onto the stack
*/
if (unlang_interpret_push(request, &xlat_instruction,
- RLM_MODULE_NOT_SET, UNLANG_NEXT_STOP, top_frame) < 0) return -1;
+ FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) return -1;
frame = &stack->frame[stack->depth];
/*