The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions
request_data.c File Reference

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

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

Go to the source code of this file.

Data Structures

struct  request_data_s
 Per-request opaque data, added by modules. More...
 

Functions

int _request_data_add (request_t *request, void const *unique_ptr, int unique_int, char const *type, void *opaque, bool free_on_replace, bool free_on_parent, bool persist, char const *file, int line)
 Add opaque data to a request_t. More...
 
static int _request_data_free (request_data_t *rd)
 Ensure opaque data is freed by binding its lifetime to the request_data_t. More...
 
static request_data_trequest_data_alloc (TALLOC_CTX *ctx)
 Allocate request data. More...
 
int request_data_by_persistance (fr_dlist_head_t *out, request_t *request, bool persist)
 Loop over all the request data, pulling out ones matching persist state. More...
 
int request_data_by_persistance_count (request_t *request, bool persist)
 Return how many request data entries exist of a given persistence. More...
 
int request_data_by_persistance_reparent (TALLOC_CTX *ctx, fr_dlist_head_t *out, request_t *request, bool persist)
 Loop over all the request data, copying, then freeing ones matching persist state. More...
 
static char * request_data_description (TALLOC_CTX *ctx, request_data_t *rd)
 
void request_data_dump (request_t *request)
 
void * request_data_get (request_t *request, void const *unique_ptr, int unique_int)
 Get opaque data from a request. More...
 
void request_data_list_dump (request_t *request, fr_dlist_head_t *head)
 
void request_data_list_init (fr_dlist_head_t *data)
 
void request_data_persistable_free (request_t *request)
 Used for removing data from subrequests that are about to be freed. More...
 
void * request_data_reference (request_t *request, void const *unique_ptr, int unique_int)
 Get opaque data from a request without removing it. More...
 
void request_data_restore (request_t *request, fr_dlist_head_t *in)
 Add request data back to a request. More...
 

Detailed Description

Functions for allocating requests and storing internal data in them.

Id
b55850d4b1ea96d0bbdab66dc874024e0aafd78e

Definition in file request_data.c.


Data Structure Documentation

◆ request_data_s

struct request_data_s

Per-request opaque data, added by modules.

Definition at line 33 of file request_data.c.

+ Collaboration diagram for request_data_s:
Data Fields
char const * file File where this request data was added.
bool free_on_parent Whether to talloc_free(opaque) when the request is freed.
bool free_on_replace Whether to talloc_free(opaque) when the request data is removed.
int line Line where this request data was added.
fr_dlist_t list Next opaque request data struct linked to this request.
void * opaque Opaque data.
bool persist Whether this data should be transferred to a session_entry_t after we're done processing this request.
char const * type Opaque type e.g. fr_pair_t, fr_dict_attr_t etc...
int unique_int Alternative key to lookup request data.
void const * unique_ptr Key to lookup request data.

Function Documentation

◆ _request_data_add()

int _request_data_add ( request_t request,
void const *  unique_ptr,
int  unique_int,
char const *  type,
void *  opaque,
bool  free_on_replace,
bool  free_on_parent,
bool  persist,
char const *  file,
int  line 
)

Add opaque data to a request_t.

The unique ptr is meant to be a module configuration, and the unique integer allows the caller to have multiple opaque data associated with a request_t.

Parameters
[in]requestto associate data with.
[in]unique_ptrIdentifier for the data.
[in]unique_intQualifier for the identifier.
[in]typeType of data (if talloced)
[in]opaqueData to associate with the request. May be NULL.
[in]free_on_replaceFree opaque data if this request_data is replaced.
[in]free_on_parentFree opaque data if the request or session is freed. Must not be set if the opaque data is also parented by the request or state (double free).
[in]persistTransfer request data to an fr_state_entry_t, and add it back to the next request we receive for the session.
[in]filerequest data was added in.
[in]linerequest data was added on.
Returns
  • -2 on bad arguments.
  • -1 on memory allocation error.
  • 0 on success.

Definition at line 183 of file request_data.c.

+ Here is the call graph for this function:

◆ _request_data_free()

static int _request_data_free ( request_data_t rd)
static

Ensure opaque data is freed by binding its lifetime to the request_data_t.

