27RCSID(
"$Id: 5f274812609cd0d23caa7c04c604e15047cdcf17 $")
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 \
150"thread { num_workers = 1}" EOL \
152"client test { ipaddr = 127.0.0.1; secret = supersecret }" EOL \
154" redis_ippool {" EOL \
155" owner = request.IP-Pool.Lease.Device" EOL \
156" pool_name = control.IP-Pool.Name" EOL \
157" requested_address = IP-Pool.Lease.Address[*]" EOL \
159" virtual_server = redis" EOL \
160" pool { start = 0 }" EOL;
166"server redis { namespace = redis } " EOL \
167"server default {" EOL \
168" namespace = radius" EOL \
169" recv Access-Request { redis_ippool.stats }" EOL \
170" recv Accounting-Request { redis_ippool.show }" EOL \
174 INFO(
"Usage: %s -adrsm range... [-p prefix_len]... [-x]... [-oShf] server[:port] [pool] [range id]",
name);
175 INFO(
"Pool management:");
176 INFO(
" -a range Add address(es)/prefix(es) to the pool.");
177 INFO(
" -d range Delete address(es)/prefix(es) in this range.");
178 INFO(
" -r range Release address(es)/prefix(es) in this range.");
179 INFO(
" -s range Show addresses/prefix in this range.");
180 INFO(
" -A address/prefix Assign a static lease.");
181 INFO(
" -O owner To use when assigning a static lease.");
182 INFO(
" -U address/prefix Un-assign a static lease");
183 INFO(
" -p prefix_len Length of prefix to allocate (defaults to 32/128)");
184 INFO(
" This is used primarily for IPv6 where a prefix is");
185 INFO(
" allocated to an intermediary router, which in turn");
186 INFO(
" allocates sub-prefixes to the devices it serves.");
187 INFO(
" This argument changes the prefix_len for the previous");
188 INFO(
" instance of an -adrsm argument, only.");
189 INFO(
" -m range Change the range id to the one specified for addresses");
190 INFO(
" in this range.");
191 INFO(
" -l List available pools.");
197 INFO(
" -S Print pool statistics");
199 INFO(
"Configuration:");
200 INFO(
" -h Print this help message and exit");
201 INFO(
" -x Increase the verbosity level");
203 INFO(
" -D dictdir Set main dictionary directory (defaults to " DICTDIR);
204 INFO(
" -f file Load connection options from a FreeRADIUS format config file");
205 INFO(
" This file should contain one or more `server = <fqdn>` pairs`");
206 INFO(
" and, optionally `port = <port>`, `password = secret`");
208 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\"");
209 INFO(
"CIDR host bits set start address, e.g. 127.0.0.200/24 -> 127.0.0.200-127.0.0.254");
215 if (bits >= 32)
return 0xffffffff;
216 return (1U << bits) - 1;
232 switch (ipaddr->
af) {
240 uint128_t ip_curr, ip_end;
242 if (!
fr_cond_assert((prefix > 0) && (prefix <= 128)))
return false;
245 memcpy(&ip_curr, ipaddr->
addr.v6.s6_addr,
sizeof(ip_curr));
246 memcpy(&ip_end, end->
addr.v6.s6_addr,
sizeof(ip_curr));
248 ip_curr = ntohlll(ip_curr);
249 ip_end = ntohlll(ip_end);
252 if (
uint128_eq(ip_curr, ip_end))
return false;
256 ip_curr = htonlll(ip_curr);
257 memcpy(&ipaddr->
addr.v6.s6_addr, &ip_curr,
sizeof(ipaddr->
addr.v6.s6_addr));
265 if (!
fr_cond_assert((prefix > 0) && (prefix <= 32)))
return false;
267 ip_curr = ntohl(ipaddr->
addr.v4.s_addr);
268 ip_end = ntohl(end->
addr.v4.s_addr);
271 if (ip_curr == ip_end)
return false;
274 ip_curr += 1 << (32 - prefix);
275 ipaddr->
addr.v4.s_addr = htonl(ip_curr);
329 ipaddr.
prefix = (ipaddr.
af == AF_INET6) ? 128 : 32;
336 strlen(ip_buff), NULL) < 0)
return -1;
368 p = strchr(ip_str,
'-');
370 char start_buff[INET6_ADDRSTRLEN + 4];
371 char end_buff[INET6_ADDRSTRLEN + 4];
374 if ((
size_t)(p - ip_str) >=
sizeof(start_buff)) {
375 ERROR(
"Start address too long");
379 len =
strlcpy(start_buff, ip_str, (p - ip_str) + 1);
381 ERROR(
"Start address too long");
385 len =
strlcpy(end_buff, p + 1,
sizeof(end_buff));
387 ERROR(
"End address too long");
391 if (
fr_inet_pton(&start, start_buff, -1, AF_UNSPEC,
false,
true) < 0) {
392 PERROR(
"Failed parsing \"%s\" as start address", start_buff);
396 if (
fr_inet_pton(&end, end_buff, -1, AF_UNSPEC,
false,
true) < 0) {
397 PERROR(
"Failed parsing \"%s\" end address", end_buff);
401 if (start.
af != end.
af) {
402 ERROR(
"Start and end address must be of the same address family");
411 if (start.
af == AF_INET6) {
412 uint128_t start_int, end_int;
414 memcpy(&start_int, start.
addr.v6.s6_addr,
sizeof(start_int));
415 memcpy(&end_int, end.
addr.v6.s6_addr,
sizeof(end_int));
416 if (
uint128_gt(ntohlll(start_int), ntohlll(end_int))) {
417 ERROR(
"End address must be greater than or equal to start address");
426 ERROR(
"End address must be greater than or equal to start address");
445 if (
fr_inet_pton(&start, ip_str, -1, AF_UNSPEC,
false,
false) < 0) {
446 ERROR(
"Failed parsing \"%s\" as IPv4/v6 subnet", ip_str);
452 if (prefix < start.
prefix) {
453 ERROR(
"-p must be greater than or equal to /<mask> (%u)", start.
prefix);
457 ERROR(
"-p must be less than or equal to address length (%u)",
IPADDR_LEN(start.
af));
461 if ((prefix - start.
prefix) > 64) {
462 ERROR(
"-p must be less than or equal to %u", start.
prefix + 64);
470 ex_broadcast = (start.
af == AF_INET) && (
IPADDR_LEN(start.
af) == prefix);
486 if (start.
af == AF_INET6) {
487 uint128_t ip, p_mask;
493 memcpy(&ip, start.
addr.v6.s6_addr,
sizeof(ip));
502 memcpy(&end.
addr.v6.s6_addr, &ip,
sizeof(end.
addr.v6.s6_addr));
509 ip = ntohl(start.
addr.v4.s_addr);
515 if (ex_broadcast) ip--;
516 end.
addr.v4.s_addr = htonl(ip);
531 &(fr_sbuff_parse_rules_t){
541 .allow_unknown =
false,
571 "%%redis_ippool.addresses.add('%s', '%pV', '%pV', %d, '%s')", op->
pool,
575 "%%redis_ippool.addresses.add('%s', '%pV', '%pV', %d)", op->
pool,
578 if (xlat_len == 0)
return -1;
591 "%%redis_ippool.addresses.remove('%s', '%pV', '%pV', %d)", op->
pool,
593 if (xlat_len == 0)
return -1;
606 "%%redis_ippool.addresses.release('%s', '%pV', '%pV', %d)", op->
pool,
608 if (xlat_len == 0)
return -1;
621 "%%redis_ippool.addresses.modify('%s', '%pV', '%pV', '%s', %d)", op->
pool,
623 if (xlat_len == 0)
return -1;
636 "%%redis_ippool.address.assign('%s', '%pV', '%s', '%s')", op->
pool,
640 "%%redis_ippool.address.assign('%s', '%pV', '%s')", op->
pool,
643 if (xlat_len == 0)
return -1;
655 "%%redis_ippool.address.unassign('%s', '%pV', '%s')", op->
pool,
657 if (xlat_len == 0)
return -1;
666 char xlat[] =
"%redis_ippool.pools.list()";
679 if (!request->packet) request->packet =
fr_packet_alloc(request,
false);
690 .s_addr = htonl(INADDR_LOOPBACK)
700 .s_addr = htonl(INADDR_LOOPBACK)
708 request->log.dst = talloc_zero(request,
log_dst_t);
715 request->async = talloc_zero(request,
fr_async_t);
719 fprintf(stderr,
"Failed converting packet IPs to attributes");
726int main(
int argc,
char *argv[])
731 int c, ret = EXIT_SUCCESS;
735 bool do_export =
false, print_stats =
false, list_pools =
false;
736 bool need_pool =
false;
737 char *do_import = NULL;
738 char *filename = NULL;
739 char const *owner = NULL;
746 TALLOC_CTX *thread_ctx;
750 char tmpdir[] =
"/tmp/ippool_toolXXXXXX";
751 char filepath[
sizeof(
"/tmp/ippool_toolXXXXXX/rlm_redis_ippool_tool.conf")];
754 fr_value_box_list_t vb_list;
760 fr_value_box_list_init(&vb_list);
775 n = strrchr(
name, FR_DIR_SEP);
796#define ADD_ACTION(_action) \
799 ERROR("Too many actions, max is " STRINGIFY(sizeof(ops))); \
802 p->action = _action; \
808 while ((c = getopt(argc, argv,
"a:d:D:r:s:Sm:A:U:O:p:ilLhxo:f:")) != -1)
switch (c) {
851 ERROR(
"Prefix may only be specified after a pool management action");
855 tmp = strtoul(optarg, &q, 10);
856 if (q != (optarg + strlen(optarg))) {
857 ERROR(
"Prefix must be an integer value");
861 (p - 1)->prefix = (
uint8_t)tmp & 0xff;
874 if (list_pools)
usage(1);
903 ERROR(
"Need server address/port");
906 if ((argc == 1) && need_pool) {
907 ERROR(
"Need pool to operate on");
910 if (argc > 3)
usage(64);
946 PERROR(
"Failed initialising main event loop");
971 conf_file = fopen(filepath,
"w");
975 fprintf(conf_file,
"$INCLUDE %s\n", filename);
977 fprintf(conf_file,
"server = %s\n", argv[0]);
988 if (!
client_find(NULL, &(
fr_ipaddr_t) { .af = AF_INET, .prefix = 32, .addr.v4.s_addr = htonl(INADDR_LOOPBACK) },
1040 if (argv[1] && (argv[1][0] !=
'\0')) {
1044 MEM(fr_sbuff_init_talloc(
autofree, &
out, &tctx, strlen(argv[1]) + 1, SIZE_MAX));
1051 if (argc >= 3 && (argv[2][0] !=
'\0')) {
1055 MEM(fr_sbuff_init_talloc(
autofree, &
out, &tctx, strlen(argv[1]) + 1, SIZE_MAX));
1062 if (!do_import && !do_export && !list_pools && !print_stats && (p == ops)) {
1063 ERROR(
"Nothing to do!");
1068 ERROR(
"NOT YET IMPLEMENTED");
1072 ERROR(
"NOT YET IMPLEMENTED");
1076 fr_value_box_list_t pools;
1078 fr_pair_t *total, *static_total, *static_free, *dyn_free;
1079 fr_pair_t *exp1m, *exp30m, *exp1h, *exp1d;
1081 fr_value_box_list_init(&pools);
1086 fr_value_box_list_insert_tail(&pools, vb);
1094 INFO(
"pool : %pV", vb);
1104 INFO(
"total : %pV", &total->data);
1108 INFO(
"dynamic total : %" PRIu64, total->vp_uint64 - static_total->vp_uint64);
1112 INFO(
"dynamic free : %pV", &dyn_free->data);
1113 INFO(
"dynamic used : %" PRIu64, total->vp_uint64 - static_total->vp_uint64 - dyn_free->vp_uint64);
1114 if ((total->vp_uint64 - static_total->vp_uint64) > 0) {
1115 INFO(
"dynamic used (%%) : %.2Lf",
1116 ((
long double)(total->vp_uint64 - dyn_free->vp_uint64 - static_total->vp_uint64) /
1117 (
long double)(total->vp_uint64 - static_total->vp_uint64)) * 100);
1119 INFO(
"used (%%) : 0");
1128 INFO(
"expiring 0-1m : %" PRIu64, exp1m->vp_uint64);
1129 INFO(
"expiring 1-30m : %" PRIu64, exp30m->vp_uint64 - exp1m->vp_uint64);
1130 INFO(
"expiring 30m-1h : %" PRIu64, exp1h->vp_uint64 - exp30m->vp_uint64);
1131 INFO(
"expiring 1h-1d : %" PRIu64, exp1d->vp_uint64 - exp1h->vp_uint64);
1132 INFO(
"static total : %pV", &static_total->data);
1136 INFO(
"static 'free' : %pV", &static_free->data);
1137 INFO(
"static issued : %" PRIu64, static_total->vp_uint64 - static_free->vp_uint64);
1138 if (static_total->vp_uint64) {
1139 INFO(
"static issued (%%) : %.2Lf",
1140 ((
long double)(static_total->vp_uint64 - static_free->vp_uint64) /
1141 (
long double)(static_total->vp_uint64)) * 100);
1143 INFO(
"static issued (%%) : 0");
1152 INFO(
"static renew 0-1m : %" PRIu64, exp1m->vp_uint64);
1153 INFO(
"static renew 1-30m : %" PRIu64, exp30m->vp_uint64 - exp1m->vp_uint64);
1154 INFO(
"static renew 30m-1h : %" PRIu64, exp1h->vp_uint64 - exp30m->vp_uint64);
1155 INFO(
"static renew 1h-1d : %" PRIu64, exp1d->vp_uint64 - exp1h->vp_uint64);
1158 fr_value_box_list_talloc_free(&pools);
1162 fr_value_box_list_t pools;
1164 fr_value_box_list_init(&pools);
1168 fr_value_box_list_talloc_free(&pools);
1176 for (p = ops; p < end; p++) {
1182 p->
pool_len = talloc_array_length(pool_arg);
1184 if (!p->
range && range_arg) {
1185 p->
range = range_arg;
1186 p->
range_len = talloc_array_length(range_arg);
1190 for (p = ops; (p < end) && (p->
start.
af != AF_UNSPEC); p++)
switch (p->
action) {
1192 fr_value_box_list_talloc_free(&vb_list);
1195 INFO(
"Added %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1199 fr_value_box_list_talloc_free(&vb_list);
1202 INFO(
"Removed %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1206 fr_value_box_list_talloc_free(&vb_list);
1209 INFO(
"Released %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1214 fr_pair_t *ippool, *
vp, *device, *gateway, *expires;
1226 INFO(
"Retrieved information for %u address(es)/prefix(es)",
1233 if (
vp)
INFO(
"range : %pV", &
vp->data);
1237 INFO(
"address/prefix : %pV", &
vp->data);
1241 INFO(
"active : %s",
vp->vp_bool ?
"yes" :
"no");
1248 if (expires)
INFO(
"lease expires : %pV", &expires->data);
1249 if (device)
INFO(
"device id : %pV", &device->data);
1250 if (gateway)
INFO(
"gateway id : %pV", &gateway->data);
1252 if (expires)
INFO(
"lease expired : %pV", &expires->data);
1253 if (device)
INFO(
"last device id : %pV", &device->data);
1254 if (gateway)
INFO(
"last gateway id : %pV", &gateway->data);
1261 fr_value_box_list_talloc_free(&vb_list);
1264 INFO(
"Modified %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1269 ERROR(
"Static assignment requires a single IP");
1273 ERROR(
"Static assignment requires an owner");
1277 fr_value_box_list_talloc_free(&vb_list);
1279 INFO(
"Assigned %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1284 ERROR(
"Static lease un-assignment requires a single IP");
1288 ERROR(
"Static lease un-assignment requires an owner");
1292 fr_value_box_list_talloc_free(&vb_list);
1294 INFO(
"Un-assigned %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
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(...)
#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_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)
int fr_dict_internal_afrom_file(fr_dict_t **out, char const *dict_subdir, char const *dependent))
(Re-)Initialize the special internal dictionary
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_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.
union fr_ipaddr_t::@154 addr
uint8_t prefix
Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.
#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)
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_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_pair_t const *prev, 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[]
#define RLM_MODULE_USER_SECTION_REJECT
Rcodes that translate to a user configurable section failing overall.
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
#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)
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
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.
ssize_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)
size_t fr_value_str_unescape(fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, char quote)
Convert a string value with escape sequences into its binary form.
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.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
#define fr_box_ipaddr(_val)
#define fr_value_box_list_foreach(_list_head, _iter)
static size_t char ** out
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)