The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
base.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: fa6a76eef9efc89b07cc502cd143171c8370599b $
19 * @file src/process/vmps/base.c
20 * @brief VMPS processing.
21 *
22 * @copyright 2018 The Freeradius server project.
23 * @copyright 2018 Alan DeKok (aland@deployingradius.com)
24 */
25#include <freeradius-devel/io/application.h>
26#include <freeradius-devel/util/dict.h>
27#include <freeradius-devel/util/debug.h>
28#include <freeradius-devel/vmps/vmps.h>
29
30#include <freeradius-devel/protocol/vmps/vmps.h>
31
32static fr_dict_t const *dict_vmps;
33
39
41
47
57
61
62#define PROCESS_PACKET_TYPE fr_vmps_packet_code_t
63#define PROCESS_CODE_MAX FR_VMPS_CODE_MAX
64#define PROCESS_CODE_DO_NOT_RESPOND FR_VMPS_DO_NOT_RESPOND
65#define PROCESS_PACKET_CODE_VALID FR_VMPS_PACKET_CODE_VALID
66#define PROCESS_INST process_vmps_t
67#include <freeradius-devel/server/process.h>
68
69static fr_process_state_t const process_state[] = {
70 [FR_PACKET_TYPE_VALUE_JOIN_REQUEST] = {
71 .packet_type = {
72 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_JOIN_RESPONSE,
73 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_JOIN_RESPONSE,
74 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_JOIN_RESPONSE,
75
76 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
77 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
78 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
79 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
80 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
81 [RLM_MODULE_TIMEOUT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND
82 },
83 .default_rcode = RLM_MODULE_NOOP,
84 .recv = recv_generic,
85 .resume = resume_recv_generic,
86 .section_offset = PROCESS_CONF_OFFSET(join_request),
87 },
88 [FR_PACKET_TYPE_VALUE_JOIN_RESPONSE] = {
89 .packet_type = {
90 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_JOIN_RESPONSE,
91 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_JOIN_RESPONSE,
92 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_JOIN_RESPONSE,
93
94 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
95 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
96 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
97 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
98 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
99 [RLM_MODULE_TIMEOUT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND
100 },
101 .default_rcode = RLM_MODULE_NOOP,
102 .result_rcode = RLM_MODULE_OK,
103 .send = send_generic,
104 .resume = resume_send_generic,
105 .section_offset = PROCESS_CONF_OFFSET(join_response),
106 },
107
108 [FR_PACKET_TYPE_VALUE_RECONFIRM_REQUEST] = {
109 .packet_type = {
110 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE,
111 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE,
112 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE,
113
114 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
115 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
116 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
117 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
118 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
119 [RLM_MODULE_TIMEOUT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND
120 },
121 .default_rcode = RLM_MODULE_NOOP,
122 .recv = recv_generic,
123 .resume = resume_recv_generic,
124 .section_offset = PROCESS_CONF_OFFSET(reconfirm_request),
125 },
126 [FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE] = {
127 .packet_type = {
128 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE,
129 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE,
130 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE,
131
132 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
133 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
134 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
135 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
136 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND,
137 [RLM_MODULE_TIMEOUT] = FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND
138 },
139 .default_rcode = RLM_MODULE_NOOP,
140 .result_rcode = RLM_MODULE_OK,
141 .send = send_generic,
142 .resume = resume_send_generic,
143 .section_offset = PROCESS_CONF_OFFSET(reconfirm_response),
144 },
145
147 .packet_type = {
152
159 },
160 .default_rcode = RLM_MODULE_NOOP,
161 .send = send_generic,
162 .resume = resume_send_generic,
163 .section_offset = PROCESS_CONF_OFFSET(do_not_respond),
164 },
165};
166
167
168static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
169{
170 fr_process_state_t const *state;
171
173
175 fr_assert(PROCESS_PACKET_CODE_VALID(request->packet->code));
176
177 request->component = "vmps";
178 request->module = NULL;
179 fr_assert(request->proto_dict == dict_vmps);
180
181 UPDATE_STATE(packet);
182
183 if (!state->recv) {
184 REDEBUG("Invalid packet type (%u)", request->packet->code);
186 }
187
188 return state->recv(p_result, mctx, request);
189}
190
192 {
193 .section = SECTION_NAME("recv", "Join-Request"),
194 .actions = &mod_actions_authorize,
195 .offset = PROCESS_CONF_OFFSET(join_request),
196 },
197 {
198 .section = SECTION_NAME("send", "Join-Response"),
200 .offset = PROCESS_CONF_OFFSET(join_response),
201 },
202 {
203 .section = SECTION_NAME("recv", "Reconfirm-Request"),
205 .offset = PROCESS_CONF_OFFSET(reconfirm_request),
206 },
207 {
208 .section = SECTION_NAME("send", "Reconfirm-Response"),
210 .offset = PROCESS_CONF_OFFSET(reconfirm_response),
211 },
212 {
213 .section = SECTION_NAME("send", "Do-Not-Respond"),
215 .offset = PROCESS_CONF_OFFSET(do_not_respond),
216 },
217
219};
220
221
224 .common = {
225 .magic = MODULE_MAGIC_INIT,
226 .name = "vmps",
228 MODULE_RCTX(process_rctx_t)
229 },
230 .process = mod_process,
231 .compile_list = compile_list,
232 .dict = &dict_vmps,
233 .packet_type = &attr_packet_type
234};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:292
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:305
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
Specifies an attribute which must be present for the module to function.
Definition dict.h:291
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:304
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
fr_dict_attr_t const * attr_packet_type
Definition base.c:91
@ FR_TYPE_UINT32
32 Bit unsigned integer.
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:45
unlang_mod_actions_t const mod_actions_postauth
Definition mod_action.c:92
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
Definition mod_action.h:69
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:42
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition base.c:168
static const virtual_server_compile_t compile_list[]
Definition base.c:192
static fr_process_state_t const process_state[]
Definition base.c:68
#define PROCESS_PACKET_CODE_VALID
Definition base.c:64
CONF_SECTION * do_not_respond
Definition base.c:55
CONF_SECTION * reconfirm_response
Definition base.c:54
fr_dict_autoload_t process_vmps_dict[]
Definition base.c:35
process_vmps_sections_t sections
Definition base.c:59
fr_process_module_t process_vmps
Definition base.c:223
fr_dict_attr_autoload_t process_vmps_dict_attr[]
Definition base.c:43
CONF_SECTION * reconfirm_request
Definition base.c:53
CONF_SECTION * join_request
Definition base.c:51
CONF_SECTION * join_response
Definition base.c:52
static fr_dict_t const * dict_vmps
Definition base.c:32
#define PROCESS_TRACE
Trace each state function as it's entered.
Definition process.h:55
#define PROCESS_CONF_OFFSET(_x)
Definition process.h:79
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
#define fr_assert(_expr)
Definition rad_assert.h:37
#define REDEBUG(fmt,...)
#define RETURN_UNLANG_FAIL
Definition rcode.h:63
@ RLM_MODULE_INVALID
The module considers the request invalid.
Definition rcode.h:51
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:49
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:48
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:52
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:47
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:56
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:53
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:55
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:54
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:50
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:39
void * data
Module's instance data.
Definition module.h:293
#define MODULE_RCTX(_ctype)
Definition module.h:259
#define MODULE_INST(_ctype)
Definition module.h:257
#define talloc_get_type_abort_const
Definition talloc.h:117
section_name_t const * section
Identifier for the section.
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.
@ FR_VMPS_DO_NOT_RESPOND
Definition vmps.h:55