The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
rlm_redis_ippool_tool.c
Go to the documentation of this file.
1/*
2 * This program 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: b323b7599503696931ff4929305c3a7351bcb5f4 $
19 * @file rlm_redis_ippool_tool.c
20 * @brief IP population tool.
21 *
22 * @author Arran Cudbard-Bell
23 *
24 * @copyright 2015 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25 * @copyright 2015 The FreeRADIUS server project
26 */
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>
33
34#include "base.h"
35#include "redis_ippool.h"
36
37#define EXIT_WITH_FAILURE \
38do { \
39 ret = EXIT_FAILURE; \
40 goto cleanup; \
41} while (0)
42
44
50
77
80 { .out = &attr_ippool, .name = "IP-Pool", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
81 { .out = &attr_ippool_name, .name = "IP-Pool.Name", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
82 { .out = &attr_ippool_lease, .name = "IP-Pool.Lease", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
83 { .out = &attr_ippool_lease_address, .name = "IP-Pool.Lease.Address", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
84 { .out = &attr_ippool_lease_active, .name = "IP-Pool.Lease.Active", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
85 { .out = &attr_ippool_lease_expires, .name = "IP-Pool.Lease.Expires", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
86 { .out = &attr_ippool_lease_device, .name = "IP-Pool.Lease.Device", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
87 { .out = &attr_ippool_lease_gateway, .name = "IP-Pool.Lease.Gateway", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
88 { .out = &attr_ippool_lease_range, .name = "IP-Pool.Lease.Range", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
89 { .out = &attr_ippool_lease_static, .name = "IP-Pool.Lease.Static", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
90 { .out = &attr_ippool_stats, .name = "IP-Pool.Stats", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
91 { .out = &attr_ippool_stats_total, .name = "IP-Pool.Stats.Total", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
92 { .out = &attr_ippool_stats_dynamic, .name = "IP-Pool.Stats.Dynamic", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
93 { .out = &attr_ippool_stats_dynamic_total, .name = "IP-Pool.Stats.Dynamic.Total", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
94 { .out = &attr_ippool_stats_dynamic_free, .name = "IP-Pool.Stats.Dynamic.Free", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
95 { .out = &attr_ippool_stats_dynamic_expire1m, .name = "IP-Pool.Stats.Dynamic.Expire-1m", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
96 { .out = &attr_ippool_stats_dynamic_expire30m, .name = "IP-Pool.Stats.Dynamic.Expire-30m", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
97 { .out = &attr_ippool_stats_dynamic_expire1h, .name = "IP-Pool.Stats.Dynamic.Expire-1h", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
98 { .out = &attr_ippool_stats_dynamic_expire1d, .name = "IP-Pool.Stats.Dynamic.Expire-1d", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
99 { .out = &attr_ippool_stats_static, .name = "IP-Pool.Stats.Static", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
100 { .out = &attr_ippool_stats_static_total, .name = "IP-Pool.Stats.Static.Total", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
101 { .out = &attr_ippool_stats_static_free, .name = "IP-Pool.Stats.Static.Free", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
102 { .out = &attr_ippool_stats_static_renew1m, .name = "IP-Pool.Stats.Static.Renew-1m", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
103 { .out = &attr_ippool_stats_static_renew30m, .name = "IP-Pool.Stats.Static.Renew-30m", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
104 { .out = &attr_ippool_stats_static_renew1h, .name = "IP-Pool.Stats.Static.Renew-1h", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
105 { .out = &attr_ippool_stats_static_renew1d, .name = "IP-Pool.Stats.Static.Renew-1d", .type = FR_TYPE_UINT64, .dict = &dict_freeradius },
107};
108
109/** Pool management actions
110 *
111 */
113 IPPOOL_TOOL_NOOP = 0, //!< Do nothing.
114 IPPOOL_TOOL_ADD, //!< Add one or more IP addresses.
115 IPPOOL_TOOL_REMOVE, //!< Remove one or more IP addresses.
116 IPPOOL_TOOL_RELEASE, //!< Release one or more IP addresses.
117 IPPOOL_TOOL_SHOW, //!< Show one or more IP addresses.
118 IPPOOL_TOOL_MODIFY, //!< Modify attributes of one or more IP addresses.
119 IPPOOL_TOOL_ASSIGN, //!< Assign a static IP address to a device.
120 IPPOOL_TOOL_UNASSIGN //!< Remove static IP address assignment.
122
123/** A single pool operation
124 *
125 */
126typedef struct {
127 char const *name; //!< Original range or CIDR string.
128
129 uint8_t const *pool; //!< Pool identifier.
130 size_t pool_len; //!< Length of the pool identifier.
131
132 uint8_t const *range; //!< Range identifier.
133 size_t range_len; //!< Length of the range identifier.
134
135 fr_ipaddr_t start; //!< Start address.
136 fr_ipaddr_t end; //!< End address.
137 uint8_t prefix; //!< Prefix - The bits between the address mask, and the prefix
138 //!< form the addresses to be modified in the pool.
139 ippool_tool_action_t action; //!< What to do to the leases described by net/prefix.
141
142static char const *name;
143
144#define EOL "\n"
145
146/** Static server config split into two parts
147 *
148 * The command line provided server value is inserted between
149 * the two sections, along with an optional $INCLUDE if the -f option is provided
150 */
151static char server_conf1[] =
152"thread { num_workers = 1}" EOL \
153"trigger { }" EOL \
154"client test { ipaddr = 127.0.0.1; secret = supersecret }" EOL \
155"modules {" 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 \
160" redis {" EOL \
161" virtual_server = redis" EOL \
162" pool { start = 0 }" EOL;
163
164static char server_conf2[] =
165" }" EOL \
166" }" EOL \
167"}" 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 \
173"}";
174
175static NEVER_RETURNS void usage(int ret) {
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.");
194// INFO(" -L List available ranges in pool [NYI]");
195// INFO(" -i file Import entries from ISC lease file [NYI]");
196 INFO(" "); /* -Werror=format-zero-length */
197// INFO("Pool status:");
198// INFO(" -I Output active entries in ISC lease file format [NYI]");
199 INFO(" -S Print pool statistics");
200 INFO(" "); /* -Werror=format-zero-length */
201 INFO("Configuration:");
202 INFO(" -h Print this help message and exit");
203 INFO(" -x Increase the verbosity level");
204// INFO(" -o attr=value Set option, these are specific to the backends [NYI]");
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`");
209 INFO(" ");
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");
212 fr_exit_now(ret);
213}
214
216{
217 if (bits >= 32) return 0xffffffff;
218 return (1U << bits) - 1;
219}
220
221/** Iterate over range of IP addresses
222 *
223 * Mutates the ipaddr passed in, adding one to the prefix bits on each call.
224 *
225 * @param[in,out] ipaddr to increment.
226 * @param[in] end ipaddr to stop at.
227 * @param[in] prefix Length of the prefix.
228 * @return
229 * - true if the prefix bits are not high (continue).
230 * - false if the prefix bits are high (stop).
231 */
232static bool ipaddr_next(fr_ipaddr_t *ipaddr, fr_ipaddr_t const *end, uint8_t prefix)
233{
234 switch (ipaddr->af) {
235 default:
236 case AF_UNSPEC:
237 fr_assert(0);
238 return false;
239
240 case AF_INET6:
241 {
242 uint128_t ip_curr, ip_end;
243
244 if (!fr_cond_assert((prefix > 0) && (prefix <= 128))) return false;
245
246 /* Don't be tempted to cast */
247 memcpy(&ip_curr, ipaddr->addr.v6.s6_addr, sizeof(ip_curr));
248 memcpy(&ip_end, end->addr.v6.s6_addr, sizeof(ip_curr));
249
250 ip_curr = ntohlll(ip_curr);
251 ip_end = ntohlll(ip_end);
252
253 /* We're done */
254 if (uint128_eq(ip_curr, ip_end)) return false;
255
256 /* Increment the prefix */
257 ip_curr = uint128_add(ip_curr, uint128_lshift(uint128_new(0, 1), (128 - prefix)));
258 ip_curr = htonlll(ip_curr);
259 memcpy(&ipaddr->addr.v6.s6_addr, &ip_curr, sizeof(ipaddr->addr.v6.s6_addr));
260 return true;
261 }
262
263 case AF_INET:
264 {
265 uint32_t ip_curr, ip_end;
266
267 if (!fr_cond_assert((prefix > 0) && (prefix <= 32))) return false;
268
269 ip_curr = ntohl(ipaddr->addr.v4.s_addr);
270 ip_end = ntohl(end->addr.v4.s_addr);
271
272 /* We're done */
273 if (ip_curr == ip_end) return false;
274
275 /* Increment the prefix */
276 ip_curr += 1 << (32 - prefix);
277 ipaddr->addr.v4.s_addr = htonl(ip_curr);
278 return true;
279 }
280 }
281}
282
283/** Run the redis_ippool.stats module method to fetch pool statistics
284 */
287{
288 rlm_rcode_t rcode;
289 fr_pair_t *vp;
290
291 /*
292 * Make sure the control list is empty before pools.list populates it.
293 */
294 fr_pair_list_free(&request->control_pairs);
295
296 /*
297 * Add the pool name for to fetch stats for
298 */
299 MEM(vp = fr_pair_afrom_da_nested(request->control_ctx, &request->control_pairs, attr_ippool_name));
300 if (fr_value_box_copy(vp, &vp->data, pool_name) < 0) return -1;
301
302 if (unlang_interpret_push_section(NULL, request, section,
303 FRAME_CONF(RLM_MODULE_OK, UNLANG_TOP_FRAME)) < 0) return -1;
304
306 switch (rcode) {
308 return -1;
309
310 default:
311 return 0;
312 }
313}
314
315/** Run the redis_ippool.show module method to fetch lease details
316 */
319{
320 rlm_rcode_t rcode;
321 fr_pair_t *vp;
322 fr_ipaddr_t ipaddr = op->start;
323 char ip_buff[FR_IPADDR_PREFIX_STRLEN];
324
325 fr_pair_list_free(&request->control_pairs);
326 fr_pair_list_free(&request->request_pairs);
327
328 MEM(vp = fr_pair_afrom_da_nested(request->control_ctx, &request->control_pairs, attr_ippool_name));
329 if (fr_value_box_bstrndup(vp, &vp->data, NULL, (char const *)op->pool, op->pool_len, false) < 0) return -1;
330
331 ipaddr.prefix = (ipaddr.af == AF_INET6) ? 128 : 32;
332
333 do {
334 IPPOOL_SPRINT_IP(ip_buff, &ipaddr, ipaddr.prefix);
335 MEM(vp = fr_pair_afrom_da_nested(request->request_ctx, &request->request_pairs,
337 if (fr_value_box_from_str(vp, &vp->data, vp->da->type, NULL, ip_buff,
338 strlen(ip_buff), NULL) < 0) return -1;
339 } while (ipaddr_next(&ipaddr, &op->end, op->prefix));
340
341 if (unlang_interpret_push_section(NULL, request, section,
342 FRAME_CONF(RLM_MODULE_OK, UNLANG_TOP_FRAME)) < 0) return -1;
343
345 switch (rcode) {
347 return -1;
348
349 default:
350 return 0;
351 }
352}
353
354/** Convert an IP range or CIDR mask to a start and stop address
355 *
356 * @param[out] start_out Where to write the start address.
357 * @param[out] end_out Where to write the end address.
358 * @param[in] ip_str Unparsed IP string.
359 * @param[in] prefix length of prefixes we'll be allocating.
360 * @return
361 * - 0 on success.
362 * - -1 on failure.
363 */
364static int parse_ip_range(fr_ipaddr_t *start_out, fr_ipaddr_t *end_out, char const *ip_str, uint8_t prefix)
365{
366 fr_ipaddr_t start, end;
367 bool ex_broadcast;
368 char const *p;
369
370 p = strchr(ip_str, '-');
371 if (p) {
372 char start_buff[INET6_ADDRSTRLEN + 4];
373 char end_buff[INET6_ADDRSTRLEN + 4];
374 size_t len;
375
376 if ((size_t)(p - ip_str) >= sizeof(start_buff)) {
377 ERROR("Start address too long");
378 return -1;
379 }
380
381 len = strlcpy(start_buff, ip_str, (p - ip_str) + 1);
382 if (is_truncated(len, sizeof(start_buff))) {
383 ERROR("Start address too long");
384 return -1;
385 }
386
387 len = strlcpy(end_buff, p + 1, sizeof(end_buff));
388 if (is_truncated(len, sizeof(end_buff))) {
389 ERROR("End address too long");
390 return -1;
391 }
392
393 if (fr_inet_pton(&start, start_buff, -1, AF_UNSPEC, false, true) < 0) {
394 PERROR("Failed parsing \"%s\" as start address", start_buff);
395 return -1;
396 }
397
398 if (fr_inet_pton(&end, end_buff, -1, AF_UNSPEC, false, true) < 0) {
399 PERROR("Failed parsing \"%s\" end address", end_buff);
400 return -1;
401 }
402
403 if (start.af != end.af) {
404 ERROR("Start and end address must be of the same address family");
405 return -1;
406 }
407
408 if (!prefix) prefix = IPADDR_LEN(start.af);
409
410 /*
411 * IPv6 addresses
412 */
413 if (start.af == AF_INET6) {
414 uint128_t start_int, end_int;
415
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");
420 return -1;
421 }
422 /*
423 * IPv4 addresses
424 */
425 } else {
426 if (ntohl((uint32_t)(start.addr.v4.s_addr)) >
427 ntohl((uint32_t)(end.addr.v4.s_addr))) {
428 ERROR("End address must be greater than or equal to start address");
429 return -1;
430 }
431 }
432
433 /*
434 * Mask start and end so we can do prefix ranges too
435 */
436 fr_ipaddr_mask(&start, prefix);
437 fr_ipaddr_mask(&end, prefix);
438 start.prefix = prefix;
439 end.prefix = prefix;
440
441 *start_out = start;
442 *end_out = end;
443
444 return 0;
445 }
446
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);
449 return -1;
450 }
451
452 if (!prefix) prefix = IPADDR_LEN(start.af);
453
454 if (prefix < start.prefix) {
455 ERROR("-p must be greater than or equal to /<mask> (%u)", start.prefix);
456 return -1;
457 }
458 if (prefix > IPADDR_LEN(start.af)) {
459 ERROR("-p must be less than or equal to address length (%u)", IPADDR_LEN(start.af));
460 return -1;
461 }
462
463 if ((prefix - start.prefix) > 64) {
464 ERROR("-p must be less than or equal to %u", start.prefix + 64U);
465 return -1;
466 }
467
468 /*
469 * Exclude the broadcast address only if we're dealing with IPv4 addresses
470 * if we're allocating IPv6 addresses or prefixes we don't need to.
471 */
472 ex_broadcast = (start.af == AF_INET) && (IPADDR_LEN(start.af) == prefix);
473
474 /*
475 * Excluding broadcast, 31/32 or 127/128 start/end are the same
476 */
477 if (ex_broadcast && (start.prefix >= (IPADDR_LEN(start.af) - 1))) {
478 *start_out = start;
479 *end_out = start;
480 return 0;
481 }
482
483 /*
484 * Set various fields (we only overwrite the IP later)
485 */
486 end = start;
487
488 if (start.af == AF_INET6) {
489 uint128_t ip, p_mask;
490
491 /* cond assert to satisfy clang scan */
492 if (!fr_cond_assert((prefix > 0) && (prefix <= 128))) return -1;
493
494 /* Don't be tempted to cast */
495 memcpy(&ip, start.addr.v6.s6_addr, sizeof(ip));
496 ip = ntohlll(ip);
497
498 /* Generate a mask that covers the prefix bits, and sets them high */
499 p_mask = uint128_lshift(uint128_gen_mask(prefix - start.prefix), (128 - prefix));
500 ip = htonlll(uint128_bor(p_mask, ip));
501
502 /* Decrement by one */
503 if (ex_broadcast) ip = uint128_sub(ip, uint128_new(0, 1));
504 memcpy(&end.addr.v6.s6_addr, &ip, sizeof(end.addr.v6.s6_addr));
505 } else {
506 uint32_t ip;
507
508 /* cond assert to satisfy clang scan */
509 if (!fr_cond_assert((prefix > 0) && (prefix <= 32))) return -1;
510
511 ip = ntohl(start.addr.v4.s_addr);
512
513 /* Generate a mask that covers the prefix bits and sets them high */
514 ip |= uint32_gen_mask(prefix - start.prefix) << (32 - prefix);
515
516 /* Decrement by one */
517 if (ex_broadcast) ip--;
518 end.addr.v4.s_addr = htonl(ip);
519 }
520
521 *start_out = start;
522 *end_out = end;
523
524 return 0;
525}
526
527static int run_xlat(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, fr_sbuff_t *xlat, fr_event_list_t *el)
528{
529 xlat_exp_head_t *ex;
530
531 if (xlat_tokenize(ctx, &ex,
532 xlat,
533 &(fr_sbuff_parse_rules_t){
534 .escapes = &(fr_sbuff_unescape_rules_t) {
535 .name = "xlat",
536 .chr = '\\',
537 .subs = {
538 ['%'] = '%',
539 ['\\'] = '\\',
540 },
541 }}, &(tmpl_rules_t) {
542 .attr = {
543 .allow_unknown = false,
544 .dict_def = dict_freeradius
545 },
546 .xlat = {
547 .runtime_el = el
548 },
549 .at_runtime = true
550 }) < 0) return -1;
551
552 if (xlat_needs_resolving(ex) &&
553 (xlat_resolve(ex, &(xlat_res_rules_t){ .allow_unresolved = false }) < 0)) {
554 talloc_free(ex);
555 return -1;
556 }
557
558 if (unlang_xlat_push(ctx, NULL, list, request, ex, UNLANG_TOP_FRAME) < 0) return -1;
560
561 return 0;
562}
563
564static int xlat_add_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list,
566{
567 char xlat[1024];
568 ssize_t xlat_len;
569
570 op->start.prefix = op->end.prefix = IPADDR_LEN(op->start.af);
571 if (op->range) {
572 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
573 "%%redis_ippool.addresses.add('%s', '%pV', '%pV', %d, '%s')", op->pool,
574 fr_box_ipaddr(op->start), fr_box_ipaddr(op->end), op->prefix, op->range);
575 } else {
576 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
577 "%%redis_ippool.addresses.add('%s', '%pV', '%pV', %d)", op->pool,
578 fr_box_ipaddr(op->start), fr_box_ipaddr(op->end), op->prefix);
579 }
580 if (xlat_len < 0) return -1;
581
582 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, (size_t)xlat_len), el);
583}
584
585static int xlat_remove_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list,
587{
588 char xlat[1024];
589 ssize_t xlat_len;
590
591 op->start.prefix = op->end.prefix = IPADDR_LEN(op->start.af);
592 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
593 "%%redis_ippool.addresses.remove('%s', '%pV', '%pV', %d)", op->pool,
594 fr_box_ipaddr(op->start), fr_box_ipaddr(op->end), op->prefix);
595 if (xlat_len < 0) return -1;
596
597 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, (size_t)xlat_len), el);
598}
599
600static int xlat_release_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request,
602{
603 char xlat[1024];
604 ssize_t xlat_len;
605
606 op->start.prefix = op->end.prefix = IPADDR_LEN(op->start.af);
607 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
608 "%%redis_ippool.addresses.release('%s', '%pV', '%pV', %d)", op->pool,
609 fr_box_ipaddr(op->start), fr_box_ipaddr(op->end), op->prefix);
610 if (xlat_len < 0) return -1;
611
612 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, (size_t)xlat_len), el);
613}
614
615static int xlat_modify_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request,
617{
618 char xlat[1024];
619 ssize_t xlat_len;
620
621 op->start.prefix = op->end.prefix = IPADDR_LEN(op->start.af);
622 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
623 "%%redis_ippool.addresses.modify('%s', '%pV', '%pV', '%s', %d)", op->pool,
624 fr_box_ipaddr(op->start), fr_box_ipaddr(op->end), op->range, op->prefix);
625 if (xlat_len < 0) return -1;
626
627 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, (size_t)xlat_len), el);
628}
629
630static int xlat_assign_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request,
631 ippool_tool_operation_t *op, char const *owner, fr_event_list_t *el)
632{
633 char xlat[1024];
634 ssize_t xlat_len;
635
636 if (op->range) {
637 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
638 "%%redis_ippool.address.assign('%s', '%pV', '%s', '%s')", op->pool,
639 fr_box_ipaddr(op->start), owner, op->range);
640 } else {
641 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
642 "%%redis_ippool.address.assign('%s', '%pV', '%s')", op->pool,
643 fr_box_ipaddr(op->start), owner);
644 }
645 if (xlat_len < 0) return -1;
646
647 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, (size_t)xlat_len), el);
648}
649
650static int xlat_unassign_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request,
651 ippool_tool_operation_t *op, char const *owner, fr_event_list_t *el)
652{
653 char xlat[1024];
654 ssize_t xlat_len;
655
656 xlat_len = fr_sbuff_in_sprintf(&FR_SBUFF_OUT(xlat, sizeof(xlat)),
657 "%%redis_ippool.address.unassign('%s', '%pV', '%s')", op->pool,
658 fr_box_ipaddr(op->start), owner);
659 if (xlat_len < 0) return -1;
660
661 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, (size_t)xlat_len), el);
662}
663
664/** Run the redis_ippool.pools.list xlat to fetch the list of pools across the cluster.
665 */
666static int redis_ippool_get_pools(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, fr_event_list_t *el)
667{
668 char xlat[] = "%redis_ippool.pools.list()";
669
670 return run_xlat(ctx, list, request, &FR_SBUFF_IN(xlat, sizeof(xlat) - 1), el);
671}
672
673static request_t *request_from_internal(TALLOC_CTX *ctx)
674{
676
677 /*
678 * Create and initialize the new request.
679 */
681 if (!request->packet) request->packet = fr_packet_alloc(request, false);
682 if (!request->reply) request->reply = fr_packet_alloc(request, false);
683
684 request->packet->socket = (fr_socket_t){
685 .type = SOCK_DGRAM,
686 .inet = {
687 .src_ipaddr = {
688 .af = AF_INET,
689 .prefix = 32,
690 .addr = {
691 .v4 = {
692 .s_addr = htonl(INADDR_LOOPBACK)
693 }
694 }
695 },
696 .src_port = 18120,
697 .dst_ipaddr = {
698 .af = AF_INET,
699 .prefix = 32,
700 .addr = {
701 .v4 = {
702 .s_addr = htonl(INADDR_LOOPBACK)
703 }
704 }
705 },
706 .dst_port = 1812
707 }
708 };
709
710 request->log.dst = talloc_zero(request, log_dst_t);
711 request->log.dst->func = vlog_request;
712 request->log.dst->uctx = &default_log;
713 request->log.dst->lvl = fr_debug_lvl;
714
715 request->master_state = REQUEST_ACTIVE;
716 request->log.lvl = fr_debug_lvl;
717 request->async = talloc_zero(request, fr_async_t);
718
719 if (fr_packet_pairs_from_packet(request->request_ctx, &request->request_pairs, request->packet) < 0) {
721 fprintf(stderr, "Failed converting packet IPs to attributes");
722 return NULL;
723 }
724
725 return request;
726}
727
728int main(int argc, char *argv[])
729{
730 static ippool_tool_operation_t ops[128];
731 ippool_tool_operation_t *p = ops, *end = ops + (NUM_ELEMENTS(ops));
732
733 int c, ret = EXIT_SUCCESS;
734
735 uint8_t *range_arg = NULL;
736 uint8_t *pool_arg = NULL;
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;
742
743 request_t *request = NULL;
744 fr_event_list_t *el = NULL;
745 fr_dict_t *dict = NULL;
746
747 TALLOC_CTX *autofree;
748 TALLOC_CTX *thread_ctx;
749
750 char *n;
752 char tmpdir[] = "/tmp/ippool_toolXXXXXX";
753 char filepath[sizeof("/tmp/ippool_toolXXXXXX/rlm_redis_ippool_tool.conf")];
754 FILE *conf_file;
755
756 fr_value_box_list_t vb_list; // To store results of xlat calls.
757 fr_value_box_t *changed;
758
759 virtual_server_t const *vs;
761 CONF_SECTION *pool_stats, *pool_show; // Process sections used to call module methods
762
763 fr_value_box_list_init(&vb_list);
764
765 name = argv[0];
766
768
770 thread_ctx = talloc_new(autofree);
771
773 if (!config) {
774 fr_perror("%s", name);
775 fr_exit_now(EXIT_FAILURE);
776 }
777
778 n = strrchr(name, FR_DIR_SEP);
779 if (!n) {
781 } else {
783 }
784
786
787#ifndef NDEBUG
788 if (fr_fault_setup(autofree, getenv("PANIC_ACTION"), name, PANIC_ACTION_SIGNALS) < 0) {
789 fr_perror("%s", config->name);
790 fr_exit_now(EXIT_FAILURE);
791 }
792#else
794#endif
795
796 fr_debug_lvl = 0;
798
799#define ADD_ACTION(_action) \
800do { \
801 if (p >= end) { \
802 ERROR("Too many actions, max is " STRINGIFY(sizeof(ops))); \
803 usage(64); \
804 } \
805 p->action = _action; \
806 p->name = optarg; \
807 p++; \
808 need_pool = true; \
809} while (0)
810
811 while ((c = getopt(argc, argv, "a:d:D:r:s:Sm:A:U:O:p:ilLhxo:f:")) != -1) switch (c) {
812 case 'a':
814 break;
815
816 case 'd':
818 break;
819
820 case 'D':
822 break;
823
824 case 'r':
826 break;
827
828 case 's':
830 break;
831
832 case 'm':
834 break;
835
836 case 'A':
838 break;
839
840 case 'U':
842 break;
843
844 case 'O':
845 owner = optarg;
846 break;
847
848 case 'p':
849 {
850 unsigned long tmp;
851 char *q;
852
853 if (p == ops) {
854 ERROR("Prefix may only be specified after a pool management action");
855 usage(64);
856 }
857
858 tmp = strtoul(optarg, &q, 10);
859 if (q != (optarg + strlen(optarg))) {
860 ERROR("Prefix must be an integer value");
861 usage(64);
862 }
863
864 (p - 1)->prefix = (uint8_t)tmp & 0xff;
865 }
866 break;
867
868 case 'i':
869 do_import = optarg;
870 break;
871
872 case 'I':
873 do_export = true;
874 break;
875
876 case 'l':
877 if (list_pools) usage(1); /* Only allowed once */
878 list_pools = true;
879 break;
880
881 case 'S':
882 print_stats = true;
883 break;
884
885 case 'h':
886 usage(0);
887
888 case 'x':
889 fr_debug_lvl++;
890 break;
891
892 case 'o':
893 break;
894
895 case 'f':
896 filename = optarg;
897 break;
898
899 default:
900 usage(1);
901 }
902 argc -= optind;
903 argv += optind;
904
905 if (argc == 0) {
906 ERROR("Need server address/port");
907 usage(64);
908 }
909 if ((argc == 1) && need_pool) {
910 ERROR("Need pool to operate on");
911 usage(64);
912 }
913 if (argc > 3) usage(64);
914
916 fr_perror("%s", config->name);
917 ret = EXIT_FAILURE;
918 goto cleanup;
919 }
920
921 modules_init(config->lib_dir);
922
923 if (!fr_dict_global_ctx_init(NULL, true, config->dict_dir)) {
924 fr_perror("%s", config->name);
926 }
927
929 fr_perror("%s", config->name);
931 }
932
934 fr_perror("%s", config->name);
936 }
937
939 fr_perror("%s", config->name);
941 }
942
943 if (request_global_init() < 0) {
944 fr_perror("%s", config->name);
946 }
947
948 if (main_loop_init() < 0) {
949 PERROR("Failed initialising main event loop");
951 }
952
953 if (unlang_global_init() < 0) {
954 fr_perror("%s", config->name);
956 }
957
958 if (modules_rlm_init() < 0) {
959 fr_perror("%s", config->name);
961 }
962 if (virtual_servers_init() < 0) {
963 fr_perror("%s", config->name);
965 }
966
967 /*
968 * Build a temporary configuration file, merging in command
969 * line provided options.
970 */
971 if (!mkdtemp(tmpdir)) EXIT_WITH_FAILURE;
973 snprintf(filepath, sizeof(filepath), "%s/%s.conf", config->confdir, config->name);
974 conf_file = fopen(filepath, "w");
975 if (!conf_file) EXIT_WITH_FAILURE;
976 fputs(server_conf1, conf_file);
977 if (filename) {
978 fprintf(conf_file, "$INCLUDE %s\n", filename);
979 } else {
980 fprintf(conf_file, "server = %s\n", argv[0]);
981 }
982 fputs(server_conf2, conf_file);
983 fclose(conf_file);
984
986 unlink(filepath);
987 rmdir(tmpdir);
988
989 if (ret < 0) EXIT_WITH_FAILURE;
990
991 if (!client_find(NULL, &(fr_ipaddr_t) { .af = AF_INET, .prefix = 32, .addr.v4.s_addr = htonl(INADDR_LOOPBACK) },
992 IPPROTO_IP)) EXIT_WITH_FAILURE;
993
994 if (server_init(config->root_cs, config->confdir, dict) < 0) EXIT_WITH_FAILURE;
995
997 fr_assert(el);
998
1000
1002 if (fr_thread_instantiate(thread_ctx, el) < 0) {
1003 fr_perror("%s", config->name);
1005 }
1006
1007 if (modules_rlm_coord_attach(el) < 0) {
1008 fr_perror("%s", config->name);
1010 }
1011
1012 if (fr_coord_pre_event_insert(el) < 0) {
1013 fr_strerror_const("Failed adding coordinator pre-check to event list");
1015 }
1016
1017 if (fr_coord_post_event_insert(el) < 0) {
1018 fr_strerror_const("Failed adding coordinator pre-check to event list");
1020 }
1021
1023
1024 vs = virtual_server_find("default");
1025 mi = module_rlm_static_by_name(NULL, "redis_ippool");
1026 if (!mi) EXIT_WITH_FAILURE;
1027
1028 /*
1029 * The module methods for these functions use call_env - which
1030 * preclude them being used with unlang_module_push. Instead they
1031 * need to be called from compiled process sections.
1032 * To avoid inventing another process module, these have been
1033 * wrapped in standard RADIUS process sections.
1034 */
1035 pool_stats = cf_section_find(virtual_server_cs(vs), "recv", "Access-Request");
1036 if (!pool_stats) EXIT_WITH_FAILURE;
1037 pool_show = cf_section_find(virtual_server_cs(vs), "recv", "Accounting-Request");
1038 if (!pool_show) EXIT_WITH_FAILURE;
1039
1040 /*
1041 * Unescape sequences in the pool name
1042 */
1043 if (argv[1] && (argv[1][0] != '\0')) {
1046
1047 MEM(fr_sbuff_init_talloc(autofree, &out, &tctx, strlen(argv[1]) + 1, SIZE_MAX));
1048 if (fr_value_str_unescape(NULL, &out, &FR_SBUFF_IN_STR(argv[1]), SIZE_MAX, '"') < 0) {
1049 ERROR("Failed unescaping pool name");
1050 fr_exit_now(EXIT_FAILURE);
1051 }
1052 talloc_realloc(autofree, out.buff, uint8_t, fr_sbuff_used(&out));
1053 pool_arg = (uint8_t *)out.buff;
1054 }
1055
1056 if (argc >= 3 && (argv[2][0] != '\0')) {
1059
1060 MEM(fr_sbuff_init_talloc(autofree, &out, &tctx, strlen(argv[1]) + 1, SIZE_MAX));
1061 if (fr_value_str_unescape(NULL, &out, &FR_SBUFF_IN_STR(argv[2]), SIZE_MAX, '"') < 0) {
1062 ERROR("Failed unescaping range name");
1063 fr_exit_now(EXIT_FAILURE);
1064 }
1065 talloc_realloc(autofree, out.buff, uint8_t, fr_sbuff_used(&out));
1066 range_arg = (uint8_t *)out.buff;
1067 }
1068
1069 if (!do_import && !do_export && !list_pools && !print_stats && (p == ops)) {
1070 ERROR("Nothing to do!");
1071 fr_exit_now(EXIT_FAILURE);
1072 }
1073
1074 if (do_import) {
1075 ERROR("NOT YET IMPLEMENTED");
1076 }
1077
1078 if (do_export) {
1079 ERROR("NOT YET IMPLEMENTED");
1080 }
1081
1082 if (print_stats) {
1083 fr_value_box_list_t pools;
1084 fr_pair_t *stats, *st, *dyn;
1085 fr_pair_t *total, *static_total, *static_free, *dyn_free;
1086 fr_pair_t *exp1m, *exp30m, *exp1h, *exp1d;
1087
1088 fr_value_box_list_init(&pools);
1089 if (pool_arg) {
1090 fr_value_box_t *vb;
1092 fr_value_box_bstrndup(vb, vb, NULL, (char *)pool_arg, talloc_array_length(pool_arg), false);
1093 fr_value_box_list_insert_tail(&pools, vb);
1094 } else {
1096 }
1097
1098 fr_value_box_list_foreach(&pools, vb) {
1099 if (redis_ippool_get_stats(request, vb, pool_stats, el) < 0) EXIT_WITH_FAILURE;
1100
1101 INFO("pool : %pV", vb);
1102 stats = fr_pair_find_by_da_nested(&request->control_pairs, attr_ippool_stats);
1103 if (!stats) EXIT_WITH_FAILURE;
1104
1105 st = fr_pair_find_by_da(&stats->vp_group, NULL, attr_ippool_stats_static);
1106 dyn = fr_pair_find_by_da(&stats->vp_group, NULL, attr_ippool_stats_dynamic);
1107 if (!st || !dyn) EXIT_WITH_FAILURE;
1108
1109 total = fr_pair_find_by_da_nested(&stats->vp_group, attr_ippool_stats_total);
1110 if (!total) EXIT_WITH_FAILURE;
1111 INFO("total : %pV", &total->data);
1112
1113 static_total = fr_pair_find_by_da(&st->vp_group, NULL, attr_ippool_stats_static_total);
1114 if (!static_total) EXIT_WITH_FAILURE;
1115 INFO("dynamic total : %" PRIu64, total->vp_uint64 - static_total->vp_uint64);
1116
1117 dyn_free = fr_pair_find_by_da(&dyn->vp_group, NULL, attr_ippool_stats_dynamic_free);
1118 if (!dyn_free) EXIT_WITH_FAILURE;
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);
1125 } else {
1126 INFO("used (%%) : 0");
1127 }
1128
1129 exp1m = fr_pair_find_by_da(&dyn->vp_group, NULL, attr_ippool_stats_dynamic_expire1m);
1130 exp30m = fr_pair_find_by_da(&dyn->vp_group, NULL, attr_ippool_stats_dynamic_expire30m);
1131 exp1h = fr_pair_find_by_da(&dyn->vp_group, NULL, attr_ippool_stats_dynamic_expire1h);
1132 exp1d = fr_pair_find_by_da(&dyn->vp_group, NULL, attr_ippool_stats_dynamic_expire1d);
1133 if (!exp1m || !exp30m || !exp1h || !exp1d) EXIT_WITH_FAILURE;
1134
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);
1140
1141 static_free = fr_pair_find_by_da(&st->vp_group, NULL, attr_ippool_stats_static_free);
1142 if (!static_free) EXIT_WITH_FAILURE;
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);
1149 } else {
1150 INFO("static issued (%%) : 0");
1151 }
1152
1153 exp1m = fr_pair_find_by_da(&st->vp_group, NULL, attr_ippool_stats_static_renew1m);
1154 exp30m = fr_pair_find_by_da(&st->vp_group, NULL, attr_ippool_stats_static_renew30m);
1155 exp1h = fr_pair_find_by_da(&st->vp_group, NULL, attr_ippool_stats_static_renew1h);
1156 exp1d = fr_pair_find_by_da(&st->vp_group, NULL, attr_ippool_stats_static_renew1d);
1157 if (!exp1m || !exp30m || !exp1h || !exp1d) EXIT_WITH_FAILURE;
1158
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);
1163 INFO("--");
1164 }
1165 fr_value_box_list_talloc_free(&pools);
1166 }
1167
1168 if (list_pools) {
1169 fr_value_box_list_t pools;
1170
1171 fr_value_box_list_init(&pools);
1173 fr_value_box_list_foreach(&pools, vb) INFO("%pV", vb);
1174 INFO("--");
1175 fr_value_box_list_talloc_free(&pools);
1176 }
1177
1178 /*
1179 * Fixup the operations without specific pools or ranges
1180 * and parse the IP ranges.
1181 */
1182 end = p;
1183 for (p = ops; p < end; p++) {
1184 if (parse_ip_range(&p->start, &p->end, p->name, p->prefix) < 0) usage(64);
1185 if (!p->prefix) p->prefix = IPADDR_LEN(p->start.af);
1186
1187 if (!p->pool) {
1188 p->pool = pool_arg;
1189 p->pool_len = talloc_array_length(pool_arg);
1190 }
1191 if (!p->range && range_arg) {
1192 p->range = range_arg;
1193 p->range_len = talloc_array_length(range_arg);
1194 }
1195 }
1196
1197 for (p = ops; (p < end) && (p->start.af != AF_UNSPEC); p++) switch (p->action) {
1198 case IPPOOL_TOOL_ADD:
1199 fr_value_box_list_talloc_free(&vb_list);
1200 if (xlat_add_lease(autofree, &vb_list, request, p, el) < 0) EXIT_WITH_FAILURE;
1201
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));
1204 continue;
1205
1206 case IPPOOL_TOOL_REMOVE:
1207 fr_value_box_list_talloc_free(&vb_list);
1208 if (xlat_remove_lease(autofree, &vb_list, request, p, el) < 0) EXIT_WITH_FAILURE;
1209
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));
1212 continue;
1213
1215 fr_value_box_list_talloc_free(&vb_list);
1216 if (xlat_release_lease(autofree, &vb_list, request, p, el) < 0) EXIT_WITH_FAILURE;
1217
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));
1220 continue;
1221
1222 case IPPOOL_TOOL_SHOW:
1223 {
1224 fr_pair_t *ippool, *vp, *device, *gateway, *expires;
1225
1226 if (redis_ippool_show(request, p, pool_show, el) < 0) EXIT_WITH_FAILURE;
1227
1229 if (vp) {
1230 ippool = fr_pair_parent(vp);
1231 } else {
1232 ippool = fr_pair_find_by_da(&request->control_pairs, NULL, attr_ippool);
1233 }
1234 if (!ippool) EXIT_WITH_FAILURE;
1235
1236 INFO("Retrieved information for %u address(es)/prefix(es)",
1237 fr_pair_count_by_da(&ippool->vp_group, attr_ippool_lease));
1238 fr_pair_list_foreach(&ippool->vp_group, lease) {
1239 if (lease->da != attr_ippool_lease) continue;
1240
1241 INFO("--");
1242 vp = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_range);
1243 if (vp) INFO("range : %pV", &vp->data);
1244
1245 vp = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_address);
1246 if (!vp) EXIT_WITH_FAILURE;
1247 INFO("address/prefix : %pV", &vp->data);
1248
1249 vp = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_static);
1250 if (vp) INFO("static : %s", vp->vp_bool ? "yes" : "no");
1251
1252 vp = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_active);
1253 if (!vp) EXIT_WITH_FAILURE;
1254 INFO("active : %s", vp->vp_bool ? "yes" : "no");
1255
1256 device = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_device);
1257 gateway = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_gateway);
1258 expires = fr_pair_find_by_da(&lease->vp_group, NULL, attr_ippool_lease_expires);
1259
1260 if (vp->vp_bool) {
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);
1264 } else {
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);
1268 }
1269 }
1270 }
1271 continue;
1272
1273 case IPPOOL_TOOL_MODIFY:
1274 fr_value_box_list_talloc_free(&vb_list);
1275 if (xlat_modify_lease(autofree, &vb_list, request, p, el) < 0) EXIT_WITH_FAILURE;
1276
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));
1279 continue;
1280
1281 case IPPOOL_TOOL_ASSIGN:
1282 if (fr_ipaddr_cmp(&p->start, &p->end) != 0) {
1283 ERROR("Static assignment requires a single IP");
1284 fr_exit_now(EXIT_FAILURE);
1285 }
1286 if (!owner) {
1287 ERROR("Static assignment requires an owner");
1288 fr_exit_now(EXIT_FAILURE);
1289 }
1290
1291 fr_value_box_list_talloc_free(&vb_list);
1292 if (xlat_assign_lease(autofree, &vb_list, request, p, owner, el) < 0) EXIT_WITH_FAILURE;
1293 INFO("Assigned %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1294 continue;
1295
1297 if (fr_ipaddr_cmp(&p->start, &p->end) != 0) {
1298 ERROR("Static lease un-assignment requires a single IP");
1299 fr_exit_now(EXIT_FAILURE);
1300 }
1301 if (!owner) {
1302 ERROR("Static lease un-assignment requires an owner");
1303 fr_exit_now(EXIT_FAILURE);
1304 }
1305
1306 fr_value_box_list_talloc_free(&vb_list);
1307 if (xlat_unassign_lease(autofree, &vb_list, request, p, owner, el) < 0) EXIT_WITH_FAILURE;
1308 INFO("Un-assigned %pV address(es)/prefix(es)", fr_value_box_list_head(&vb_list));
1309 continue;
1310
1311 case IPPOOL_TOOL_NOOP:
1312 break;
1313 }
1314
1315cleanup:
1316
1317 /*
1318 * The same clean up sequence as unit_test_module.c
1319 */
1320 if (el && (modules_rlm_coord_detach() > 0)) {
1322 ERROR("Failed setting up coordinator close events");
1323 }
1325 }
1326 talloc_free(thread_ctx);
1331 server_free();
1336 fr_dict_free(&dict, __FILE__);
1339
1340 return ret;
1341}
int n
Definition acutest.h:642
int fr_atexit_global_setup(void)
Setup the atexit handler, should be called at the start of a program's execution.
Definition atexit.c:179
int fr_atexit_global_trigger_all(void)
Cause all global free triggers to fire.
Definition atexit.c:310
#define fr_atexit_thread_trigger_all(...)
Definition atexit.h:236
static uint8_t request[4]
#define RCSID(id)
Definition build.h:603
#define NEVER_RETURNS
Should be placed before the function return type.
Definition build.h:413
#define unlikely(_x)
Definition build.h:486
#define NUM_ELEMENTS(_t)
Definition build.h:437
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
Definition cf_util.c:1247
TALLOC_CTX * autofree
Definition common.c:29
fr_dict_t * dict
Definition common.c:31
int fr_coords_create(TALLOC_CTX *ctx, fr_event_list_t *el)
Start coordinators in single threaded mode.
Definition coord.c:619
void fr_coords_destroy(void)
Clean up coordinators in single threaded mode.
Definition coord.c:601
int fr_coord_close_event_insert(fr_event_list_t *el)
Definition coord.c:900
int fr_coord_post_event_insert(fr_event_list_t *el)
Insert instance specific post-event callbacks.
Definition coord.c:856
int fr_coord_pre_event_insert(fr_event_list_t *el)
Insert instance specific pre-event callbacks.
Definition coord.c:831
void fr_disable_null_tracking_on_free(TALLOC_CTX *ctx)
Disable the null tracking context when a talloc chunk is freed.
Definition debug.c:1031
void fr_talloc_fault_setup(void)
Register talloc fault handlers.
Definition debug.c:1047
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.
Definition debug.c:1071
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:177
#define PANIC_ACTION_SIGNALS
Definition debug.h:133
#define MEM(x)
Definition debug.h:38
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
Definition debug.h:272
#define ERROR(fmt,...)
Definition dhcpclient.c:40
static NEVER_RETURNS void usage(void)
Definition dhcpclient.c:113
#define fr_dict_autofree(_to_free)
Definition dict.h:942
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:316
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:329
int fr_dict_free(fr_dict_t **dict, char const *dependent)
Decrement the reference count on a previously loaded dictionary.
Definition dict_util.c:4474
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.
Definition dict_util.c:4540
#define fr_dict_autoload(_to_load)
Definition dict.h:939
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:335
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.
Definition dict_util.c:4858
Specifies an attribute which must be present for the module to function.
Definition dict.h:315
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:328
int fr_dict_internal_afrom_file(fr_dict_t **out, char const *dict_subdir, char const *dependent)
(Re-)Initialize the special internal dictionary
talloc_free(hp)
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.
Definition inet.c:783
void fr_ipaddr_mask(fr_ipaddr_t *addr, uint8_t prefix)
Zeroes out the host portion of an fr_ipaddr_t.
Definition inet.c:218
fr_cmp_ret_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
Definition inet.c:1353
uint8_t prefix
Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.
Definition inet.h:69
int af
Address family.
Definition inet.h:64
union fr_ipaddr_t::@160 addr
#define FR_IPADDR_PREFIX_STRLEN
Like FR_IPADDR_STRLEN but with space for a prefix.
Definition inet.h:93
IPv4/6 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.
Definition interpret.c:1535
#define FRAME_CONF(_default_rcode, _top_frame)
Definition interpret.h:158
#define UNLANG_TOP_FRAME
Definition interpret.h:36
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/.
Definition base.c:42
void server_free(void)
Free src/lib/server/.
Definition base.c:137
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.
Definition log.c:293
#define PERROR(_fmt,...)
Definition log.h:233
Definition log.h:70
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.
Definition packet.c:91
int unlang_global_init(void)
Definition base.c:158
int fr_event_loop(fr_event_list_t *el)
Run an event loop.
Definition event.c:2445
Stores all information relating to an event list.
Definition event.c:375
int fr_debug_lvl
Definition log.c:41
fr_log_t default_log
Definition log.c:308
fr_packet_t * fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new fr_packet_t.
Definition packet.c:38
Minimal data structure to use the new code.
Definition listen.h:79
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.
Definition main_config.h:59
fr_event_list_t * main_loop_event_list(void)
Return the main loop event list.
Definition main_loop.c:173
int main_loop_init(void)
Initialise the main event loop, setting up signal handlers.
Definition main_loop.c:262
void main_loop_free(void)
Definition main_loop.c:198
@ 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.
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
module_instance_t * module_rlm_static_by_name(module_instance_t const *parent, char const *asked_name)
Definition module_rlm.c:814
int modules_rlm_coord_attach(fr_event_list_t *el)
Runs the coord_attach method of all registered backend modules.
Definition module_rlm.c:992
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.
Definition module_rlm.c:999
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.
Definition pair.c:693
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.
Definition pair.c:791
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.
Definition pair.c:716
fr_pair_t * fr_pair_parent(fr_pair_t const *vp)
Return a pointer to the parent pair.
Definition pair.c:923
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.
Definition pair.c:486
#define is_truncated(_ret, _max)
Definition print.h:48
static const conf_parser_t config[]
Definition base.c:164
#define fr_assert(_expr)
Definition rad_assert.h:37
#define INFO(fmt,...)
Definition radict.c:67
static bool cleanup
Definition radsniff.c:59
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:44
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:49
#define RLM_MODULE_USER_SECTION_REJECT
Rcodes that translate to a user configurable section failing overall.
Definition rcode.h:85
#define IPADDR_LEN(_af)
#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)
Definition request.c:614
#define request_local_alloc_internal(_ctx, _args)
Allocate a new internal request outside of the request pool.
Definition request.h:344
@ REQUEST_ACTIVE
Request is active (running or runnable)
Definition request.h:89
static fr_dict_attr_t const * attr_ippool_stats_dynamic_expire1d
int main(int argc, char *argv[])
static int xlat_remove_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, ippool_tool_operation_t *op, fr_event_list_t *el)
fr_dict_attr_autoload_t redis_ippool_tool_dict_attr[]
static fr_dict_attr_t const * attr_ippool_stats_static_renew1m
char const * name
Original range or CIDR string.
static fr_dict_attr_t const * attr_ippool_stats_static
static fr_dict_attr_t const * attr_ippool_stats_static_renew1h
static fr_dict_attr_t const * attr_ippool_stats_dynamic_free
static char server_conf2[]
static fr_dict_attr_t const * attr_ippool_stats_static_renew30m
static int xlat_release_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, ippool_tool_operation_t *op, fr_event_list_t *el)
static fr_dict_attr_t const * attr_ippool_stats_dynamic_expire1m
static fr_dict_attr_t const * attr_ippool_lease_device
static fr_dict_attr_t const * attr_ippool_stats_dynamic_expire30m
static fr_dict_attr_t const * attr_ippool_lease_gateway
static fr_dict_t const * dict_freeradius
#define EOL
static fr_dict_attr_t const * attr_ippool_stats_static_total
ippool_tool_action
Pool management actions.
@ IPPOOL_TOOL_ADD
Add one or more IP addresses.
@ IPPOOL_TOOL_REMOVE
Remove one or more IP addresses.
@ IPPOOL_TOOL_NOOP
Do nothing.
@ IPPOOL_TOOL_MODIFY
Modify attributes of one or more IP addresses.
@ IPPOOL_TOOL_SHOW
Show one or more IP addresses.
@ IPPOOL_TOOL_ASSIGN
Assign a static IP address to a device.
@ IPPOOL_TOOL_RELEASE
Release one or more IP addresses.
@ IPPOOL_TOOL_UNASSIGN
Remove static IP address assignment.
static fr_dict_attr_t const * attr_ippool_name
fr_dict_autoload_t redis_ippool_tool_dict[]
size_t pool_len
Length of the pool identifier.
static int redis_ippool_get_stats(request_t *request, fr_value_box_t *pool_name, CONF_SECTION *section, fr_event_list_t *el)
Run the redis_ippool.stats module method to fetch pool statistics.
static fr_dict_attr_t const * attr_ippool_stats_static_free
static char const * name
static fr_dict_attr_t const * attr_ippool_lease
static char server_conf1[]
Static server config split into two parts.
static uint32_t uint32_gen_mask(uint8_t bits)
static fr_dict_attr_t const * attr_ippool_lease_active
static int xlat_add_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, ippool_tool_operation_t *op, fr_event_list_t *el)
static fr_dict_attr_t const * attr_ippool
static fr_dict_attr_t const * attr_ippool_stats_dynamic
#define ADD_ACTION(_action)
static int xlat_unassign_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, ippool_tool_operation_t *op, char const *owner, fr_event_list_t *el)
static int redis_ippool_show(request_t *request, ippool_tool_operation_t const *op, CONF_SECTION *section, fr_event_list_t *el)
Run the redis_ippool.show module method to fetch lease details.
uint8_t const * range
Range identifier.
static fr_dict_attr_t const * attr_ippool_lease_address
static fr_dict_attr_t const * attr_ippool_lease_expires
uint8_t prefix
Prefix - The bits between the address mask, and the prefix form the addresses to be modified in the p...
uint8_t const * pool
Pool identifier.
ippool_tool_action_t action
What to do to the leases described by net/prefix.
size_t range_len
Length of the range identifier.
fr_ipaddr_t end
End address.
#define EXIT_WITH_FAILURE
static fr_dict_attr_t const * attr_ippool_lease_range
static int parse_ip_range(fr_ipaddr_t *start_out, fr_ipaddr_t *end_out, char const *ip_str, uint8_t prefix)
Convert an IP range or CIDR mask to a start and stop address.
static fr_dict_attr_t const * attr_ippool_stats
static fr_dict_attr_t const * attr_ippool_stats_dynamic_expire1h
fr_ipaddr_t start
Start address.
static fr_dict_attr_t const * attr_ippool_stats_static_renew1d
static int xlat_modify_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, ippool_tool_operation_t *op, fr_event_list_t *el)
static int redis_ippool_get_pools(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, fr_event_list_t *el)
Run the redis_ippool.pools.list xlat to fetch the list of pools across the cluster.
static fr_dict_attr_t const * attr_ippool_stats_dynamic_total
static int run_xlat(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, fr_sbuff_t *xlat, fr_event_list_t *el)
static bool ipaddr_next(fr_ipaddr_t *ipaddr, fr_ipaddr_t const *end, uint8_t prefix)
Iterate over range of IP addresses.
static fr_dict_attr_t const * attr_ippool_lease_static
static int xlat_assign_lease(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, ippool_tool_operation_t *op, char const *owner, fr_event_list_t *el)
static request_t * request_from_internal(TALLOC_CTX *ctx)
static fr_dict_attr_t const * attr_ippool_stats_total
enum ippool_tool_action ippool_tool_action_t
Pool management actions.
A single pool operation.
ssize_t fr_sbuff_in_sprintf(fr_sbuff_t *sbuff, char const *fmt,...)
Print using a fmt string to an sbuff.
Definition sbuff.c:1680
#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.
Definition sbuff.h:138
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.
Definition schedule.c:120
Module instance data.
Definition module.h:291
struct tmpl_rules_s tmpl_rules_t
Definition tmpl.h:240
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
Definition snprintf.c:689
fr_client_t * client_find(fr_client_list_t const *clients, fr_ipaddr_t const *ipaddr, int proto)
Definition client.c:370
void modules_init(char const *lib_dir)
Perform global initialisation for modules.
Definition module.c:1981
fr_pair_t * vp
size_t strlcpy(char *dst, char const *src, size_t siz)
Definition strlcpy.c:34
fr_log_dst_t dst
Log destination.
Definition log.h:94
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
Definition talloc.h:55
int fr_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el)
Instantiate thread-specific data for modules, virtual servers, xlats, unlang, and TLS.
Definition thread.c:177
int fr_time_start(void)
Initialize the local time.
Definition time.c:157
static uint128_t uint128_new(uint64_t h, uint64_t l)
Creates a new uint128_t from a uint64_t.
Definition uint128.h:268
static uint128_t uint128_gen_mask(uint8_t bits)
Create a 128 bit integer value with n bits high.
Definition uint128.h:65
static uint128_t uint128_bor(uint128_t a, uint128_t b)
Perform bitwise | of two 128bit unsigned integers.
Definition uint128.h:239
static uint128_t uint128_lshift(uint128_t num, uint8_t bits)
Left shift 128 bit integer.
Definition uint128.h:191
static bool uint128_gt(uint128_t a, uint128_t b)
Return whether one integer is greater than the other.
Definition uint128.h:258
static bool uint128_eq(uint128_t a, uint128_t b)
Return whether the integers are equal.
Definition uint128.h:250
static uint128_t uint128_sub(uint128_t a, uint128_t b)
Subtract one 128bit integer from another.
Definition uint128.h:128
static uint128_t uint128_add(uint128_t a, uint128_t b)
Add two 128bit unsigned integers.
Definition uint128.h:115
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.
Definition xlat.c:269
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
Definition conf.h:7
#define fr_pair_list_foreach(_list_head, _iter)
Iterate over the contents of a fr_pair_list_t.
Definition pair.h:285
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.
Definition socket.h:60
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
Definition strerror.c:737
#define fr_strerror_const(_msg)
Definition strerror.h:223
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
Definition version.c:40
#define RADIUSD_MAGIC_NUMBER
Definition version.h:81
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)
Definition value.c:6256
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:4526
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.
Definition value.c:5014
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.
Definition value.c:1232
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
Definition value.h:668
#define fr_box_ipaddr(_val)
Definition value.h:348
static fr_sbuff_err_t char ** out
Definition value.h:1061
static fr_sbuff_err_t char size_t * len
Definition value.h:1061
#define fr_value_box_list_foreach(_list_head, _iter)
Definition value.h:253
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)