The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
request.h File Reference

The main request structure, and allocation functions. More...

#include <freeradius-devel/server/log.h>
#include <freeradius-devel/server/rcode.h>
#include <freeradius-devel/server/signal.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/heap.h>
#include <freeradius-devel/util/packet.h>
#include <freeradius-devel/util/dlist.h>
+ Include dependency graph for request.h:

Go to the source code of this file.

Data Structures

struct  request_init_args_t
 Optional arguments for initialising requests. More...
 
struct  request_pair_lists_t
 Pair lists accessible from the request. More...
 
struct  request_s
 
struct  request_s.flags
 Capabilities flags for this request. More...
 
struct  request_s.log
 Logging information. More...
 

Macros

#define control_ctx   pair_list.control
 Talloc ctx for allocating control pairs under.
 
#define control_pairs   pair_list.control->children
 Convenience macro for accessing the control list.
 
#define local_ctx   pair_list.local
 Talloc ctx for allocating local variagbles.
 
#define local_pairs   pair_list.local->children
 Convenience macro for accessing the state list.
 
#define RAD_REQUEST_LVL_DEBUG   (1)
 
#define RAD_REQUEST_LVL_DEBUG2   (2)
 
#define RAD_REQUEST_LVL_DEBUG3   (3)
 
#define RAD_REQUEST_LVL_DEBUG4   (4)
 
#define RAD_REQUEST_LVL_NONE   (0)
 No debug messages should be printed.
 
#define RAD_REQUEST_OPTION_CTX   (1 << 1)
 
#define RAD_REQUEST_OPTION_DETAIL   (1 << 2)
 
#define reply_ctx   pair_list.reply
 Talloc ctx for allocating reply pairs under.
 
#define reply_pairs   pair_list.reply->children
 Convenience macro for accessing the reply list.
 
#define request_ctx   pair_list.request
 Talloc ctx for allocating request pairs under.
 
#define request_init(_ctx, _type, _args)    _request_init(__FILE__, __LINE__, _ctx, _type, _args)
 
#define request_is_detachable(_x)   ((_x)->flags.detachable)
 
#define request_is_detached(_x)   ((_x)->type == REQUEST_TYPE_DETACHED)
 
#define request_is_dynamic_client(_x)   ((_x)->flags.dynamic_client)
 
#define request_is_external(_x)   ((_x)->type == REQUEST_TYPE_EXTERNAL)
 
#define request_is_internal(_x)   ((_x)->type == REQUEST_TYPE_INTERNAL)
 
#define request_local_alloc_external(_ctx, _args)    _request_local_alloc(__FILE__, __LINE__, (_ctx), REQUEST_TYPE_EXTERNAL, (_args))
 Allocate a new external request outside of the request pool.
 
#define request_local_alloc_internal(_ctx, _args)    _request_local_alloc(__FILE__, __LINE__, (_ctx), REQUEST_TYPE_INTERNAL, (_args))
 Allocate a new internal request outside of the request pool.
 
#define REQUEST_MAGIC   (0xdeadbeef)
 
#define REQUEST_MASTER_NUM_STATES   (REQUEST_COUNTED + 1)
 
#define request_pairs   pair_list.request->children
 Convenience macro for accessing the request list.
 
#define REQUEST_POOL_HEADERS
 
#define REQUEST_POOL_SIZE
 
#define request_set_dynamic_client(_x)   ((_x)->flags.dynamic_client = true)
 
#define REQUEST_VERIFY(_x)   fr_assert(_x)
 
#define session_state_ctx   pair_list.state
 Talloc ctx for allocating reply pairs under.
 
#define session_state_pairs   pair_list.state->children
 Convenience macro for accessing the state list.
 

Typedefs

typedef struct fr_async_s fr_async_t
 
typedef struct fr_client_s fr_client_t
 
typedef enum request_state_t request_state_t
 
typedef struct request_s request_t
 

Enumerations

enum  request_master_state_t {
  REQUEST_ACTIVE = 1 ,
  REQUEST_STOP_PROCESSING ,
  REQUEST_DONE
}
 
