Functions for allocating requests and storing internal data in them.
More...
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/server/request_data.h>
Go to the source code of this file.
|
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_t * | request_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...
|
|
Functions for allocating requests and storing internal data in them.
- Id
- b55850d4b1ea96d0bbdab66dc874024e0aafd78e
- Copyright
- 2019 The FreeRADIUS server project
Definition in file request_data.c.
◆ request_data_s
Per-request opaque data, added by modules.
Definition at line 33 of file request_data.c.
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. |
◆ _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] | request | to associate data with. |
[in] | unique_ptr | Identifier for the data. |
[in] | unique_int | Qualifier for the identifier. |
[in] | type | Type of data (if talloced) |
[in] | opaque | Data to associate with the request. May be NULL. |
[in] | free_on_replace | Free opaque data if this request_data is replaced. |
[in] | free_on_parent | Free 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] | persist | Transfer request data to an fr_state_entry_t, and add it back to the next request we receive for the session. |
[in] | file | request data was added in. |
[in] | line | request 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.
◆ _request_data_free()
Ensure opaque data is freed by binding its lifetime to the request_data_t.
- Parameters
-
rd | Request 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.
◆ request_data_alloc()
Allocate request data.
- Parameters
-
[in] | ctx | to allocate request data in. |
- Returns
- new request data.
Definition at line 149 of file request_data.c.
◆ request_data_by_persistance()
Loop over all the request data, pulling out ones matching persist state.
- Parameters
-
[out] | out | Head of result list. |
[in] | request | to search for request_data_t in. |
[in] | persist | Whether to pull persistable or non-persistable data. |
- Returns
- number of request_data_t retrieved.
Definition at line 372 of file request_data.c.
◆ 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] | request | to check in. |
[in] | persist | Whether 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.
◆ request_data_by_persistance_reparent()
Loop over all the request data, copying, then freeing ones matching persist state.
- Parameters
-
[in] | ctx | To allocate new request_data_t. |
[out] | out | Head of result list. If NULL, data will be reparented in place. |
[in] | request | to search for request_data_t in. |
[in] | persist | Whether to pull persistable or non-persistable data. |
- Returns
- number of request_data_t retrieved.
Definition at line 397 of file request_data.c.
◆ request_data_description()
static char* request_data_description |
( |
TALLOC_CTX * |
ctx, |
|
|
request_data_t * |
rd |
|
) |
| |
|
static |
◆ request_data_dump()
void request_data_dump |
( |
request_t * |
request | ) |
|
◆ 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] | request | to retrieve data from. |
[in] | unique_ptr | Identifier for the data. |
[in] | unique_int | Qualifier 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.
◆ request_data_list_dump()
◆ request_data_list_init()
◆ 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] | request | to remove persistable data from. |
Definition at line 470 of file request_data.c.
◆ 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
-
request | to retrieve data from. |
unique_ptr | Identifier for the data. |
unique_int | Qualifier for the identifier. |
- Returns
- NULL if no opaque data could be found.
- the opaque data.
Definition at line 339 of file request_data.c.
◆ request_data_restore()
Add request data back to a request.
- Note
- May add multiple entries (if they're linked).
-
Will not check for duplicates.
- Parameters
-
request | to add data to. |
in | Data to add. |
Definition at line 461 of file request_data.c.