From: Alan T. DeKok Date: Mon, 30 Aug 2021 18:04:19 +0000 (-0400) Subject: add function to change resumption handler for a module. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e442437e39ea59463ef2e91215fdf05d18e5d2a3;p=thirdparty%2Ffreeradius-server.git add function to change resumption handler for a module. --- diff --git a/src/lib/unlang/module.c b/src/lib/unlang/module.c index a8e740614a2..f14521c285e 100644 --- a/src/lib/unlang/module.c +++ b/src/lib/unlang/module.c @@ -410,6 +410,36 @@ int unlang_module_push(rlm_rcode_t *p_result, request_t *request, return 0; } +/** Change the resume function of a module. + * + * @param[in] request The current request. + * @param[in] resume function to call when the XLAT expansion is complete. + * @return + * - <0 on error + * - 0 on success + */ +int unlang_module_set_resume(request_t *request, unlang_module_resume_t resume) +{ + unlang_stack_t *stack = request->stack; + unlang_stack_frame_t *frame = &stack->frame[stack->depth]; + unlang_frame_state_module_t *state; + + /* + * Can't resume if it isn't yielded. + */ + if (!is_yielded(frame)) return -1; + + /* + * It must be yielded in a module. + */ + if (frame->instruction->type != UNLANG_TYPE_MODULE) return -1; + + state = talloc_get_type_abort(frame->state, unlang_frame_state_module_t); + state->resume = resume; + + return 0; +} + /** Push a pre-compiled xlat and resumption state onto the stack for evaluation * * In order to use the async unlang processor the calling module needs to establish diff --git a/src/lib/unlang/module.h b/src/lib/unlang/module.h index f4ced552f78..0a0bcd58369 100644 --- a/src/lib/unlang/module.h +++ b/src/lib/unlang/module.h @@ -113,6 +113,8 @@ int unlang_module_push(rlm_rcode_t *p_result, request_t *request, module_instance_t *module_instance, module_method_t method, bool top_frame) CC_HINT(warn_unused_result); +int unlang_module_set_resume(request_t *request, unlang_module_resume_t resume); + unlang_action_t unlang_module_yield_to_subrequest(rlm_rcode_t *p_result, request_t *child, unlang_module_resume_t resume, unlang_module_signal_t signal,