enum  request_state_t {
  REQUEST_INIT = 0 ,
  REQUEST_RECV ,
  REQUEST_PROCESS ,
  REQUEST_SEND ,
  REQUEST_OTHER_1 ,
  REQUEST_OTHER_2 ,
  REQUEST_OTHER_3 ,
  REQUEST_OTHER_4
}
 
enum  request_type_t {
  REQUEST_TYPE_EXTERNAL = 0 ,
  REQUEST_TYPE_INTERNAL ,
  REQUEST_TYPE_DETACHED
}
 

Functions

int _request_init (char const *file, int line, request_t *request, request_type_t type, request_init_args_t const *args)
 Setup logging and other fields for a request.
 
request_t_request_local_alloc (char const *file, int line, TALLOC_CTX *ctx, request_type_t type, request_init_args_t const *args)
 Allocate a request that's not in the free list.
 
int request_detach (request_t *child)
 Unlink a subrequest from its parent.
 
void request_global_free (void)
 
int request_global_init (void)
 
void request_log_prepend (request_t *request, fr_log_t *log, fr_log_lvl_t lvl)
 Prepend another logging destination to the list.
 
int request_slab_deinit (request_t *request)
 Callback for slabs to deinitialise the request.
 
fr_pair_trequest_state_replace (request_t *request, fr_pair_t *state))
 Replace the session_state_ctx with a new one.
 

Variables

fr_dict_attr_t const * request_attr_control
 
fr_dict_attr_t const * request_attr_local
 
fr_dict_attr_t const * request_attr_reply
 
fr_dict_attr_t const * request_attr_request
 
HIDDEN fr_dict_attr_t const * request_attr_root
 
fr_dict_attr_t const * request_attr_state
 

Detailed Description

The main request structure, and allocation functions.

Id
dbf1d53798f0d73e01928c3b207004aeb0efc8ca

Definition in file request.h.


Data Structure Documentation

◆ request_init_args_t

struct request_init_args_t

Optional arguments for initialising requests.

Definition at line 283 of file request.h.

+ Collaboration diagram for request_init_args_t:
Data Fields
bool detachable Request should be detachable, i.e.

able to run even if its parent exits.

request_pair_lists_t pair_list Alternative pair list heads.

These allow a request to expose nested attributes as request or reply lists from the parent.

request_t * parent < The namespace this request implements.

If set, the request is a child request used to run policy sections and additional virtual servers.

◆ request_pair_lists_t

struct request_pair_lists_t

Pair lists accessible from the request.

Definition at line 169 of file request.h.

+ Collaboration diagram for request_pair_lists_t:
Data Fields
fr_pair_t * control Pair containing the control list.
fr_pair_t * local Pair containing local variables.
fr_pair_t * reply Pair containing the reply list.
fr_pair_t * request Pair containing the request list.
fr_pair_t * state Pair containing the state list.

◆ request_s

struct request_s

Definition at line 191 of file request.h.

+ Collaboration diagram for request_s:
Data Fields
char const * alloc_file File the request was allocated in.
int alloc_line Line the request was allocated on.
fr_async_t * async for new async listeners
uint64_t child_number Monotonically increasing number for children of this request.
fr_client_t * client The client that originally sent us the request.
char const * component Section the request is in.
bool counted Set if the request has been counted in the stats.
fr_dlist_head_t data Request data.
fr_rb_node_t dedup_node entry in the deduplication tree.
struct request_s.flags flags Capabilities flags for this request.
uint64_t ins_count count of instructions we've ran
uint64_t ins_max max instruction to bail out at
fr_dlist_t listen_entry request's entry in the list for this listener / socket
fr_dict_t const * local_dict dictionary for local variables
struct request_s.log log Logging information.
uint32_t magic Magic number used to detect memory corruption, or request structs that have not been properly initialised.
request_master_state_t master_state Set by the master thread to signal the child that's currently working with the request, to do something.
char const * name for debug printing, as (d) is no longer sufficient
uint64_t number Monotonically increasing request number. Reset on server restart.
uint32_t options mainly for proxying EAP-MSCHAPv2.
char const *fr_packet_t * packet < Module the request is currently being processed by.

