The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
request.c File Reference

Functions for allocating requests and storing internal data in them. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/util/debug.h>
+ Include dependency graph for request.c:

Go to the source code of this file.

Macros

#define list_init(_ctx, _list)
 

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...
 
static int _request_free (request_t *request)
 Callback for freeing a request struct. More...
 
static int _request_free_list_free_on_exit (void *arg)
 Free any free requests when the thread is joined. 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...
 
static int _request_local_free (request_t *request)
 
static int _state_ctx_free (fr_pair_t *state)
 
static request_trequest_alloc_pool (TALLOC_CTX *ctx)
 
static int request_child_init (request_t *child, request_t *parent)
 
int request_detach (request_t *child)
 Unlink a subrequest from its parent. More...
 
static int request_detachable_init (request_t *child, request_t *parent)
 
void request_global_free (void)
 
int request_global_init (void)
 
static 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. More...
 
static void request_log_init_child (request_t *child, request_t const *parent)
 
static void request_log_init_detachable (request_t *child, request_t const *parent)
 
static void request_log_init_orphan (request_t *request)
 
void request_log_prepend (request_t *request, fr_log_t *log_dst, fr_log_lvl_t lvl)
 Prepend another logging destination to the list. More...
 
fr_pair_trequest_state_replace (request_t *request, fr_pair_t *new_state)
 Replace the session_state_ctx with a new one. More...
 

Variables

static request_init_args_t default_args
 
static fr_dict_t const * dict_freeradius
 
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
 
fr_dict_attr_t const * request_attr_root
 
fr_dict_attr_t const * request_attr_state
 
fr_dict_autoload_t request_dict []
 
fr_dict_attr_autoload_t request_dict_attr []
 
static _Thread_local fr_dlist_head_trequest_free_list
 The thread local free list. More...
 

Detailed Description

Functions for allocating requests and storing internal data in them.

Id
39d5b16168106544eda1d5c0cf97dbc33342a375

Definition in file request.c.

Macro Definition Documentation

◆ list_init

#define list_init (   _ctx,
  _list 
)
Value:
do { \
vp = fr_pair_afrom_da(_ctx, request_attr_##_list); \
if (unlikely(!vp)) { \
talloc_free(pair_root); \
memset(&request->pair_list, 0, sizeof(request->pair_list)); \
return -1; \
} \
fr_pair_append(&pair_root->children, vp); \
request->pair_list._list = vp; \
} while(0)
#define unlikely(_x)
Definition: build.h:378
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.
Definition: pair.c:278
fr_pair_t * vp

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_free()

static int _request_free ( request_t request)
static

Callback for freeing a request struct.

Parameters
[in]requestto free or return to the free list.
Returns
  • 0 in the request was freed.
  • -1 if the request was inserted into the free list.

Definition at line 358 of file request.c.

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

◆ _request_free_list_free_on_exit()

static int _request_free_list_free_on_exit ( void *  arg)
static

Free any free requests when the thread is joined.

Definition at line 446 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 604 of file request.c.

+ Here is the call graph for this function:

◆ _request_local_free()

static int _request_local_free ( request_t request)
static

Definition at line 560 of file request.c.

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

◆ _state_ctx_free()

static int _state_ctx_free ( fr_pair_t state)
static

Definition at line 65 of file request.c.

+ Here is the caller graph for this function:

◆ request_alloc_pool()

static request_t* request_alloc_pool ( TALLOC_CTX *  ctx)
inlinestatic

Definition at line 458 of file request.c.

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

◆ request_child_init()

static int request_child_init ( request_t child,
request_t parent 
)
inlinestatic

Definition at line 194 of file request.c.

+ Here is the call graph for this function:
+ Here is the caller 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_detachable_init()

static int request_detachable_init ( request_t child,
request_t parent 
)
inlinestatic

Definition at line 181 of file request.c.

+ 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_init()

static int request_init ( char const *  file,
int  line,
request_t request,
request_type_t  type,
request_init_args_t const *  args 
)
inlinestatic

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 238 of file request.c.

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

◆ request_log_init_child()

static void request_log_init_child ( request_t child,
request_t const *  parent 
)
inlinestatic

Definition at line 158 of file request.c.

+ Here is the caller graph for this function:

◆ request_log_init_detachable()

static void request_log_init_detachable ( request_t child,
request_t const *  parent 
)
inlinestatic

Definition at line 169 of file request.c.

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

◆ request_log_init_orphan()

static void request_log_init_orphan ( request_t request)
inlinestatic

Definition at line 73 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

◆ default_args

request_init_args_t default_args
static

Definition at line 30 of file request.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 32 of file request.c.

◆ request_attr_control

fr_dict_attr_t const* request_attr_control

Definition at line 43 of file request.c.

◆ request_attr_local

fr_dict_attr_t const* request_attr_local

Definition at line 45 of file request.c.

◆ request_attr_reply

fr_dict_attr_t const* request_attr_reply

Definition at line 42 of file request.c.

◆ request_attr_request

fr_dict_attr_t const* request_attr_request

Definition at line 41 of file request.c.

◆ request_attr_root

fr_dict_attr_t const* request_attr_root

Definition at line 40 of file request.c.

◆ request_attr_state

fr_dict_attr_t const* request_attr_state

Definition at line 44 of file request.c.

◆ request_dict

fr_dict_autoload_t request_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: request.c:32

Definition at line 35 of file request.c.

◆ request_dict_attr

fr_dict_attr_autoload_t request_dict_attr
Initial value:
= {
{ .out = &request_attr_root, .name = "root", .type = FR_TYPE_GROUP, .dict = &dict_freeradius },
{ .out = &request_attr_request, .name = "request", .type = FR_TYPE_GROUP, .dict = &dict_freeradius },
{ .out = &request_attr_reply, .name = "reply", .type = FR_TYPE_GROUP, .dict = &dict_freeradius },
{ .out = &request_attr_control, .name = "control", .type = FR_TYPE_GROUP, .dict = &dict_freeradius },
{ .out = &request_attr_state, .name = "session-state", .type = FR_TYPE_GROUP, .dict = &dict_freeradius },
{ .out = &request_attr_local, .name = "local-variables", .type = FR_TYPE_GROUP, .dict = &dict_freeradius },
{ NULL }
}
@ FR_TYPE_GROUP
A grouping of other attributes.
Definition: merged_model.c:124
fr_dict_attr_t const * request_attr_request
Definition: request.c:41
fr_dict_attr_t const * request_attr_control
Definition: request.c:43
fr_dict_attr_t const * request_attr_local
Definition: request.c:45
fr_dict_attr_t const * request_attr_state
Definition: request.c:44
fr_dict_attr_t const * request_attr_reply
Definition: request.c:42
fr_dict_attr_t const * request_attr_root
Definition: request.c:40

Definition at line 48 of file request.c.

◆ request_free_list

_Thread_local fr_dlist_head_t* request_free_list
static

The thread local free list.

Any entries remaining in the list will be freed when the thread is joined

Definition at line 62 of file request.c.