The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
src
lib
server
pair.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: ce7a792dde8614223ebd161d0ef6f4b773ef23d5 $
20
*
21
* @file lib/server/pair.h
22
* @brief Server pair manipulation macros
23
*
24
* @copyright 2021 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
25
* @copyright 2018 The FreeRADIUS server project
26
*/
27
RCSIDH
(server_pair_h,
"$Id: ce7a792dde8614223ebd161d0ef6f4b773ef23d5 $"
)
28
29
/** Allocate and append a fr_pair_t to the request list
30
*
31
* @param[in] _attr allocated.
32
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
33
* @return
34
* - 0 on success.
35
* - -1 on failure.
36
*/
37
#define pair_append_request(_attr, _da) fr_pair_append_by_da(request->request_ctx, _attr, &request->request_pairs, _da)
38
39
/** Allocate and append a fr_pair_t to reply list
40
*
41
* @param[in] _attr allocated.
42
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
43
* @return
44
* - 0 on success.
45
* - -1 on failure.
46
*/
47
#define pair_append_reply(_attr, _da) fr_pair_append_by_da(request->reply_ctx, _attr, &request->reply_pairs, _da)
48
49
/** Allocate and append a fr_pair_t to the control list
50
*
51
* @param[in] _attr allocated.
52
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
53
* @return
54
* - 0 on success.
55
* - -1 on failure.
56
*/
57
#define pair_append_control(_attr, _da) fr_pair_append_by_da(request->control_ctx, _attr, &request->control_pairs, _da)
58
59
/** Allocate and append a fr_pair_t to session-state list
60
*
61
* @param[in] _attr allocated.
62
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
63
* @return
64
* - 0 on success.
65
* - -1 on failure.
66
*/
67
#define pair_append_session_state(_attr, _da) fr_pair_append_by_da(request->session_state_ctx, _attr, &request->session_state_pairs, _da)
68
69
/** Allocate and prepend a fr_pair_t to the request list
70
*
71
* @param[in] _attr allocated.
72
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
73
* @return
74
* - 0 on success.
75
* - -1 on failure.
76
*/
77
#define pair_prepend_request(_attr, _da) fr_pair_prepend_by_da(request->request_ctx, _attr, &request->request_pairs, _da)
78
79
/** Allocate and prepend a fr_pair_t to reply list
80
*
81
* @param[in] _attr allocated.
82
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
83
* @return
84
* - 0 on success.
85
* - -1 on failure.
86
*/
87
#define pair_prepend_reply(_attr, _da) fr_pair_prepend_by_da(request->reply_ctx, _attr, &request->reply_pairs, _da)
88
89
/** Allocate and prepend a fr_pair_t to the control list
90
*
91
* @param[in] _attr allocated.
92
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
93
* @return
94
* - 0 on success.
95
* - -1 on failure.
96
*/
97
#define pair_prepend_control(_attr, _da) fr_pair_prepend_by_da(request->control_ctx, _attr, &request->control_pairs, _da)
98
99
/** Allocate and prepend a fr_pair_t to session-state list
100
*
101
* @param[in] _attr allocated.
102
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
103
* @return
104
* - 0 on success.
105
* - -1 on failure.
106
*/
107
#define pair_prepend_session_state(_attr, _da) fr_pair_prepend_by_da(request->session_state_ctx, _attr, &request->session_state_pairs, _da)
108
109
/** Return or allocate a fr_pair_t in the request list
110
*
111
* @param[in] _attr allocated or found.
112
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
113
* @return
114
* - 1 if attribute already existed.
115
* - 0 if we allocated a new attribute.
116
* - -1 on failure.
117
*/
118
#define pair_update_request(_attr, _da) fr_pair_update_by_da_parent(request->request_ctx, _attr, _da)
119
120
/** Return or allocate a fr_pair_t in the reply list
121
*
122
* @param[in] _attr allocated or found.
123
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
124
* @return
125
* - 1 if attribute already existed.
126
* - 0 if we allocated a new attribute.
127
* - -1 on failure.
128
*/
129
#define pair_update_reply(_attr, _da) fr_pair_update_by_da_parent(request->reply_ctx, _attr, _da)
130
131
/** Return or allocate a fr_pair_t in the control list
132
*
133
* @param[in] _attr allocated or found.
134
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
135
* @return
136
* - 1 if attribute already existed.
137
* - 0 if we allocated a new attribute.
138
* - -1 on failure.
139
*/
140
#define pair_update_control(_attr, _da) fr_pair_update_by_da_parent(request->control_ctx, _attr, _da)
141
142
/** Return or allocate a fr_pair_t in the session_state list
143
*
144
* @param[in] _attr allocated or found.
145
* @param[in] _da #fr_dict_attr_t of the pair to be found or allocated.
146
* @return
147
* - 1 if attribute already existed.
148
* - 0 if we allocated a new attribute.
149
* - -1 on failure.
150
*/
151
#define pair_update_session_state(_attr, _da) fr_pair_update_by_da_parent(request->session_state_ctx, _attr, _da)
152
153
/** Delete one or move fr_pair_t in a list
154
*
155
* @param[in] _list to delete the pair from.
156
* @param[in] _pair_or_da To delete. May be a #fr_pair_t or #fr_dict_attr_t.
157
*/
158
#define pair_delete(_list, _pair_or_da) \
159
_Generic((_pair_or_da), \
160
fr_dict_attr_t const * : fr_pair_delete_by_da_nested(_list, UNCONST(fr_dict_attr_t *, _pair_or_da)), \
161
fr_dict_attr_t * : fr_pair_delete_by_da_nested(_list, UNCONST(fr_dict_attr_t *, _pair_or_da)), \
162
fr_pair_t * : fr_pair_delete(_list, UNCONST(fr_pair_t *, _pair_or_da)) \
163
)
164
165
/** Delete a fr_pair_t in the request list
166
*
167
* @param[in] _pair_or_da To delete. May be a #fr_pair_t or #fr_dict_attr_t.
168
* @return
169
* - >0 the number of pairs deleted.
170
* - 0 if no pairs were deleted.
171
*/
172
#define pair_delete_request(_pair_or_da) pair_delete(&request->request_pairs, _pair_or_da)
173
174
/** Delete a fr_pair_t in the reply list
175
*
176
* @param[in] _pair_or_da To delete. May be a #fr_pair_t or #fr_dict_attr_t.
177
* @return
178
* - >0 the number of pairs deleted.
179
* - 0 if no pairs were deleted.
180
*/
181
#define pair_delete_reply(_pair_or_da) pair_delete(&request->reply_pairs, _pair_or_da)
182
183
/** Delete a fr_pair_t in the control list
184
*
185
* @param[in] _pair_or_da To delete. May be a #fr_pair_t or #fr_dict_attr_t.
186
* @return
187
* - >0 the number of pairs deleted.
188
* - 0 if no pairs were deleted.
189
*/
190
#define pair_delete_control(_pair_or_da) pair_delete(&request->control_pairs, _pair_or_da)
191
192
/** Delete a fr_pair_t in the session_state list
193
*
194
* @param[in] _pair_or_da To delete. May be a #fr_pair_t or #fr_dict_attr_t.
195
* @return
196
* - >0 the number of pairs deleted.
197
* - 0 if no pairs were deleted.
198
*/
199
#define pair_delete_session_state(_pair_or_da) pair_delete(&request->session_state_pairs, _pair_or_da)
RCSIDH
#define RCSIDH(h, id)
Definition:
build.h:482
Generated by
1.9.1