The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Functions to allow modules to push resumption frames onto the stack and inform the interpreter about the conditions they need to be resumed under (usually an I/O event or timer event). More...
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/rcode.h>
#include <freeradius-devel/unlang/subrequest.h>
#include <freeradius-devel/unlang/tmpl.h>
Go to the source code of this file.
Typedefs | |
typedef void(* | unlang_module_fd_event_t) (module_ctx_t const *mctx, request_t *request, int fd) |
A callback when the FD is ready for reading. More... | |
typedef void(* | unlang_module_retry_t) (module_ctx_t const *mctx, request_t *request, fr_retry_t const *retry) |
A callback when a retry happens. More... | |
typedef void(* | unlang_module_signal_t) (module_ctx_t const *mctx, request_t *request, fr_signal_t action) |
A callback when the request gets a fr_signal_t. More... | |
Functions | |
int | unlang_module_push (rlm_rcode_t *p_result, request_t *request, module_instance_t *module_instance, module_method_t method, bool top_frame) |
Push a module or submodule onto the stack for evaluation. More... | |
void | unlang_module_retry_now (module_ctx_t const *mctx, request_t *request) |
Run the retry handler. More... | |
int | unlang_module_set_resume (request_t *request, module_method_t resume) |
Change the resume function of a module. More... | |
unlang_action_t | unlang_module_yield (request_t *request, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx) |
Yield a request back to the interpreter from within a module. More... | |
unlang_action_t | unlang_module_yield_to_retry (request_t *request, module_method_t resume, unlang_module_retry_t retry_cb, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx, fr_retry_config_t const *retry_cfg) |
Yield a request back to the interpreter, with retries. More... | |
unlang_action_t | unlang_module_yield_to_section (rlm_rcode_t *p_result, request_t *request, CONF_SECTION *subcs, rlm_rcode_t default_rcode, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx) |
unlang_action_t | unlang_module_yield_to_tmpl (TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, tmpl_t const *vpt, unlang_tmpl_args_t *args, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx) |
Push a pre-compiled tmpl and resumption state onto the stack for evaluation. More... | |
unlang_action_t | unlang_module_yield_to_xlat (TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *xlat, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx) |
Push a pre-compiled xlat and resumption state onto the stack for evaluation. More... | |
Functions to allow modules to push resumption frames onto the stack and inform the interpreter about the conditions they need to be resumed under (usually an I/O event or timer event).
Definition in file module.h.
typedef void(* unlang_module_fd_event_t) (module_ctx_t const *mctx, request_t *request, int fd) |
A callback when the FD is ready for reading.
Used when a module needs to read from an FD. Typically the callback is set, and then the module returns unlang_module_yield().
[in] | mctx | calling context for the module. Contains global, thread-specific, and call-specific data for a module. |
[in] | request | the current request. |
[in] | fd | the file descriptor. |
typedef void(* unlang_module_retry_t) (module_ctx_t const *mctx, request_t *request, fr_retry_t const *retry) |
A callback when a retry happens.
Used when a module needs wait for an event. Typically the callback is set, and then the module returns unlang_module_yield().
[in] | mctx | calling context for the module. Contains global, thread-specific, and call-specific data for a module. |
[in] | request | the request. |
[in] | retry | retry status. "now" is in retry->updated |
typedef void(* unlang_module_signal_t) (module_ctx_t const *mctx, request_t *request, fr_signal_t action) |
A callback when the request gets a fr_signal_t.
A module may call unlang_yeild(), but still need to do something on FR_SIGNAL_DUP. If so, it's set here.
[in] | mctx | calling context for the module. Contains global, thread-specific, and call-specific data for a module. |
[in] | request | The current request. |
[in] | action | which is signalling the request. |
int unlang_module_push | ( | rlm_rcode_t * | p_result, |
request_t * | request, | ||
module_instance_t * | mi, | ||
module_method_t | method, | ||
bool | top_frame | ||
) |
Push a module or submodule onto the stack for evaluation.
[out] | p_result | Where to write the result of calling the module. |
[in] | request | The current request. |
[in] | mi | Instance of the module to call. |
[in] | method | to call. |
[in] | top_frame | Set to UNLANG_TOP_FRAME if the interpreter should return. Set to UNLANG_SUB_FRAME if the interprer should continue. |
Definition at line 53 of file module.c.
void unlang_module_retry_now | ( | module_ctx_t const * | mctx, |
request_t * | request | ||
) |
int unlang_module_set_resume | ( | request_t * | request, |
module_method_t | resume | ||
) |
Change the resume function of a module.
[in] | request | The current request. |
[in] | resume | function to call when the XLAT expansion is complete. |
Definition at line 132 of file module.c.
unlang_action_t unlang_module_yield | ( | request_t * | request, |
module_method_t | resume, | ||
unlang_module_signal_t | signal, | ||
fr_signal_t | sigmask, | ||
void * | rctx | ||
) |
Yield a request back to the interpreter from within a module.
This passes control of the request back to the unlang interpreter, setting callbacks to execute when the request is 'signalled' asynchronously, or whatever timer or I/O event the module was waiting for occurs.
return unlang_module_yield(...)
.[in] | request | The current request. |
[in] | resume | Called on unlang_interpret_mark_runnable(). |
[in] | signal | Called on unlang_action(). |
[in] | sigmask | Set of signals to block. |
[in] | rctx | to pass to the callbacks. |
Definition at line 419 of file module.c.
unlang_action_t unlang_module_yield_to_retry | ( | request_t * | request, |
module_method_t | resume, | ||
unlang_module_retry_t | retry, | ||
unlang_module_signal_t | signal, | ||
fr_signal_t | sigmask, | ||
void * | rctx, | ||
fr_retry_config_t const * | retry_cfg | ||
) |
Yield a request back to the interpreter, with retries.
This passes control of the request back to the unlang interpreter, setting callbacks to execute when the request is 'signalled' asynchronously, or when the retry timer hits.
return unlang_module_yield_to_retry(...)
.[in] | request | The current request. |
[in] | resume | Called on unlang_interpret_mark_runnable(). |
[in] | retry | Called on when a retry timer hits |
[in] | signal | Called on unlang_action(). |
[in] | sigmask | Set of signals to block. |
[in] | rctx | to pass to the callbacks. |
[in] | retry_cfg | to set up the retries |
Definition at line 361 of file module.c.
unlang_action_t unlang_module_yield_to_section | ( | rlm_rcode_t * | p_result, |
request_t * | request, | ||
CONF_SECTION * | subcs, | ||
rlm_rcode_t | default_rcode, | ||
module_method_t | resume, | ||
unlang_module_signal_t | signal, | ||
fr_signal_t | sigmask, | ||
void * | rctx | ||
) |
unlang_action_t unlang_module_yield_to_tmpl | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t * | out, | ||
request_t * | request, | ||
tmpl_t const * | vpt, | ||
unlang_tmpl_args_t * | args, | ||
module_method_t | resume, | ||
unlang_module_signal_t | signal, | ||
fr_signal_t | sigmask, | ||
void * | rctx | ||
) |
Push a pre-compiled tmpl and resumption state onto the stack for evaluation.
In order to use the async unlang processor the calling module needs to establish a resumption point, as the call to an xlat function may require yielding control back to the interpreter.
To simplify the calling conventions, this function is provided to first push a resumption stack frame for the module, and then push a tmpl stack frame.
After pushing those frames the function updates the stack pointer to jump over the resumption frame and execute the tmpl expansion.
When the tmpl interpreter finishes, and pops the tmpl frame, the unlang interpreter will then call the module resumption frame, allowing the module to continue execution.
[in] | ctx | To allocate talloc value boxes and values in. |
[out] | out | Where to write the result of the expansion. |
[in] | request | The current request. |
[in] | vpt | the tmpl to expand |
[in] | args | Arguments which control how to evaluate the various types of xlats. |
[in] | resume | function to call when the XLAT expansion is complete. |
[in] | signal | function to call if a signal is received. |
[in] | sigmask | Signals to block. |
[in] | rctx | to pass to the resume() and signal() callbacks. |
Definition at line 228 of file module.c.
unlang_action_t unlang_module_yield_to_xlat | ( | TALLOC_CTX * | ctx, |
bool * | p_success, | ||
fr_value_box_list_t * | out, | ||
request_t * | request, | ||
xlat_exp_head_t const * | exp, | ||
module_method_t | resume, | ||
unlang_module_signal_t | signal, | ||
fr_signal_t | sigmask, | ||
void * | rctx | ||
) |
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 a resumption point, as the call to an xlat function may require yielding control back to the interpreter.
To simplify the calling conventions, this function is provided to first push a resumption stack frame for the module, and then push an xlat stack frame.
After pushing those frames the function updates the stack pointer to jump over the resumption frame and execute the xlat interpreter.
When the xlat interpreter finishes, and pops the xlat frame, the unlang interpreter will then call the module resumption frame, allowing the module to continue execution.
[in] | ctx | To allocate talloc value boxes and values in. |
[out] | p_success | Whether xlat evaluation was successful. |
[out] | out | Where to write the result of the expansion. |
[in] | request | The current request. |
[in] | exp | XLAT expansion to evaluate. |
[in] | resume | function to call when the XLAT expansion is complete. |
[in] | signal | function to call if a signal is received. |
[in] | sigmask | Signals to block. |
[in] | rctx | to pass to the resume() and signal() callbacks. |
Definition at line 181 of file module.c.