Incoming request.

request_pair_lists_t pair_list Pair lists associated with the request.
Warning
DO NOT allocate pairs directly beneath the root or in the ctx of the request. They MUST be allocated beneath their appropriate list attribute. Structure containing all pair lists.
fr_pair_t * pair_root Root attribute which contains the other list attributes as children.
request_t * parent Request that generated this request.
fr_dict_t const * proto_dict Dictionary of the protocol that this request belongs to.
rlm_rcode_t rcode Last rcode returned by a module.
fr_packet_t * reply Outgoing response.
fr_heap_index_t runnable entry in the heap of runnable packets
uint64_t seq_start State sequence ID.

Stable identifier for a sequence of requests and responses.

void * stack unlang interpreter stack.
fr_timer_t * timeout Timer event for this request.

This tracks when we need to forcefully terminate a request.

request_type_t type What type of request this is.

◆ request_s.flags

struct request_s.flags

Capabilities flags for this request.

Definition at line 232 of file request.h.

Data Fields
uint8_t detachable: 1 This request may be detached from its parent..
uint8_t dynamic_client: 1 this is a dynamic client request

◆ request_s.log

struct request_s.log

Logging information.

Definition at line 240 of file request.h.

Data Fields
log_dst_t * dst First in a list of log destinations.
rindent_t indent Indentation for log messages.
fr_log_lvl_t lvl Log messages with lvl >= to this should be logged.

Macro Definition Documentation

◆ control_ctx

#define control_ctx   pair_list.control

Talloc ctx for allocating control pairs under.

Definition at line 142 of file request.h.

◆ control_pairs

#define control_pairs   pair_list.control->children

Convenience macro for accessing the control list.

This should be used in the form &request->control_pairs to get a pointer to the head of the request list.

Definition at line 138 of file request.h.

◆ local_ctx

#define local_ctx   pair_list.local

Talloc ctx for allocating local variagbles.

Definition at line 164 of file request.h.

◆ local_pairs

#define local_pairs   pair_list.local->children

Convenience macro for accessing the state list.

This should be used in the form &request->local_pairs to get a pointer to the head of the local list.

Definition at line 160 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG

#define RAD_REQUEST_LVL_DEBUG   (1)

Definition at line 309 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG2

#define RAD_REQUEST_LVL_DEBUG2   (2)

Definition at line 310 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG3

#define RAD_REQUEST_LVL_DEBUG3   (3)

Definition at line 311 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG4

#define RAD_REQUEST_LVL_DEBUG4   (4)

Definition at line 312 of file request.h.

◆ RAD_REQUEST_LVL_NONE

#define RAD_REQUEST_LVL_NONE   (0)

No debug messages should be printed.

Definition at line 308 of file request.h.

◆ RAD_REQUEST_OPTION_CTX

#define RAD_REQUEST_OPTION_CTX   (1 << 1)

Definition at line 314 of file request.h.

◆ RAD_REQUEST_OPTION_DETAIL

#define RAD_REQUEST_OPTION_DETAIL   (1 << 2)

Definition at line 315 of file request.h.

◆ reply_ctx

#define reply_ctx   pair_list.reply

Talloc ctx for allocating reply pairs under.

Definition at line 131 of file request.h.

◆ reply_pairs

#define reply_pairs   pair_list.reply->children

Convenience macro for accessing the reply list.

This should be used in the form &request->reply_pairs to get a pointer to the head of the request list.

Definition at line 127 of file request.h.

◆ request_ctx

#define request_ctx   pair_list.request

Talloc ctx for allocating request pairs under.

Definition at line 120 of file request.h.

◆ request_init

#define request_init (   _ctx,
  _type,
  _args 
)     _request_init(__FILE__, __LINE__, _ctx, _type, _args)

Definition at line 317 of file request.h.

