include::../img/header.adoc[]
-# Pre-defined Expansions
+== Pre-defined Expansions
In addition to storing attribute references, the server has a number
of pre-defined references, as follows:
-### - `%{base64:<string>}`
+## - `%{base64:<string>}`
Encode a string using Base64.
The base64 of foo is Q2FpcGlyaW5oYQ==
```
-### - `%{base64decode:<string>}`
+## - `%{base64decode:<string>}`
Decode a string previously encoded using Base64.
The base64decode of Q2FpcGlyaW5oYQ== is Caipirinha
```
-### - `%{bin:<string>}`
+## - `%{bin:<string>}`
Convert string to binary.
The 10 in binary is \020
```
-### - `%{config:<key>}`
+## - `%{config:<key>}`
Refers to a variable in the configuration file. See the documentation
on configuration file references.
Module rlm_exec.shell_escape = yes
```
-### - `%{client:<key>}`
+## - `%{client:<key>}`
Refers to a variable that was defined in the client section for the
current client. See the sections `client { ... }` in `clients.conf`.
The client ipaddr is 192.168.5.9
```
-### - `%{concat:<delim> <&ref:[idx]>}`
+## - `%{concat:<delim> <&ref:[idx]>}`
Used to join two or more attributes.
aaa,bb,c
```
-### - `%{debug:<level>}`
+## - `%{debug:<level>}`
Dynamically change the debug level to something high, recording the old level.
...
```
-### - `%{debug_attr:<list:[index]>}`
+## - `%{debug_attr:<list:[index]>}`
Print to debug output all instances of current attribute, or all attributes in a list.
expands to a zero-length string.
...
```
-### - `%{explode:<&ref> <delim>}`
+## - `%{explode:<&ref> <delim>}`
Split an attribute into multiple new attributes based on a delimiter.
Welcome bob.toba
```
-### - `%{hex:<string>}`
+## - `%{hex:<string>}`
Convert to hex.
The value of 12345 in hex is 3132333435
```
-### - `%{integer:<&ref>}`
+## - `%{integer:<&ref>}`
Print the value of the attribute an integer. In normal operation,
`integer` attributes are printed using the name given by a `VALUE`
The value of Framed-User is 1
```
-### - `%{length:<string>}`
+## - `%{length:<string>}`
The string length operator returns the number of characters in the
given string as a decimal number. It can be used with attribute or
The lenght of Caipirinha is 10
```
-### - `%{md5:<string>}` +
+## - `%{md5:<string>}` +
Dynamically expands the string and performs an MD5 hash on it. The
result is octal digits.
md5 of Caipirinha is hex=14840b6d647c7c98a3e732f833d86ea9
```
-### - `%{nexttime:<time>}`
+## - `%{nexttime:<time>}`
Calculate number of seconds until next n hour(`s`), day(`s`), week(`s`), year(`s`).
You should wait for 2520s
```
-### - `%{lpad:<&ref> <val> <char>}`
+## - `%{lpad:<&ref> <val> <char>}`
Left-pad a string.
Maximum should be 00000000123
```
-### - `%{rpad:<&ref> <val> <char>}`
+## - `%{rpad:<&ref> <val> <char>}`
Right-pad a string.
Maximum should be 12300000000
```
-### - `%{hmacmd5:<shared_key> <string>}`
+## - `%{hmacmd5:<shared_key> <string>}`
Generate `HMAC-MD5` of string.
The HMAC-MD5 of Caipirinha in hex is 636f6e74726f6c3a546d702d4f63746574732d30
```
-### - `%{hmacsha1:<shared_key> <string>}`
+## - `%{hmacsha1:<shared_key> <string>}`
Generate `HMAC-SHA1` of string.
The HMAC-SHA1 of Caipirinha in hex is 636f6e74726f6c3a546d702d4f63746574732d30
```
-### - `%{pairs:<&list:[*]>}`
+## - `%{pairs:<&list:[*]>}`
Serialize attributes as comma-delimited string.
Serialize output: Tmp-String-0 = \"This is a string\"Tmp-String-0 = \"This is another one\"
```
-### - `%{rand:<number>}`
+## - `%{rand:<number>}`
Get random number from `0` to `n-1`.
The random number is 347
```
-### - `%{randstr:<character_classes>}`
+## - `%{randstr:<character_classes>}`
Get random string built from character classes.
The random string output is 4Uq0gPyG
```
-### - `%{regex:<capture_group>}`
+## - `%{regex:<capture_group>}`
Return named subcapture value from previous regex.
The user@example.com { login=user, domain=example.com }
```
-### - `%{strlen:<string>}`
+## - `%{strlen:<string>}`
Length of given string.
The lenght of Caipirinha is 21
```
-### - `%{tag:<attribute:<tag>>}`
+## - `%{tag:<attribute:<tag>>}`
Tag of an attribute reference.
The tag 1 of Tunnel-Server-Endpoint is 192.0.5.2
```
-### - `%{tolower:<string>}`
+## - `%{tolower:<string>}`
Dynamically expands the string and returns the lowercase version of
it. This definition is only available in version 2.1.10 and later.
```unlang
tolower of CAIPIRINHA is caipirinha
```
-### - `%{toupper:<string>}`
+## - `%{toupper:<string>}`
Dynamically expands the string and returns the uppercase version of
it. This definition is only available in version 2.1.10 and later.
toupper of caipirinha is CAIPIRINHA
```
-### - `%{urlquote:<string>}`
+## - `%{urlquote:<string>}`
Quote URL special characters.
The urlquote of http://example.org/ is http%3A%2F%2Fexample.org%2F
```
-### - `%{urlunquote:<string>}`
+## - `%{urlunquote:<string>}`
Unquote URL special characters.
The urlunquote of http%3A%2F%2Fexample.org%2F is http://example.org/
```
-.Result: _string_.
+== Encryption functions
-Example
-
-# Encryption functions
-
-### `OpenSSL >= 1.0.0`
+## `OpenSSL >= 1.0.0`
Should support at least:
- `%{sha384:<string>}`
- `%{sha512:<string>}`
-### `OpenSSL >= 1.1.1`
+## `OpenSSL >= 1.1.1`
Also supports the `sha3` and `blake` family of digest functions.
- `%{sha3_384:<string>}`
- `%{sha3_512:<string>}`
-### Example
+## Example
.Return: _octal_
The md5 of Caipirinha in hex is 14840b6d647c7c98a3e732f833d86ea9
```
-# Miscellaneous
+== Miscellaneous
-### - `%{0}`
+## - `%{0}`
Refers to the string that was last used to match a regular expression. The variables `%{1}` through `%{8}` refer to the matched substring in the regular expression.
-### - `%{Packet-Type}`
+## - `%{Packet-Type}`
The packet type (`Access-Request`, etc.)
-### - `%{Packet-SRC-IP-Address}`, `%{Packet-SRC-IPv6-Address}`
+## - `%{Packet-SRC-IP-Address}`, `%{Packet-SRC-IPv6-Address}`
The source IPv4 or IPv6 address of the packet. See also the expansions
`%{client:ipaddr}` and `%{client:ipv6addr}`. The two expansions
should be identical, unless `%{client:ipaddr}` contains a DNS hostname.
-### - `%{Packet-DST-IP-Address}`, `%{Packet-DST-IPv6-Address}`
+## - `%{Packet-DST-IP-Address}`, `%{Packet-DST-IPv6-Address}`
The destination IPv4 or IPv6 address of the packet. See also the
expansions `%{listen:ipaddr}` and `%{listen:ipv6addr}`. If the socket
address and `%{Packet-DST-IP-Address}` will be the unicast address to
which the packet was sent.
-### - `%{Packet-SRC-Port}`, `%{Packet-DST-Port}`
+## - `%{Packet-SRC-Port}`, `%{Packet-DST-Port}`
The source/destination ports associated with the packet.