The general rule is that refs are only used where information from the VALUE_PAIR is required
return XLAT_ACTION_DONE;
}
-/** Return the on-the-wire size of the attribute(s) in bytes
+/** Return the on-the-wire size of the boxes in bytes
*
*/
static xlat_action_t xlat_func_length(TALLOC_CTX *ctx, fr_cursor_t *out,
- REQUEST *request, UNUSED void const *xlat_inst,
+ UNUSED REQUEST *request, UNUSED void const *xlat_inst,
UNUSED void *xlat_thread_inst, fr_value_box_t **in)
{
- VALUE_PAIR *vp;
fr_value_box_t *vb;
- fr_cursor_t *cursor;
-
- if (!*in) {
- REDEBUG("Missing attribute reference");
- return XLAT_ACTION_FAIL;
- }
-
- /*
- * Concatenate input boxes to form the reference
- */
- if (fr_value_box_list_concat(ctx, *in, in, FR_TYPE_STRING, true) < 0) {
- RPEDEBUG("Failed concatenating input string for attribute reference");
- return XLAT_ACTION_FAIL;
- }
-
- if (xlat_fmt_to_cursor(NULL, &cursor, NULL, request, (*in)->vb_strvalue) < 0) return XLAT_ACTION_FAIL;
+ fr_cursor_t cursor;
- MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_SIZE, NULL, false));
- vb->vb_size = 0;
+ for (vb = fr_cursor_talloc_init(&cursor, in, fr_value_box_t);
+ vb;
+ vb = fr_cursor_next(&cursor)) {
+ fr_value_box_t *new;
- /*
- * Get the length of all VPs
- */
- for (vp = fr_cursor_head(cursor);
- vp;
- vp = fr_cursor_next(cursor)) {
- vb->vb_size += fr_value_box_network_length(&vp->data);
+ MEM(new = fr_value_box_alloc(ctx, FR_TYPE_SIZE, NULL, false));
+ new->vb_size = fr_value_box_network_length(vb);
+ fr_cursor_append(out, new);
}
- talloc_free(cursor);
- fr_cursor_append(out, vb);
return XLAT_ACTION_DONE;
}
}
-if ("%{length:Tmp-String-0}" != 39) {
+if ("%{length:%{Tmp-String-0}}" != 39) {
test_fail
}
-if ("%{length:Tmp-String-1}" != 42) {
+if ("%{length:%{Tmp-String-1}}" != 42) {
test_fail
}
}
update request {
- &Tmp-Integer-0 := "%{length:Tmp-String-0}"
+ &Tmp-Integer-0 := "%{length:%{Tmp-String-0}}"
}
if (&Tmp-Integer-0 != 260) {
}
update request {
- &Tmp-Integer-0 := "%{length:Tmp-String-2}"
- &Tmp-Integer-1 := "%{length:Tmp-Octets-0}"
- &Tmp-Integer-2 := "%{length:Tmp-IP-Address-0}"
- &Tmp-Integer-3 := "%{length:Tmp-Date-0}"
- &Tmp-Integer-4 := "%{length:Tmp-Integer-0}"
- &Tmp-Integer-5 := "%{length:Tmp-Cast-Abinary}"
- &Tmp-Integer-6 := "%{length:Tmp-Cast-Ifid}"
- &Tmp-Integer-7 := "%{length:Tmp-Cast-IPv6Addr}"
- &Tmp-Integer-8 := "%{length:Tmp-Cast-IPv6Prefix}"
- &Tmp-Integer-9 := "%{length:Tmp-Cast-Byte}"
+ &Tmp-Integer-0 := "%{length:%{Tmp-String-2}}"
+ &Tmp-Integer-1 := "%{length:%{Tmp-Octets-0}}"
+ &Tmp-Integer-2 := "%{length:%{Tmp-IP-Address-0}}"
+ &Tmp-Integer-3 := "%{length:%{Tmp-Date-0}}"
+ &Tmp-Integer-4 := "%{length:%{Tmp-Integer-0}}"
+ &Tmp-Integer-5 := "%{length:%{Tmp-Cast-Abinary}}"
+ &Tmp-Integer-6 := "%{length:%{Tmp-Cast-Ifid}}"
+ &Tmp-Integer-7 := "%{length:%{Tmp-Cast-IPv6Addr}}"
+ &Tmp-Integer-8 := "%{length:%{Tmp-Cast-IPv6Prefix}}"
+ &Tmp-Integer-9 := "%{length:%{Tmp-Cast-Byte}}"
}
# String - bin 0x39383730
}
update request {
- &Tmp-Integer-0 := "%{length:Tmp-Cast-Short}"
- &Tmp-Integer-1 := "%{length:Tmp-Cast-Ether}"
- &Tmp-Integer-2 := "%{length:Tmp-Cast-Integer64}"
- &Tmp-Integer-3 := "%{length:Tmp-Cast-IPv4Prefix}"
+ &Tmp-Integer-0 := "%{length:%{Tmp-Cast-Short}}"
+ &Tmp-Integer-1 := "%{length:%{Tmp-Cast-Ether}}"
+ &Tmp-Integer-2 := "%{length:%{Tmp-Cast-Integer64}}"
+ &Tmp-Integer-3 := "%{length:%{Tmp-Cast-IPv4Prefix}}"
}
# short - bin 0x373b
#
# Check repitition of binary output
#
-if ("%{strlen:%{Tmp-String-5}}" != 10) {
+if ("%{length:%{Tmp-String-5}}" != 10) {
test_fail
}
# Actual length of octet string is 4083 bytes
update request {
- &Tmp-Integer-0 := "%{length:Tmp-Octets-0}"
+ &Tmp-Integer-0 := "%{length:%{Tmp-Octets-0}}"
}
if (&Tmp-Integer-0 != 4083) {
&Tmp-String-0 := "%{1}"
}
-if ("%{length:Tmp-String-0}" != 8166) {
+if ("%{length:%{Tmp-String-0}}" != 8166) {
test_fail
}
test_fail
}
-if ("%{length:Tmp-String-1}" == 11) {
+if ("%{length:%{Tmp-String-1}}" == 11) {
test_pass
}
else {
test_fail
}
-if ("%{length:Tmp-String-1}" == 7) {
+if ("%{length:%{Tmp-String-1}}" == 7) {
test_pass
}
else {
test_fail
}
-if ("%{length:Tmp-String-1}" == 11) {
+if ("%{length:%{Tmp-String-1}}" == 11) {
test_pass
}
else {
test_fail
}
-if ("%{length:Tmp-String-1}" == 7) {
+if ("%{length:%{Tmp-String-1}}" == 7) {
test_pass
}
else {