49 #include <freeradius-devel/server/virtual_servers.h>
50 #include <freeradius-devel/server/pair.h>
65 # define PROCESS_TRACE RDEBUG3("Entered state %s", __FUNCTION__)
67 # define PROCESS_TRACE
74 # define PROCESS_CONF_OFFSET(_x) offsetof(PROCESS_INST, sections._x)
77 #if defined(PROCESS_INST) && defined(PROCESS_PACKET_TYPE) && defined(PROCESS_PACKET_CODE_VALID)
80 #ifndef PROCESS_STATE_EXTRA_FIELDS
81 # define PROCESS_STATE_EXTRA_FIELDS
90 size_t section_offset;
103 } fr_process_state_t;
108 #ifndef PROCESS_SEND_RECV
109 #define process_state_packet process_state
110 #define process_state_reply process_state
120 #define UPDATE_STATE_CS(_x) \
122 state = &process_state_ ## _x[request->_x->code]; \
123 memcpy(&cs, (CONF_SECTION * const *) (((uint8_t const *) &inst->sections) + state->section_offset), sizeof(cs)); \
126 #define UPDATE_STATE(_x) state = &process_state_ ## _x [request->_x->code]
128 #define RECV(_x) static inline unlang_action_t recv_ ## _x(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
129 #define SEND(_x) static inline unlang_action_t send_ ## _x(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
130 #define RESUME(_x) static inline unlang_action_t resume_ ## _x(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
131 #define RESUME_NO_MCTX(_x) static inline unlang_action_t resume_ ## _x(rlm_rcode_t *p_result, UNUSED module_ctx_t const *mctx, request_t *request)
144 static inline CC_HINT(always_inline)
149 our_mctx.
rctx = rctx;
151 return method(p_result, &our_mctx, request);
156 #define CALL_RECV(_x) recv_ ## _x(p_result, mctx, request)
160 #define CALL_RECV_RCTX(_x, _rctx) process_with_rctx(p_result, mctx, request, recv_ ## _x, _rctx);
164 #define CALL_SEND(_x) send_ ## _x(p_result, mctx, request)
168 #define CALL_RESUME(_x) resume_ ## _x(p_result, mctx, request)
172 #define CALL_SEND_STATE(_state) state->send(p_result, mctx, request)
176 #define CALL_SEND_TYPE(_x) call_send_type(process_state_reply[(request->reply->code = _x)].send, p_result, mctx, request)
187 return send(p_result, mctx, request);
193 fr_process_state_t
const *state;
198 UPDATE_STATE_CS(packet);
207 REDEBUG(
"Invalid packet type (%u)", request->packet->code);
215 cs, state->rcode, state->resume,
216 NULL, 0, mctx->
rctx);
222 fr_process_state_t
const *state;
228 UPDATE_STATE(packet);
230 request->reply->code = state->packet_type[rcode];
231 if (!request->reply->code) request->reply->code = state->default_reply;
232 #ifdef PROCESS_CODE_DO_NOT_RESPOND
240 return state->send(p_result, mctx, request);
246 fr_process_state_t
const *state;
252 UPDATE_STATE(packet);
254 request->reply->code = state->packet_type[rcode];
255 if (!request->reply->code) request->reply->code = state->default_reply;
256 #ifdef PROCESS_CODE_DO_NOT_RESPOND
269 fr_process_state_t
const *state;
282 UPDATE_STATE_CS(reply);
298 vp->vp_uint32 = request->reply->code;
308 request->reply->code =
vp->vp_uint32;
309 UPDATE_STATE_CS(reply);
313 RWDEBUG(
"Ignoring invalid packet-type &reply.%pP",
vp);
314 goto update_packet_type;
323 cs, state->rcode, state->resume,
324 NULL, 0, mctx->
rctx);
331 fr_process_state_t
const *state;
346 UPDATE_STATE_CS(reply);
349 switch (state->packet_type[rcode]) {
368 (state->packet_type[rcode] != request->reply->code)) {
371 request->reply->code = state->packet_type[rcode];
372 UPDATE_STATE_CS(reply);
377 cs, state->rcode, state->send,
378 NULL, 0, mctx->
rctx);
381 fr_assert(!state->packet_type[rcode] || (state->packet_type[rcode] == request->reply->code));
384 #ifdef PROCESS_CODE_DO_NOT_RESPOND
390 RDEBUG(
"The 'send %s' section returned %s - not sending a response",
399 request->reply->timestamp =
fr_time();
401 #ifdef PROCESS_CODE_DO_NOT_RESPOND
406 RDEBUG(
"Not sending reply to client");
414 #ifdef PROCESS_CODE_DYNAMIC_CLIENT
419 request->reply->timestamp =
fr_time();
433 cs =
inst->sections.add_client;
438 cs =
inst->sections.deny_client;
444 request->component = NULL;
445 request->module = NULL;
450 NULL, 0, mctx->
rctx);
460 cs =
inst->sections.new_client;
465 NULL, 0, mctx->
rctx);
468 #define DYNAMIC_CLIENT_SECTIONS \
470 .section = SECTION_NAME("new", "client"), \
471 .actions = &mod_actions_authorize, \
472 .offset = PROCESS_CONF_OFFSET(new_client), \
475 .section = SECTION_NAME("add", "client"), \
476 .actions = &mod_actions_authorize, \
477 .offset = PROCESS_CONF_OFFSET(add_client), \
480 .section = SECTION_NAME("deny", "client"), \
481 .actions = &mod_actions_authorize, \
482 .offset = PROCESS_CONF_OFFSET(deny_client), \
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
A section grouping multiple CONF_PAIR.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
static fr_dict_attr_t const * attr_packet_type
char const * fr_dict_enum_name_by_value(fr_dict_attr_t const *da, fr_value_box_t const *value)
Lookup the name of an enum value in a fr_dict_attr_t.
module_instance_t const * mi
Instance of the module being instantiated.
void * rctx
Resume ctx that a module previously set.
Temporary structure to hold arguments for module calls.
#define PROCESS_PACKET_TYPE
static fr_process_state_t const process_state[]
#define PROCESS_PACKET_CODE_VALID
#define PROCESS_CODE_DO_NOT_RESPOND
static fr_process_state_t const process_state_reply[]
static fr_process_state_t const process_state_packet[]
#define PROCESS_CODE_DYNAMIC_CLIENT
#define PROCESS_STATE_EXTRA_FIELDS
RECV(for_any_server)
Validate a solicit/rebind/confirm message.
fr_dict_t const ** dict
pointer to local fr_dict_t *
#define PROCESS_TRACE
Trace each state function as it's entered.
module_method_t process
Process packets.
virtual_server_compile_t const * compile_list
list of processing sections
struct fr_process_module_s fr_process_module_t
Common public symbol definition for all process modules.
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
fr_table_num_sorted_t const rcode_table[]
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
void * data
Module's instance data.
unlang_action_t(* module_method_t)(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
Struct exported by a rlm_* module.
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
#define pair_delete_reply(_pair_or_da)
Delete a fr_pair_t in the reply list.
unlang_action_t unlang_module_yield_to_section(rlm_rcode_t *p_result, request_t *request, CONF_SECTION *subcs, rlm_rcode_t default_rcode, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
#define fr_time()
Allow us to arbitrarily manipulate time.
Stores an attribute, a value and various bits of other data.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
#define fr_box_uint32(_val)
Processing sections which are allowed in this virtual server.