The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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. More...
 
#define control_pairs   pair_list.control->children
 Convenience macro for accessing the control list. More...
 
#define local_ctx   pair_list.local
 Talloc ctx for allocating local variagbles. More...
 
#define local_pairs   pair_list.local->children
 Convenience macro for accessing the state list. More...
 
#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. More...
 
#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. More...
 
#define reply_pairs   pair_list.reply->children
 Convenience macro for accessing the reply list. More...
 
#define request_alloc_external(_ctx, _args)    _request_alloc( __FILE__, __LINE__, (_ctx), REQUEST_TYPE_EXTERNAL, (_args))
 Allocate a new external request. More...
 
#define request_alloc_internal(_ctx, _args)    _request_alloc( __FILE__, __LINE__, (_ctx), REQUEST_TYPE_INTERNAL, (_args))
 Allocate a new internal request. More...
 
#define request_ctx   pair_list.request
 Talloc ctx for allocating request pairs under. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#define session_state_pairs   pair_list.state->children
 Convenience macro for accessing the state list. More...
 

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_COUNTED
}
 
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

request_t_request_alloc (char const *file, int line, TALLOC_CTX *ctx, request_type_t type, request_init_args_t const *args)
 Create a new request_t data structure. More...
 
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. More...
 
int request_detach (request_t *child)
 Unlink a subrequest from its parent. More...
 
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. More...
 
fr_pair_trequest_state_replace (request_t *request, fr_pair_t *state))
 Replace the session_state_ctx with a new one. More...
 

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
b11f56481400256d941ed1f0b9c70c5b260357d3

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 253 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 143 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 165 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.
fr_dlist_head_t data Request data.
fr_rb_node_t dedup_node entry in the deduplication tree.
fr_dict_t const * dict Dictionary of the protocol that this request belongs to.
struct request_s flags Capabilities flags for this request.
fr_dlist_t free_entry Request's entry in the free list.
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
struct request_s 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 * module Module the request is currently being processed by.
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.
fr_packet_t * packet 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.
rlm_rcode_t rcode Last rcode returned by a module.
fr_packet_t * reply Outgoing response.
fr_heap_index_t runnable_id 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_heap_index_t time_order_id entry in the heap of time ordered packets
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 205 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 213 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 116 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 112 of file request.h.

◆ local_ctx

#define local_ctx   pair_list.local

Talloc ctx for allocating local variagbles.

Definition at line 138 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 134 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG

#define RAD_REQUEST_LVL_DEBUG   (1)

Definition at line 279 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG2

#define RAD_REQUEST_LVL_DEBUG2   (2)

Definition at line 280 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG3

#define RAD_REQUEST_LVL_DEBUG3   (3)

Definition at line 281 of file request.h.

◆ RAD_REQUEST_LVL_DEBUG4

#define RAD_REQUEST_LVL_DEBUG4   (4)

Definition at line 282 of file request.h.

◆ RAD_REQUEST_LVL_NONE

#define RAD_REQUEST_LVL_NONE   (0)

No debug messages should be printed.

Definition at line 278 of file request.h.

◆ RAD_REQUEST_OPTION_CTX

#define RAD_REQUEST_OPTION_CTX   (1 << 1)

Definition at line 284 of file request.h.

◆ RAD_REQUEST_OPTION_DETAIL

#define RAD_REQUEST_OPTION_DETAIL   (1 << 2)

Definition at line 285 of file request.h.

◆ reply_ctx

#define reply_ctx   pair_list.reply

Talloc ctx for allocating reply pairs under.

Definition at line 105 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 101 of file request.h.

◆ request_alloc_external

#define request_alloc_external (   _ctx,
  _args 
)     _request_alloc( __FILE__, __LINE__, (_ctx), REQUEST_TYPE_EXTERNAL, (_args))

Allocate a new external request.

Use for requests produced by listeners

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

Definition at line 294 of file request.h.

◆ request_alloc_internal

#define request_alloc_internal (   _ctx,
  _args 
)     _request_alloc( __FILE__, __LINE__, (_ctx), REQUEST_TYPE_INTERNAL, (_args))

Allocate a new internal request.

Use for requests produced by modules and unlang

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

Definition at line 304 of file request.h.

◆ request_ctx

#define request_ctx   pair_list.request

Talloc ctx for allocating request pairs under.

Definition at line 94 of file request.h.

◆ request_is_detachable

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

Definition at line 161 of file request.h.

◆ request_is_detached

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

Definition at line 160 of file request.h.

◆ request_is_dynamic_client

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

Definition at line 162 of file request.h.

◆ request_is_external

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

Definition at line 158 of file request.h.

◆ request_is_internal

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

Definition at line 159 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 315 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 323 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 65 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 90 of file request.h.

◆ request_set_dynamic_client

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

Definition at line 163 of file request.h.

◆ REQUEST_VERIFY

#define REQUEST_VERIFY (   _x)    fr_assert(_x)

Definition at line 275 of file request.h.

◆ session_state_ctx

#define session_state_ctx   pair_list.state

Talloc ctx for allocating reply pairs under.

Definition at line 127 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 123 of file request.h.

Typedef Documentation

◆ fr_async_t

typedef struct fr_async_s fr_async_t

Definition at line 1 of file request.h.

◆ fr_client_t

typedef struct fr_client_s fr_client_t

Definition at line 1 of file request.h.

◆ request_state_t

◆ request_t

typedef struct request_s request_t

Definition at line 1 of file request.h.

Enumeration Type Documentation

◆ request_master_state_t

Enumerator
REQUEST_ACTIVE 
REQUEST_STOP_PROCESSING 
REQUEST_COUNTED 

Definition at line 60 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 67 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 151 of file request.h.

Function Documentation

◆ _request_alloc()

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

Create a new request_t data structure.

Parameters
[in]filewhere the request was allocated.
[in]linewhere the request was allocated.
[in]ctxto bind the request to.
[in]typewhat type of request to alloc.
[in]argsOptional arguments.
Returns
  • A request on success.
  • NULL on error.

Definition at line 497 of file request.c.

+ Here is the call 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 604 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 664 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  )

Definition at line 713 of file request.c.

+ Here is the caller graph for this function:

◆ request_global_init()

int request_global_init ( void  )

Definition at line 698 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 96 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 633 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 43 of file request.c.

◆ request_attr_local

fr_dict_attr_t const* request_attr_local
extern

Definition at line 45 of file request.c.

◆ request_attr_reply

fr_dict_attr_t const* request_attr_reply
extern

Definition at line 42 of file request.c.

◆ request_attr_request

fr_dict_attr_t const* request_attr_request
extern

Definition at line 41 of file request.c.

◆ request_attr_root

HIDDEN fr_dict_attr_t const* request_attr_root
extern

Definition at line 40 of file request.c.

◆ request_attr_state

fr_dict_attr_t const* request_attr_state
extern

Definition at line 44 of file request.c.