static void CC_HINT(nonnull) actions_dump(request_t *request, unlang_t const *instruction)
{
- char buffer[20];
int i;
RDEBUG2("actions");
RINDENT();
for (i = 0; i < RLM_MODULE_NUMCODES; i++) {
- snprintf(buffer, sizeof(buffer), "%d", instruction->actions.actions[i]);
-
RDEBUG2("%s: %s",
fr_table_str_by_value(mod_rcode_table, i, "<invalid>"),
- fr_table_str_by_value(mod_action_table, instruction->actions.actions[i], buffer),
- instruction->actions.actions[i]);
+ mod_action_name[instruction->actions.actions[i]]);
}
REXDENT();
}
RDEBUG2("next <none>");
}
+ fr_assert(MOD_ACTION_VALID(frame->result_p->priority));
+
if (is_private_result(frame)) {
int location;
result_p_location_t type;
void *chunk;
RDEBUG2("p_rcode %s", fr_table_str_by_value(mod_rcode_table, frame->result_p->rcode, "<invalid>"));
- RDEBUG2("p_priority %d", frame->result_p->priority);
+ RDEBUG2("p_priority %s", mod_action_name[frame->result_p->priority]);
location = find_result_p_location(&type, &chunk, request, frame->result_p);
RDEBUG2("p_location %s [%i] %p (%s)", fr_table_str_by_value(result_p_location_table, type, "<invalid>"),
);
} else {
RDEBUG2("sec_rcode %s", fr_table_str_by_value(mod_rcode_table, frame->section_result.rcode, "<invalid>"));
- RDEBUG2("sec_priority %d", frame->section_result.priority);
+ RDEBUG2("sec_priority %s", mod_action_name[frame->section_result.priority]);
}
RDEBUG2("scr_rcode %s", fr_table_str_by_value(mod_rcode_table, frame->scratch_result.rcode, "<invalid>"));
- RDEBUG2("scr_priority %d", frame->scratch_result.priority);
+ RDEBUG2("scr_priority %s", mod_action_name[frame->scratch_result.priority]);
RDEBUG2("top_frame %s", is_top_frame(frame) ? "yes" : "no");
RDEBUG2("repeat %s", is_repeatable(frame) ? "yes" : "no");
RDEBUG2("yielded %s", is_yielded(frame) ? "yes" : "no");
return UNLANG_FRAME_ACTION_NEXT;
}
- RDEBUG4("** [%i] %s - have (%s %d) frame or module returned (%s %d)",
+ fr_assert(MOD_ACTION_VALID(frame_result->priority));
+ fr_assert(MOD_ACTION_VALID(result->priority));
+
+ RDEBUG4("** [%i] %s - have (%s %s) frame or module returned (%s %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, frame_result->rcode, "<invalid>"),
- frame_result->priority,
+ mod_action_name[frame_result->priority],
fr_table_str_by_value(mod_rcode_table, result->rcode, "<invalid>"),
- result->priority);
+ mod_action_name[result->priority]);
/*
* Update request->rcode if the instruction says we should
if (result->priority == MOD_ACTION_NOT_SET) {
result->priority = instruction->actions.actions[result->rcode];
- RDEBUG4("** [%i] %s - using default instruction priority for %s, %d",
+ fr_assert(MOD_ACTION_VALID(result->priority));
+
+ RDEBUG4("** [%i] %s - using default instruction priority for %s, %s",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, result->rcode, "<invalid>"),
- result->priority);
+ mod_action_name[result->priority]);
}
/*
* should return from this frame.
*/
case MOD_ACTION_RETURN:
- RDEBUG4("** [%i] %s - action says to return with (%s %d)",
+ RDEBUG4("** [%i] %s - action says to return with (%s %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, result->rcode, "<invalid>"),
- result->priority);
+ mod_action_name[result->priority]);
*frame_result = UNLANG_RESULT_RCODE(result->rcode);
return UNLANG_FRAME_ACTION_POP;
* after the module returns...
*/
case MOD_ACTION_REJECT:
- RDEBUG4("** [%i] %s - action says to return with (%s %d)",
+ RDEBUG4("** [%i] %s - action says to return with (%s %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, RLM_MODULE_REJECT, "<invalid>"),
- result->priority);
+ mod_action_name[result->priority]);
*frame_result = UNLANG_RESULT_RCODE(RLM_MODULE_REJECT);
return UNLANG_FRAME_ACTION_POP;
* return code and priority.
*/
if (result->priority >= frame_result->priority) {
- RDEBUG4("** [%i] %s - overwriting existing result (%s %d) with higher priority (%s %d)",
+ fr_assert(MOD_ACTION_VALID(result->priority));
+ fr_assert(MOD_ACTION_VALID(frame_result->priority));
+
+ RDEBUG4("** [%i] %s - overwriting existing result (%s %s) with higher priority (%s %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, frame_result->rcode, "<invalid>"),
- frame_result->priority,
+ mod_action_name[frame_result->priority],
fr_table_str_by_value(mod_rcode_table, result->rcode, "<invalid>"),
- result->priority);
+ mod_action_name[result->priority]);
*frame->result_p = *result;
}
unlang_stack_t *stack = request->stack;
unlang_result_t our_result = *result;
+ fr_assert(MOD_ACTION_VALID(result->priority));
+
/*
* When a stack frame is being popped, the priority of the
* source (lower) frame is ignored, and the default priority
* cases for this yet.
*/
if (result->rcode != RLM_MODULE_NOT_SET) {
+ fr_assert(MOD_ACTION_VALID(frame->instruction->actions.actions[result->rcode]));
our_result.priority = frame->instruction->actions.actions[result->rcode];
}
- RDEBUG4("** [%i] %s - using instruction priority for higher frame (%s, %d)",
+ RDEBUG4("** [%i] %s - using instruction priority for higher frame (%s, %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, our_result.rcode, "<invalid>"),
- our_result.priority);
+ mod_action_name[our_result.priority]);
return result_calculate(request, frame, &our_result);
}
*/
ua = frame->process(&frame->scratch_result, request, frame);
- RDEBUG4("** [%i] %s << %s (%s %d)", stack->depth, __FUNCTION__,
+ fr_assert(MOD_ACTION_VALID(scratch->priority));
+
+ RDEBUG4("** [%i] %s << %s (%s %s)", stack->depth, __FUNCTION__,
fr_table_str_by_value(unlang_action_table, ua, "<INVALID>"),
fr_table_str_by_value(mod_rcode_table, scratch->rcode, "<INVALID>"),
- scratch->priority);
-
- fr_assert(scratch->priority >= MOD_ACTION_NOT_SET);
- fr_assert(scratch->priority <= MOD_PRIORITY_MAX);
+ mod_action_name[scratch->priority]);
/*
* If the frame is cancelled we ignore the
"instead", instruction->name);
unlang_frame_perf_yield(frame);
yielded_set(frame);
- RDEBUG4("** [%i] %s - yielding with current (%s %d)", stack->depth, __FUNCTION__,
+ RDEBUG4("** [%i] %s - yielding with current (%s %s)", stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, scratch->rcode, "<invalid>"),
- scratch->priority);
+ mod_action_name[scratch->priority]);
return UNLANG_FRAME_ACTION_YIELD;
/*
}
pop:
- RDEBUG4("** [%i] %s - done current subsection with (%s %d), %s",
+ fr_assert(MOD_ACTION_VALID(frame->result_p->priority));
+
+ RDEBUG4("** [%i] %s - done current subsection with (%s %s), %s",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, frame->result_p->rcode, "<invalid>"),
- frame->result_p->priority,
+ mod_action_name[frame->result_p->priority],
frame->result_p == &(frame->section_result) ? "will set higher frame rcode" : "will NOT set higher frame rcode (result_p)");
return UNLANG_FRAME_ACTION_POP;
*/
instruction_done_debug(request, frame, frame->instruction);
+ fr_assert(MOD_ACTION_VALID(frame->section_result.priority));
+
/*
* If we're continuing after popping a frame
* then we advance the instruction else we
*/
switch (fa) {
case UNLANG_FRAME_ACTION_NEXT:
- DEBUG4("** [%i] %s - continuing after subsection with (%s %d)",
+ DEBUG4("** [%i] %s - continuing after subsection with (%s %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, frame->section_result.rcode, "<invalid>"),
- frame->section_result.priority);
+ mod_action_name[frame->section_result.priority]);
frame_next(stack, frame);
goto next;
* print some helpful debug...
*/
default:
- RDEBUG4("** [%i] %s - done current subsection with (%s %d)",
+ RDEBUG4("** [%i] %s - done current subsection with (%s %s)",
stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, frame->section_result.rcode, "<invalid>"),
- frame->section_result.priority);
+ mod_action_name[frame->section_result.priority]);
continue;
}
},
.retry = RETRY_INIT
};
+
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wgnu-designator"
+#endif
+
+const char *mod_action_name[MOD_PRIORITY_MAX + 1] = {
+ [MOD_ACTION_NOT_SET] = "not-set",
+ [MOD_ACTION_RETRY] = "retry",
+ [MOD_ACTION_REJECT] = "reject",
+ [MOD_ACTION_RETURN] = "return",
+
+ [4 ... 0x80] = "<INVALID>",
+
+ // zsh: for x ({1..64}); do print -n "[MOD_PRIORITY($x)] = \"$x\", "; done
+ [MOD_PRIORITY(1)] = "1", [MOD_PRIORITY(2)] = "2", [MOD_PRIORITY(3)] = "3", [MOD_PRIORITY(4)] = "4",
+ [MOD_PRIORITY(5)] = "5", [MOD_PRIORITY(6)] = "6", [MOD_PRIORITY(7)] = "7", [MOD_PRIORITY(8)] = "8",
+ [MOD_PRIORITY(9)] = "9", [MOD_PRIORITY(10)] = "10", [MOD_PRIORITY(11)] = "11", [MOD_PRIORITY(12)] = "12",
+ [MOD_PRIORITY(13)] = "13", [MOD_PRIORITY(14)] = "14", [MOD_PRIORITY(15)] = "15", [MOD_PRIORITY(16)] = "16",
+ [MOD_PRIORITY(17)] = "17", [MOD_PRIORITY(18)] = "18", [MOD_PRIORITY(19)] = "19", [MOD_PRIORITY(20)] = "20",
+ [MOD_PRIORITY(21)] = "21", [MOD_PRIORITY(22)] = "22", [MOD_PRIORITY(23)] = "23", [MOD_PRIORITY(24)] = "24",
+ [MOD_PRIORITY(25)] = "25", [MOD_PRIORITY(26)] = "26", [MOD_PRIORITY(27)] = "27", [MOD_PRIORITY(28)] = "28",
+ [MOD_PRIORITY(29)] = "29", [MOD_PRIORITY(30)] = "30", [MOD_PRIORITY(31)] = "31", [MOD_PRIORITY(32)] = "32",
+ [MOD_PRIORITY(33)] = "33", [MOD_PRIORITY(34)] = "34", [MOD_PRIORITY(35)] = "35", [MOD_PRIORITY(36)] = "36",
+ [MOD_PRIORITY(37)] = "37", [MOD_PRIORITY(38)] = "38", [MOD_PRIORITY(39)] = "39", [MOD_PRIORITY(40)] = "40",
+ [MOD_PRIORITY(41)] = "41", [MOD_PRIORITY(42)] = "42", [MOD_PRIORITY(43)] = "43", [MOD_PRIORITY(44)] = "44",
+ [MOD_PRIORITY(45)] = "45", [MOD_PRIORITY(46)] = "46", [MOD_PRIORITY(47)] = "47", [MOD_PRIORITY(48)] = "48",
+ [MOD_PRIORITY(49)] = "49", [MOD_PRIORITY(50)] = "50", [MOD_PRIORITY(51)] = "51", [MOD_PRIORITY(52)] = "52",
+ [MOD_PRIORITY(53)] = "53", [MOD_PRIORITY(54)] = "54", [MOD_PRIORITY(55)] = "55", [MOD_PRIORITY(56)] = "56",
+ [MOD_PRIORITY(57)] = "57", [MOD_PRIORITY(58)] = "58", [MOD_PRIORITY(59)] = "59", [MOD_PRIORITY(60)] = "60",
+ [MOD_PRIORITY(61)] = "61", [MOD_PRIORITY(62)] = "62", [MOD_PRIORITY(63)] = "63", [MOD_PRIORITY(64)] = "64",
+};