request via a `name`, or the parent request via `.name`. If there is
no parent, the expansion returns the string `<underflow>`.
-=== %interpeter(module)
+=== %interpeter('module')
The current module being executed. If the expansions is done in an
`unlang` statement and outside of any module, it returns the name of
the previous module which was executed.
-=== %interpeter(processing_stage)
+=== %interpeter('processing_stage')
Which section of a virtual server is processing the request.
-=== %interpeter(rcode)
+=== %interpeter('rcode')
The current interpreter return code, e.g. `handle`, or `ok`, etc.
-=== %interpeter(server)
+=== %interpeter('server')
The name of the virtual server which is running the request.
[source,unlang]
----
-"Server installed in %config(prefix)"
-"Module rlm_exec.shell_escape = %config(modules.exec.shell_escape)"
+"Server installed in %config('prefix')"
+"Module rlm_exec.shell_escape = %config('modules.exec.shell_escape')"
----
.Output
== String manipulation
-=== %concat(<&ref:[idx]> <delim>)
+=== %concat(<&ref:[idx]>, <delim>)
Used to join two or more attributes, separated by an optional delimiter.
}
&reply += {
- &Reply-Message = "%concat(%{control.Tmp-String-0[*]} ', ')"
- &Reply-Message = "%concat(%{control.Tmp-String-0[*]} ,)"
+ &Reply-Message = "%concat(%{control.Tmp-String-0[*]}, ', ')"
+ &Reply-Message = "%concat(%{control.Tmp-String-0[*]}, ',')"
}
----
----
-=== %explode(<&ref> <delim>)
+=== %explode(<&ref>, <delim>)
Split an string into multiple new strings based on a delimiter.
----
&control.Tmp-String-0 := "bob.toba@domain.com"
-&control.Tmp-String-1 := "%explode(&control.Tmp-String-0 @)"
+&control.Tmp-String-1 := "%explode(&control.Tmp-String-0, '@')"
&reply.Reply-Message := "Welcome %{control.Tmp-String-1[0]}"
----
Welcome bob.toba
```
-=== %lpad(<string> <val> <char>)
+=== %lpad(<string>, <val>, <char>)
Left-pad a string.
----
&control.Tmp-String-0 := "123"
-&reply.Reply-Message := "Maximum should be %lpad(%{control.Tmp-String-0} 11 0)"
+&reply.Reply-Message := "Maximum should be %lpad(%{control.Tmp-String-0}, 11, '0')"
----
.Output
Maximum should be 00000000123
```
-=== %rpad(<string> <val> <char>)
+=== %rpad(<string>, <val>, <char>)
Right-pad a string.
----
&control.Tmp-String-0 := "123"
-&reply.Reply-Message := "Maximum should be %rpad(%{control.Tmp-String-0} 11 0)"
+&reply.Reply-Message := "Maximum should be %rpad(%{control.Tmp-String-0}, 11, '0')"
----
.Output
The HMAC-MD5 of Caipirinha in hex is 636f6e74726f6c3a546d702d4f63746574732d30
```
-=== %hmacsha1(<shared_key> <string>)
+=== %hmacsha1(<shared_key>, <string>)
Generate `HMAC-SHA1` of string.
----
&control.Tmp-String-0 := "mykey"
&control.Tmp-String-1 := "Caipirinha"
-&control.Tmp-Octets-0 := "%hmacsha1(%{control.Tmp-String-0} %{control.Tmp-String-1})"
+&control.Tmp-Octets-0 := "%hmacsha1(%{control.Tmp-String-0}, %{control.Tmp-String-1})"
&reply += {
&Reply-Message = "The HMAC-SHA1 of %{control.Tmp-String-1} in octets is %{control.Tmp-Octets-0}"
The HMAC-SHA1 of Caipirinha in hex is 636f6e74726f6c3a546d702d4f63746574732d30
```
-=== %md5( ... }
+=== %md5( ... )
Dynamically expands the string and performs an MD5 hash on it. The
result is binary data.
You should wait for 2520s
```
-=== +%pack(%{Attribute-Name}%{Attribute-Name}...)+
-
-Pack multiple multiple attributes and/or literals into a binary string.
-For best results, each attribute passed to `pack` should be fixed size.
-That is, not data type `octets` or `string` as the length of those values
-will not be encoded.
-
-See also the `unpack` module, which is the inverse to `pack`.
-
-.Return: _octets_
-
-.Example
-
-[source,unlang]
-----
-&reply.Class := "%pack(%{reply.Framed-IP-Address}%{NAS-IP-Address}}"
-----
-
-.Output
-
-```
-You should wait for 2520s
-```
-
-### %sub(<subject> /<regex>/[flags] <replace>)
+### %sub(<subject>, /<regex>/[flags], <replace>)
Substitute text just as easily as it can match it, even using regex patterns.
[source,unlang]
----
&control.Tmp-String-0 := "Caipirinha is a light and refreshing drink!"
-&reply.Reply-Message := "%sub(%{control.Tmp-String-0} / / ,)"
+&reply.Reply-Message := "%sub(%{control.Tmp-String-0}, / /, ',')"
----
.Output
date tomorrow
time_delta time_of_day
- &now := %time(request)
+ &now := %time('request')
# We are this many seconds into one day
&time_of_day := &now % (time_delta) 1d
date tomorrow
time_delta time_of_day
- &now := %time(request)
+ &now := %time('request')
# We are this many seconds into one day
&time_of_day := &now % (time_delta) 1d
&tomorrow := &now - &time_of_day + (time_delta) 1d
# add in the time zone offset
- &tomorrow += %time(offset)
+ &tomorrow += %time('offset')
}
----
&reply.Reply-Message := "Value of Service-Type is %{(integer) &Service-Type}"
----
+=== +%pack(%{Attribute-Name}%{Attribute-Name}...)+
+
+Pack multiple multiple attributes and/or literals into a binary string.
+For best results, each attribute passed to `pack` should be fixed size.
+That is, not data type `octets` or `string` as the length of those values
+will not be encoded.
+
+See also the `unpack` module, which is the inverse to `pack`.
+
+.Return: _octets_
+
+.Example
+
+[source,unlang]
+----
+&reply.Class := "%pack(%{reply.Framed-IP-Address}%{NAS-IP-Address}}"
+----
+
+It is easier to just use casting and string append:
+
+.Better example
+
+[source,unlang]
+----
+&reply.Class := (octets) &Framed-IP-Address + (octets) &NAS-IP-Address.
+----
+
=== %string(...)
This expansion has been removed. Instead, just use `%{(string) ...}` with math inside of the brackets.