proto-dictionary radius

xlat_expr 3 + 4
match (3 + 4)

xlat_expr 3 * 4
match (3 * 4)

xlat_expr 2 + 3 * 4
match (2 + (3 * 4))

xlat_expr 2 + 3 * 4 + 5
match ((2 + (3 * 4)) + 5)

#  Same as above with brackets
xlat_expr 2 + (3 * 4) + 5
match ((2 + (3 * 4)) + 5)

# not the same
xlat_expr (2 + 3) * (4 + 5)
match ((2 + 3) * (4 + 5))

xlat_expr (2 + 3) * 4 + 5
match (((2 + 3) * 4) + 5)

xlat_expr &NAS-Port + 5
match (&NAS-Port + 5)

xlat_expr &Framed-IP-Address & 0xffff0000
match (&Framed-IP-Address & 0xffff0000)

#xlat_expr %{Framed-IP-Address} + 4
#match (%{Framed-IP-Address} + 0.0.0.4)

xlat_expr 1 < 4
match (1 < 4)

xlat_expr &Service-Type == Framed-User
match (&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")

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)

xlat_expr &Framed-IP-Address < (ipv4prefix) 192.168.0.0
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)

#  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)

#
#  Logical && and ||
#
xlat_expr 1 < 2 || 4 > 3
match ((1 < 2) || (4 > 3))

#
#  Peephole optimization for some cases
#
xlat_expr 2 || (1 > 4)
match 2

#
#  Repeated operations of the same type are mashed together into one list.
#  This only happens where the operations are associative.
#
xlat_expr 1 < 2 || 4 > 3 || 4 == 4 || 1 < 2
match ((1 < 2) || (4 > 3) || (4 == 4) || (1 < 2))

#
#  Other stuff
#
xlat_expr &Filter-Id
match &Filter-Id

xlat_expr %md5('foo') + "foo"
match  (%md5('foo') + "foo")

#  We can name the xlat's, tho we don't need to
xlat_expr %op_add(4, 3) + 6
match ((4 + 3) + 6)


#
#  useless casts are omitted.
#
xlat_expr 1 < (uint32) 2
match (1 < 2)

xlat_expr 1 < 2 < 3
match ((1 < 2) < 3)

xlat_expr (uint32) %concat(1, 2)
match (uint32)%concat(1, 2)

#
# Mashing multiple brackets together.  The brackets are removed as
# part of the parsing step, because no intermediate nodes are created for them.
#
xlat_expr (((1 + 2)))
match (1 + 2)

xlat_expr (((1 + 2)) * ((3 + 4)))
match ((1 + 2) * (3 + 4))

#xlat_expr &Filter-Id =~ /foo/
#match bar

xlat_expr &reply
match &reply

xlat_expr &reply && (1 < 2)
match (&reply && (1 < 2))

xlat_expr 5 + 5 - 10
match ((5 + 5) - 10)

xlat_expr (integer) &Service-Type
match (uint32)&Service-Type

#
#  Wrapping the RHS in brackets means that the parse doesn't hoist
#  things, and thus can't add the cast to the tmpl.
#
xlat_expr (uint32) (&Service-Type)
match %cast(uint32, &Service-Type)

count
match 69
