48#include <freeradius-devel/server/virtual_servers.h> 
   49#include <freeradius-devel/server/pair.h> 
   50#include <freeradius-devel/server/process_types.h> 
   55#  define PROCESS_TRACE RDEBUG3("Entered state %s", __FUNCTION__) 
   64#  error PROCESS_INST must be defined to the C type of the process instance e.g. process_bfd_t 
   68#  define PROCESS_RCTX  process_rctx_t 
   71#if defined(PROCESS_RCTX) && defined(PROCESS_RCTX_EXTRA_FIELDS) 
   72#  error Only one of PROCESS_RCTX (the type of the rctx struct) OR PROCESS_RCTX_EXTRA_FIELDS (extra fields for the common rctx struct) can be defined. 
   75#ifndef PROCESS_RCTX_RESULT 
   76#  define PROCESS_RCTX_RESULT result 
   79#define PROCESS_CONF_OFFSET(_x) offsetof(PROCESS_INST, sections._x) 
   80#define RESULT_UNUSED           UNUSED 
   82#if defined(PROCESS_INST) && defined(PROCESS_PACKET_TYPE) && defined(PROCESS_PACKET_CODE_VALID) 
   85#ifndef PROCESS_STATE_EXTRA_FIELDS 
   86#  define PROCESS_STATE_EXTRA_FIELDS 
   89#ifndef PROCESS_RCTX_EXTRA_FIELDS 
   90#  define PROCESS_RCTX_EXTRA_FIELDS 
   98        size_t                  section_offset; 
 
  118        PROCESS_RCTX_EXTRA_FIELDS
 
  124#ifndef PROCESS_SEND_RECV 
  125#define process_state_packet process_state 
  126#define process_state_reply process_state 
  136#define UPDATE_STATE_CS(_x) \ 
  138        state = &process_state_ ## _x[request->_x->code]; \ 
  139        memcpy(&cs, (CONF_SECTION * const *) (((uint8_t const *) &inst->sections) + state->section_offset), sizeof(cs)); \ 
  142#define UPDATE_STATE(_x) state = &process_state_ ## _x [request->_x->code] 
  144#define RECV(_x) static inline unlang_action_t recv_ ## _x(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) 
  145#define SEND(_x) static inline unlang_action_t send_ ## _x(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) 
  146#define SEND_NO_RESULT(_x) static inline unlang_action_t send_ ## _x(UNUSED unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) 
  147#define RESUME(_x) static inline unlang_action_t resume_ ## _x(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) 
  148#define RESUME_FLAG(_x, _p_result_flag, _mctx_flag) static inline unlang_action_t resume_ ## _x(_p_result_flag unlang_result_t *p_result, _mctx_flag module_ctx_t const *mctx, request_t *request) 
  159#define RESULT_RCODE    (((PROCESS_RCTX *)mctx->rctx)->result.rcode) 
  160#define RESULT_P        process_result_reset(&(((PROCESS_RCTX *)mctx->rctx)->result), state) 
  173static inline CC_HINT(always_inline)
 
  178        our_mctx.
rctx = rctx;
 
  180        return method(p_result, &our_mctx, request);
 
  185#define CALL_RECV(_x) recv_ ## _x(p_result, mctx, request) 
  189#define CALL_RECV_RCTX(_x, _rctx) process_with_rctx(p_result, mctx, request, recv_ ## _x, _rctx); 
  193#define CALL_SEND(_x) send_ ## _x(p_result, mctx, request) 
  197#define CALL_RESUME(_x) resume_ ## _x(p_result, mctx, request) 
  201#define CALL_SEND_STATE(_state) state->send(p_result, mctx, request) 
  205#define CALL_SEND_TYPE(_x) call_send_type(process_state_reply[(request->reply->code = _x)].send, p_result, mctx, request) 
  216        return send(p_result, mctx, request);
 
  222        fr_process_state_t 
const        *state;
 
  227        UPDATE_STATE_CS(packet);
 
  236                        REDEBUG(
"Invalid packet type (%u)", request->packet->code);
 
  244                                              cs, state->default_rcode, state->resume,
 
  245                                              NULL, 0, mctx->
rctx);
 
  251        fr_process_state_t 