◆ request_is_detachable

#define request_is_detachable (   _x)    ((_x)->flags.detachable)

Definition at line 187 of file request.h.

◆ request_is_detached

#define request_is_detached (   _x)    ((_x)->type == REQUEST_TYPE_DETACHED)

Definition at line 186 of file request.h.

◆ request_is_dynamic_client

#define request_is_dynamic_client (   _x)    ((_x)->flags.dynamic_client)

Definition at line 188 of file request.h.

◆ request_is_external

#define request_is_external (   _x)    ((_x)->type == REQUEST_TYPE_EXTERNAL)

Definition at line 184 of file request.h.

◆ request_is_internal

#define request_is_internal (   _x)    ((_x)->type == REQUEST_TYPE_INTERNAL)

Definition at line 185 of file request.h.

◆ request_local_alloc_external

#define request_local_alloc_external (   _ctx,
  _args 
)     _request_local_alloc(__FILE__, __LINE__, (_ctx), REQUEST_TYPE_EXTERNAL, (_args))

Allocate a new external request outside of the request pool.

Parameters
[in]_ctxTalloc ctx to allocate the request in.
[in]_argsOptional arguments that control how the request is initialised.

Definition at line 331 of file request.h.

◆ request_local_alloc_internal

#define request_local_alloc_internal (   _ctx,
  _args 
)     _request_local_alloc(__FILE__, __LINE__, (_ctx), REQUEST_TYPE_INTERNAL, (_args))

Allocate a new internal request outside of the request pool.

Parameters
[in]_ctxTalloc ctx to allocate the request in.
[in]_argsOptional arguments that control how the request is initialised.

Definition at line 339 of file request.h.

◆ REQUEST_MAGIC

#define REQUEST_MAGIC   (0xdeadbeef)

Definition at line 57 of file request.h.

◆ REQUEST_MASTER_NUM_STATES

#define REQUEST_MASTER_NUM_STATES   (REQUEST_COUNTED + 1)

Definition at line 91 of file request.h.

◆ request_pairs

#define request_pairs   pair_list.request->children

Convenience macro for accessing the request list.

This should be used in the form &request->request_pairs to get a pointer to the head of the request list.

Definition at line 116 of file request.h.

◆ REQUEST_POOL_HEADERS

#define REQUEST_POOL_HEADERS
Value:
( \
1 + \
2 + \
10 \
)
#define UNLANG_STACK_MAX
The maximum depth of the stack.
Definition interpret.h:38

Definition at line 66 of file request.h.

◆ REQUEST_POOL_SIZE

#define REQUEST_POOL_SIZE
Value:
( \
(sizeof(fr_pair_t) * 5) + \
(sizeof(fr_packet_t) * 2) + \
128 \
)
#define UNLANG_FRAME_PRE_ALLOC
How much memory we pre-alloc for each frame.
Definition interpret.h:39
Stores an attribute, a value and various bits of other data.
Definition pair.h:68

Definition at line 79 of file request.h.

◆ request_set_dynamic_client

#define request_set_dynamic_client (   _x)    ((_x)->flags.dynamic_client = true)

Definition at line 189 of file request.h.

◆ REQUEST_VERIFY

#define REQUEST_VERIFY (   _x)    fr_assert(_x)

Definition at line 305 of file request.h.

◆ session_state_ctx

#define session_state_ctx   pair_list.state

Talloc ctx for allocating reply pairs under.

Definition at line 153 of file request.h.

◆ session_state_pairs

#define session_state_pairs   pair_list.state->children

Convenience macro for accessing the state list.

This should be used in the form &request->session_state_pairs to get a pointer to the head of the request list.

Definition at line 149 of file request.h.

Typedef Documentation

◆ fr_async_t

typedef struct fr_async_s fr_async_t

Definition at line 35 of file request.h.

◆ fr_client_t

typedef struct fr_client_s fr_client_t

Definition at line 38 of file request.h.

◆ request_state_t

◆ request_t

typedef struct request_s request_t

Definition at line 36 of file request.h.

