The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
module_priv.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software Foundation,
15  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16  */
17 
18 /**
19  * $Id: f19bb00ad70080e814999bec64ec948485c40a38 $
20  *
21  * @file unlang/module_priv.h
22  * @brief Declarations for the unlang module interface
23  *
24  * @copyright 2006-2019 The FreeRADIUS server project
25  */
26 #include "unlang_priv.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /** A call to a module method
33  *
34  */
35 typedef struct {
36  unlang_t self; //!< Common fields in all #unlang_t tree nodes.
37  call_env_t const *call_env; //!< The per call parsed call environment.
38  module_method_call_t mmc; //!< Everything needed to call a module method.
40 
41 /** A module stack entry
42  *
43  * Represents a single module call on the unlang stack.
44  */
45 typedef struct {
46  char const *previous_module; //!< old request->module
47  module_thread_instance_t *thread; //!< thread-local data for this module.
48  ///< Caching is necessary in the frame state
49  ///< structure because the #unlang_t tree is
50  ///< shared between all threads, so we can't
51  ///< cache thread-specific data in the #unlang_t.
52  call_env_result_t env_result; //!< Result of the previous call environment expansion.
53  void *env_data; //!< Expanded per call "call environment" tmpls.
54 
55 #ifndef NDEBUG
56  int unlang_indent; //!< Record what this was when we entered the module.
57 #endif
58 
59  /** @name rcode output
60  * @{
61  */
62  rlm_rcode_t *p_result; //!< Where to store the result.
63  rlm_rcode_t rcode; //!< the result, only for unlang_module_resume_final.
64  bool rcode_set; //!< Overwrite the current rcode for the section with
65  ///< the module rcode.
66  /** @} */
67 
68  /** @name Resumption and signalling
69  * @{
70  */
71  void *rctx; //!< for resume / signal
72  module_method_t resume; //!< resumption handler
73  unlang_module_signal_t signal; //!< for signal handlers
74  fr_signal_t sigmask; //!< Signals to block.
75 
76  /** @} */
77 
78  /** @name Retry handlers.
79  * @{
80  */
81  module_method_t retry_resume; //!< which stops retries on resume
82  unlang_module_retry_t retry_cb; //!< callback to run on timeout
83  void *timeout_rctx; //!< rctx data to pass to timeout callback
84  module_instance_t const *mi; //!< Module instance to pass to callbacks.
86 
87  fr_event_timer_t const *ev; //!< retry timer just for this module.
88  fr_retry_t retry; //!< retry timers, etc.
89 
90  /** @} */
91 
93 
95 {
98 }
99 
101 {
102  return (unlang_t *)p;
103 }
104 
105 #ifdef __cplusplus
106 }
107 #endif
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition: build.h:165
call_env_result_t
Definition: call_env.h:51
Structure containing both a talloc pool, a list of parsed call_env_pairs.
Definition: call_env.h:247
A timer event.
Definition: event.c:102
static unlang_module_t * unlang_generic_to_module(unlang_t const *p)
Definition: module_priv.h:94
fr_event_timer_t const * ev
retry timer just for this module.
Definition: module_priv.h:87
rlm_rcode_t rcode
the result, only for unlang_module_resume_final.
Definition: module_priv.h:63
module_instance_t const * mi
Module instance to pass to callbacks.
Definition: module_priv.h:84
module_method_t resume
resumption handler
Definition: module_priv.h:72
static unlang_t * unlang_module_to_generic(unlang_module_t *p)
Definition: module_priv.h:100
char const * previous_module
old request->module
Definition: module_priv.h:46
fr_signal_t sigmask
Signals to block.
Definition: module_priv.h:74
module_method_t retry_resume
which stops retries on resume
Definition: module_priv.h:81
bool rcode_set
Overwrite the current rcode for the section with the module rcode.
Definition: module_priv.h:64
call_env_result_t env_result
Result of the previous call environment expansion.
Definition: module_priv.h:52
module_method_call_t mmc
Everything needed to call a module method.
Definition: module_priv.h:38
fr_retry_t retry
retry timers, etc.
Definition: module_priv.h:88
void * env_data
Expanded per call "call environment" tmpls.
Definition: module_priv.h:53
rlm_rcode_t * p_result
Where to store the result.
Definition: module_priv.h:62
module_thread_instance_t * thread
thread-local data for this module.
Definition: module_priv.h:47
unlang_module_signal_t signal
for signal handlers
Definition: module_priv.h:73
int unlang_indent
Record what this was when we entered the module.
Definition: module_priv.h:56
void * timeout_rctx
rctx data to pass to timeout callback
Definition: module_priv.h:83
void * rctx
for resume / signal
Definition: module_priv.h:71
call_env_t const * call_env
The per call parsed call environment.
Definition: module_priv.h:37
unlang_module_retry_t retry_cb
callback to run on timeout
Definition: module_priv.h:82
A module stack entry.
Definition: module_priv.h:45
A call to a module method.
Definition: module_priv.h:35
The output of module_rlm_by_name_and_method.
Definition: module_rlm.h:62
rlm_rcode_t
Return codes indicating the result of the module call.
Definition: rcode.h:40
unlang_action_t(* module_method_t)(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
Definition: module.h:68
Module instance data.
Definition: module.h:265
Per thread per instance data.
Definition: module.h:347
fr_signal_t
Definition: signal.h:48
fr_assert(0)
#define talloc_get_type_abort_const
Definition: talloc.h:282
void(* unlang_module_retry_t)(module_ctx_t const *mctx, request_t *request, fr_retry_t const *retry)
A callback when a retry happens.
Definition: module.h:52
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.
Definition: module.h:80
Private interpreter structures and functions.
@ UNLANG_TYPE_MODULE
Module method.
Definition: unlang_priv.h:46
unlang_type_t type
The specialisation of this node.
Definition: unlang_priv.h:117
A node in a graph of unlang_op_t (s) that we execute.
Definition: unlang_priv.h:112