The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rlm_cache_redis.c
Go to the documentation of this file.
1/*
2 * This program is is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: b0d471f1622bc94f284f056504865e4091533b8a $
19 * @file rlm_cache_redis.c
20 * @brief redis based cache.
21 *
22 * @copyright 2015 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23 */
24#define LOG_PREFIX "cache - redis"
25
26#include <freeradius-devel/server/base.h>
27#include <freeradius-devel/util/debug.h>
28#include <freeradius-devel/util/value.h>
29
30#include "../../rlm_cache.h"
31#include <freeradius-devel/redis/base.h>
32#include <freeradius-devel/redis/cluster.h>
37
38typedef struct {
39 fr_redis_conf_t conf; //!< Connection parameters for the Redis server.
40 //!< Must be first field in this struct.
41
42 tmpl_t *created_attr; //!< LHS of the Cache-Created map.
43 tmpl_t *expires_attr; //!< LHS of the Cache-Expires map.
44
47
49
52 { .out = &dict_freeradius, .proto = "freeradius" },
53 { NULL }
54};
55
58
61 { .out = &attr_cache_created, .name = "Cache-Created", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
62 { .out = &attr_cache_expires, .name = "Cache-Expires", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
63 { NULL }
64};
65
66/** Create a new rlm_cache_redis instance
67 *
68 * @param[in] mctx Data required for instantiation.
69 * @return
70 * - 0 on success.
71 * - -1 on failure.
72 */
73static int mod_instantiate(module_inst_ctx_t const *mctx)
74{
75 rlm_cache_redis_t *driver = talloc_get_type_abort(mctx->mi->data, rlm_cache_redis_t);
76 char buffer[256];
77
78 snprintf(buffer, sizeof(buffer), "rlm_cache (%s)", mctx->mi->parent->name);
79
80 driver->cluster = fr_redis_cluster_alloc(driver, mctx->mi->conf, &driver->conf, true,
81 buffer, "modules.cache.pool", NULL);
82 if (!driver->cluster) {
83 ERROR("Cluster failure");
84 return -1;
85 }
86
87 /*
88 * These never change, so do it once on instantiation
89 */
90 if (tmpl_afrom_attr_str(driver, NULL, &driver->created_attr, "&Cache-Created", NULL) <= 0) {
91 ERROR("Cache-Created attribute not defined");
92 return -1;
93 }
94
95 if (tmpl_afrom_attr_str(driver, NULL, &driver->expires_attr, "&Cache-Expires", NULL) <= 0) {
96 ERROR("Cache-Expires attribute not defined");
97 return -1;
98 }
99
100 return 0;
101}
102
103static int mod_load(void)
104{
106 return 0;
107}
108
110{
111 talloc_free(c);
112}
113
114/** Locate a cache entry in redis
115 *
116 * @copydetails cache_entry_find_t
117 */
119 UNUSED rlm_cache_config_t const *config, void *instance,
120 request_t *request, UNUSED void *handle, fr_value_box_t const *key)
121{
122 rlm_cache_redis_t *driver = instance;
123 size_t i;
124
126 fr_redis_conn_t *conn;
127 fr_redis_rcode_t status;
128 redisReply *reply = NULL;
129 int s_ret;
130
131 map_list_t head;
132#ifdef HAVE_TALLOC_ZERO_POOLED_OBJECT
133 size_t pool_size = 0;
134#endif
136
137 map_list_init(&head);
138 for (s_ret = fr_redis_cluster_state_init(&state, &conn, driver->cluster, request, (uint8_t const *)key->vb_strvalue, key->vb_length, false);
139 s_ret == REDIS_RCODE_TRY_AGAIN; /* Continue */
140 s_ret = fr_redis_cluster_state_next(&state, &conn, driver->cluster, request, status, &reply)) {
141 /*
142 * Grab all the data for this hash, should return an array
143 * of alternating keys/values which we then convert into maps.
144 */
145 RDEBUG3("LRANGE %pV 0 -1", key);
146 reply = redisCommand(conn->handle, "LRANGE %b 0 -1", key->vb_strvalue, key->vb_length);
147 status = fr_redis_command_status(conn, reply);
148 }
149 if (s_ret != REDIS_RCODE_SUCCESS) {
150 RERROR("Failed retrieving entry for key \"%pV\"", key);
151
152 error:
153 fr_redis_reply_free(&reply);
154 return CACHE_ERROR;
155 }
156
157 if (!fr_cond_assert(reply)) goto error;
158
159 if (reply->type != REDIS_REPLY_ARRAY) {
160 REDEBUG("Bad result type, expected array, got %s",
161 fr_table_str_by_value(redis_reply_types, reply->type, "<UNKNOWN>"));
162 goto error;
163 }
164
165 RDEBUG3("Entry contains %zu elements", reply->elements);
166
167 if (reply->elements == 0) {
168 fr_redis_reply_free(&reply);
169 return CACHE_MISS;
170 }
171
172 if (reply->elements % 3) {
173 REDEBUG("Invalid number of reply elements (%zu). "
174 "Reply must contain triplets of keys operators and values",
175 reply->elements);
176 goto error;
177 }
178
179#ifdef HAVE_TALLOC_ZERO_POOLED_OBJECT
180 /*
181 * We can get a pretty good idea of the required size of the pool
182 */
183 for (i = 0; i < reply->elements; i += 3) {
184 pool_size += sizeof(map_t) + (sizeof(tmpl_t) * 2);
185 if (reply->element[i]->type == REDIS_REPLY_STRING) pool_size += reply->element[i]->len + 1;
186 }
187
188 /*
189 * reply->elements gives us the number of chunks, as the maps are triplets, and there
190 * are three chunks per map
191 */
192
193 c = talloc_zero_pooled_object(NULL, rlm_cache_entry_t, reply->elements, pool_size);
194#else
195 c = talloc_zero(NULL, rlm_cache_entry_t);
196#endif
197 map_list_init(&c->maps);
198 /*
199 * Convert the key/value pairs back into maps
200 */
201 for (i = 0; i < reply->elements; i += 3) {
202 if (fr_redis_reply_to_map(c, &head, request,
203 reply->element[i], reply->element[i + 1], reply->element[i + 2]) < 0) {
204 talloc_free(c);
205 fr_redis_reply_free(&reply);
206 return CACHE_ERROR;
207 }
208 }
209 fr_redis_reply_free(&reply);
210
211 /*
212 * Pull out the cache created date
213 */
214 if (tmpl_attr_tail_da(map_list_head(&head)->lhs) == attr_cache_created) {
215 map_t *map;
216
217 c->created = tmpl_value(map_list_head(&head)->rhs)->vb_date;
218
219 map = map_list_pop_head(&head);
220 talloc_free(map);
221 }
222
223 /*
224 * Pull out the cache expires date
225 */
226 if (tmpl_attr_tail_da(map_list_head(&head)->lhs) == attr_cache_expires) {
227 map_t *map;
228
229 c->expires = tmpl_value(map_list_head(&head)->rhs)->vb_date;
230
231 map = map_list_pop_head(&head);
232 talloc_free(map);
233 }
234
235 if (unlikely(fr_value_box_copy(c, &c->key, key) < 0)) goto error;
236
237 map_list_move(&c->maps, &head);
238 *out = c;
239
240 return CACHE_OK;
241}
242
243
244/** Insert a new entry into the data store
245 *
246 * @copydetails cache_entry_insert_t
247 */
249 request_t *request, UNUSED void *handle, const rlm_cache_entry_t *c)
250{
251 rlm_cache_redis_t *driver = instance;
252 TALLOC_CTX *pool;
253
254 map_t *map = NULL;
255
256 fr_redis_conn_t *conn;
258 fr_redis_rcode_t status;
259 redisReply *reply = NULL;
260 int s_ret;
261
262 static char const command[] = "RPUSH";
263 char const **argv;
264 size_t *argv_len;
265 char const **argv_p;
266 size_t *argv_len_p;
267
268 unsigned int pipelined = 0; /* How many commands pending in the pipeline */
269 redisReply *replies[5]; /* Should have the same number of elements as pipelined commands */
270 size_t reply_cnt = 0, i;
271
272 int cnt;
273
274 tmpl_t expires_value;
275 map_t expires = {
276 .op = T_OP_SET,
277 .lhs = driver->expires_attr,
278 .rhs = &expires_value,
279 };
280
281 tmpl_t created_value;
282 map_t created = {
283 .op = T_OP_SET,
284 .lhs = driver->created_attr,
285 .rhs = &created_value,
286 };
287
288 /*
289 * Encode the entry created date
290 */
291 tmpl_init_shallow(&created_value, TMPL_TYPE_DATA, T_BARE_WORD, "<TEMP>", 6, NULL);
292 fr_value_box_init(&created_value.data.literal, FR_TYPE_DATE, NULL, true);
293 tmpl_value(&created_value)->vb_date = c->created;
294
295 /*
296 * Encode the entry expiry time
297 *
298 * Although Redis objects expire on their own, we still need this
299 * to ignore entries that were created before the last epoch.
300 */
301 tmpl_init_shallow(&expires_value, TMPL_TYPE_DATA, T_BARE_WORD, "<TEMP>", 6, NULL);
302 fr_value_box_init(&expires_value.data.literal, FR_TYPE_DATE, NULL, true);
303 tmpl_value(&expires_value)->vb_date = c->expires;
304
305 cnt = map_list_num_elements(&c->maps) + 2;
306
307 /*
308 * The majority of serialized entries should be under 1k.
309 *
310 * @todo We should really calculate this using some sort of moving average.
311 */
312 pool = talloc_pool(request, 1024);
313 if (!pool) return CACHE_ERROR;
314
315 argv_p = argv = talloc_array(pool, char const *, (cnt * 3) + 2); /* pair = 3 + cmd + key */
316 argv_len_p = argv_len = talloc_array(pool, size_t, (cnt * 3) + 2); /* pair = 3 + cmd + key */
317
318 *argv_p++ = command;
319 *argv_len_p++ = sizeof(command) - 1;
320
321 *argv_p++ = (char const *)c->key.vb_strvalue;
322 *argv_len_p++ = c->key.vb_length;
323
324 /*
325 * Add the maps to the command string in reverse order
326 */
327 if (fr_redis_tuple_from_map(pool, argv_p, argv_len_p, &created) < 0) {
328 REDEBUG("Failed encoding map as Redis K/V pair");
329 talloc_free(pool);
330 return CACHE_ERROR;
331 }
332 argv_p += 3;
333 argv_len_p += 3;
334 if (fr_redis_tuple_from_map(pool, argv_p, argv_len_p, &expires) < 0) {
335 REDEBUG("Failed encoding map as Redis K/V pair");
336 talloc_free(pool);
337 return CACHE_ERROR;
338 }
339 argv_p += 3;
340 argv_len_p += 3;
341 while ((map = map_list_next(&c->maps, map))) {
342 if (fr_redis_tuple_from_map(pool, argv_p, argv_len_p, map) < 0) {
343 REDEBUG("Failed encoding map as Redis K/V pair");
344 talloc_free(pool);
345 return CACHE_ERROR;
346 }
347 argv_p += 3;
348 argv_len_p += 3;
349 }
350
351 RDEBUG3("Pipelining commands");
352
353 for (s_ret = fr_redis_cluster_state_init(&state, &conn, driver->cluster, request, (uint8_t const *)c->key.vb_strvalue, c->key.vb_length, false);
354 s_ret == REDIS_RCODE_TRY_AGAIN; /* Continue */
355 s_ret = fr_redis_cluster_state_next(&state, &conn, driver->cluster, request, status, &reply)) {
356 /*
357 * Start the transaction, as we need to set an expiry time too.
358 */
359 if (fr_unix_time_ispos(c->expires)) {
360 RDEBUG3("MULTI");
361 if (redisAppendCommand(conn->handle, "MULTI") != REDIS_OK) {
362 append_error:
363 REXDENT();
364 RERROR("Failed appending Redis command to output buffer: %s", conn->handle->errstr);
365 talloc_free(pool);
366 return CACHE_ERROR;
367 }
368 pipelined++;
369 }
370
371 RDEBUG3("DEL \"%pV\"", &c->key);
372
373 if (redisAppendCommand(conn->handle, "DEL %b", (uint8_t const *)c->key.vb_strvalue, c->key.vb_length) != REDIS_OK) goto append_error;
374 pipelined++;
375
376 if (RDEBUG_ENABLED3) {
377 RDEBUG3("argv command");
378 RINDENT();
379 for (i = 0; i < talloc_array_length(argv); i++) {
380 RDEBUG3("%pV", fr_box_strvalue_len(argv[i], argv_len[i]));
381 }
382 REXDENT();
383 }
384 redisAppendCommandArgv(conn->handle, talloc_array_length(argv), argv, argv_len);
385 pipelined++;
386
387 /*
388 * Set the expiry time and close out the transaction.
389 */
390 if (fr_unix_time_ispos(c->expires)) {
391 RDEBUG3("EXPIREAT \"%pV\" %" PRIu64,
392 &c->key,
394 if (redisAppendCommand(conn->handle, "EXPIREAT %b %" PRIu64, (uint8_t const *)c->key.vb_strvalue, (size_t)c->key.vb_length,
395 fr_unix_time_to_sec(c->expires)) != REDIS_OK) goto append_error;
396 pipelined++;
397 RDEBUG3("EXEC");
398 if (redisAppendCommand(conn->handle, "EXEC") != REDIS_OK) goto append_error;
399 pipelined++;
400 }
401
402 reply_cnt = fr_redis_pipeline_result(&pipelined, &status,
403 replies, NUM_ELEMENTS(replies),
404 conn);
405 reply = replies[0];
406 }
407 talloc_free(pool);
408
409 if (s_ret != REDIS_RCODE_SUCCESS) {
410 RPERROR("Failed inserting entry");
411 return CACHE_ERROR;
412 }
413
414 RDEBUG3("Command results");
415 RINDENT();
416 if (RDEBUG_ENABLED3) for (i = 0; i < reply_cnt; i++) fr_redis_reply_print(L_DBG_LVL_3, replies[i], request, i);
417 fr_redis_pipeline_free(replies, reply_cnt);
418 REXDENT();
419
420 return CACHE_OK;
421}
422
423/** Call delete the cache entry from redis
424 *
425 * @copydetails cache_entry_expire_t
426 */
428 request_t *request, UNUSED void *handle, fr_value_box_t const *key)
429{
430 rlm_cache_redis_t *driver = instance;
432 fr_redis_conn_t *conn;
433 fr_redis_rcode_t status;
434 redisReply *reply = NULL;
435 int s_ret;
436 cache_status_t cache_status;
437
438 for (s_ret = fr_redis_cluster_state_init(&state, &conn, driver->cluster, request, (uint8_t const *)key->vb_strvalue, key->vb_length, false);
439 s_ret == REDIS_RCODE_TRY_AGAIN; /* Continue */
440 s_ret = fr_redis_cluster_state_next(&state, &conn, driver->cluster, request, status, &reply)) {
441 reply = redisCommand(conn->handle, "DEL %b", (uint8_t const *)key->vb_strvalue, key->vb_length);
442 status = fr_redis_command_status(conn, reply);
443 }
444
445 if (s_ret != REDIS_RCODE_SUCCESS) {
446 RERROR("Failed expiring entry");
447 error:
448 fr_redis_reply_free(&reply);
449 return CACHE_ERROR;
450 }
451 if (!fr_cond_assert(reply)) goto error;
452
453 if (reply->type == REDIS_REPLY_INTEGER) {
454 cache_status = CACHE_MISS;
455 if (reply->integer) cache_status = CACHE_OK; /* Affected */
456 fr_redis_reply_free(&reply);
457 return cache_status;
458 }
459
460 REDEBUG("Bad result type, expected integer, got %s",
461 fr_table_str_by_value(redis_reply_types, reply->type, "<UNKNOWN>"));
462 fr_redis_reply_free(&reply);
463
464 return CACHE_ERROR;
465}
466
469 .common = {
470 .magic = MODULE_MAGIC_INIT,
471 .name = "cache_redis",
472 .onload = mod_load,
474 .inst_size = sizeof(rlm_cache_redis_t),
476 },
477 .free = cache_entry_free,
478 .find = cache_entry_find,
479 .insert = cache_entry_insert,
480 .expire = cache_entry_expire,
481};
static int const char char buffer[256]
Definition acutest.h:576
#define unlikely(_x)
Definition build.h:381
#define UNUSED
Definition build.h:315
#define NUM_ELEMENTS(_t)
Definition build.h:337
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:642
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:579
fr_redis_cluster_t * fr_redis_cluster_alloc(TALLOC_CTX *ctx, CONF_SECTION *module, fr_redis_conf_t *conf, bool triggers_enabled, char const *log_prefix, char const *trigger_prefix, fr_pair_list_t *trigger_args)
Allocate and initialise a new cluster structure.
Definition cluster.c:2261
fr_redis_rcode_t fr_redis_cluster_state_next(fr_redis_cluster_state_t *state, fr_redis_conn_t **conn, fr_redis_cluster_t *cluster, request_t *request, fr_redis_rcode_t status, redisReply **reply)
Get the next connection to attempt a command against.
Definition cluster.c:1863
fr_redis_rcode_t fr_redis_cluster_state_init(fr_redis_cluster_state_t *state, fr_redis_conn_t **conn, fr_redis_cluster_t *cluster, request_t *request, uint8_t const *key, size_t key_len, bool read_only)
Resolve a key to a pool, and reserve a connection in that pool.
Definition cluster.c:1741
A redis cluster.
Definition cluster.c:251
Redis connection sequence state.
Definition cluster.h:49
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:139
#define ERROR(fmt,...)
Definition dhcpclient.c:41
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:268
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:281
Specifies an attribute which must be present for the module to function.
Definition dict.h:267
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:280
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
#define REXDENT()
Exdent (unindent) R* messages by one level.
Definition log.h:443
#define RDEBUG_ENABLED3
True if request debug level 1-3 messages are enabled.
Definition log.h:335
#define RDEBUG3(fmt,...)
Definition log.h:343
#define RERROR(fmt,...)
Definition log.h:298
#define RPERROR(fmt,...)
Definition log.h:302
#define RINDENT()
Indent R* messages by one level.
Definition log.h:430
talloc_free(reap)
@ L_DBG_LVL_3
3rd highest priority debug messages (-xxx | -Xx).
Definition log.h:72
struct map_s map_t
Definition map.h:33
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
unsigned char uint8_t
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
static const conf_parser_t config[]
Definition base.c:183
#define REDEBUG(fmt,...)
Definition radclient.h:52
static void fr_redis_pipeline_free(redisReply *reply[], size_t num)
Definition base.h:70
redisContext * handle
Hiredis context used when issuing commands.
Definition base.h:101
#define REDIS_COMMON_CONFIG
Definition base.h:133
int fr_redis_tuple_from_map(TALLOC_CTX *pool, char const *out[], size_t out_len[], map_t *map)
Add a single map pair to an existing command string as three elements.
Definition redis.c:459
void fr_redis_reply_print(fr_log_lvl_t lvl, redisReply *reply, request_t *request, int idx)
Print the response data in a useful treelike form.
Definition redis.c:141
static void fr_redis_reply_free(redisReply **reply)
Wrap freeReplyObject so we consistently check for NULL pointers.
Definition base.h:64
void fr_redis_version_print(void)
Print the version of libhiredis the server was built against.
Definition redis.c:53
fr_redis_rcode_t fr_redis_command_status(fr_redis_conn_t *conn, redisReply *reply)
Check the reply for errors.
Definition redis.c:71
fr_table_num_sorted_t const redis_reply_types[]
Definition redis.c:30
fr_redis_rcode_t fr_redis_pipeline_result(unsigned int *pipelined, fr_redis_rcode_t *rcode, redisReply *out[], size_t out_len, fr_redis_conn_t *conn)
Simplifies handling of pipelined commands with Redis cluster.
Definition redis.c:535
fr_redis_rcode_t
Codes are ordered inversely by priority.
Definition base.h:87
@ REDIS_RCODE_SUCCESS
Operation was successful.
Definition base.h:88
@ REDIS_RCODE_TRY_AGAIN
Try the operation again.
Definition base.h:90
int fr_redis_reply_to_map(TALLOC_CTX *ctx, map_list_t *out, request_t *request, redisReply *key, redisReply *op, redisReply *value)
Convert a pair of redis reply objects to a map.
Definition redis.c:365
Configuration parameters for a redis connection.
Definition base.h:109
Connection handle, holding a redis context.
Definition base.h:100
fr_value_box_t key
Key used to identify entry.
Definition rlm_cache.h:73
map_list_t maps
Head of the maps list.
Definition rlm_cache.h:78
fr_unix_time_t created
When the entry was created.
Definition rlm_cache.h:75
module_t common
Common fields for all loadable modules.
Definition rlm_cache.h:258
cache_status_t
Definition rlm_cache.h:39
@ CACHE_ERROR
Fatal error.
Definition rlm_cache.h:41
@ CACHE_OK
Cache entry found/updated.
Definition rlm_cache.h:42
@ CACHE_MISS
Cache entry notfound.
Definition rlm_cache.h:43
fr_unix_time_t expires
When the entry expires.
Definition rlm_cache.h:76
Configuration for the rlm_cache module.
Definition rlm_cache.h:51
Definition rlm_cache.h:72
static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, const rlm_cache_entry_t *c)
Insert a new entry into the data store.
static int mod_load(void)
fr_redis_conf_t conf
Connection parameters for the Redis server.
static fr_dict_attr_t const * attr_cache_created
static void cache_entry_free(rlm_cache_entry_t *c)
fr_dict_attr_autoload_t rlm_cache_redis_dict_attr[]
rlm_cache_driver_t rlm_cache_redis
tmpl_t * expires_attr
LHS of the Cache-Expires map.
static fr_dict_t const * dict_freeradius
static conf_parser_t driver_config[]
static cache_status_t cache_entry_expire(UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, fr_value_box_t const *key)
Call delete the cache entry from redis.
static fr_dict_attr_t const * attr_cache_expires
static cache_status_t cache_entry_find(rlm_cache_entry_t **out, UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, fr_value_box_t const *key)
Locate a cache entry in redis.
fr_redis_cluster_t * cluster
fr_dict_autoload_t rlm_cache_redis_dict[]
tmpl_t * created_attr
LHS of the Cache-Created map.
static int mod_instantiate(module_inst_ctx_t const *mctx)
Create a new rlm_cache_redis instance.
char const * name
Instance name e.g. user_database.
Definition module.h:335
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:329
void * data
Module's instance data.
Definition module.h:271
module_instance_t const * parent
Parent module's instance (if any).
Definition module.h:337
module_instantiate_t instantiate
Callback to allow the module to register any per-instance resources like sockets and file handles.
Definition module.h:218
#define tmpl_value(_tmpl)
Definition tmpl.h:948
ssize_t tmpl_afrom_attr_str(TALLOC_CTX *ctx, tmpl_attr_error_t *err, tmpl_t **out, char const *name, tmpl_rules_t const *rules))
Parse a string into a TMPL_TYPE_ATTR_* type tmpl_t.
@ TMPL_TYPE_DATA
Value in native boxed format.
Definition tmpl.h:142
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
Definition tmpl.h:812
tmpl_t * tmpl_init_shallow(tmpl_t *vpt, tmpl_type_t type, fr_token_t quote, char const *name, ssize_t len, tmpl_rules_t const *t_rules))
Initialise a tmpl without copying the input name string.
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
Definition snprintf.c:689
Value pair map.
Definition map.h:77
fr_token_t op
The operator that controls insertion of the dst attribute.
Definition map.h:82
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
Definition table.h:772
#define talloc_zero_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size)
Definition talloc.h:177
#define fr_unix_time_ispos(_a)
Definition time.h:372
static int64_t fr_unix_time_to_sec(fr_unix_time_t delta)
Definition time.h:506
@ T_BARE_WORD
Definition token.h:120
@ T_OP_SET
Definition token.h:84
static fr_slen_t head
Definition xlat.h:422
int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src)
Copy value data verbatim duplicating any buffers.
Definition value.c:3740
#define fr_box_strvalue_len(_val, _len)
Definition value.h:286
#define fr_value_box_init(_vb, _type, _enumv, _tainted)
Initialise a fr_value_box_t.
Definition value.h:587
static size_t char ** out
Definition value.h:997