* @param[in] request to push the frame onto.
* @param[in] instruction One or more unlang_t nodes describing the operations to execute.
* @param[in] conf Configuration for the frame. If NULL, the following values areused:
- * - default_rcode = RLM_MODULE_NOT_SET
- * - default_priority = MOD_ACTION_NOT_SET
+ * - default result = UNLANG_RESULT_NOT_SET
* - top_frame = UNLANG_SUB_FRAME
* - no_rcode = false
* @param[in] do_next_sibling Whether to only execute the first node in the #unlang_t program
unlang_stack_frame_t *frame;
static unlang_frame_conf_t default_conf = {
- .default_rcode = RLM_MODULE_NOT_SET,
- .default_priority = MOD_ACTION_NOT_SET,
+ .default_result = UNLANG_RESULT_NOT_SET,
.top_frame = UNLANG_SUB_FRAME
};
if (conf->top_frame) top_frame_set(frame);
frame->result_p = result_p ? result_p : &frame->section_result;
- frame->result_p->rcode = conf->default_rcode;
- frame->result_p->priority = conf->default_priority;
+ *frame->result_p = conf->default_result;
frame->indent = request->log.indent;
fr_table_str_by_value(mod_rcode_table, result->rcode, "<invalid>"),
result->priority);
- frame_result->priority = 0;
- frame_result->rcode = result->rcode;
+ *frame_result = UNLANG_RESULT_RCODE(result->rcode);
return UNLANG_FRAME_ACTION_POP;
/*
fr_table_str_by_value(mod_rcode_table, RLM_MODULE_REJECT, "<invalid>"),
result->priority);
- frame_result->priority = 0;
- frame_result->rcode = RLM_MODULE_REJECT;
+ *frame_result = UNLANG_RESULT_RCODE(RLM_MODULE_REJECT);
return UNLANG_FRAME_ACTION_POP;
case MOD_ACTION_RETRY:
if (fr_timer_in(retry, unlang_interpret_event_list(request)->tl, &retry->ev, instruction->actions.retry.mrd,
false, instruction_retry_handler, request) < 0) {
RPEDEBUG("Failed inserting retry event");
- frame_result->rcode = RLM_MODULE_FAIL;
+ *frame_result = UNLANG_RESULT_RCODE(RLM_MODULE_FAIL);
goto finalize;
}
}
REDEBUG("Retries hit max_rtx_count (%u) - returning 'timeout'", instruction->actions.retry.mrc);
timeout:
- frame_result->rcode = RLM_MODULE_TIMEOUT;
+ *frame_result = UNLANG_RESULT_RCODE(RLM_MODULE_TIMEOUT);
goto finalize;
}
}
unlang_mod_action_t priority; //!< The priority or action for that rcode.
} unlang_result_t;
-#define UNLANG_RESULT_NOT_SET ((unlang_result_t){ .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET })
+#define UNLANG_RESULT_NOT_SET ((unlang_result_t) { .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET })
+#define UNLANG_RESULT_RCODE(_x) ((unlang_result_t) { .rcode = (_x), .priority = MOD_ACTION_NOT_SET })
/** 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?
- 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.
- unlang_mod_action_t default_priority; //!< The default priority for the frame.
+ unlang_result_t default_result; //!< The default result for the frame.
///< This needs to be specified separately
///< from p_result, because we may be passing
///< in NULL for p_result.
#define FRAME_CONF(_default_rcode, _top_frame) \
&(unlang_frame_conf_t){ \
.top_frame = (_top_frame), \
- .default_rcode = (_default_rcode), \
- .default_priority = MOD_ACTION_NOT_SET \
+ .default_result = UNLANG_RESULT_RCODE(_default_rcode), \
}
#define FRAME_CONF_NO_RCODE(_default_rcode, _top_frame) \
&(unlang_frame_conf_t){ \
.top_frame = (_top_frame), \
- .default_rcode = (_default_rcode), \
- .default_priority = MOD_ACTION_NOT_SET \
+ .default_result = UNLANG_RESULT_RCODE(_default_rcode), \
}
* Pretend as if we called the section
* and used the default rcode value.
*/
- frame->scratch_result.rcode = default_rcode;
+ frame->scratch_result = (unlang_result_t) {.rcode = default_rcode, .priority = MOD_ACTION_NOT_SET };
state = talloc_get_type_abort(frame->state, unlang_frame_state_module_t);
state->children[i].state = CHILD_DONE;
/*
- * Return isn't allowed to make it back
- * to the parent... Not sure this is
- * the correct behaviour, but it's what
- * was there before.
+ * Over-ride "return" and "reject". A "return"
+ * in a child of a parallel just stops the child.
+ * It doesn't stop the parent.
*/
if (cr->result.priority == MOD_ACTION_RETURN) {
- cr->result.priority = 0;
+ cr->result.priority = MOD_ACTION_NOT_SET;
+
} else if (cr->result.priority == MOD_ACTION_REJECT) {
- cr->result.rcode = RLM_MODULE_REJECT;
- cr->result.priority = 0;
+ cr->result = UNLANG_RESULT_RCODE(RLM_MODULE_REJECT);
+
+ } else {
+ fr_assert(cr->result.priority != MOD_ACTION_RETRY);
}
/*
p_result->priority,
fr_table_str_by_value(mod_rcode_table, cr->result.rcode, "<invalid>"),
cr->result.priority);
- p_result->rcode = cr->result.rcode;
- p_result->priority = cr->result.priority;
+ *p_result = cr->result;
}
}
return UNLANG_ACTION_YIELD;
case XLAT_ACTION_DONE:
- p_result->rcode = RLM_MODULE_OK;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_OK);
REXDENT();
return UNLANG_ACTION_CALCULATE_RESULT;
case XLAT_ACTION_FAIL:
fail:
- p_result->rcode = RLM_MODULE_FAIL;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_FAIL);
REXDENT();
return UNLANG_ACTION_CALCULATE_RESULT;
return UNLANG_ACTION_YIELD;
case XLAT_ACTION_DONE:
- p_result->rcode = RLM_MODULE_OK;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_OK);
RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
case XLAT_ACTION_FAIL:
fail:
- p_result->rcode = RLM_MODULE_FAIL;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_FAIL);
RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
return UNLANG_ACTION_YIELD;
case XLAT_ACTION_DONE:
- p_result->rcode = RLM_MODULE_OK;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_OK);
RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
return UNLANG_ACTION_PUSHED_CHILD;
case XLAT_ACTION_FAIL:
- p_result->rcode = RLM_MODULE_FAIL;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_FAIL);
RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
/* DON'T SET DEFAULT */
fr_assert(0); /* Garbage xlat action */
- p_result->rcode = RLM_MODULE_FAIL;
+ *p_result = UNLANG_RESULT_RCODE(RLM_MODULE_FAIL);
RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
}