Functions
You can use pre-defined functions in message manipulations for special operations such as changing a returned value from lower case to upper case (see example below).
Functions can be used in fields where manipulation terms are read-only:
■ | Message Manipulations: 'Condition' and 'Action Value' fields |
■ | Pre-Parsing Message Manipulation Set: "Replace-With" manipulation term |
■ | Call Setup Rules: 'Request Key', 'Condition', and 'Action Value' fields |
Syntax:
Func.<FunctionName>(<Message Manipulation Term>)
The following table describes the supported functions.
Function Descriptions
Function |
Description |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Encrypt |
Encrypts the value of the specified SIP header, using AES-256 encryption key algorithm. The key is configured using the [EncryptKeyAES256] parameter. Note: This function is intended for SIP headers that are not used by the device for classification or routing. For example, you may want to encrypt the value of a proprietary SIP header called "P-Access-Network-Info" that may contain sensitive information. |
||||||||||||||||||
Decrypt |
Decrypts the AES-256 encrypted value of the specified SIP header. The key is configured using the [EncryptKeyAES256] parameter. Note: This function is intended for SIP headers that are not used by the device for classification or routing. For example, you may want to encrypt the value of a proprietary SIP header called "P-Access-Network-Info" that may contain sensitive information. |
||||||||||||||||||
Decrement |
If the message manipulation term is evaluated to be integer x, the function returns x – 1. If the term is evaluated to be a non-integer, no action is done. |
||||||||||||||||||
Increment |
If a message manipulation term is evaluated to be integer x, the function returns x + 1. If the term is evaluated to be a non-integer, no action is done. |
||||||||||||||||||
Length |
Returns the length of the evaluated message manipulation term string. |
||||||||||||||||||
To-Lower |
Changes characters in the evaluated message manipulation term to lowercase. |
||||||||||||||||||
To-Upper |
Changes characters in the evaluated message manipulation term to uppercase. |
||||||||||||||||||
URL-Decode |
Decodes evaluated Message Manipulation term characters according to RFC 3986 Section 2. Translates each encoded character in the string to the character itself. Example: ‘User%40audiocodes.com’ is decoded to ‘User@audiocodes.com’. |
||||||||||||||||||
URL-Encode |
Encodes evaluated message manipulation term characters according to RFC 3986 Section 2. It replaces reserved characters in a string with their hexadecimal representation (preceded by "%"). All characters are encoded except the following (considered unreserved):
For example, "user@abc.com" is encoded to "user%40abc.com". |
||||||||||||||||||
UUID-Generate |
Generates a random Universally Unique Identifier (UUID) value. |
Currently, concatenated message manipulation terms inside the function's parentheses is not supported. For example, the following is not supported: Func.To-Upper(header.form.url.user + ‘@’ + header.to.url.host). However, for fields supporting concatenation, you can concatenate the function as shown in the following example:
Func.To-Upper(header.form.url.user) + ‘@’ + Func.To-Upper(header.to.url.host)
Examples:
■ | The following Message Manipulation rule encrypts the value of the header "My-Identifier" in the outgoing SIP INVITE message: |
Message Type |
Condition |
Action Subject |
Action Type |
Action Value |
---|---|---|---|---|
invite.request |
- |
Header.My-Identifier |
Modify |
Func.Encrypt(Header.My-Identifier) |
■ | The following Message Manipulation rule adds the header "My-Host" to the outgoing SIP message, whose value is set to the source host, which is converted into upper case letters, using the function To-Upper: |
Message Type |
Condition |
Action Subject |
Action Type |
Action Value |
---|---|---|---|---|
invite.request |
- |
Header.My-Host |
Add |
Func.To-Upper(Param.Call.Src.Host) |
If the above rule is used and the host part in the From header of the SIP message is "JohnB":
From: <SIP:1000@JohnB>; tag-1c1000228485
After manipulation, the following header with the host value in upper case ("JOHNB") is added to the outgoing message:
From: <SIP:1000@JohnB>; tag-1c1000228485 My-Host: JOHNB
■ | The following Call Setup rule performs an ENUM query on an ENUM server for the source user and if found, it returns a string from the URL that is defined by regex (the string after "us-ascii,"), and then converts encoded characters in the string and adds it as the name in the From header. |
Request Type |
Request Key |
Condition |
Action Subject |
Action Type |
Action Value |
---|---|---|---|---|---|
Enum |
Param.Call.Src.User |
Enum.Found Exists AND Enum.Result.Url regex 'us-ascii,(.*)' |
Header.From.Name |
Modify |
Func.URL-Decode($1) |
If the above rule is used and the returned URL from the ENUM query is:
: pstndata:cnam/7039532959;;charset=us-ascii,John%20Bow
The rule then extracts and decodes " John%20Bow" to "John Bow" and adds it to the From header:
From: "John Bow" <sip:+61424795803@abc.rob.com.au>;tag=1c1474248679
■ | The following Message Manipulation rule adds the header "My-Identifier" to the outgoing SIP message, whose value is a randomly generated UUID, using the function UUID-Generate: |
Message Type |
Condition |
Action Subject |
Action Type |
Action Value |
---|---|---|---|---|
invite.request |
- |
Header.My-Identifier |
Add |
Func.UUID-Generate |