Parameters
rdRequest data being freed.
Returns
  • 0 if free on parent is false or there's no opaque data.
  • ...else whatever the destructor for the opaque data returned.

Definition at line 104 of file request_data.c.

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

◆ request_data_alloc()

static request_data_t* request_data_alloc ( TALLOC_CTX *  ctx)
inlinestatic

Allocate request data.

Parameters
[in]ctxto allocate request data in.
Returns
new request data.

Definition at line 149 of file request_data.c.

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

◆ request_data_by_persistance()

int request_data_by_persistance ( fr_dlist_head_t out,
request_t request,
bool  persist 
)

Loop over all the request data, pulling out ones matching persist state.

Parameters
[out]outHead of result list.
[in]requestto search for request_data_t in.
[in]persistWhether to pull persistable or non-persistable data.
Returns
number of request_data_t retrieved.

Definition at line 372 of file request_data.c.

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

◆ request_data_by_persistance_count()

int request_data_by_persistance_count ( request_t request,
bool  persist 
)

Return how many request data entries exist of a given persistence.

Parameters
[in]requestto check in.
[in]persistWhether to count persistable or non-persistable data.
Returns
number of request_data_t that exist in persistable or non-persistable form

Definition at line 439 of file request_data.c.

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

◆ request_data_by_persistance_reparent()

int request_data_by_persistance_reparent ( TALLOC_CTX *  ctx,
fr_dlist_head_t out,
request_t request,
bool  persist 
)

Loop over all the request data, copying, then freeing ones matching persist state.

Parameters
[in]ctxTo allocate new request_data_t.
[out]outHead of result list. If NULL, data will be reparented in place.
[in]requestto search for request_data_t in.
[in]persistWhether to pull persistable or non-persistable data.
Returns
number of request_data_t retrieved.

Definition at line 397 of file request_data.c.

+ Here is the call graph for this function:

◆ request_data_description()

static char* request_data_description ( TALLOC_CTX *  ctx,
request_data_t rd 
)
static

Definition at line 51 of file request_data.c.

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

◆ request_data_dump()

void request_data_dump ( request_t request)

Definition at line 497 of file request_data.c.

+ Here is the call graph for this function:

◆ request_data_get()

void* request_data_get ( request_t request,
void const *  unique_ptr,
int  unique_int 
)

Get opaque data from a request.

Note
The unique ptr is meant to be a module configuration, and the unique integer allows the caller to have multiple opaque data associated with a request_t.
Parameters
[in]requestto retrieve data from.
[in]unique_ptrIdentifier for the data.
[in]unique_intQualifier for the identifier.
Returns
  • NULL if no opaque data could be found.
  • the opaque data. The entry holding the opaque data is removed from the request.

Definition at line 292 of file request_data.c.

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

◆ request_data_list_dump()

void request_data_list_dump ( request_t request,
fr_dlist_head_t head 
)

Definition at line 482 of file request_data.c.

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

◆ request_data_list_init()

void request_data_list_init ( fr_dlist_head_t data)

Definition at line 92 of file request_data.c.

+ Here is the caller graph for this function:

◆ request_data_persistable_free()

void request_data_persistable_free ( request_t request)

Used for removing data from subrequests that are about to be freed.

Parameters
[in]requestto remove persistable data from.

Definition at line 470 of file request_data.c.

+ Here is the call graph for this function:

◆ request_data_reference()

void* request_data_reference ( request_t request,
void const *  unique_ptr,
int  unique_int 
)

Get opaque data from a request without removing it.

Note
The unique ptr is meant to be a module configuration, and the unique integer allows the caller to have multiple opaque data associated with a request_t.
Parameters
requestto retrieve data from.
unique_ptrIdentifier for the data.
unique_intQualifier for the identifier.
Returns
  • NULL if no opaque data could be found.
  • the opaque data.

Definition at line 339 of file request_data.c.

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

◆ request_data_restore()

void request_data_restore ( request_t request,
fr_dlist_head_t in 
)

Add request data back to a request.

Note
May add multiple entries (if they're linked).
Will not check for duplicates.
Parameters
requestto add data to.
inData to add.

Definition at line 461 of file request_data.c.

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