The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
request_data.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 236092b856548e85db31505040179c116384734a $
20 *
21 * @file lib/server/request_data.h
22 * @brief Request data management functions.
23 *
24 * @copyright 2019 The FreeRADIUS server project
25 */
26RCSIDH(request_data_h, "$Id: 236092b856548e85db31505040179c116384734a $")
27
28#include <freeradius-devel/server/request.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
35
37
38/** Add opaque data to a request_t
39 *
40 * The unique ptr is meant to be a module configuration, and the unique
41 * integer allows the caller to have multiple opaque data associated with a request_t.
42 *
43 * @param[in] _request to associate data with.
44 * @param[in] _unique_ptr Identifier for the data.
45 * @param[in] _unique_int Qualifier for the identifier.
46 * @param[in] _opaque Data to associate with the request. May be NULL.
47 * @param[in] _free_on_replace Free opaque data if this request_data is replaced.
48 * @param[in] _free_on_parent Free opaque data if the request is freed.
49 * Must not be set if the opaque data is also parented by
50 * the request or state (double free).
51 * @param[in] _persist Transfer request data to an #fr_state_entry_t, and
52 * add it back to the next request we receive for the
53 * session.
54 * @return
55 * - -2 on bad arguments.
56 * - -1 on memory allocation error.
57 * - 0 on success.
58 */
59#define request_data_add(_request, _unique_ptr, _unique_int, _opaque, _free_on_replace, _free_on_parent, _persist) \
60 _request_data_add(_request, _unique_ptr, _unique_int, NULL, _opaque, \
61 _free_on_replace, _free_on_parent, _persist, __FILE__, __LINE__)
62
63
64/** Add opaque data to a request_t
65 *
66 * The unique ptr is meant to be a module configuration, and the unique
67 * integer allows the caller to have multiple opaque data associated with a request_t.
68 *
69 * @param[in] _request to associate data with.
70 * @param[in] _unique_ptr Identifier for the data.
71 * @param[in] _unique_int Qualifier for the identifier.
72 * @param[in] _type Type of data i.e. fr_pair_t.
73 * @param[in] _opaque Data to associate with the request. May be NULL.
74 * @param[in] _free_on_replace Free opaque data if this request_data is replaced.
75 * @param[in] _free_on_parent Free opaque data if the request is freed.
76 * Must not be set if the opaque data is also parented by
77 * the request or state (double free).
78 * @param[in] _persist Transfer request data to an #fr_state_entry_t, and
79 * add it back to the next request we receive for the
80 * session.
81 * @return
82 * - -2 on bad arguments.
83 * - -1 on memory allocation error.
84 * - 0 on success.
85 */
86#define request_data_talloc_add(_request, _unique_ptr, _unique_int, _type, _opaque, _free_on_replace, _free_on_parent, _persist) \
87 _request_data_add(_request, _unique_ptr, _unique_int, STRINGIFY(_type), _opaque, \
88 _free_on_replace, _free_on_parent, _persist, __FILE__, __LINE__)
89
90int _request_data_add(request_t *request, void const *unique_ptr, int unique_int, char const *type, void *opaque,
91 bool free_on_replace, bool free_on_parent, bool persist, char const *file, int line);
92
93void *request_data_get(request_t *request, void const *unique_ptr, int unique_int);
94
95void *request_data_reference(request_t *request, void const *unique_ptr, int unique_int);
96
98
100 request_t *request, bool persist);
101
103
105
107
109
110void request_data_dump(request_t *request);
111
112#ifdef WITH_VERIFY_PTR
113bool request_data_persistable(request_data_t *rd);
114
115bool request_data_verify_parent(TALLOC_CTX *parent, fr_dlist_head_t *entry);
116#endif
117
118#ifdef __cplusplus
119}
120#endif
int const char * file
Definition acutest.h:702
int const char int line
Definition acutest.h:702
#define RCSIDH(h, id)
Definition build.h:484
static fr_slen_t in
Definition dict.h:824
Head of a doubly linked list.
Definition dlist.h:51
bool free_on_replace
Whether to talloc_free(opaque) when the request data is removed.
void * opaque
Opaque data.
void const * unique_ptr
Key to lookup request data.
bool persist
Whether this data should be transferred to a session_entry_t after we're done processing this request...
bool free_on_parent
Whether to talloc_free(opaque) when the request is freed.
int unique_int
Alternative key to lookup request data.
Per-request opaque data, added by modules.
int request_data_by_persistance_count(request_t *request, bool persist)
Return how many request data entries exist of a given persistence.
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.
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.
void request_data_list_init(fr_dlist_head_t *data)
void request_data_restore(request_t *request, fr_dlist_head_t *in)
Add request data back to a request.
void request_data_dump(request_t *request)
void request_data_persistable_free(request_t *request)
Used for removing data from subrequests that are about to be freed.
void * request_data_reference(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request without removing it.
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.
void * request_data_get(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request.
void request_data_list_dump(request_t *request, fr_dlist_head_t *head)
fr_aka_sim_id_type_t type
static fr_slen_t head
Definition xlat.h:422
static fr_slen_t parent
Definition pair.h:851
static fr_slen_t data
Definition value.h:1265
static size_t char ** out
Definition value.h:997