The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
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: 6d152068e0ee4248acd382c6f8dbfcedde25c792 $
19 * @file src/process/arp/base.c
20 * @brief ARP processing.
21 *
22 * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
23 */
24#include <freeradius-devel/util/debug.h>
25#include <freeradius-devel/arp/arp.h>
26#include <freeradius-devel/unlang/interpret.h>
27
28static fr_dict_t const *dict_arp;
29
35
37
43
54
55typedef struct {
56 process_arp_sections_t sections; //!< First, as the state machine finds them by offset.
57
58 bool test;
60
61#define FR_ARP_PROCESS_CODE_VALID(_x) (FR_ARP_PACKET_CODE_VALID(_x) || (_x == FR_ARP_DO_NOT_RESPOND))
62
63#define PROCESS_PACKET_TYPE fr_arp_packet_code_t
64#define PROCESS_CODE_MAX FR_ARP_CODE_MAX
65#define PROCESS_CODE_DO_NOT_RESPOND FR_ARP_DO_NOT_RESPOND
66#define PROCESS_PACKET_CODE_VALID FR_ARP_PROCESS_CODE_VALID
67#define PROCESS_INST process_arp_t
68#include <freeradius-devel/server/process.h>
69
70static fr_process_state_t const process_state[] = {
71 [ FR_ARP_REQUEST ] = {
72 .packet_type = {
76
83 },
84 .default_rcode = RLM_MODULE_NOOP,
85 .recv = recv_generic,
86 .resume = resume_recv_generic,
87 .section_offset = PROCESS_CONF_OFFSET(request),
88 },
89 [ FR_ARP_REPLY ] = {
90 .packet_type = {
94
101 },
102 .default_rcode = RLM_MODULE_NOOP,
103 .result_rcode = RLM_MODULE_OK,
104 .send = send_generic,
105 .resume = resume_send_generic,
106 .section_offset = PROCESS_CONF_OFFSET(reply),
107 },
108
110 .packet_type = {
114
121 },
122 .default_rcode = RLM_MODULE_NOOP,
123 .recv = recv_generic,
124 .resume = resume_recv_generic,
125 .section_offset = PROCESS_CONF_OFFSET(reverse_request),
126 },
128 .packet_type = {
132
139 },
140 .default_rcode = RLM_MODULE_NOOP,
141 .result_rcode = RLM_MODULE_OK,
142 .send = send_generic,
143 .resume = resume_send_generic,
144 .section_offset = PROCESS_CONF_OFFSET(reverse_reply),
145 },
146
147 // @todo - recv reply, to look at other replies.
148
150 .packet_type = {
154
161 },
162 .default_rcode = RLM_MODULE_NOOP,
163 .result_rcode = RLM_MODULE_HANDLED,
164 .send = send_generic,
165 .resume = resume_send_generic,
166 .section_offset = PROCESS_CONF_OFFSET(do_not_respond),
167 },
168};
169
171{
172 fr_process_state_t const *state;
173
175
178
179 request->component = "arp";
180 request->module = NULL;
181 fr_assert(request->proto_dict == dict_arp);
182
183 UPDATE_STATE(packet);
184
185 if (!state->recv) {
186 REDEBUG("Invalid packet type (%u)", request->packet->code);
188 }
189
190 return state->recv(p_result, mctx, request);
191}
192
193
195 {
196 .section = SECTION_NAME("recv", "Request"),
197 .actions = &mod_actions_postauth,
198 .offset = PROCESS_CONF_OFFSET(request),
199 },
200 {
201 .section = SECTION_NAME("send", "Reply"),
203 .offset = PROCESS_CONF_OFFSET(reply),
204 },
205 { /* we can listen for others ARP replies, too */
206 .section = SECTION_NAME("recv", "Reply"),
208 .offset = PROCESS_CONF_OFFSET(recv_reply),
209 },
210 {
211 .section = SECTION_NAME("recv", "Reverse-Request"),
213 .offset = PROCESS_CONF_OFFSET(reverse_request),
214 },
215 {
216 .section = SECTION_NAME("send", "Reverse-Reply"),
218 .offset = PROCESS_CONF_OFFSET(reverse_reply),
219 },
220 {
221 .section = SECTION_NAME("send", "Do-Not-Respond"),
223 .offset = PROCESS_CONF_OFFSET(do_not_respond),
224 },
226};
227
228
231 .common = {
232 .magic = MODULE_MAGIC_INIT,
233 .name = "arp",
235 MODULE_RCTX(process_rctx_t)
236 },
237 .process = mod_process,
238 .compile_list = compile_list,
239 .dict = &dict_arp,
240 .packet_type = &attr_packet_type
241};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
@ FR_ARP_REVERSE_REQUEST
Definition arp.h:71
@ FR_ARP_REQUEST
Definition arp.h:69
@ FR_ARP_DO_NOT_RESPOND
Definition arp.h:74
@ FR_ARP_REVERSE_REPLY
Definition arp.h:72
@ FR_ARP_REPLY
Definition arp.h:70
static uint8_t request[4]
static uint8_t reply[4]
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:316
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:329
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:335
Specifies an attribute which must be present for the module to function.
Definition dict.h:315
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:328
#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_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
bool test
Definition base.c:58
uint64_t nothing
Definition base.c:45
process_arp_sections_t sections
First, as the state machine finds them by offset.
Definition base.c:56
CONF_SECTION * request
Definition base.c:47
CONF_SECTION * reverse_reply
Definition base.c:51
fr_dict_autoload_t process_arp_dict[]
Definition base.c:31
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition base.c:170
fr_dict_attr_autoload_t process_arp_dict_attr[]
Definition base.c:39
static const virtual_server_compile_t compile_list[]
Definition base.c:194
CONF_SECTION * reply
Definition base.c:48
static fr_process_state_t const process_state[]
Definition base.c:70
CONF_SECTION * recv_reply
Definition base.c:49
static fr_dict_t const * dict_arp
Definition base.c:28
CONF_SECTION * reverse_request
Definition base.c:50
fr_process_module_t process_arp
Definition base.c:230
#define PROCESS_PACKET_CODE_VALID
Definition base.c:66
CONF_SECTION * do_not_respond
Definition base.c:52
#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,...)
@ 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 RETURN_UNLANG_FAIL
Definition rcode.h:69
#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:297
#define MODULE_RCTX(_ctype)
Definition module.h:262
#define MODULE_INST(_ctype)
Definition module.h:260
#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.