They're only used by xlat functions and should go away once all the functions have been converted.
void log_module_failure_msg(REQUEST *request, char const *fmt, ...) CC_HINT(format (printf, 2, 3));
void vlog_module_failure_msg(REQUEST *request, char const *fmt, va_list ap) CC_HINT(format (printf, 2, 0));
-int radius_get_vp(VALUE_PAIR **out, REQUEST *request, char const *name);
-int radius_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name);
-
/*
* Less code == fewer bugs
*/
typedef int (*xlat_thread_detach_t)(void *xlat_thread_inst, void *uctx);
+int xlat_fmt_get_vp(VALUE_PAIR **out, REQUEST *request, char const *name);
+int xlat_fmt_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name);
+
ssize_t xlat_eval(char *out, size_t outlen, REQUEST *request, char const *fmt, xlat_escape_t escape,
void const *escape_ctx)
CC_HINT(nonnull (1 ,3 ,4));
}
REXDENT();
}
-
-/** Return a VP from the specified request.
- *
- * @param out where to write the pointer to the resolved VP. Will be NULL if the attribute couldn't
- * be resolved.
- * @param request current request.
- * @param name attribute name including qualifiers.
- * @return
- * - -4 if either the attribute or qualifier were invalid.
- * - The same error codes as #tmpl_find_vp for other error conditions.
- */
-int radius_get_vp(VALUE_PAIR **out, REQUEST *request, char const *name)
-{
- int rcode;
- vp_tmpl_t *vpt;
-
- *out = NULL;
-
- if (tmpl_afrom_attr_str(request, &vpt, name,
- REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false) <= 0) return -4;
-
- rcode = tmpl_find_vp(out, request, vpt);
- talloc_free(vpt);
-
- return rcode;
-}
-
-/** Copy VP(s) from the specified request.
- *
- * @param ctx to alloc new VALUE_PAIRs in.
- * @param out where to write the pointer to the copied VP. Will be NULL if the attribute couldn't be
- * resolved.
- * @param request current request.
- * @param name attribute name including qualifiers.
- * @return
- * - -4 if either the attribute or qualifier were invalid.
- * - The same error codes as #tmpl_find_vp for other error conditions.
- */
-int radius_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name)
-{
- int rcode;
- vp_tmpl_t *vpt;
-
- *out = NULL;
-
- if (tmpl_afrom_attr_str(request, &vpt, name,
- REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false) <= 0) return -4;
-
- rcode = tmpl_copy_vps(ctx, out, request, vpt);
- talloc_free(vpt);
-
- return rcode;
-}
-
-
static int xlat_foreach_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; /* up to 10 for foreach */
+/** Return a VP from the specified request.
+ *
+ * @param out where to write the pointer to the resolved VP. Will be NULL if the attribute couldn't
+ * be resolved.
+ * @param request current request.
+ * @param name attribute name including qualifiers.
+ * @return
+ * - -4 if either the attribute or qualifier were invalid.
+ * - The same error codes as #tmpl_find_vp for other error conditions.
+ */
+int xlat_fmt_get_vp(VALUE_PAIR **out, REQUEST *request, char const *name)
+{
+ int rcode;
+ vp_tmpl_t *vpt;
+
+ *out = NULL;
+
+ if (tmpl_afrom_attr_str(request, &vpt, name,
+ REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false) <= 0) return -4;
+
+ rcode = tmpl_find_vp(out, request, vpt);
+ talloc_free(vpt);
+
+ return rcode;
+}
+
+/** Copy VP(s) from the specified request.
+ *
+ * @param ctx to alloc new VALUE_PAIRs in.
+ * @param out where to write the pointer to the copied VP. Will be NULL if the attribute couldn't be
+ * resolved.
+ * @param request current request.
+ * @param name attribute name including qualifiers.
+ * @return
+ * - -4 if either the attribute or qualifier were invalid.
+ * - The same error codes as #tmpl_find_vp for other error conditions.
+ */
+int xlat_fmt_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name)
+{
+ int rcode;
+ vp_tmpl_t *vpt;
+
+ *out = NULL;
+
+ if (tmpl_afrom_attr_str(request, &vpt, name,
+ REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false) <= 0) return -4;
+
+ rcode = tmpl_copy_vps(ctx, out, request, vpt);
+ talloc_free(vpt);
+
+ return rcode;
+}
+
/** Print length of its RHS.
*
*/
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
snprintf(*out, outlen, "%zu", fr_value_box_network_length(&vp->data));
return strlen(*out);
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
switch (vp->vp_type) {
case FR_TYPE_OCTETS:
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) {
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) {
error:
return -1;
}
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
if (!vp->da->flags.has_tag || !TAG_VALID(vp->tag)) return 0;
/*
* See modcall, "FOREACH" for how this works.
*/
- pvp = (VALUE_PAIR **) request_data_reference(request, (void *)radius_get_vp, *(int const *) mod_inst);
+ pvp = (VALUE_PAIR **) request_data_reference(request, (void *)xlat_fmt_get_vp, *(int const *) mod_inst);
if (!pvp || !*pvp) return 0;
*out = fr_pair_value_asprint(ctx, *pvp, '\0');
return 0;
}
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) goto nothing;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) goto nothing;
/*
* These are printed specially.
return 0;
}
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) goto nothing;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) goto nothing;
RDEBUG2("EXPAND %s", fmt);
RINDENT();
* attribute, and then store the data in network byte
* order.
*/
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return -1;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return -1;
fr_value_box_copy(ctx, out, &vp->data);
while (isspace((int) *fmt)) fmt++;
- if ((radius_copy_vp(request, &vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_copy_vp(request, &vp, request, fmt) < 0) || !vp) return 0;
fr_cursor_init(&cursor, &vp);
len = fr_dhcpv4_encode_option(binbuf, sizeof(binbuf), &cursor, NULL);
return date_encode_strftime(out, outlen, inst, request, now.tv_sec);
}
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
switch (vp->vp_type) {
/*
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
vendor = fr_dict_vendor_by_da(vp->da);
if (!vendor) return 0;
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
*out = talloc_typed_asprintf(ctx, "%i", fr_dict_vendor_num_by_da(vp->da));
return talloc_array_length(*out) - 1;
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
strlcpy(*out, vp->da->name, outlen);
*out = talloc_typed_strdup(ctx, vp->da->name);
while (isspace((int) *fmt)) fmt++;
- if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
+ if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;
*out = talloc_typed_asprintf(ctx, "%i", vp->da->attr);
return talloc_array_length(*out) - 1;
* Attribute reference
*/
if (*data_name == '&') {
- if (radius_get_vp(&vp, request, data_name) < 0) goto nothing;
+ if (xlat_fmt_get_vp(&vp, request, data_name) < 0) goto nothing;
if ((vp->vp_type != FR_TYPE_OCTETS) &&
(vp->vp_type != FR_TYPE_STRING)) {
RDEBUG2("%s", unlang_ops[instruction->type].name);
for (i = 8; i >= 0; i--) {
- copy_p = request_data_get(request, (void *)radius_get_vp, i);
+ copy_p = request_data_get(request, (void *)xlat_fmt_get_vp, i);
if (copy_p) {
if (instruction->type == UNLANG_TYPE_BREAK) {
RDEBUG2("# break Foreach-Variable-%d", i);
* FIXME: figure this out by walking up the modcall stack instead.
*/
for (i = 0; i < 8; i++) {
- if (!request_data_reference(request, (void *)radius_get_vp, i)) {
+ if (!request_data_reference(request, (void *)xlat_fmt_get_vp, i)) {
foreach_depth = i;
break;
}
* the xlat outside of a foreach loop and trigger a segv.
*/
fr_pair_list_free(&foreach->vps);
- request_data_get(request, (void *)radius_get_vp, foreach->depth);
+ request_data_get(request, (void *)xlat_fmt_get_vp, foreach->depth);
*presult = frame->result;
if (*presult != RLM_MODULE_UNKNOWN) *priority = instruction->actions[*presult];
* xlat.c, xlat_foreach() can find it.
*/
foreach->variable = vp;
- request_data_add(request, (void *)radius_get_vp, foreach->depth, &foreach->variable,
+ request_data_add(request, (void *)xlat_fmt_get_vp, foreach->depth, &foreach->variable,
false, false, false);
/*