27RCSID(
"$Id: b323b7599503696931ff4929305c3a7351bcb5f4 $")
28#include <freeradius-devel/server/base.h>
29#include <freeradius-devel/server/module_rlm.h>
30#include <freeradius-devel/io/listen.h>
31#include <freeradius-devel/unlang/base.h>
32#include <freeradius-devel/io/thread.h>
37#define EXIT_WITH_FAILURE \
152"thread { num_workers = 1}" EOL \
154"client test { ipaddr = 127.0.0.1; secret = supersecret }" EOL \
156" redis_ippool {" EOL \
157" owner = request.IP-Pool.Lease.Device" EOL \
158" pool_name = control.IP-Pool.Name" EOL \
159" requested_address = IP-Pool.Lease.Address[*]" EOL \
161" virtual_server = redis" EOL \
162" pool { start = 0 }" EOL;
168"server redis { namespace = redis } " EOL \
169"server default {" EOL \
170" namespace = radius" EOL \
171" recv Access-Request { redis_ippool.stats }" EOL \
172" recv Accounting-Request { redis_ippool.show }" EOL \
176 INFO(
"Usage: %s -adrsm range... [-p prefix_len]... [-x]... [-oShf] server[:port] [pool] [range id]",
name);
177 INFO(
"Pool management:");
178 INFO(
" -a range Add address(es)/prefix(es) to the pool.");
179 INFO(
" -d range Delete address(es)/prefix(es) in this range.");
180 INFO(
" -r range Release address(es)/prefix(es) in this range.");
181 INFO(
" -s range Show addresses/prefix in this range.");
182 INFO(
" -A address/prefix Assign a static lease.");
183 INFO(
" -O owner To use when assigning a static lease.");
184 INFO(
" -U address/prefix Un-assign a static lease");
185 INFO(
" -p prefix_len Length of prefix to allocate (defaults to 32/128)");
186 INFO(
" This is used primarily for IPv6 where a prefix is");
187 INFO(
" allocated to an intermediary router, which in turn");
188 INFO(
" allocates sub-prefixes to the devices it serves.");
189 INFO(
" This argument changes the prefix_len for the previous");
190 INFO(
" instance of an -adrsm argument, only.");
191 INFO(
" -m range Change the range id to the one specified for addresses");
192 INFO(
" in this range.");
193 INFO(
" -l List available pools.");
199 INFO(
" -S Print pool statistics");
201 INFO(
"Configuration:");
202 INFO(
" -h Print this help message and exit");
203 INFO(
" -x Increase the verbosity level");
205 INFO(
" -D dictdir Set main dictionary directory (defaults to " DICTDIR);
206 INFO(
" -f file Load connection options from a FreeRADIUS format config file");
207 INFO(
" This file should contain one or more `server = <fqdn>` pairs`");
208 INFO(
" and, optionally `port = <port>`, `password = secret`");
210 INFO(
"<range> is range \"127.0.0.1-127.0.0.254\" or CIDR network \"127.0.0.1/24\" or host \"127.0.0.1\"");
211 INFO(
"CIDR host bits set start address, e.g. 127.0.0.200/24 -> 127.0.0.200-127.0.0.254");
217 if (bits >= 32)
return 0xffffffff;
218 return (1U << bits) - 1;
234 switch (ipaddr->
af) {
242 uint128_t ip_curr, ip_end;
244 if (!
fr_cond_assert((prefix > 0) && (prefix <= 128)))
return false;
247 memcpy(&ip_curr, ipaddr->
addr.v6.s6_addr,
sizeof(ip_curr));
248 memcpy(&ip_end, end->
addr.v6.s6_addr,
sizeof(ip_curr));
250 ip_curr = ntohlll(ip_curr);
251 ip_end = ntohlll(ip_end);
254 if (
uint128_eq(ip_curr, ip_end))
return false;
258 ip_curr = htonlll(ip_curr);
259 memcpy(&ipaddr->
addr.v6.s6_addr, &ip_curr,
sizeof(ipaddr->
addr.v6.s6_addr));
267 if (!
fr_cond_assert((prefix > 0) && (prefix <= 32)))
return false;
269 ip_curr = ntohl(ipaddr->
addr.v4.s_addr);
270 ip_end = ntohl(end->
addr.v4.s_addr);
273 if (ip_curr == ip_end)
return false;
276 ip_curr += 1 << (32 - prefix);
277 ipaddr->
addr.v4.s_addr = htonl(ip_curr);
331 ipaddr.
prefix = (ipaddr.
af == AF_INET6) ? 128 : 32;
338 strlen(ip_buff), NULL) < 0)
return -1;
370 p = strchr(ip_str,
'-');
372 char start_buff[INET6_ADDRSTRLEN + 4];
373 char end_buff[INET6_ADDRSTRLEN + 4];
376 if ((
size_t)(p - ip_str) >=
sizeof(start_buff)) {
377 ERROR(
"Start address too long");
381 len =
strlcpy(start_buff, ip_str, (p - ip_str) + 1);
383 ERROR(
"Start address too long");
387 len =
strlcpy(end_buff, p + 1,
sizeof(end_buff));
389 ERROR(
"End address too long");
393 if (
fr_inet_pton(&start, start_buff, -1, AF_UNSPEC,
false,
true) < 0) {
394 PERROR(
"Failed parsing \"%s\" as start address", start_buff);
398 if (
fr_inet_pton(&end, end_buff, -1, AF_UNSPEC,
false,
true) < 0) {
399 PERROR(
"Failed parsing \"%s\" end address", end_buff);
403 if (start.
af != end.
af) {
404 ERROR(
"Start and end address must be of the same address family");
413 if (start.
af == AF_INET6) {
414 uint128_t start_int, end_int;
416 memcpy(&start_int, start.
addr.v6.s6_addr,
sizeof(start_int));
417 memcpy(&end_int, end.
addr.v6.s6_addr,
sizeof(end_int));
418 if (
uint128_gt(ntohlll(start_int), ntohlll(end_int))) {
419 ERROR(
"End address must be greater than or equal to start address");
428 ERROR(
"End address must be greater than or equal to start address");
447 if (
fr_inet_pton(&start, ip_str, -1, AF_UNSPEC,
false,
false) < 0) {
448 ERROR(
"Failed parsing \"%s\" as IPv4/v6 subnet", ip_str);
454 if (prefix < start.
prefix) {
455 ERROR(
"-p must be greater than or equal to /<mask> (%u)", start.
prefix);
459 ERROR(
"-p must be less than or equal to address length (%u)",
IPADDR_LEN(start.
af));
463 if ((prefix - start.
prefix) > 64) {
464 ERROR(
"-p must be less than or equal to %u", start.
prefix + 64U);
472 ex_broadcast = (start.
af == AF_INET) && (
IPADDR_LEN(start.
af) == prefix);
488 if (start.
af == AF_INET6) {
489 uint128_t ip, p_mask;
495 memcpy(&ip, start.
addr.v6.s6_addr,
sizeof(ip));
504 memcpy(&end.
addr.v6.s6_addr, &ip,
sizeof(end.
addr.v6.s6_addr));
511 ip = ntohl(start.
addr.v4.s_addr);
517 if (ex_broadcast) ip--;
518 end.
addr.v4.s_addr = htonl(ip);
533 &(fr_sbuff_parse_rules_t){
543 .allow_unknown =
false,
573 "%%redis_ippool.addresses.add('%s', '%pV', '%pV', %d, '%s')", op->
pool,
577 "%%redis_ippool.addresses.add('%s', '%pV', '%pV', %d)", op->
pool,
580 if (xlat_len < 0)
return -1;
593 "%%redis_ippool.addresses.remove('%s', '%pV', '%pV', %d)", op->
pool,
595 if (xlat_len < 0)
return -1;
608 "%%redis_ippool.addresses.release('%s', '%pV', '%pV', %d)", op->
pool,
610 if (xlat_len < 0)
return -1;
623 "%%redis_ippool.addresses.modify('%s', '%pV', '%pV', '%s', %d)", op->
pool,
625 if (xlat_len < 0)
return -1;
638 "%%redis_ippool.address.assign('%s', '%pV', '%s', '%s')", op->
pool,
642 "%%redis_ippool.address.assign('%s', '%pV', '%s')", op->
pool,
645 if (xlat_len < 0)
return -1;
657 "%%redis_ippool.address.unassign('%s', '%pV', '%s')", op->
pool,
659 if (xlat_len < 0)
return -1;
668 char xlat[] =
"%redis_ippool.pools.list()";
692 .s_addr = htonl(INADDR_LOOPBACK)
702 .s_addr = htonl(INADDR_LOOPBACK)
721 fprintf(stderr,
"Failed converting packet IPs to attributes");
728int main(
int argc,
char *argv[])
733 int c, ret = EXIT_SUCCESS;
737 bool do_export =
false, print_stats =
false, list_pools =
false;
738 bool need_pool =
false;
739 char *do_import = NULL;
740 char *filename = NULL;
741 char const *owner = NULL;
748 TALLOC_CTX *thread_ctx;
752 char tmpdir[] =
"/tmp/ippool_toolXXXXXX";
753 char filepath[
sizeof(
"/tmp/ippool_toolXXXXXX/rlm_redis_ippool_tool.conf")];
756 fr_value_box_list_t vb_list;
763 fr_value_box_list_init(&vb_list);
778 n = strrchr(
name, FR_DIR_SEP);
799#define ADD_ACTION(_action) \
802 ERROR("Too many actions, max is " STRINGIFY(sizeof(ops))); \
805 p->action = _action; \
811 while ((c = getopt(argc, argv,
"a:d:D:r:s:Sm:A:U:O:p:ilLhxo:f:")) != -1)
switch (c) {
854 ERROR(
"Prefix may only be specified after a pool management action");
858 tmp = strtoul(optarg, &q, 10);
859 if (q != (optarg + strlen(optarg))) {
860 ERROR(
"Prefix must be an integer value");
864 (p - 1)->prefix = (
uint8_t)tmp & 0xff;
877 if (list_pools)
usage(1);
906 ERROR(
"Need server address/port");
909 if ((argc == 1) && need_pool) {
910 ERROR(
"Need pool to operate on");
913 if (argc > 3)
usage(64);
949 PERROR(
"Failed initialising main event loop");
974 conf_file = fopen(filepath,
"w");
978 fprintf(conf_file,
"$INCLUDE %s\n", filename);
980 fprintf(conf_file,
"server = %s\n", argv[0]);
991 if (!
client_find(NULL, &(
fr_ipaddr_t) { .af = AF_INET, .prefix = 32, .addr.v4.s_addr = htonl(INADDR_LOOPBACK) },
1043 if (argv[1] && (argv[1][0] !=
'\0')) {
1047 MEM(fr_sbuff_init_talloc(
autofree, &
out, &tctx, strlen(argv[1]) + 1, SIZE_MAX));
1049 ERROR(
"Failed unescaping pool name");
1056 if (argc >= 3 && (argv[2][0] !=
'\0')) {
1060 MEM(fr_sbuff_init_talloc(
autofree, &
out, &tctx, strlen(argv[1]) + 1, SIZE_MAX));
1062 ERROR(
"Failed unescaping range name");
1069 if (!do_import && !do_export && !list_pools && !print_stats && (p == ops)) {
1070 ERROR(
"Nothing to do!");
1075 ERROR(
"NOT YET IMPLEMENTED");
1079 ERROR(
"NOT YET IMPLEMENTED");
1083 fr_value_box_list_t pools;
1085 fr_pair_t *total, *static_total, *static_free, *dyn_free;
1086 fr_pair_t *exp1m, *exp30m, *exp1h, *exp1d;
1088 fr_value_box_list_init(&pools);
1093 fr_value_box_list_insert_tail(&pools, vb);
1101 INFO(
"pool : %pV", vb);
1111 INFO(
"total : %pV", &total->data);
1115 INFO(
"dynamic total : %" PRIu64, total->vp_uint64 - static_total->vp_uint64);
1119 INFO(
"dynamic free : %pV", &dyn_free->data);
1120 INFO(
"dynamic used : %" PRIu64, total->vp_uint64 - static_total->vp_uint64 - dyn_free->vp_uint64);
1121 if ((total->vp_uint64 - static_total->vp_uint64) > 0) {
1122 INFO(
"dynamic used (%%) : %.2Lf",
1123 ((
long double)(total->vp_uint64 - dyn_free->vp_uint64 - static_total->vp_uint64) /
1124 (
long double)(total->vp_uint64 - static_total->vp_uint64)) * 100);
1126 INFO(
"used (%%) : 0");
1135 INFO(
"expiring 0-1m : %" PRIu64, exp1m->vp_uint64);
1136 INFO(
"expiring 1-30m : %" PRIu64, exp30m->vp_uint64 - exp1m->vp_uint64);
1137 INFO(
"expiring 30m-1h : %" PRIu64, exp1h->vp_uint64 - exp30m->vp_uint64);
1138 INFO(
"expiring 1h-1d : %" PRIu64, exp1d->vp_uint64 - exp1h->vp_uint64);
1139 INFO(
"static total : %pV", &static_total->data);
1143 INFO(
"static 'free' : %pV", &static_free->data);
1144 INFO(
"static issued : %" PRIu64, static_total->vp_uint64 - static_free->vp_uint64);
1145 if (static_total->vp_uint64) {
1146 INFO(
"static issued (%%) : %.2Lf",
1147 ((
long double)(static_total->vp_uint64 - static_free->vp_uint64) /
1148 (
long double)(static_total->vp_uint64)) * 100);
1150 INFO(
"static issued (%%) : 0");
1159 INFO(
"static renew 0-1m : %" PRIu64, exp1m->vp_uint64);
1160 INFO(
"static renew 1-30m : %" PRIu64, exp30m->vp_uint64 - exp1m->vp_uint64);
1161 INFO(
"static renew 30m-1h : %" PRIu64, exp1h->vp_uint64 - exp30m->vp_uint64);
1162 INFO(
"static renew 1h-1d : %" PRIu64, exp1d->vp_uint64 - exp1h->vp_uint64);
1165 fr_value_box_list_talloc_free(&pools);
1169 fr_value_box_list_t pools;
1171 fr_value_box_list_init(&pools);
1175 fr_value_box_list_talloc_free(&pools);
1183 for (p = ops; p < end; p++) {
1189 p->
pool_len = talloc_array_length(pool_arg);
1191 if (!p->
range && range_arg) {
1192 p->
range = range_arg;
1193 p->
range_len = talloc_array_length(range_arg);
1197 for (p = ops; (p < end) && (p->
start.
af != AF_UNSPEC); p++)
switch (p->
action) {
1199 fr_value_box_list_talloc_free(&vb_list);
1202 changed = fr_value_box_list_head(&vb_list);
1203 INFO(
"Added %pV address(es)/prefix(es), %pV unchanged", changed, fr_value_box_list_next(&vb_list, changed));
1207 fr_value_box_list_talloc_free(&vb_list);
1210 changed = fr_value_box_list_head(&vb_list);
1211 INFO(
"Removed %pV address(es)/prefix(es), %pV unchanged", changed, fr_value_box_list_next(&vb_list, changed));
1215 fr_value_box_list_talloc_free(&vb_list);
1218 changed = fr_value_box_list_head(&vb_list);
1219 INFO(
"Released %pV address(es)/prefix(es). %pV unchanged", changed, fr_value_box_list_next(&vb_list, changed));
1224 fr_pair_t *ippool, *
vp, *device, *gateway, *expires;
1236 INFO(
"Retrieved information for %u address(es)/prefix(es)",
1243 if (
vp)
INFO(
"range : %pV", &
vp->data);
1247 INFO(
"address/prefix : %pV", &
vp->data);
1250 if (
vp)
INFO(
"static : %s",
vp->vp_bool ?
"yes" :
"no");
1254 INFO(
"active : %s",
vp->vp_bool ?
"yes" :
"no");
1261 if (expires)
INFO(
"lease expires : %pV", &expires->data);
1262 if (device)
INFO(
"device id : %pV", &device->data);
1263 if (gateway)
INFO(
"gateway id : %pV", &gateway->data);
1265 if (expires)
INFO(
"lease expired : %pV", &expires->data);
1266 if (device)
INFO(
"last device id : %pV", &device->data);
1267 if (gateway)
INFO(
"last gateway id : %pV", &gateway->data);
1274 fr_value_box_list_talloc_free(&vb_list);
1277 changed = fr_value_box_list_head(&vb_list);
1278 INFO(
"Modified %pV address(es)/prefix(es), %pV unchanged", changed, fr_value_box_list_next(&vb_list, changed));
1283 ERROR(
"Static assignment requires a single IP");
1287 ERROR(
"Static assignment requires an owner");
1291 fr_value_box_list_talloc_free(&vb_list);
1293 INFO(
"Assigned %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1298 ERROR(
"Static lease un-assignment requires a single IP");
1302 ERROR(
"Static lease un-assignment requires an owner");
1306 fr_value_box_list_talloc_free(&vb_list);
1308 INFO(
"Un-assigned %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1322 ERROR(
"Failed setting up coordinator close events");
int fr_atexit_global_setup(void)
Setup the atexit handler, should be called at the start of a program's execution.
int fr_atexit_global_trigger_all(void)
Cause all global free triggers to fire.
#define fr_atexit_thread_trigger_all(...)
static uint8_t request[4]
#define NEVER_RETURNS
Should be placed before the function return type.
A section grouping multiple CONF_PAIR.
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
int fr_coords_create(TALLOC_CTX *ctx, fr_event_list_t *el)
Start coordinators in single threaded mode.
void fr_coords_destroy(void)
Clean up coordinators in single threaded mode.
int fr_coord_close_event_insert(fr_event_list_t *el)
int fr_coord_post_event_insert(fr_event_list_t *el)
Insert instance specific post-event callbacks.
int fr_coord_pre_event_insert(fr_event_list_t *el)
Insert instance specific pre-event callbacks.
void fr_disable_null_tracking_on_free(TALLOC_CTX *ctx)
Disable the null tracking context when a talloc chunk is freed.
void fr_talloc_fault_setup(void)
Register talloc fault handlers.
int fr_fault_setup(TALLOC_CTX *ctx, char const *cmd, char const *program, unsigned long fault_signals)
Registers signal handlers to execute panic_action on fatal signal.
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
#define PANIC_ACTION_SIGNALS
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
static NEVER_RETURNS void usage(void)
#define fr_dict_autofree(_to_free)
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
int fr_dict_free(fr_dict_t **dict, char const *dependent)
Decrement the reference count on a previously loaded dictionary.
int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
Process a dict_attr_autoload element to load/verify a dictionary attribute.
#define fr_dict_autoload(_to_load)
#define DICT_AUTOLOAD_TERMINATOR
fr_dict_gctx_t * fr_dict_global_ctx_init(TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir))
Initialise the global protocol hashes.
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
int fr_dict_internal_afrom_file(fr_dict_t **out, char const *dict_subdir, char const *dependent)
(Re-)Initialize the special internal dictionary
int fr_inet_pton(fr_ipaddr_t *out, char const *value, ssize_t inlen, int af, bool resolve, bool mask)
Simple wrapper to decide whether an IP value is v4 or v6 and call the appropriate parser.
void fr_ipaddr_mask(fr_ipaddr_t *addr, uint8_t prefix)
Zeroes out the host portion of an fr_ipaddr_t.
fr_cmp_ret_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
uint8_t prefix
Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.
union fr_ipaddr_t::@160 addr
#define FR_IPADDR_PREFIX_STRLEN
Like FR_IPADDR_STRLEN but with space for a prefix.
int unlang_interpret_push_section(unlang_result_t *p_result, request_t *request, CONF_SECTION *cs, unlang_frame_conf_t const *conf)
Push a configuration section onto the request stack for later interpretation.
#define FRAME_CONF(_default_rcode, _top_frame)
rlm_rcode_t unlang_interpret_synchronous(fr_event_list_t *el, request_t *request)
Execute an unlang section synchronously.
int server_init(CONF_SECTION *cs, char const *conf_dir, fr_dict_t *dict)
Initialize src/lib/server/.
void server_free(void)
Free src/lib/server/.
void vlog_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt, va_list ap, void *uctx)
Send a log message to its destination, possibly including fields from the request.
int fr_packet_pairs_from_packet(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_packet_t const *packet)
Allocate a "Net." struct with src/dst host and port.
int unlang_global_init(void)
int fr_event_loop(fr_event_list_t *el)
Run an event loop.
Stores all information relating to an event list.
fr_packet_t * fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new fr_packet_t.
Minimal data structure to use the new code.
int main_config_free(main_config_t **config)
main_config_t * main_config_alloc(TALLOC_CTX *ctx)
Allocate a main_config_t struct, setting defaults.
void main_config_name_set_default(main_config_t *config, char const *name, bool overwrite_config)
Set the server name.
int main_config_init(main_config_t *config)
void main_config_confdir_set(main_config_t *config, char const *name)
Set the global radius config directory.
void main_config_dict_dir_set(main_config_t *config, char const *name)
Set the global dictionary directory.
Main server configuration.
fr_event_list_t * main_loop_event_list(void)
Return the main loop event list.
int main_loop_init(void)
Initialise the main event loop, setting up signal handlers.
void main_loop_free(void)
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
module_instance_t * module_rlm_static_by_name(module_instance_t const *parent, char const *asked_name)
int modules_rlm_coord_attach(fr_event_list_t *el)
Runs the coord_attach method of all registered backend modules.
int modules_rlm_free(void)
Cleanup all global structures.
int modules_rlm_coord_detach(void)
Runs the coord_detach method of all registered backend modules.
int modules_rlm_init(void)
Initialise the module list structure.
unsigned int fr_pair_count_by_da(fr_pair_list_t const *list, fr_dict_attr_t const *da)
Return the number of instances of a given da in the specified list.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
fr_pair_t * fr_pair_parent(fr_pair_t const *vp)
Return a pointer to the parent pair.
fr_pair_t * fr_pair_afrom_da_nested(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da)
Create a pair (and all intermediate parents), and append it to the list.
#define is_truncated(_ret, _max)
static const conf_parser_t config[]
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
#define RLM_MODULE_USER_SECTION_REJECT
Rcodes that translate to a user configurable section failing overall.
#define IPPOOL_SPRINT_IP(_buff, _ip, _prefix)
If the prefix is as wide as the AF data size then print it without CIDR notation.
int request_global_init(void)
#define request_local_alloc_internal(_ctx, _args)
Allocate a new internal request outside of the request pool.
@ REQUEST_ACTIVE
Request is active (running or runnable)
ssize_t fr_sbuff_in_sprintf(fr_sbuff_t *sbuff, char const *fmt,...)
Print using a fmt string to an sbuff.
#define FR_SBUFF_IN(_start, _len_or_end)
#define FR_SBUFF_IN_STR(_start)
#define FR_SBUFF_OUT(_start, _len_or_end)
#define fr_sbuff_used(_sbuff_or_marker)
Talloc sbuff extension structure.
Set of parsing rules for *unescape_until functions.
void fr_schedule_worker_id_set(int id)
Explicitly set the worker id for the current thread.
struct tmpl_rules_s tmpl_rules_t
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
fr_client_t * client_find(fr_client_list_t const *clients, fr_ipaddr_t const *ipaddr, int proto)
void modules_init(char const *lib_dir)
Perform global initialisation for modules.
size_t strlcpy(char *dst, char const *src, size_t siz)
fr_log_dst_t dst
Log destination.
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
int fr_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el)
Instantiate thread-specific data for modules, virtual servers, xlats, unlang, and TLS.
int fr_time_start(void)
Initialize the local time.
static uint128_t uint128_new(uint64_t h, uint64_t l)
Creates a new uint128_t from a uint64_t.
static uint128_t uint128_gen_mask(uint8_t bits)
Create a 128 bit integer value with n bits high.
static uint128_t uint128_bor(uint128_t a, uint128_t b)
Perform bitwise | of two 128bit unsigned integers.
static uint128_t uint128_lshift(uint128_t num, uint8_t bits)
Left shift 128 bit integer.
static bool uint128_gt(uint128_t a, uint128_t b)
Return whether one integer is greater than the other.
static bool uint128_eq(uint128_t a, uint128_t b)
Return whether the integers are equal.
static uint128_t uint128_sub(uint128_t a, uint128_t b)
Subtract one 128bit integer from another.
static uint128_t uint128_add(uint128_t a, uint128_t b)
Add two 128bit unsigned integers.
static fr_event_list_t * el
int unlang_xlat_push(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *xlat, bool top_frame)
Push a pre-compiled xlat onto the stack for evaluation.
bool xlat_needs_resolving(xlat_exp_head_t const *head)
Check to see if the expansion needs resolving.
fr_slen_t xlat_tokenize(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)
Tokenize an xlat expansion.
int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
Walk over an xlat tree recursively, resolving any unresolved functions or references.
#define FR_DICTIONARY_INTERNAL_DIR
#define fr_pair_list_foreach(_list_head, _iter)
Iterate over the contents of a fr_pair_list_t.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
Holds information necessary for binding or connecting to a socket.
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
#define fr_strerror_const(_msg)
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
#define RADIUSD_MAGIC_NUMBER
fr_slen_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, char const *in, size_t inlen, fr_sbuff_unescape_rules_t const *erules)
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.
int fr_value_box_bstrndup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, size_t len, bool tainted)
Copy a string to to a fr_value_box_t.
fr_sbuff_err_t fr_value_str_unescape(size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, char quote)
Convert a string value with escape sequences into its binary form.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
#define fr_box_ipaddr(_val)
static fr_sbuff_err_t char ** out
static fr_sbuff_err_t char size_t * len
#define fr_value_box_list_foreach(_list_head, _iter)
virtual_server_t const * virtual_server_find(char const *name)
Return virtual server matching the specified name.
CONF_SECTION * virtual_server_cs(virtual_server_t const *vs)
Return the configuration section for a virtual server.
int virtual_servers_init(void)
Performs global initialisation for the virtual server code.
int virtual_servers_free(void)