-#
-# PRE: update
-#
-update request {
- &Vendor-Specific.3GPP.IMSI := "hello"
-}
+&request.Vendor-Specific.3GPP.IMSI := "hello"
#
# "request.[0-9]" should be parsed as a list followed
# by an attribute.
#
-update control {
- &Tmp-String-0 := &Vendor-Specific.3GPP.IMSI
- &Tmp-String-1 := &request.Vendor-Specific.3GPP.IMSI
-}
+&control.Tmp-String-0 := &Vendor-Specific.3GPP.IMSI
+&control.Tmp-String-1 := &request.Vendor-Specific.3GPP.IMSI
success
#
-# PRE: update if
+# PRE: if
#
# Use pre-defined date and time
-update request {
- &Tmp-Integer-0 := 1506101100;
-}
+&Tmp-Integer-0 := 1506101100
# Convert to string representation
-update request {
- &Tmp-String-0 := "%(date:%{Tmp-Integer-0})"
-}
+&Tmp-String-0 := %(date:%{Tmp-Integer-0})
# Some systems report GMT some UTC...
if (&Tmp-String-0 != "Fri 22 Sep 17:25:00 GMT 2017") && (&Tmp-String-0 != "Fri 22 Sep 17:25:00 UTC 2017") {
}
# Convert string to integer
-update request {
- &Tmp-Integer-1 := %(integer:%(date:%{Tmp-String-0}))
-}
+&Tmp-Integer-1 := %(integer:%(date:%{Tmp-String-0}))
if (&Tmp-Integer-1 != &Tmp-Integer-0) {
test_fail
}
# Compare two methods of reading request timestamp in local timezone
-update request {
- &Tmp-String-0 := "%(localdate:request)"
- &Tmp-String-1 := "%S"
-}
+&Tmp-String-0 := %(localdate:request)
+&Tmp-String-1 := "%S"
if (&Tmp-String-0 != &Tmp-String-1) {
test_fail
}
# Convert different string format
-update request {
- &Tmp-String-2 := "2017-09-22 17:25:00"
-}
+&Tmp-String-2 := "2017-09-22 17:25:00"
-update request {
- &Tmp-Integer-2 := %(integer:%(sqldate:%{Tmp-String-2}))
-}
+&Tmp-Integer-2 := %(integer:%(sqldate:%{Tmp-String-2}))
if (&Tmp-Integer-2 != &Tmp-Integer-0) {
test_fail
}
# Use a date attribute
-update request {
- &Tmp-Date-0 := 1659985459
-}
-
-update request {
- &Tmp-String-2 := "%(sqldate:%{Tmp-Date-0})"
-}
+&Tmp-Date-0 := 1659985459
+&Tmp-String-2 := "%(sqldate:%{Tmp-Date-0})"
if (&Tmp-String-2 != '2022-08-08 19:04:19') {
test_fail
}
# Invalid format
-update request {
- &Tmp-String-3 := '201-32-22 17:25:00'
-}
-
-update request {
- &Tmp-String-0 := "%(sqldate:%{Tmp-String-3})"
-}
+&Tmp-String-3 := '201-32-22 17:25:00'
+&Tmp-String-0 := "%(sqldate:%{Tmp-String-3})"
if (&Tmp-String-0 != "") {
test_fail
test_fail
}
-update request {
- &NAS-IP-Address := "192.168.1.1"
-}
-
# Invalid type
-update request {
- &Tmp-String-4 := "%(date:%{NAS-IP-Address})"
-}
+&NAS-IP-Address := "192.168.1.1"
+&Tmp-String-4 := %(date:%{NAS-IP-Address})
if (&Tmp-String-4 != "") {
test_fail
#
-# PRE: update if
+# PRE: if
#
-update request {
- &Tmp-Integer-0 := "%(debug:4)"
-}
+&Tmp-Integer-0 := "%(debug:4)"
# Check debug level is now 4
if ("%(debug:3)" != 4) {
#
-# PRE: update if-empty-allow
+# PRE: if-empty-allow
#
if (&User-Name == 'bob') {
#
-# PRE: update if
+# PRE: if
#
# "else" has to be preceded by an "if" or "elsif"
#
if (1) {
- update control {
- &Password.Cleartext := "fail"
- }
+ &control.Password.Cleartext := "fail"
else { # ERROR
ok
#
# PRE: update if xlat-attr-index
#
-update request {
- &Tmp-String-0 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /'
- &Tmp-String-1 := '±§#$%^&+={[}];<,>?`|"'
- &Tmp-String-2 := '™¥¤'
- &Tmp-String-3 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22'
- &Tmp-String-4 := '=E2=84=A2=C2=A5=C2=A4'
- &Tmp-String-5 := '=40=61=62=63=64=65=66=67'
-
- # Mixture of safe and unsafe chars
- &Tmp-String-6 := 'ŒČÿ'
- &Tmp-String-7 := 'Œ=C4=8Cÿ'
-
- # = not followed by hex and without 2 following chars
- &Tmp-String-8 := 'a=Az=y'
-}
+&Tmp-String-0 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /'
+&Tmp-String-1 := '±§#$%^&+={[}];<,>?`|"'
+&Tmp-String-2 := '™¥¤'
+&Tmp-String-3 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22'
+&Tmp-String-4 := '=E2=84=A2=C2=A5=C2=A4'
+&Tmp-String-5 := '=40=61=62=63=64=65=66=67'
+
+# Mixture of safe and unsafe chars
+&Tmp-String-6 := 'ŒČÿ'
+&Tmp-String-7 := 'Œ=C4=8Cÿ'
+
+# = not followed by hex and without 2 following chars
+&Tmp-String-8 := 'a=Az=y'
if (<string>"%{escape:%{Tmp-String-0}}" != &Tmp-String-0) {
test_fail
#
-# PRE: update if
+# PRE: if
#
#
#
# attribute references
#
-update request {
- &Tmp-Integer-0 = 1
- &Tmp-Integer-1 = 3
- &Tmp-Integer-2 = 4
- &Tmp-Date-0 = "%l"
-}
+&Tmp-Integer-0 := 1
+&Tmp-Integer-1 := 3
+&Tmp-Integer-2 := 4
+&Tmp-Date-0 := "%l"
if ("%{expr: 1 + 2 * &Tmp-Integer-1 + 4}" != 11) {
test_fail
}
+
if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + 4)}" != 15) {
test_fail
}
-update {
- &request.Packet-Type !* ANY
-}
+&request -= &Packet-Type
foreach &Filter-Id {
- update reply {
- &Called-Station-Id += "%{Foreach-Variable-0}"
- }
+ &Called-Station-Id += "%{Foreach-Variable-0}"
}
#
-# PRE: update
+# PRE: if
#
-update request {
- &Tmp-String-0 := '9870'
- &Tmp-Octets-0 := 0x39383731
- &Tmp-IP-Address-0 := 57.56.55.50
- &Tmp-Integer-0 := 959985460
- &Tmp-Cast-IfId := '0000:0000:3938:3737'
- &Tmp-Cast-IPv6Addr := '::3938:3738'
- &Tmp-Cast-IPv6Prefix := '::3938:3739/128'
- &Tmp-Cast-Byte := 58
- &Tmp-Cast-Short := 14139
- &Tmp-Cast-Ether := 00:00:39:38:37:3c
- &Tmp-Cast-Integer64 := 1152921505566832445
- &Tmp-Cast-IPv4Prefix := 57.56.55.62/32
-}
-
-update request {
- &Tmp-String-0 := "%{hex:%{Tmp-String-0}}"
- &Tmp-String-1 := "%{hex:%{Tmp-Octets-0}}"
- &Tmp-String-2 := "%{hex:%{Tmp-IP-Address-0}}"
- &Tmp-String-4 := "%{hex:%{Tmp-Integer-0}}"
- &Tmp-String-6 := "%{hex:%{Tmp-Cast-Ifid}}"
- &Tmp-String-7 := "%{hex:%{Tmp-Cast-IPv6Addr}}"
- &Tmp-String-8 := "%{hex:%{Tmp-Cast-IPv6Prefix}}"
- &Tmp-String-9 := "%{hex:%{Tmp-Cast-Byte}}"
+&request <= {
+ &Tmp-String-0 = '9870'
+ &Tmp-Octets-0 = 0x39383731
+ &Tmp-IP-Address-0 = 57.56.55.50
+ &Tmp-Integer-0 = 959985460
+ &Tmp-Cast-IfId = '0000:0000:3938:3737'
+ &Tmp-Cast-IPv6Addr = '::3938:3738'
+ &Tmp-Cast-IPv6Prefix = '::3938:3739/128'
+ &Tmp-Cast-Byte = 58
+ &Tmp-Cast-Short = 14139
+ &Tmp-Cast-Ether = 00:00:39:38:37:3c
+ &Tmp-Cast-Integer64 = 1152921505566832445
+ &Tmp-Cast-IPv4Prefix = 57.56.55.62/32
+}
+
+ok # break up edit sections
+
+&request <= {
+ &Tmp-String-0 = "%{hex:%{Tmp-String-0}}"
+ &Tmp-String-1 = "%{hex:%{Tmp-Octets-0}}"
+ &Tmp-String-2 = "%{hex:%{Tmp-IP-Address-0}}"
+ &Tmp-String-4 = "%{hex:%{Tmp-Integer-0}}"
+ &Tmp-String-6 = "%{hex:%{Tmp-Cast-Ifid}}"
+ &Tmp-String-7 = "%{hex:%{Tmp-Cast-IPv6Addr}}"
+ &Tmp-String-8 = "%{hex:%{Tmp-Cast-IPv6Prefix}}"
+ &Tmp-String-9 = "%{hex:%{Tmp-Cast-Byte}}"
}
# String
test_fail
}
-update request {
- &Tmp-String-0 := "%{hex:%{Tmp-Cast-Short}}"
- &Tmp-String-1 := "%{hex:%{Tmp-Cast-Ether}}"
- &Tmp-String-2 := "%{hex:%{Tmp-Cast-Integer64}}"
- &Tmp-String-3 := "%{hex:%{Tmp-Cast-IPv4Prefix}}"
- &Tmp-String-4 := "%{hex:%{Tmp-Octets-9}}"
+&request <= {
+ &Tmp-String-0 = "%{hex:%{Tmp-Cast-Short}}"
+ &Tmp-String-1 = "%{hex:%{Tmp-Cast-Ether}}"
+ &Tmp-String-2 = "%{hex:%{Tmp-Cast-Integer64}}"
+ &Tmp-String-3 = "%{hex:%{Tmp-Cast-IPv4Prefix}}"
+ &Tmp-String-4 = "%{hex:%{Tmp-Octets-9}}"
}
# short