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: 0b3e9532c1e274d03b3c2b3c4c85f10f0fcab96c $
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  module_instance_t *instance; //!< Global instance of the module we're calling.
38  module_method_t method; //!< The entry point into the module.
39  call_env_t const *call_env; //!< The per call parsed call environment.
41 
42 /** A module stack entry
43  *
44  * Represents a single module call on the unlang stack.
45  */
46 typedef struct {
47  char const *previous_module; //!< old request->module
48  module_thread_instance_t *thread; //!< thread-local data for this module.
49  ///< Caching is necessary in the frame state
50  ///< structure because the #unlang_t tree is
51  ///< shared between all threads, so we can't
52  ///< cache thread-specific data in the #unlang_t.
53  call_env_result_t env_result; //!< Result of the previous call environment expansion.
54  void *env_data; //!< Expanded per call "call environment" tmpls.
55 
56 #ifndef NDEBUG
57  int unlang_indent; //!< Record what this was when we entered the module.
58 #endif
59 
60  /** @name rcode output
61  * @{
62  */
63  rlm_rcode_t *p_result; //!< Where to store the result.
64  rlm_rcode_t rcode; //!< the result, only for unlang_module_resume_final.
65  bool set_rcode; //!< Overwrite the current rcode for the section with
66  ///< the module rcode.
67  /** @} */
68 
69  /** @name Resumption and signalling
70  * @{
71  */
72  void *rctx; //!< for resume / signal
73  module_method_t resume; //!< resumption handler
74  unlang_module_signal_t signal; //!< for signal handlers
75  fr_signal_t sigmask; //!< Signals to block.
76 
77  /** @} */
78 
79  /** @name Retry handlers.
80  * @{
81  */
82  fr_event_timer_t const *ev; //!< retry timer just for this module.
83  fr_retry_t retry; //!< retry timers, etc.
84 
85  /** @} */
86 
88 
90 {
93 }
94 
96 {
97  return (unlang_t *)p;
98 }
99 
100 #ifdef __cplusplus
101 }
102 #endif
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition: build.h:165
call_env_result_t
Definition: call_env.h:49
Structure containing both a talloc pool, a list of parsed call_env_pairs.
Definition: call_env.h:228
A timer event.
Definition: event.c:102
static unlang_module_t * unlang_generic_to_module(unlang_t const *p)
Definition: module_priv.h:89
fr_event_timer_t const * ev
retry timer just for this module.
Definition: module_priv.h:82
rlm_rcode_t rcode
the result, only for unlang_module_resume_final.
Definition: module_priv.h:64
module_method_t resume
resumption handler
Definition: module_priv.h:73
module_instance_t * instance
Global instance of the module we're calling.
Definition: module_priv.h:37
static unlang_t * unlang_module_to_generic(unlang_module_t *p)
Definition: module_priv.h:95
char const * previous_module
old request->module
Definition: module_priv.h:47
fr_signal_t sigmask
Signals to block.
Definition: module_priv.h:75
bool set_rcode
Overwrite the current rcode for the section with the module rcode.
Definition: module_priv.h:65
call_env_result_t env_result
Result of the previous call environment expansion.
Definition: module_priv.h:53
fr_retry_t retry
retry timers, etc.
Definition: module_priv.h:83
void * env_data
Expanded per call "call environment" tmpls.
Definition: module_priv.h:54
rlm_rcode_t * p_result
Where to store the result.
Definition: module_priv.h:63
module_thread_instance_t * thread
thread-local data for this module.
Definition: module_priv.h:48
unlang_module_signal_t signal
for signal handlers
Definition: module_priv.h:74
int unlang_indent
Record what this was when we entered the module.
Definition: module_priv.h:57
module_method_t method
The entry point into the module.
Definition: module_priv.h:38
void * rctx
for resume / signal
Definition: module_priv.h:72
call_env_t const * call_env
The per call parsed call environment.
Definition: module_priv.h:39
A module stack entry.
Definition: module_priv.h:46
A call to a module method.
Definition: module_priv.h:35
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:69
Per instance data.
Definition: module.h:169
Per thread per instance data.
Definition: module.h:215
fr_signal_t
Definition: signal.h:48
fr_assert(0)
#define talloc_get_type_abort_const
Definition: talloc.h:270
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:79
Private interpreter structures and functions.
@ UNLANG_TYPE_MODULE
Module method.
Definition: unlang_priv.h:56
unlang_type_t type
The specialisation of this node.
Definition: unlang_priv.h:127
A node in a graph of unlang_op_t (s) that we execute.
Definition: unlang_priv.h:122