25 RCSID(
"$Id: 35c8e18c71d17cfa0644fa5f01de83c1c76ed96a $")
27 #include <freeradius-devel/server/state.h>
28 #include <freeradius-devel/server/tmpl_dcursor.h>
29 #include <freeradius-devel/unlang/action.h>
96 RDEBUG3(
"subrequest detached during its execution - Not updating rcode or reply attributes");
106 RDEBUG3(
"subrequest complete");
131 RPDEBUG(
"Discarding subrequest attributes - Failed allocating groups");
194 RDEBUG(
"Failed finding attribute %s", gext->
vpt->name);
201 RDEBUG(
"Unknown Packet-Type %pV", &attr->data);
205 child->packet->code =
vp->vp_uint32 = type_enum->
value->vb_uint32;
211 RDEBUG(
"Failed casting value from %pV to data type uint32", &attr->data);
224 RDEBUG(
"Invalid value %pV for Packet-Type", &box);
228 child->packet->code =
vp->vp_uint32 = box.vb_uint32;
235 RPEDEBUG(
"Failed copying source attributes into subrequest");
299 .name =
"subrequest",
303 .debug_braces =
true,
305 .frame_state_type =
"unlang_frame_state_subrequest_t",
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_EXECUTE_NEXT
Execute the next unlang_t.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
fr_dict_enum_value_t * fr_dict_enum_by_value(fr_dict_attr_t const *da, fr_value_box_t const *value)
Lookup the structure representing an enum value in a fr_dict_attr_t.
fr_value_box_t const * value
Enum value (what name maps to).
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Value of an enumerated attribute.
bool unlang_request_is_done(request_t const *request)
Return whether a request has been marked done.
int unlang_interpret_push(request_t *request, unlang_t const *instruction, rlm_rcode_t default_rcode, bool do_next_sibling, bool top_frame)
Push a new frame onto the stack.
void unlang_interpret_signal(request_t *request, fr_signal_t action)
Send a signal (usually stop) to a request.
Private declarations for the unlang interpreter.
#define RPEDEBUG(fmt,...)
void unlang_register(int type, unlang_op_t *op)
Register an operation with the interpreter.
request_t * unlang_io_subrequest_alloc(request_t *parent, fr_dict_t const *namespace, bool detachable)
Allocate a child request based on the parent.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
int request_detach(request_t *child)
Unlink a subrequest from its parent.
int tmpl_find_vp(fr_pair_t **out, request_t *request, tmpl_t const *vpt))
Returns the first VP matching a tmpl_t.
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
int tmpl_copy_pair_children(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, tmpl_t const *vpt))
Copy children of pairs matching a tmpl_t in the current request_t.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
Stores an attribute, a value and various bits of other data.
static unlang_action_t unlang_subrequest_parent_resume(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
Parent being resumed after a child completes.
request_t * unlang_subrequest_alloc(request_t *parent, fr_dict_t const *namespace)
Allocate a subrequest to run through a virtual server at some point in the future.
int unlang_subrequest_op_init(void)
Initialise subrequest ops.
static void unlang_subrequest_signal_child(UNUSED request_t *request, unlang_stack_frame_t *frame, fr_signal_t action)
Send a signal from parent request to subrequest.
void unlang_subrequest_detach_and_free(request_t **child)
Free a child request, detaching it from its parent and freeing allocated memory.
static unlang_action_t unlang_subrequest_parent_init(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
void unlang_subrequest_op_free(void)
int unique_int
Session unique int identifier.
void const * unique_ptr
Session unique ptr identifier.
bool enable
Whether we should store/restore sessions.
void unlang_subrequest_child_op_free(void)
int unlang_subrequest_child_push_resume(request_t *child, unlang_frame_state_subrequest_t *state)
Push a resumption frame onto a child's stack.
int unlang_subrequest_child_op_init(void)
unlang_action_t unlang_subrequest_child_run(UNUSED rlm_rcode_t *p_result, UNUSED request_t *request, unlang_stack_frame_t *frame)
Function called by the unlang interpreter to start the child running.
tmpl_t * vpt
Value to expand to find the value to place into the packet-type attribute.
unlang_subrequest_session_t session
Session configuration.
fr_dict_attr_t const * attr_packet_type
Packet-type attribute in the subrequest protocol.
request_t * child
Pre-allocated child request.
tmpl_t * src
Pairs to copy into the subrequest request list.
fr_dict_t const * dict
Dictionary of the subrequest protocol.
static unlang_subrequest_t * unlang_group_to_subrequest(unlang_group_t *g)
Cast a group structure to the subrequest keyword extension.
tmpl_t * dst
Where to copy pairs from the reply list in the subrequest to.
fr_dict_enum_value_t const * type_enum
Static enumeration value for attr_packet_type.
rlm_rcode_t * p_result
Where to store the result.
bool detachable
Whether the request can be detached.
Parameters for initialising the subrequest (parent's frame state)
fr_pair_t * tmpl_dcursor_pair_build(fr_pair_t *parent, fr_dcursor_t *cursor, fr_dict_attr_t const *da, UNUSED void *uctx)
Simple pair building callback for use with tmpl_dcursors.
void tmpl_dcursor_clear(tmpl_dcursor_ctx_t *cc)
Clear any temporary state allocations.
#define tmpl_dcursor_build_init(_err, _ctx, _cc, _cursor, _request, _vpt, _build, _uctx)
Maintains state between cursor calls.
Private interpreter structures and functions.
#define UNLANG_NORMAL_CHILD
#define UNLANG_DETACHABLE
#define UNLANG_NEXT_SIBLING
void * state
Stack frame specialisations.
static unlang_group_t * unlang_generic_to_group(unlang_t const *p)
@ UNLANG_TYPE_SUBREQUEST
create a child subrequest
static void frame_repeat(unlang_stack_frame_t *frame, unlang_process_t process)
Mark the current stack frame up for repeat, and set a new process function.
unlang_t const * instruction
The unlang node we're evaluating.
rlm_rcode_t result
The result from executing the instruction.
unlang_t * children
Children beneath this group.
Generic representation of a grouping.
Our interpreter stack, as distinct from the C stack.
int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_value_box_t const *src)
Convert one type of fr_value_box_t to another.
#define fr_value_box_init(_vb, _type, _enumv, _tainted)
Initialise a fr_value_box_t.