xlat_print(out, tmpl_xlat(node->vpt), fr_value_escape_by_quote[node->quote]);
goto done;
}
+
+ // attr or list
+ fr_assert(tmpl_is_list(node->vpt) || tmpl_is_attr(node->vpt));
+ fr_assert(talloc_parent(node->vpt) == node);
+
+ /*
+ * We prefer the name from the configuration file, otherwise when we get
+ * &User-Name on input, the tmpl_printer will print the full path, as
+ * &request[0].User-Name.
+ */
+ if (node->vpt->name[0] == '&') {
+ FR_SBUFF_IN_STRCPY_RETURN(out, node->fmt);
+ goto done;
+ }
break;
case XLAT_ONE_LETTER:
*/
if (node->call.func->print) {
slen = node->call.func->print(out, node, node->call.inst->data, e_rules);
- if (slen < 0) goto error;
+ if (slen < 0) return slen;
goto done;
}
break;
switch (node->type) {
case XLAT_TMPL:
- fr_assert(tmpl_is_list(node->vpt) || tmpl_is_attr(node->vpt));
- fr_assert(talloc_parent(node->vpt) == node);
slen = tmpl_attr_print(out, node->vpt, TMPL_ATTR_REF_PREFIX_NO);
- if (slen < 0) {
- error:
- return slen;
- }
+ if (slen < 0) return slen;
break;
#ifdef HAVE_REGEX
case XLAT_REGEX:
if (xlat_exp_head(node->call.args)) {
slen = xlat_print(out, node->call.args, &xlat_escape);
- if (slen < 0) goto error;
+ if (slen < 0) return slen;
}
break;
if (xlat_exp_head(node->call.args)) {
slen = xlat_print(out, node->call.args, &xlat_escape);
- if (slen < 0) goto error;
+ if (slen < 0) return slen;
}
break;
case XLAT_ALTERNATE:
slen = xlat_print(out, node->alternate[0], &xlat_escape);
- if (slen < 0) goto error;
+ if (slen < 0) return slen;
FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, ":-");
slen = xlat_print(out, node->alternate[1], &xlat_escape);
- if (slen < 0) goto error;
+ if (slen < 0) return slen;
break;
fr_assert_fail(NULL);
match (((2 + 3) * 4) + 5)
xlat_expr &NAS-Port + 5
-match (%{NAS-Port} + 5)
+match (&NAS-Port + 5)
xlat_expr &Framed-IP-Address & 0xffff0000
-match (%{Framed-IP-Address} & 0xffff0000)
+match (&Framed-IP-Address & 0xffff0000)
#xlat_expr %{Framed-IP-Address} + 4
#match (%{Framed-IP-Address} + 0.0.0.4)
match (1 < 4)
xlat_expr &Service-Type == Framed-User
-match (%{Service-Type} == Framed-User)
+match (&Service-Type == Framed-User)
-#xlat_expr 1 + (&Service-Type == Framed-User)
-#match (1 + (%{Service-Type} == Framed-User))
+xlat_expr 1 + (&Service-Type == Framed-User)
+match (1 + (&Service-Type == Framed-User))
#
# Strings of various forms
#
xlat_expr &Filter-Id == "foo"
-match (%{Filter-Id} == "foo")
+match (&Filter-Id == "foo")
xlat_expr "foo" == "bar"
match ("foo" == "bar")
# note '/' is a prefix, not "divide by 24".
# and a useless cast is removed
xlat_expr &Framed-IP-Address < (ipv4prefix) 192.168.0.0/24
-match (%{Framed-IP-Address} < 192.168.0.0/24)
+match (&Framed-IP-Address < 192.168.0.0/24)
xlat_expr &Framed-IP-Address < (ipv4prefix) 192.168.0.0
-match (%{Framed-IP-Address} < 192.168.0.0/32)
+match (&Framed-IP-Address < 192.168.0.0/32)
#
# For IP addresses, the other side is automatically upcast to a prefix
#
xlat_expr &Framed-IP-Address < 192.168.0.0/24
-match (%{Framed-IP-Address} < 192.168.0.0/24)
+match (&Framed-IP-Address < 192.168.0.0/24)
# same as above, but swap the order
xlat_expr (ipv4prefix) 192.168.0.0/24 > &Framed-IP-Address
-match (192.168.0.0/24 > %{Framed-IP-Address})
+match (192.168.0.0/24 > &Framed-IP-Address)
#
# Logical && and ||
# Other stuff
#
xlat_expr &Filter-Id
-match %{Filter-Id}
+match &Filter-Id
xlat_expr %{md5:foo} + "foo"
match (%{md5:foo} + "foo")
count
-match 57
+match 59
match 25
xlat_purify &NAS-Port + 5
-match (%{NAS-Port} + 5)
+match (&NAS-Port + 5)
xlat_purify &Framed-IP-Address & 0xffff0000
-match (%{Framed-IP-Address} & 0xffff0000)
+match (&Framed-IP-Address & 0xffff0000)
#
# Can't parse or cast RHS to nothing.
#
xlat_purify &Framed-IP-Address + 4
-match (%{Framed-IP-Address} + 4)
+match (&Framed-IP-Address + 4)
xlat_purify 1 < 4
match yes
# * the tokenizer needs to track offsets, so it can return the offset which cause the error.
#
xlat_purify &Service-Type == Framed-User
-match (%{Service-Type} == Framed-User)
+match (&Service-Type == Framed-User)
#xlat_purify 1 + (&Service-Type == Framed-User)
-#match (1 + (%{Service-Type} == Framed-User))
+#match (1 + (&Service-Type == Framed-User))
#
# Strings of various forms
#
xlat_purify &Filter-Id == "foo"
-match (%{Filter-Id} == "foo")
+match (&Filter-Id == "foo")
xlat_purify "foo" == "bar"
match no
# note '/' is a prefix, not "divide by 24".
# and a useless cast is removed
xlat_purify &Framed-IP-Address < (ipv4prefix) 192.168.0.0/24
-match (%{Framed-IP-Address} < 192.168.0.0/24)
+match (&Framed-IP-Address < 192.168.0.0/24)
xlat_purify &Framed-IP-Address < (ipv4prefix) 192.168.0.0
-match (%{Framed-IP-Address} < 192.168.0.0/32)
+match (&Framed-IP-Address < 192.168.0.0/32)
#
# For IP addresses, the other side is automatically upcast to a prefix
#
xlat_purify &Framed-IP-Address < 192.168.0.0/24
-match (%{Framed-IP-Address} < 192.168.0.0/24)
+match (&Framed-IP-Address < 192.168.0.0/24)
# same as above, but swap the order
xlat_purify (ipv4prefix) 192.168.0.0/24 > &Framed-IP-Address
-match (192.168.0.0/24 > %{Framed-IP-Address})
+match (192.168.0.0/24 > &Framed-IP-Address)
#
# Logical && and ||
match yes
xlat_purify &Filter-Id
-match %{Filter-Id}
+match &Filter-Id
xlat_purify %{md5:foo} + "bar"
match 0xacbd18db4cc2f85cedef654fccc4a4d8626172
match yes
xlat_purify &Service-Type == 1
-match (%{Service-Type} == 1)
+match (&Service-Type == 1)
#
# Convert the RHS to a simpler version
#
xlat_purify &Service-Type == (1 + 2)
-match (%{Service-Type} == 3)
+match (&Service-Type == 3)
-#
-# This is so wrong...
-#
-#xlat_purify &Reply-Message == "foo"
-#match ERROR offset 1: Failed resolving attribute in expansion: Message
+xlat_purify &Reply-Message == "foo"
+match (&Reply-Message == "foo")
#
# Strings are single quoted
#
xlat_purify &Filter-Id == ("foo" + "bar")
-match (%{Filter-Id} == 'foobar')
+match (&Filter-Id == 'foobar')
xlat_purify !&User-Name
-match !%{User-Name}
+match !&User-Name
xlat_purify (1 < 2)
match yes
match no
count
-match 67
+match 69