Enumeration Type Documentation

◆ request_master_state_t

Enumerator
REQUEST_ACTIVE 

Request is active (running or runnable)

REQUEST_STOP_PROCESSING 

Request has been signalled to stop.

REQUEST_DONE 

Request has completed.

Definition at line 86 of file request.h.

◆ request_state_t

Enumerator
REQUEST_INIT 
REQUEST_RECV 
REQUEST_PROCESS 
REQUEST_SEND 
REQUEST_OTHER_1 
REQUEST_OTHER_2 
REQUEST_OTHER_3 
REQUEST_OTHER_4 

Definition at line 93 of file request.h.

◆ request_type_t

Enumerator
REQUEST_TYPE_EXTERNAL 

A request received on the wire.

REQUEST_TYPE_INTERNAL 

A request generated internally.

REQUEST_TYPE_DETACHED 

A request that was generated internally, but is now detached (not associated with a parent request.)

Definition at line 177 of file request.h.

Function Documentation

◆ _request_init()

int _request_init ( char const *  file,
int  line,
request_t request,
request_type_t  type,
request_init_args_t const *  args 
)

Setup logging and other fields for a request.

Parameters
[in]filethe request was allocated in.
[in]linethe request was allocated on.
[in]requestto (re)-initialise.
[in]typeof request to initialise.
[in]argsOther optional arguments.

Definition at line 237 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _request_local_alloc()

request_t * _request_local_alloc ( char const *  file,
int  line,
TALLOC_CTX *  ctx,
request_type_t  type,
request_init_args_t const *  args 
)

Allocate a request that's not in the free list.

This can be useful if modules need a persistent request for their own purposes which needs to be outside of the normal free list, so that it can be freed when the module requires, not when the thread destructor runs.

Definition at line 477 of file request.c.

+ Here is the call graph for this function:

◆ request_detach()

int request_detach ( request_t child)

Unlink a subrequest from its parent.

Note
This should be used for requests in preparation for freeing them.
Parameters
[in]childrequest to unlink.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 535 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ request_global_free()

void request_global_free ( void  )

◆ request_global_init()

int request_global_init ( void  )

Definition at line 589 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ request_log_prepend()

void request_log_prepend ( request_t request,
fr_log_t log_dst,
fr_log_lvl_t  lvl 
)

Prepend another logging destination to the list.

Parameters
requestthe request
log_dstthe logging destination
lvlthe new request debug lvl

Definition at line 92 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ request_slab_deinit()

int request_slab_deinit ( request_t request)

Callback for slabs to deinitialise the request.

Does not need to be called for local requests.

Parameters
[in]requestdeinitialise
Returns
  • 0 in the request was deinitialised.
  • -1 if the request is in an unexpected state.

Definition at line 378 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ request_state_replace()

fr_pair_t * request_state_replace ( request_t request,
fr_pair_t new_state 
)

Replace the session_state_ctx with a new one.

NOTHING should rewrite request->session_state_ctx.

It's now a pair, and is stored in request->pair_root. So it's wrong for anyone other than this function to play games with it.

Parameters
[in]requestto replace the state of.
[in]new_statestate to assign to the request. May be NULL in which case a new_state state will be alloced and assigned.
Returns
the fr_pair_t containing the old state list.

Definition at line 504 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ request_attr_control

fr_dict_attr_t const* request_attr_control
extern

Definition at line 45 of file request.c.

◆ request_attr_local

fr_dict_attr_t const* request_attr_local
extern

Definition at line 47 of file request.c.

◆ request_attr_reply

fr_dict_attr_t const* request_attr_reply
extern

Definition at line 44 of file request.c.

◆ request_attr_request

fr_dict_attr_t const* request_attr_request
extern

Definition at line 43 of file request.c.

◆ request_attr_root

HIDDEN fr_dict_attr_t const* request_attr_root
extern

Definition at line 42 of file request.c.

◆ request_attr_state

fr_dict_attr_t const* request_attr_state
extern

Definition at line 46 of file request.c.