const        *state;
 
  257        UPDATE_STATE(packet);
 
  259        request->reply->code = state->packet_type[rcode];
 
  260        if (!request->reply->code) request->reply->code = state->default_reply;
 
  261#ifdef PROCESS_CODE_DO_NOT_RESPOND 
  269        return state->send(p_result, mctx, request);
 
  275        fr_process_state_t 
const        *state;
 
  281        UPDATE_STATE(packet);
 
  283        request->reply->code = state->packet_type[rcode];
 
  284        if (!request->reply->code) request->reply->code = state->default_reply;
 
  285#ifdef PROCESS_CODE_DO_NOT_RESPOND 
  294SEND_NO_RESULT(generic)
 
  298        fr_process_state_t 
const        *state;
 
  311        UPDATE_STATE_CS(reply);
 
  327                vp->vp_uint32 = request->reply->code;
 
  337                        request->reply->code = 
vp->vp_uint32;
 
  338                        UPDATE_STATE_CS(reply);
 
  342                RWDEBUG(
"Ignoring invalid packet-type reply.%pP", 
vp);
 
  343                goto update_packet_type;
 
  356                        RWDEBUG(
"No 'send %s { ... } section was found.", 
name);
 
  358                        RWDEBUG(
"No 'send %u { ... } section was found.", request->reply->code);
 
  363                                              cs, state->default_rcode, state->resume,
 
  364                                              NULL, 0, mctx->
rctx);
 
  371        fr_process_state_t 
const        *state;
 
  386        UPDATE_STATE_CS(reply);
 
  389        switch (state->packet_type[rcode]) {
 
  391                p_result->rcode = state->result_rcode;
 
  409                    (state->packet_type[rcode] != request->reply->code)) {
 
  412                        request->reply->code = state->packet_type[rcode];
 
  413                        UPDATE_STATE_CS(reply);
 
  418                                                              cs, state->default_rcode, state->send,
 
  419                                                              NULL, 0, mctx->
rctx);
 
  421                p_result->rcode = state->result_rcode;
 
  423                fr_assert(!state->packet_type[rcode] || (state->packet_type[rcode] == request->reply->code));
 
  426#ifdef PROCESS_CODE_DO_NOT_RESPOND 
  432                        RDEBUG(
"The 'send %s' section returned %s - not sending a response",
 
  437                p_result->rcode = state->result_rcode;
 
  443        request->reply->timestamp = 
fr_time();
 
  445#ifdef PROCESS_CODE_DO_NOT_RESPOND 
  450                RDEBUG(
"Not sending reply to client");
 
  459#ifdef PROCESS_CODE_DYNAMIC_CLIENT 
  464        request->reply->timestamp = 
fr_time();
 
  474        fr_process_state_t 
const        *state;
 
  481                RDEBUG(
"new client was successful.");
 
  482                cs = 
inst->sections.add_client;
 
  487                RDEBUG(
"new client was denied.");
 
  488                cs = 
inst->sections.deny_client;
 
  493        request->component = NULL;
 
  494        request->module = NULL;
 
  498                request->reply->timestamp = 
fr_time();
 
  505                                              NULL, 0, mctx->
rctx);
 
  512        fr_process_state_t 
const        *state;
 
  514        UPDATE_STATE(packet);
 
  518        cs = 
inst->sections.new_client;
 
  523                                              NULL, 0, mctx->
rctx);
 
  526#define DYNAMIC_CLIENT_SECTIONS \ 
  528                .section = SECTION_NAME("new", "client"), \ 
  529                .actions = &mod_actions_authorize, \ 
  530                .offset = PROCESS_CONF_OFFSET(new_client), \ 
  533                .section = SECTION_NAME("add", "client"), \ 
  534                .actions = &mod_actions_authorize, \ 
  535                .offset = PROCESS_CONF_OFFSET(add_client), \ 
  538                .section = SECTION_NAME("deny", "client"), \ 
  539                .actions = &mod_actions_authorize, \ 
  540                .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.
 
#define UNLANG_RESULT_RCODE(_x)
 
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[]
 
RESUME_FLAG(recv_bfd, UNUSED,)
 
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.
 
#define PROCESS_TRACE
Trace each state function as it's entered.
 
fr_table_num_sorted_t const rcode_table[]
 
#define RETURN_UNLANG_FAIL
 
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.
 
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
 
void * data
Module's instance data.
 
unlang_action_t(* module_method_t)(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
 
#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(unlang_result_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)
 
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)