The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
virtual_servers.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 of the License, or
6 * (at your option) 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
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 11f219b11058a672e94830f4e15dae24bb59eed5 $
20 *
21 * @file src/lib/server/virtual_servers.h
22 * @brief Declarations for functions that parse and manipulate virtual server sections.
23 *
24 * @copyright 2019 The FreeRADIUS server project
25 */
26
27#include <freeradius-devel/server/virtual_servers.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
35
36#include <freeradius-devel/io/schedule.h>
37#include <freeradius-devel/server/cf_parse.h>
38#include <freeradius-devel/unlang/module.h>
39#include <freeradius-devel/unlang/mod_action.h>
40#include <freeradius-devel/util/dict.h>
41
44
45/** @name Debug functions
46 * @{
47 */
49
51/** @} */
52
53/** @name Resolution functions
54 * @{
55 */
57/** @} */
58
59/** @name Callbacks for dealing with transports
60 *
61 * @{
62 */
63int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent,
64 CONF_ITEM *ci, conf_parser_t const *rule);
65/** @} */
66
67/** @name Namespace management
68 *
69 * @{
70 */
71fr_dict_t const *virtual_server_dict_by_name(char const *virtual_server) CC_HINT(nonnull);
72
73fr_dict_t const *virtual_server_dict_by_cs(CONF_SECTION const *server_cs) CC_HINT(nonnull);
74
76
78 char const *virtual_server, fr_dict_t const *namespace,
79 CONF_ITEM *ci) CC_HINT(nonnull(2,3));
80/** @} */
81
82/** @name Lookup and namespace management
83 *
84 * @{
85 */
87
89
90virtual_server_t const *virtual_server_find(char const *name) CC_HINT(nonnull);
91
93
94/** Additional validation rules for virtual server lookup
95 *
96 * This is used to ensure that the virtual server we find matches
97 * the requirements of the caller.
98 *
99 * This should be passed in the rule calling this function:
100 @code{.c}
101 { FR_CONF_OFFSET_TYPE_FLAGS("virtual_server", FR_TYPE_VOID, 0, module_conf_t, virtual_server),
102 .func = virtual_server_cf_parse,
103 .uctx = &(virtual_server_cf_parse_uctx_t){ .process_module_name = "eap_aka"} },
104 @endcode
105 *
106 * @note process_module_name is the name field in the exported symbol of the module.
107 *
108 * The double dereference is to work around compile time constant issues.
109 */
110typedef struct {
111 char const *process_module_name; //!< Virtual server we find must use this
112 ///< this process module. This is a string
113 ///< identifier as the process modules are
114 ///< often not loaded at the same time as the modules
115 ///< and this makes ordering issues easier to deal with.
116 ///< Ignored if NULL.
117
118 fr_dict_t **required_dict; //!< Virtual server we find must have this
119 ///< dictionary. Ignored if NULL
121
122int virtual_server_cf_parse(TALLOC_CTX *ctx, void *out, void *parent,
123 CONF_ITEM *ci, conf_parser_t const *rule) CC_HINT(nonnull(2,4));
124/** @} */
125
127bool listen_record(fr_listen_t *li) CC_HINT(nonnull);
128
129/** Processing sections which are allowed in this virtual server.
130 *
131 */
133 section_name_t const *section; //!< Identifier for the section.
134 size_t offset; //!< where the CONF_SECTION pointer is written
135 bool dont_cache; //!< If true, the CONF_SECTION pointer won't be written
136 ///< and the offset will be ignored.
137 size_t instruction; //!< where the instruction pointer is written
138 unlang_mod_actions_t const *actions; //!< Default actions for this section.
139 section_name_t const **methods; //!< list of auxilliary module methods which are allowed in
140 ///< if the main name doesn't match.
141};
142
143#define COMPILE_TERMINATOR { .section = NULL }
144
146
148
149unlang_action_t virtual_server_push(unlang_result_t *p_result, request_t *request, virtual_server_t const *vs, bool top_frame) CC_HINT(nonnull(2,3));
150
151/** @name Parsing, bootstrap and instantiation
152 *
153 * @{
154 */
155int virtual_server_section_attribute_define(CONF_SECTION *server_cs, char const *subcs_name,
156 fr_dict_attr_t const *da) CC_HINT(nonnull);
157
159
161
162int virtual_servers_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el) CC_HINT(nonnull);
163
164int virtual_servers_instantiate(void) CC_HINT(nonnull);
165
167
168int virtual_servers_free(void);
169
170int virtual_servers_init(void) CC_HINT(nonnull);
171/** @} */
172
173#ifdef __cplusplus
174}
175#endif
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:599
Common header for all CONF_* types.
Definition cf_priv.h:49
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
Stores all information relating to an event list.
Definition event.c:377
static const conf_parser_t config[]
Definition base.c:186
static char const * name
The scheduler.
Definition schedule.c:125
Section name identifier.
Definition section.h:44
Module instance data.
Definition module.h:285
static const uchar sc[16]
Definition smbdes.c:115
static fr_event_list_t * el
static fr_slen_t parent
Definition pair.h:841
static fr_slen_t data
Definition value.h:1291
int nonnull(2, 5))
static size_t char ** out
Definition value.h:1023
section_name_t const * section
Identifier for the section.
bool listen_record(fr_listen_t *li)
Record that we're listening on a particular IP / port.
unlang_action_t virtual_server_push(unlang_result_t *p_result, request_t *request, virtual_server_t const *vs, bool top_frame))
Set the request processing function.
int virtual_server_section_register(virtual_server_t *vs, virtual_server_compile_t const *entry)
Register name1 / name2 as allowed processing sections.
int virtual_servers_bootstrap(CONF_SECTION *config)
Load protocol modules and call their bootstrap methods.
const conf_parser_t virtual_servers_on_read_config[]
fr_dict_t const * virtual_server_dict_by_name(char const *virtual_server)
Return the namespace for the named virtual server.
char const * process_module_name
Virtual server we find must use this this process module.
module_instance_t * virtual_server_listener_by_data(void const *data)
Resolve proto data to a module instance.
size_t offset
where the CONF_SECTION pointer is written
section_name_t const ** virtual_server_section_methods(virtual_server_t const *vs, section_name_t const *section)
Find the component for a section.
int virtual_servers_open(fr_schedule_t *sc)
Open all the listen sockets.
fr_dict_t ** required_dict
Virtual server we find must have this dictionary.
int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.
const conf_parser_t virtual_servers_config[]
int virtual_server_cf_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule))
virtual_server_t const * virtual_server_find(char const *name)
Return virtual server matching the specified name.
fr_dict_t const * virtual_server_dict_by_child_ci(CONF_ITEM const *ci)
Return the namespace for a given virtual server specified by a CONF_ITEM within the virtual server.
int virtual_server_has_namespace(CONF_SECTION **out, char const *virtual_server, fr_dict_t const *namespace, CONF_ITEM *ci))
Verify that a given virtual_server exists and is of a particular namespace.
fr_listen_t * listen_find_any(fr_listen_t *li)
See if another global listener is using a particular IP / port.
int virtual_server_section_attribute_define(CONF_SECTION *server_cs, char const *subcs_name, fr_dict_attr_t const *da)
Define a values for Auth-Type attributes by the sections present in a virtual-server.
void virtual_servers_thread_detach(void)
Free thread-specific data for all process modules and listeners.
void virtual_server_process_debug(void)
Print all the loaded process module instances.
CONF_SECTION * virtual_server_cs(virtual_server_t const *vs)
Return the configuration section for a virtual server.
fr_dict_t const * virtual_server_dict_by_cs(CONF_SECTION const *server_cs)
Return the namespace for the virtual server specified by a config section.
int virtual_servers_init(void)
Performs global initialisation for the virtual server code.
void virtual_server_listen_debug(void)
Print all the loaded listener instances.
int virtual_servers_instantiate(void)
Instantiate all the virtual servers.
virtual_server_t const * virtual_server_by_child(CONF_ITEM const *ci)
Find a virtual server using one of its sections.
int virtual_servers_free(void)
bool dont_cache
If true, the CONF_SECTION pointer won't be written and the offset will be ignored.
size_t instruction
where the instruction pointer is written
int virtual_servers_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el)
Perform thread instantiation for all process modules and listeners.
virtual_server_t const * virtual_server_from_cs(CONF_SECTION *server_cs)
Resolve a CONF_SECTION to a virtual server.
section_name_t const ** methods
list of auxilliary module methods which are allowed in if the main name doesn't match.
unlang_mod_actions_t const * actions
Default actions for this section.
Additional validation rules for virtual server lookup.
Processing sections which are allowed in this virtual server.