]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add function to change resumption handler for a module.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Aug 2021 18:04:19 +0000 (14:04 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Aug 2021 18:17:10 +0000 (14:17 -0400)
src/lib/unlang/module.c
src/lib/unlang/module.h

index a8e740614a2f544cdd4bd2403cd49fc47ec88422..f14521c285ea57cde58071d8152c9baeedf3b49f 100644 (file)
@@ -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
index f4ced552f787325b16f4ecf6cb26543515b00ee9..0a0bcd583694d54516c7b91efb83dbcfc5801933 100644 (file)
@@ -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,