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
5 * (at your option) any later version.
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.
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
21 * @brief String expansion ("translation"). Implements %Attribute -> value
23 * @copyright 2000,2006 The FreeRADIUS server project
24 * @copyright 2000 Alan DeKok <aland@ox.org>
29 #include <freeradius-devel/radiusd.h>
30 #include <freeradius-devel/parser.h>
31 #include <freeradius-devel/rad_assert.h>
32 #include <freeradius-devel/base64.h>
36 typedef struct xlat_t {
37 char name[MAX_STRING_LEN]; //!< Name of the xlat expansion.
38 int length; //!< Length of name.
39 void *instance; //!< Module instance passed to xlat and escape functions.
40 RAD_XLAT_FUNC func; //!< xlat function.
41 RADIUS_ESCAPE_STRING escape; //!< Escape function to apply to dynamic input to func.
42 bool internal; //!< If true, cannot be redefined.
46 XLAT_LITERAL, //!< Literal string
47 XLAT_PERCENT, //!< Literal string with %v
48 XLAT_MODULE, //!< xlat module
49 XLAT_VIRTUAL, //!< virtual attribute
50 XLAT_ATTRIBUTE, //!< xlat attribute
52 XLAT_REGEX, //!< regex reference
54 XLAT_ALTERNATE //!< xlat conditional syntax :-
58 char const *fmt; //!< The format string.
59 size_t len; //!< Length of the format string.
61 xlat_state_t type; //!< type of this expansion.
62 xlat_exp_t *next; //!< Next in the list.
64 xlat_exp_t *child; //!< Nested expansion.
65 xlat_exp_t *alternate; //!< Alternative expansion if this one expanded to a zero length string.
67 value_pair_tmpl_t attr; //!< An attribute template.
68 xlat_t const *xlat; //!< The xlat expansion to expand format with.
71 typedef struct xlat_out {
72 char const *out; //!< Output data.
73 size_t len; //!< Length of the output string.
76 static rbtree_t *xlat_root = NULL;
79 static char const * const xlat_foreach_names[] = {"Foreach-Variable-0",
92 #if REQUEST_MAX_REGEX > 8
93 # error Please fix the following line
95 static int xlat_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* up to 8 for regex */
97 char const *radiusd_short_version = RADIUSD_VERSION_STRING;
99 /** Print length of its RHS.
102 static ssize_t xlat_strlen(UNUSED void *instance, UNUSED REQUEST *request,
103 char const *fmt, char *out, size_t outlen)
105 snprintf(out, outlen, "%u", (unsigned int) strlen(fmt));
109 /** Print the size of the attribute in bytes.
112 static ssize_t xlat_length(UNUSED void *instance, UNUSED REQUEST *request,
113 char const *fmt, char *out, size_t outlen)
116 while (isspace((int) *fmt)) fmt++;
118 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) {
123 snprintf(out, outlen, "%zu", vp->length);
127 /** Print data as integer, not as VALUE.
130 static ssize_t xlat_integer(UNUSED void *instance, REQUEST *request,
131 char const *fmt, char *out, size_t outlen)
135 uint64_t int64 = 0; /* Needs to be initialised to zero */
136 uint32_t int32 = 0; /* Needs to be initialised to zero */
138 while (isspace((int) *fmt)) fmt++;
140 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) {
145 switch (vp->da->type) {
148 if (vp->length > 8) {
152 if (vp->length > 4) {
153 memcpy(&int64, vp->vp_octets, vp->length);
154 return snprintf(out, outlen, "%" PRIu64, htonll(int64));
157 memcpy(&int32, vp->vp_octets, vp->length);
158 return snprintf(out, outlen, "%i", htonl(int32));
160 case PW_TYPE_INTEGER64:
161 return snprintf(out, outlen, "%" PRIu64, vp->vp_integer64);
164 * IP addresses are treated specially, as parsing functions assume the value
165 * is bigendian and will convert it for us.
167 case PW_TYPE_IPV4_ADDR:
168 return snprintf(out, outlen, "%u", htonl(vp->vp_ipaddr));
170 case PW_TYPE_IPV4_PREFIX:
171 return snprintf(out, outlen, "%u", htonl((*(uint32_t *)(vp->vp_ipv4prefix + 2))));
173 case PW_TYPE_INTEGER:
175 return snprintf(out, outlen, "%u", vp->vp_integer);
177 return snprintf(out, outlen, "%u", (unsigned int) vp->vp_byte);
179 return snprintf(out, outlen, "%u", (unsigned int) vp->vp_short);
182 * Ethernet is weird... It's network related, so we assume to it should be
185 case PW_TYPE_ETHERNET:
186 memcpy(&int64, &vp->vp_ether, vp->length);
187 return snprintf(out, outlen, "%" PRIu64, htonll(int64));
190 return snprintf(out, outlen, "%i", vp->vp_signed);
192 case PW_TYPE_IPV6_ADDR:
193 return fr_prints_uint128(out, outlen, ntohlll(*(uint128_t const *) &vp->vp_ipv6addr));
195 case PW_TYPE_IPV6_PREFIX:
196 return fr_prints_uint128(out, outlen, ntohlll(*(uint128_t const *) &(vp->vp_ipv6prefix[2])));
202 REDEBUG("Type '%s' of length %zu cannot be converted to integer",
203 fr_int2str(dict_attr_types, vp->da->type, "???"), vp->length);
209 /** Print data as hex, not as VALUE.
212 static ssize_t xlat_hex(UNUSED void *instance, REQUEST *request,
213 char const *fmt, char *out, size_t outlen)
221 while (isspace((int) *fmt)) fmt++;
223 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) {
228 ret = rad_vp2data(&p, vp);
235 * Don't truncate the data.
237 if ((ret < 0 ) || (outlen < (len * 2))) {
242 for (i = 0; i < len; i++) {
243 snprintf(out + 2*i, 3, "%02x", p[i]);
249 /** Return the tag of an attribute reference
252 static ssize_t xlat_tag(UNUSED void *instance, REQUEST *request,
253 char const *fmt, char *out, size_t outlen)
257 while (isspace((int) *fmt)) fmt++;
259 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) {
264 if (!vp->da->flags.has_tag || !TAG_VALID(vp->tag)) {
269 return snprintf(out, outlen, "%u", vp->tag);
272 /** Print out attribute info
274 * Prints out all instances of a current attribute, or all attributes in a list.
276 * At higher debugging levels, also prints out alternative decodings of the same
277 * value. This is helpful to determine types for unknown attributes of long
278 * passed vendors, or just crazy/broken NAS.
280 * It's also useful for exposing issues in the packet decoding functions, as in
281 * some cases they get fed random garbage data.
283 * This expands to a zero length string.
285 static ssize_t xlat_debug_attr(UNUSED void *instance, REQUEST *request, char const *fmt,
286 char *out, UNUSED size_t outlen)
288 VALUE_PAIR *vp, **vps;
293 value_pair_tmpl_t vpt;
295 if (!RDEBUG_ENABLED2) {
300 while (isspace((int) *fmt)) fmt++;
302 if (tmpl_from_attr_str(&vpt, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST) <= 0) {
303 RDEBUG("%s", fr_strerror());
308 if (radius_request(¤t, vpt.tmpl_request) < 0) return -2;
310 vps = radius_list(current, vpt.tmpl_list);
315 RIDEBUG("Attributes matching \"%s\"", fmt);
316 vp = fr_cursor_init(&cursor, vps);
319 vp = fr_cursor_next_by_da(&cursor, vpt.tmpl_da, TAG_ANY);
322 DICT_ATTR *dac = NULL;
325 vp_prints_value(buffer, sizeof(buffer), vp, '\'');
328 if (vp->da->flags.has_tag) {
329 RIDEBUG2("%s:%s:%i %s %s",
330 fr_int2str(pair_lists, vpt.tmpl_list, "<INVALID>"),
333 fr_int2str(fr_tokens, vp->op, "<INVALID>"),
336 RIDEBUG2("%s:%s %s %s",
337 fr_int2str(pair_lists, vpt.tmpl_list, "<INVALID>"),
339 fr_int2str(fr_tokens, vp->op, "<INVALID>"),
344 if (!RDEBUG_ENABLED3) goto next_vp;
348 if (vp->da->vendor) {
349 dv = dict_vendorbyvalue(vp->da->vendor);
350 RDEBUG3("Vendor : %i (%s)", vp->da->vendor, dv ? dv->name : "unknown");
352 RDEBUG3("Type : %s", fr_int2str(dict_attr_types, vp->da->type, "<INVALID>"));
353 RDEBUG3("Length : %zu", vp->length);
357 dac = talloc_memdup(request, vp->da, sizeof(DICT_ATTR));
359 talloc_set_type(dac, DICT_ATTR);
365 vp = fr_cursor_next_by_da(&cursor, vpt.tmpl_da, TAG_ANY);
367 vp = fr_cursor_next(&cursor);
375 /** Prints the current module processing the request
378 static ssize_t xlat_module(UNUSED void *instance, REQUEST *request,
379 UNUSED char const *fmt, char *out, size_t outlen)
381 strlcpy(out, request->module, outlen);
387 /** Implements the Foreach-Variable-X
391 static ssize_t xlat_foreach(void *instance, REQUEST *request,
392 UNUSED char const *fmt, char *out, size_t outlen)
398 * See modcall, "FOREACH" for how this works.
400 pvp = (VALUE_PAIR **) request_data_reference(request, radius_get_vp, *(int*) instance);
406 len = vp_prints_value(out, outlen, *pvp, 0);
407 if (is_truncated(len, outlen)) {
408 RDEBUG("Insufficient buffer space to write foreach value");
416 /** Print data as string, if possible.
418 * If attribute "Foo" is defined as "octets" it will normally
419 * be printed as 0x0a0a0a. The xlat "%{string:Foo}" will instead
422 static ssize_t xlat_string(UNUSED void *instance, REQUEST *request,
423 char const *fmt, char *out, size_t outlen)
430 while (isspace((int) *fmt)) fmt++;
438 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) goto nothing;
440 ret = rad_vp2data(&p, vp);
445 switch (vp->da->type) {
447 len = fr_print_string((char const *) p, vp->length, out, outlen, '\0');
451 len = strlcpy(out, vp->vp_strvalue, outlen);
455 len = fr_print_string((char const *) p, ret, out, outlen, '\0');
462 /** xlat expand string attribute value
465 static ssize_t xlat_xlat(UNUSED void *instance, REQUEST *request,
466 char const *fmt, char *out, size_t outlen)
470 while (isspace((int) *fmt)) fmt++;
478 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) goto nothing;
480 return radius_xlat(out, outlen, request, vp->vp_strvalue, NULL, NULL);
483 /** Dynamically change the debugging level for the current request
487 static ssize_t xlat_debug(UNUSED void *instance, REQUEST *request,
488 char const *fmt, char *out, size_t outlen)
493 * Expand to previous (or current) level
495 snprintf(out, outlen, "%d", request->log.lvl & RAD_REQUEST_OPTION_DEBUG4);
498 * Assume we just want to get the current value and NOT set it to 0
505 request->log.lvl = RAD_REQUEST_OPTION_NONE;
506 request->log.func = NULL;
508 if (level > 4) level = 4;
510 request->log.lvl = level;
511 request->log.func = vradlog_request;
519 * Compare two xlat_t structs, based ONLY on the module name.
521 static int xlat_cmp(void const *one, void const *two)
523 xlat_t const *a = one;
524 xlat_t const *b = two;
526 if (a->length != b->length) {
527 return a->length - b->length;
530 return memcmp(a->name, b->name, a->length);
535 * find the appropriate registered xlat function.
537 static xlat_t *xlat_find(char const *name)
541 strlcpy(my_xlat.name, name, sizeof(my_xlat.name));
542 my_xlat.length = strlen(my_xlat.name);
544 return rbtree_finddata(xlat_root, &my_xlat);
548 /** Register an xlat function.
550 * @param[in] name xlat name.
551 * @param[in] func xlat function to be called.
552 * @param[in] escape function to sanitize any sub expansions passed to the xlat function.
553 * @param[in] instance of module that's registering the xlat function.
554 * @return 0 on success, -1 on failure
556 int xlat_register(char const *name, RAD_XLAT_FUNC func, RADIUS_ESCAPE_STRING escape, void *instance)
562 if (!name || !*name) {
563 DEBUG("xlat_register: Invalid xlat name");
568 * First time around, build up the tree...
570 * FIXME: This code should be hoisted out of this function,
571 * and into a global "initialization". But it isn't critical...
578 xlat_root = rbtree_create(NULL, xlat_cmp, free, 0);
580 DEBUG("xlat_register: Failed to create tree");
585 for (i = 0; xlat_foreach_names[i] != NULL; i++) {
586 xlat_register(xlat_foreach_names[i],
587 xlat_foreach, NULL, &xlat_inst[i]);
588 c = xlat_find(xlat_foreach_names[i]);
589 rad_assert(c != NULL);
594 #define XLAT_REGISTER(_x) xlat_register(STRINGIFY(_x), xlat_ ## _x, NULL, NULL); \
595 c = xlat_find(STRINGIFY(_x)); \
596 rad_assert(c != NULL); \
599 XLAT_REGISTER(integer);
600 XLAT_REGISTER(strlen);
601 XLAT_REGISTER(length);
604 XLAT_REGISTER(string);
606 XLAT_REGISTER(module);
607 XLAT_REGISTER(debug_attr);
609 xlat_register("debug", xlat_debug, NULL, &xlat_inst[0]);
610 c = xlat_find("debug");
611 rad_assert(c != NULL);
616 * If it already exists, replace the instance.
618 strlcpy(my_xlat.name, name, sizeof(my_xlat.name));
619 my_xlat.length = strlen(my_xlat.name);
620 c = rbtree_finddata(xlat_root, &my_xlat);
623 DEBUG("xlat_register: Cannot re-define internal xlat");
629 c->instance = instance;
634 * Doesn't exist. Create it.
636 c = rad_malloc(sizeof(*c));
637 memset(c, 0, sizeof(*c));
641 strlcpy(c->name, name, sizeof(c->name));
642 c->length = strlen(c->name);
643 c->instance = instance;
645 node = rbtree_insert_node(xlat_root, c);
654 /** Unregister an xlat function
656 * We can only have one function to call per name, so the passing of "func"
657 * here is extraneous.
659 * @param[in] name xlat to unregister.
660 * @param[in] func unused.
661 * @param[in] instance data.
663 void xlat_unregister(char const *name, UNUSED RAD_XLAT_FUNC func, void *instance)
670 strlcpy(my_xlat.name, name, sizeof(my_xlat.name));
671 my_xlat.length = strlen(my_xlat.name);
673 c = rbtree_finddata(xlat_root, &my_xlat);
676 if (c->instance != instance) return;
678 rbtree_deletebydata(xlat_root, c);
682 /** Crappy temporary function to add attribute ref support to xlats
684 * This needs to die, and hopefully will die, when xlat functions accept
685 * xlat node structures.
687 * Provides either a pointer to a buffer which contains the value of the reference VALUE_PAIR
688 * in an architecture independent format. Or a pointer to the start of the fmt string.
690 * The pointer is only guaranteed to be valid between calls to xlat_fmt_to_ref,
691 * and so long as the source VALUE_PAIR is not freed.
693 * @param out where to write a pointer to the buffer to the data the xlat function needs to work on.
694 * @param request current request.
696 * @returns the length of the data or -1 on error.
698 ssize_t xlat_fmt_to_ref(uint8_t const **out, REQUEST *request, char const *fmt)
702 while (isspace((int) *fmt)) fmt++;
705 if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) {
710 return rad_vp2data(out, vp);
713 *out = (uint8_t const *)fmt;
717 /** De-register all xlat functions, used mainly for debugging.
722 rbtree_free(xlat_root);
727 # define XLAT_DEBUG DEBUG3
729 # define XLAT_DEBUG(...)
732 static ssize_t xlat_tokenize_expansion(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **head,
734 static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **head,
735 int brace, char const **error);
736 static size_t xlat_process(char **out, REQUEST *request, xlat_exp_t const * const head,
737 RADIUS_ESCAPE_STRING escape, void *escape_ctx);
739 static ssize_t xlat_tokenize_alternation(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **head,
746 rad_assert(fmt[0] == '%');
747 rad_assert(fmt[1] == '{');
748 rad_assert(fmt[2] == '%');
749 rad_assert(fmt[3] == '{');
751 XLAT_DEBUG("ALTERNATE <-- %s", fmt);
753 node = talloc_zero(ctx, xlat_exp_t);
754 node->type = XLAT_ALTERNATE;
757 slen = xlat_tokenize_expansion(node, p, &node->child, error);
760 return slen - (p - fmt);
766 *error = "Expected ':' after first expansion";
773 *error = "Expected '-' after ':'";
779 * Allow the RHS to be empty as a special case.
783 * Hack up an empty string.
785 node->alternate = talloc_zero(node, xlat_exp_t);
786 node->alternate->type = XLAT_LITERAL;
787 node->alternate->fmt = talloc_typed_strdup(node->alternate, "");
791 slen = xlat_tokenize_literal(node, p, &node->alternate, true, error);
794 return slen - (p - fmt);
797 if (!node->alternate) {
799 *error = "Empty expansion is invalid";
809 static ssize_t xlat_tokenize_expansion(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **head,
814 char const *attrname;
817 rad_assert(fmt[0] == '%');
818 rad_assert(fmt[1] == '{');
823 if ((fmt[2] == '%') && (fmt[3] == '{')) {
824 return xlat_tokenize_alternation(ctx, fmt, head, error);
827 XLAT_DEBUG("EXPANSION <-- %s", fmt);
828 node = talloc_zero(ctx, xlat_exp_t);
829 attrname = node->fmt = fmt + 2;
834 * Handle regex's specially.
836 if (isdigit((int) fmt[2]) && (fmt[3] == '}')) {
839 *error = "Invalid regex reference";
843 XLAT_DEBUG("REGEX <-- %s", fmt);
845 node->attr.tmpl_num = fmt[2] - '0'; /* ASCII */
847 node->type = XLAT_REGEX;
851 #endif /* HAVE_REGEX */
856 * %{Tunnel-Password:1}
857 * %{Tunnel-Password:1[#]}
858 * %{request:Attr-Name}
859 * %{request:Tunnel-Password:1}
860 * %{request:Tunnel-Password:1[#]}
864 for (p = fmt + 2; *p != '\0'; p++) {
865 if (*p == ':') break;
867 if (isspace((int) *p)) break;
869 if (*p == '[') break;
871 if (*p == '}') break;
874 if (*p != ':') p = NULL;
877 * Might be a module name reference.
885 node->xlat = xlat_find(node->fmt);
887 node->type = XLAT_MODULE;
889 XLAT_DEBUG("MOD <-- %s ... %s", node->fmt, p + 1);
891 slen = xlat_tokenize_literal(node, p + 1, &node->child, true, error);
894 return slen - (p - fmt);
899 rad_assert(node->next == NULL);
904 * Modules can have '}' in their RHS, so we
905 * didn't check for that until now.
907 * As of now, node->fmt MUST be a reference to an
908 * attribute, however complicated. So it MUST have a closing brace.
910 brace = strchr(p + 1, '}');
911 if (!brace) goto no_brace;
917 * %{Tunnel-Password:1}
918 * %{request:Tunnel-Password:1}
920 * <sigh> The syntax is fairly poor.
922 XLAT_DEBUG("Looking for list in '%s'", attrname);
925 * Not a module. Has to be an attribute
928 * As of v3, we've removed %{request: ..>} as
929 * internally registered xlats.
932 node->attr.tmpl_request = radius_request_name(&attrname, REQUEST_CURRENT);
933 rad_assert(node->attr.tmpl_request != REQUEST_UNKNOWN);
935 node->attr.tmpl_list = radius_list_name(&attrname, PAIR_LIST_REQUEST);
936 if (node->attr.tmpl_list == PAIR_LIST_UNKNOWN) {
938 *error = "Unknown module";
943 * Check for a trailing tag.
945 p = strchr(attrname, ':');
949 brace = strchr(attrname, '}');
953 *error = "No matching closing brace";
954 return -1; /* second character of format string */
958 node->attr.tmpl_request = REQUEST_CURRENT;
959 node->attr.tmpl_list = PAIR_LIST_REQUEST;
964 XLAT_DEBUG("Looking for attribute name in %s", attrname);
967 * Allow for an array reference. They come AFTER the
968 * tag, if the tag exists. Otherwise, they come after
969 * the attribute name.
972 q = strchr(p + 1, '[');
974 q = strchr(attrname, '[');
976 if (q) *(q++) = '\0';
980 *error = "Empty expression is invalid";
981 return -(attrname - fmt);
985 * It's either an attribute name, or a Tunnel-Password:TAG
986 * with the ':' already set to NULL.
988 node->attr.tmpl_da = dict_attrbyname(attrname);
989 if (!node->attr.tmpl_da) {
991 * Foreach. Maybe other stuff, too.
993 node->xlat = xlat_find(attrname);
995 node->type = XLAT_VIRTUAL;
996 node->fmt = attrname;
998 XLAT_DEBUG("VIRTUAL <-- %s", node->fmt);
1000 rad_assert(node->next == NULL);
1006 *error = "Unknown attribute";
1007 return -(attrname - fmt);
1017 if (!node->attr.tmpl_da->flags.has_tag) {
1019 *error = "Attribute cannot have a tag";
1023 tag = strtoul(p + 1, &end, 10);
1026 if (tag == ULONG_MAX) {
1028 *error = "Invalid tag value";
1032 node->attr.tmpl_tag = tag;
1037 *error = "Unexpected text after tag";
1042 node->attr.tmpl_tag = TAG_ANY;
1047 * Check for array reference
1055 node->attr.tmpl_num = NUM_COUNT;
1058 } else if (*p == '*') {
1059 node->attr.tmpl_num = NUM_ALL;
1062 } else if (isdigit((int) *p)) {
1063 num = strtoul(p, &end, 10);
1066 *error = "Invalid array index";
1070 node->attr.tmpl_num = num;
1074 *error = "Invalid array index";
1080 *error = "Expected ']'";
1087 *error = "Unexpected text after array reference";
1091 node->attr.tmpl_num = NUM_ANY;
1094 rad_assert(!p || (p == brace));
1096 node->type = XLAT_ATTRIBUTE;
1100 rad_assert(node->next == NULL);
1105 static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **head,
1106 int brace, char const **error)
1111 if (!*fmt) return 0;
1113 XLAT_DEBUG("LITERAL <-- %s", fmt);
1115 node = talloc_zero(ctx, xlat_exp_t);
1118 node->type = XLAT_LITERAL;
1126 *error = "Invalid escape at end of string";
1134 * Process the expansion.
1136 if ((p[0] == '%') && (p[1] == '{')) {
1139 XLAT_DEBUG("LITERAL <-- %s", node->fmt);
1141 slen = xlat_tokenize_expansion(node, p, &node->next, error);
1144 return slen - (p - fmt);
1146 *p = '\0'; /* end the literal */
1149 rad_assert(node->next != NULL);
1152 * Short-circuit the recursive call.
1153 * This saves another function call and
1154 * memory allocation.
1159 * "foo %{User-Name} bar"
1161 * EXPANSION User-Name
1164 slen = xlat_tokenize_literal(node->next, p, &(node->next->next), brace, error);
1165 rad_assert(slen != 0);
1168 return slen - (p - fmt);
1172 break; /* stop processing the string */
1176 * Check for valid single-character expansions.
1182 if (!p[1] || !strchr("%dlmtDGHISTYv", p[1])) {
1184 *error = "Invalid variable expansion";
1189 next = talloc_zero(node, xlat_exp_t);
1193 next->fmt = talloc_typed_strdup(next, "%");
1195 XLAT_DEBUG("LITERAL <-- %s", next->fmt);
1196 next->type = XLAT_LITERAL;
1201 XLAT_DEBUG("PERCENT <-- %c", *next->fmt);
1202 next->type = XLAT_PERCENT;
1214 slen = xlat_tokenize_literal(node->next, p, &(node->next->next), brace, error);
1215 rad_assert(slen != 0);
1218 return slen - (p - fmt);
1222 break; /* stop processing the string */
1226 * If required, eat the brace.
1228 if (brace && (*p == '}')) {
1239 * Squash zero-width literals
1241 if (node->len > 0) {
1244 *head = talloc_steal(ctx, node->next);
1252 static char const xlat_tabs[] = " ";
1254 static void xlat_tokenize_debug(xlat_exp_t const *node, int lvl)
1256 rad_assert(node != NULL);
1258 if (lvl >= (int) sizeof(xlat_tabs)) lvl = sizeof(xlat_tabs);
1261 switch (node->type) {
1263 DEBUG("%.*sliteral --> %s", lvl, xlat_tabs, node->fmt);
1267 DEBUG("%.*spercent --> %c", lvl, xlat_tabs, node->fmt[0]);
1270 case XLAT_ATTRIBUTE:
1271 rad_assert(node->attr.tmpl_da != NULL);
1272 DEBUG("%.*sattribute --> %s", lvl, xlat_tabs, node->attr.tmpl_da->name);
1273 rad_assert(node->child == NULL);
1274 if ((node->attr.tmpl_tag != TAG_ANY) || (node->attr.tmpl_num != NUM_ANY)) {
1275 DEBUG("%.*s{", lvl, xlat_tabs);
1277 DEBUG("%.*sref %d", lvl + 1, xlat_tabs, node->attr.tmpl_request);
1278 DEBUG("%.*slist %d", lvl + 1, xlat_tabs, node->attr.tmpl_list);
1280 if (node->attr.tmpl_tag != TAG_ANY) {
1281 DEBUG("%.*stag %d", lvl + 1, xlat_tabs, node->attr.tmpl_tag);
1283 if (node->attr.tmpl_num != NUM_ANY) {
1284 if (node->attr.tmpl_num == NUM_COUNT) {
1285 DEBUG("%.*s[#]", lvl + 1, xlat_tabs);
1286 } else if (node->attr.tmpl_num == NUM_ALL) {
1287 DEBUG("%.*s[*]", lvl + 1, xlat_tabs);
1289 DEBUG("%.*s[%d]", lvl + 1, xlat_tabs, node->attr.tmpl_num);
1293 DEBUG("%.*s}", lvl, xlat_tabs);
1298 rad_assert(node->fmt != NULL);
1299 DEBUG("%.*svirtual --> %s", lvl, xlat_tabs, node->fmt);
1303 rad_assert(node->xlat != NULL);
1304 DEBUG("%.*sxlat --> %s", lvl, xlat_tabs, node->xlat->name);
1306 DEBUG("%.*s{", lvl, xlat_tabs);
1307 xlat_tokenize_debug(node->child, lvl + 1);
1308 DEBUG("%.*s}", lvl, xlat_tabs);
1314 DEBUG("%.*sregex-var --> %d", lvl, xlat_tabs, node->attr.tmpl_num);
1318 case XLAT_ALTERNATE:
1319 DEBUG("%.*sif {", lvl, xlat_tabs);
1320 xlat_tokenize_debug(node->child, lvl + 1);
1321 DEBUG("%.*s}", lvl, xlat_tabs);
1322 DEBUG("%.*selse {", lvl, xlat_tabs);
1323 xlat_tokenize_debug(node->alternate, lvl + 1);
1324 DEBUG("%.*s}", lvl, xlat_tabs);
1331 size_t xlat_sprint(char *buffer, size_t bufsize, xlat_exp_t const *node)
1342 end = buffer + bufsize;
1345 switch (node->type) {
1347 strlcpy(p, node->fmt, end - p);
1353 p[1] = node->fmt[0];
1357 case XLAT_ATTRIBUTE:
1361 if (node->attr.tmpl_request != REQUEST_CURRENT) {
1362 strlcpy(p, fr_int2str(request_refs, node->attr.tmpl_request, "??"), end - p);
1367 if ((node->attr.tmpl_request != REQUEST_CURRENT) ||
1368 (node->attr.tmpl_list != PAIR_LIST_REQUEST)) {
1369 strlcpy(p, fr_int2str(pair_lists, node->attr.tmpl_list, "??"), end - p);
1374 strlcpy(p, node->attr.tmpl_da->name, end - p);
1377 if (node->attr.tmpl_tag != TAG_ANY) {
1379 snprintf(p, end - p, "%u", node->attr.tmpl_tag);
1383 if (node->attr.tmpl_num != NUM_ANY) {
1385 switch (node->attr.tmpl_num) {
1395 snprintf(p, end - p, "%i", node->attr.tmpl_num);
1404 snprintf(p, end - p, "%%{%i}", node->attr.tmpl_num);
1411 strlcpy(p, node->fmt, end - p);
1419 strlcpy(p, node->xlat->name, end - p);
1422 rad_assert(node->child != NULL);
1423 len = xlat_sprint(p, end - p, node->child);
1428 case XLAT_ALTERNATE:
1432 len = xlat_sprint(p, end - p, node->child);
1438 len = xlat_sprint(p, end - p, node->alternate);
1446 if (p == end) break;
1456 ssize_t xlat_tokenize(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **head,
1459 return xlat_tokenize_literal(ctx, fmt, head, false, error);
1463 /** Tokenize an xlat expansion
1465 * @param[in] request the input request. Memory will be attached here.
1466 * @param[in] fmt the format string to expand
1467 * @param[out] head the head of the xlat list / tree structure.
1469 static ssize_t xlat_tokenize_request(REQUEST *request, char const *fmt, xlat_exp_t **head)
1478 * Copy the original format string to a buffer so that
1479 * the later functions can mangle it in-place, which is
1482 tokens = talloc_typed_strdup(request, fmt);
1483 if (!tokens) return -1;
1485 slen = xlat_tokenize_literal(request, tokens, head, false, &error);
1488 * Zero length expansion, return a zero length node.
1491 *head = talloc_zero(request, xlat_exp_t);
1495 * Output something like:
1498 * " ^ error was here"
1501 talloc_free(tokens);
1502 rad_assert(error != NULL);
1504 REMARKER(fmt, -slen, error);
1508 if (*head && (debug_flag > 2)) {
1510 DEBUG("Parsed xlat tree:");
1511 xlat_tokenize_debug(*head, 0);
1515 * All of the nodes point to offsets in the "tokens"
1516 * string. Let's ensure that free'ing head will free
1519 (void) talloc_steal(*head, tokens);
1525 static char *xlat_getvp(TALLOC_CTX *ctx, REQUEST *request, pair_lists_t list, DICT_ATTR const *da,
1526 int8_t tag, int num, bool return_null)
1528 VALUE_PAIR *vp, *vps = NULL, *myvp = NULL;
1529 RADIUS_PACKET *packet = NULL;
1534 * Arg. Too much abstraction is annoying.
1538 if (return_null) return NULL;
1539 return vp_aprint_type(ctx, da->type);
1541 case PAIR_LIST_CONTROL:
1542 vps = request->config_items;
1545 case PAIR_LIST_REQUEST:
1546 packet = request->packet;
1547 if (packet) vps = packet->vps;
1550 case PAIR_LIST_REPLY:
1551 packet = request->reply;
1552 if (packet) vps = packet->vps;
1556 case PAIR_LIST_PROXY_REQUEST:
1557 packet = request->proxy;
1558 if (packet) vps = packet->vps;
1561 case PAIR_LIST_PROXY_REPLY:
1562 packet = request->proxy_reply;
1563 if (packet) vps = packet->vps;
1570 if (request->coa) packet = request->coa->packet;
1571 if (packet) vps = packet->vps;
1574 case PAIR_LIST_COA_REPLY:
1575 case PAIR_LIST_DM_REPLY:
1576 if (request->coa) packet = request->coa->reply;
1577 if (packet) vps = packet->vps;
1584 * Now we have the list, check to see if we have an attribute in
1585 * the request, if we do, it takes precedence over the virtual
1588 * This allows users to manipulate virtual attributes as if they
1591 vp = pairfind(vps, da->attr, da->vendor, tag);
1592 if (vp) goto do_print;
1595 * We didn't find the VP in a list. It MIGHT be a
1596 * virtual one, in which case we do lots more checks
1597 * below. However, if we're looking for a normal
1598 * attribute, it must exist, and therefore not finding it
1599 * means we return NULL.
1601 if (!da->flags.virtual) return NULL;
1604 * Some non-packet expansions
1608 break; /* ignore them */
1610 case PW_CLIENT_SHORTNAME:
1611 if (num == NUM_COUNT) goto count;
1612 if (request->client && request->client->shortname) {
1613 return talloc_typed_strdup(ctx, request->client->shortname);
1615 return talloc_typed_strdup(ctx, "<UNKNOWN-CLIENT>");
1617 case PW_REQUEST_PROCESSING_STAGE:
1618 if (num == NUM_COUNT) goto count;
1619 if (request->component) {
1620 return talloc_typed_strdup(ctx, request->component);
1622 return talloc_typed_strdup(ctx, "server_core");
1624 case PW_VIRTUAL_SERVER:
1625 if (num == NUM_COUNT) goto count;
1626 if (!request->server) return NULL;
1627 return talloc_typed_strdup(ctx, request->server);
1629 case PW_MODULE_RETURN_CODE:
1630 if (num == NUM_COUNT) goto count;
1631 if (!request->rcode) return NULL;
1632 return talloc_typed_strdup(ctx, fr_int2str(modreturn_table, request->rcode, ""));
1636 * All of the attributes must now refer to a packet.
1637 * If there's no packet, we can't print any attribute
1641 if (return_null) return NULL;
1642 return vp_aprint_type(ctx, da->type);
1650 case PW_PACKET_TYPE:
1651 dv = dict_valbyattr(PW_PACKET_TYPE, 0, packet->code);
1652 if (dv) return talloc_typed_strdup(ctx, dv->name);
1653 return talloc_typed_asprintf(ctx, "%d", packet->code);
1655 case PW_RESPONSE_PACKET_TYPE:
1660 if (request->proxy_reply && (!request->reply || !request->reply->code)) {
1661 code = request->proxy_reply->code;
1664 if (request->reply) {
1665 code = request->reply->code;
1668 return talloc_typed_strdup(ctx, fr_packet_codes[code]);
1672 * Virtual attributes which require a temporary VALUE_PAIR
1673 * to be allocated. We can't use stack allocated memory
1674 * because of the talloc checks sprinkled throughout the
1675 * various VP functions.
1677 case PW_PACKET_AUTHENTICATION_VECTOR:
1678 myvp = pairalloc(ctx, da);
1679 pairmemcpy(myvp, packet->vector, sizeof(packet->vector));
1683 case PW_CLIENT_IP_ADDRESS:
1684 case PW_PACKET_SRC_IP_ADDRESS:
1685 if (packet->src_ipaddr.af == AF_INET) {
1686 myvp = pairalloc(ctx, da);
1687 myvp->vp_ipaddr = packet->src_ipaddr.ipaddr.ip4addr.s_addr;
1692 case PW_PACKET_DST_IP_ADDRESS:
1693 if (packet->dst_ipaddr.af == AF_INET) {
1694 myvp = pairalloc(ctx, da);
1695 myvp->vp_ipaddr = packet->dst_ipaddr.ipaddr.ip4addr.s_addr;
1700 case PW_PACKET_SRC_IPV6_ADDRESS:
1701 if (packet->src_ipaddr.af == AF_INET6) {
1702 myvp = pairalloc(ctx, da);
1703 memcpy(&myvp->vp_ipv6addr,
1704 &packet->src_ipaddr.ipaddr.ip6addr,
1705 sizeof(packet->src_ipaddr.ipaddr.ip6addr));
1710 case PW_PACKET_DST_IPV6_ADDRESS:
1711 if (packet->dst_ipaddr.af == AF_INET6) {
1712 myvp = pairalloc(ctx, da);
1713 memcpy(&myvp->vp_ipv6addr,
1714 &packet->dst_ipaddr.ipaddr.ip6addr,
1715 sizeof(packet->dst_ipaddr.ipaddr.ip6addr));
1720 case PW_PACKET_SRC_PORT:
1721 myvp = pairalloc(ctx, da);
1722 myvp->vp_integer = packet->src_port;
1726 case PW_PACKET_DST_PORT:
1727 myvp = pairalloc(ctx, da);
1728 myvp->vp_integer = packet->dst_port;
1734 * Fake various operations for virtual attributes.
1737 if (num != NUM_ANY) switch (num) {
1739 * [n] is NULL (we only have [0])
1744 * [*] means only one.
1750 * [#] means 1 (as there's only one)
1754 ret = talloc_strdup(ctx, "1");
1758 * [0] is fine (get the first instance)
1768 * We want the N'th VP.
1770 if (num != NUM_ANY) {
1776 * Return a count of the VPs.
1779 fr_cursor_init(&cursor, &vp);
1780 while (fr_cursor_next_by_da(&cursor, da, tag) != NULL) {
1783 return talloc_typed_asprintf(ctx, "%d", count);
1786 * Ugly, but working.
1792 (void) fr_cursor_init(&cursor, &vp);
1793 vp = fr_cursor_next_by_da(&cursor, da, tag);
1794 if (!vp) return NULL;
1796 p = vp_aprint_value(ctx, vp, '"');
1797 if (!p) return NULL;
1798 while ((vp = fr_cursor_next_by_da(&cursor, da, tag)) != NULL) {
1799 q = vp_aprint_value(ctx, vp, '"');
1800 if (!q) return NULL;
1801 p = talloc_strdup_append(p, ",");
1802 p = talloc_strdup_append(p, q);
1809 fr_cursor_init(&cursor, &vp);
1810 while ((vp = fr_cursor_next_by_da(&cursor, da, tag)) != NULL) {
1811 if (count++ == num) break;
1818 if (return_null) return NULL;
1819 return vp_aprint_type(ctx, da->type);
1823 ret = vp_aprint_value(ctx, vp, '"');
1831 static const char xlat_spaces[] = " ";
1834 static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * const node,
1835 RADIUS_ESCAPE_STRING escape, void *escape_ctx, int lvl)
1838 char *str = NULL, *child;
1841 XLAT_DEBUG("%.*sxlat aprint %d", lvl, xlat_spaces, node->type);
1843 switch (node->type) {
1845 * Don't escape this.
1848 XLAT_DEBUG("xlat_aprint LITERAL");
1849 return talloc_typed_strdup(ctx, node->fmt);
1852 * Do a one-character expansion.
1858 size_t freespace = 256;
1862 XLAT_DEBUG("xlat_aprint PERCENT");
1864 str = talloc_array(ctx, char, freespace); /* @todo do better allocation */
1867 when = request->timestamp;
1868 if (request->packet) {
1869 when = request->packet->timestamp.tv_sec;
1878 case 'd': /* request day */
1879 (void) localtime_r(&when, &ts);
1880 strftime(str, freespace, "%d", &ts);
1883 case 'l': /* request timestamp */
1884 snprintf(str, freespace, "%lu",
1885 (unsigned long) when);
1888 case 'm': /* request month */
1889 (void) localtime_r(&when, &ts);
1890 strftime(str, freespace, "%m", &ts);
1893 case 'n': /* Request Number*/
1894 snprintf(str, freespace, "%u", request->number);
1897 case 't': /* request timestamp */
1898 CTIME_R(&when, str, freespace);
1899 nl = strchr(str, '\n');
1903 case 'D': /* request date */
1904 (void) localtime_r(&when, &ts);
1905 strftime(str, freespace, "%Y%m%d", &ts);
1908 case 'G': /* request minute */
1909 (void) localtime_r(&when, &ts);
1910 strftime(str, freespace, "%M", &ts);
1913 case 'H': /* request hour */
1914 (void) localtime_r(&when, &ts);
1915 strftime(str, freespace, "%H", &ts);
1918 case 'I': /* Request ID */
1919 if (request->packet) {
1920 snprintf(str, freespace, "%i", request->packet->id);
1924 case 'S': /* request timestamp in SQL format*/
1925 (void) localtime_r(&when, &ts);
1926 strftime(str, freespace, "%Y-%m-%d %H:%M:%S", &ts);
1929 case 'T': /* request timestamp */
1930 (void) localtime_r(&when, &ts);
1931 strftime(str, freespace, "%Y-%m-%d-%H.%M.%S.000000", &ts);
1934 case 'Y': /* request year */
1935 (void) localtime_r(&when, &ts);
1936 strftime(str, freespace, "%Y", &ts);
1939 case 'v': /* Version of code */
1940 snprintf(str, freespace, "%s", radiusd_short_version);
1950 case XLAT_ATTRIBUTE:
1951 XLAT_DEBUG("xlat_aprint ATTRIBUTE");
1953 if (radius_request(&ref, node->attr.tmpl_request) < 0) {
1958 * Some attributes are virtual <sigh>
1960 str = xlat_getvp(ctx, ref, node->attr.tmpl_list, node->attr.tmpl_da, node->attr.tmpl_tag, node->attr.tmpl_num, true);
1962 XLAT_DEBUG("EXPAND attr %s", node->attr.tmpl_da->name);
1963 XLAT_DEBUG(" ---> %s", str);
1968 XLAT_DEBUG("xlat_aprint VIRTUAL");
1969 str = talloc_array(ctx, char, 2048); /* FIXME: have the module call talloc_typed_asprintf */
1970 rcode = node->xlat->func(node->xlat->instance, request, NULL, str, 2048);
1978 XLAT_DEBUG("xlat_aprint MODULE");
1979 if (xlat_process(&child, request, node->child, node->xlat->escape, node->xlat->instance) == 0) {
1983 XLAT_DEBUG("%.*sEXPAND mod %s %s", lvl, xlat_spaces, node->fmt, node->child->fmt);
1984 XLAT_DEBUG("%.*s ---> %s", lvl, xlat_spaces, child);
1986 str = talloc_array(ctx, char, 2048); /* FIXME: have the module call talloc_typed_asprintf */
1987 *str = '\0'; /* Be sure the string is NULL terminated, we now only free on error */
1990 * Convert \n --> CR if requested.
1993 rcode = node->xlat->func(node->xlat->instance, request, child, str, 2048);
2003 XLAT_DEBUG("xlat_aprint REGEX");
2004 child = request_data_reference(request, request,
2005 REQUEST_DATA_REGEX | node->attr.tmpl_num);
2006 if (!child) return NULL;
2008 str = talloc_typed_strdup(ctx, child);
2012 case XLAT_ALTERNATE:
2013 XLAT_DEBUG("xlat_aprint ALTERNATE");
2014 rad_assert(node->child != NULL);
2015 rad_assert(node->alternate != NULL);
2017 str = xlat_aprint(ctx, request, node->child, escape, escape_ctx, lvl);
2020 str = xlat_aprint(ctx, request, node->alternate, escape, escape_ctx, lvl);
2026 * Escape the non-literals we found above.
2028 if (str && escape) {
2031 escaped = talloc_array(ctx, char, 2048); /* FIXME: do something intelligent */
2032 escape(request, escaped, 2038, str, escape_ctx);
2041 static size_t xlat_process(char **out, REQUEST *request, xlat_exp_t const * const head,
2042 RADIUS_ESCAPE_STRING escape, void *escape_ctx)
2046 char **array, *answer;
2047 xlat_exp_t const *node;
2052 * There are no nodes to process, so the result is a zero
2056 *out = talloc_zero_array(request, char, 1);
2061 * Hack for speed. If it's one expansion, just allocate
2062 * that and return, instead of allocating an intermediary
2067 * Pass the MAIN escape function. Recursive
2068 * calls will call node-specific escape
2071 answer = xlat_aprint(request, request, head, escape, escape_ctx, 0);
2073 *out = talloc_zero_array(request, char, 1);
2077 return strlen(answer);
2080 list = 0; /* FIXME: calculate this once */
2081 for (node = head; node != NULL; node = node->next) {
2085 array = talloc_array(request, char *, list);
2086 if (!array) return -1;
2088 for (node = head, i = 0; node != NULL; node = node->next, i++) {
2089 array[i] = xlat_aprint(array, request, node, escape, escape_ctx, 0); /* may be NULL */
2093 for (i = 0; i < list; i++) {
2094 if (array[i]) total += strlen(array[i]); /* FIXME: calculate strlen once */
2099 *out = talloc_zero_array(request, char, 1);
2103 answer = talloc_array(request, char, total + 1);
2106 for (i = 0; i < list; i++) {
2110 len = strlen(array[i]);
2111 memcpy(answer + total, array[i], len);
2115 answer[total] = '\0';
2116 talloc_free(array); /* and child entries */
2123 /** Replace %whatever in a string.
2125 * See 'doc/variables.txt' for more information.
2127 * @param[out] out Where to write pointer to output buffer.
2128 * @param[in] outlen Size of out.
2129 * @param[in] request current request.
2130 * @param[in] node the xlat structure to expand
2131 * @param[in] escape function to escape final value e.g. SQL quoting.
2132 * @param[in] escape_ctx pointer to pass to escape function.
2133 * @return length of string written @bug should really have -1 for failure
2135 static ssize_t xlat_expand_struct(char **out, size_t outlen, REQUEST *request, xlat_exp_t const *node,
2136 RADIUS_ESCAPE_STRING escape, void *escape_ctx)
2141 rad_assert(node != NULL);
2143 len = xlat_process(&buff, request, node, escape, escape_ctx);
2144 if ((len < 0) || !buff) {
2145 rad_assert(buff == NULL);
2146 if (*out) *out[0] = '\0';
2153 strlcpy(*out, buff, outlen);
2157 return strlen(*out);
2160 static ssize_t xlat_expand(char **out, size_t outlen, REQUEST *request, char const *fmt,
2161 RADIUS_ESCAPE_STRING escape, void *escape_ctx) CC_HINT(nonnull (1, 3, 4));
2163 /** Replace %whatever in a string.
2165 * See 'doc/variables.txt' for more information.
2167 * @param[out] out Where to write pointer to output buffer.
2168 * @param[in] outlen Size of out.
2169 * @param[in] request current request.
2170 * @param[in] fmt string to expand.
2171 * @param[in] escape function to escape final value e.g. SQL quoting.
2172 * @param[in] escape_ctx pointer to pass to escape function.
2173 * @return length of string written @bug should really have -1 for failure
2175 static ssize_t CC_HINT(nonnull (1, 3, 4)) xlat_expand(char **out, size_t outlen, REQUEST *request, char const *fmt,
2176 RADIUS_ESCAPE_STRING escape, void *escape_ctx)
2182 * Give better errors than the old code.
2184 len = xlat_tokenize_request(request, fmt, &node);
2189 *out = talloc_zero_array(request, char, 1);
2195 if (*out) *out[0] = '\0';
2199 len = xlat_expand_struct(out, outlen, request, node, escape, escape_ctx);
2202 RDEBUG2("EXPAND %s", fmt);
2203 RDEBUG2(" --> %s", *out);
2209 * Try to convert an xlat to a tmpl for efficiency
2211 value_pair_tmpl_t *radius_xlat2tmpl(TALLOC_CTX *ctx, xlat_exp_t *node)
2213 value_pair_tmpl_t *vpt;
2215 if (node->next || (node->type != XLAT_ATTRIBUTE)) return NULL;
2218 * @todo it should be possible to emulate the concat and count operations in the
2221 if ((node->attr.tmpl_num == NUM_COUNT) || (node->attr.tmpl_num == NUM_ALL)) return NULL;
2223 vpt = tmpl_alloc(ctx, TMPL_TYPE_ATTR, node->fmt, -1);
2224 if (!vpt) return NULL;
2225 vpt->tmpl_request = node->attr.tmpl_request;
2226 vpt->tmpl_list = node->attr.tmpl_list;
2227 vpt->tmpl_da = node->attr.tmpl_da;
2228 vpt->tmpl_num = node->attr.tmpl_num;
2229 vpt->tmpl_tag = node->attr.tmpl_tag;
2236 ssize_t radius_xlat(char *out, size_t outlen, REQUEST *request, char const *fmt, RADIUS_ESCAPE_STRING escape, void *ctx)
2238 return xlat_expand(&out, outlen, request, fmt, escape, ctx);
2241 ssize_t radius_axlat(char **out, REQUEST *request, char const *fmt, RADIUS_ESCAPE_STRING escape, void *ctx)
2243 return xlat_expand(out, 0, request, fmt, escape, ctx);
2246 ssize_t radius_axlat_struct(char **out, REQUEST *request, xlat_exp_t const *xlat, RADIUS_ESCAPE_STRING escape, void *ctx)
2248 return xlat_expand_struct(out, 0, request, xlat, escape, ctx);