Syntax of recording filter condition
Syntax
Condition of recording filter has following syntax:
[ NOT ] EXPRESSION [ AND | OR ] [ ( ] EXPRESSION [ ) ] ...
Where, EXPRESSION is:
CALL-PARAMETER [ = | > | >= | < | <= | <> | != | LIKE | RLIKE ] [ VALUE | CALL-PARAMETER ]
- CALL-PARAMETER is a call parameter, like caller-ip, caller-number, duration etc.
- VALUE is a literal value, to which a call parameter is compared, for example, 1234, "Jonh Smith" etc.
- \=, >, >=, <, <=, <>, !=, LIKE and RLIKE are comparison operators.
Examples of recording filter condition:
caller-ip = 192.168.0.1
caller-number = 1234 OR caller-number = 5678
caller-ip = 10.0.0.0/24 AND NOT callee-ip = 192.168.1.2
(caller-number = 100 OR caller-number = 200) AND callee-number <> 300
caller-number LIKE '011%'
caller-number RLIKE '^011(22|34).*$'
Call parameters
The following table lists all supported call parameters.
| Call parameter | Description |
|---|---|
caller-ip callee-ip |
IP-address of caller/callee Formats:
where:
Examples: |
caller-port callee-port |
IP port Examples: |
caller-mac callee-mac |
MAC-address. Format: XX-XX-XX-XX-XX-XX Examples: |
caller-number callee-number |
Phone number Examples: |
caller-name callee-name |
Name of phone. The value of this parameter depends on voip signaling protocol (SIP, H.323, Skinny etc). Examples: |
caller-id callee-id |
Id of phone. The value of this parameter depends on voip signaling protocol (SIP, H.323, Skinny etc). Examples: |
agent-id agent-name |
Id and Name of Agent. These parameters are available only when Avaya TSAPI integration is enabled. Examples: |
transfer-from-number transfer-from-name transfer-from-id |
Number, name and id of phone, from which the call was transferred. The value of this parameter depends on voip signaling protocol (SIP, H.323, Skinny etc). Examples: |
transfer-to-number transfer-to-name transfer-to-id |
Number, name and id of phone, to which the call was transferred. The value of this parameter depends on voip signaling protocol (SIP, H.323, Skinny etc). Examples: |
| setup-time | Date/time when call was started Format: YYYY-mm-DD HH:MM:SS Where:
Example: |
| voip-protocol | Voip protocol of the call. It is a numeric value, one of:
Example: |
| sip-header-invite | Value of specific SIP header inside INVITE message. The name of header is specified after hash (#) symbol. Examples: |
Call parameters can be compared to literal values or to other call parameters, like:
caller-ip = 10.0.0.1
caller-port = callee-port
Literal values
Literal values are contacts, which are compared to call parameters.
Example:
caller-number = '123456789'
In above example a literal value '123456789' is compared to call parameter caller-number.
If a literal value contains space characters, then it should be enclosed into single (') or double (") quotes. For example:
caller-number = 123456789 <-- OK
caller-number = '123456789' <-- OK
caller-name = "John Smith" <-- OK
caller-name = John Smith <-- Not valid
If a literal value itself contains a quote character, for example, d’Arnaud, then use following rules:
-
If a literal value contains either a single or double quote character, but not both at the same time, then enclose the value into different quotes, like:
caller-name = "d'Arnaud" caller-name = 'Using double quotes charcter (")' -
If a literal value contains both single and double quote characters, precede them with a special escape character ‘\’, like:
caller-name = 'd\'Arnaud' caller-name = "Using double quotes charcter (\")" -
If a literal value contains escape character '\', you must double it, like:
caller-name = "Sample \\ name"
Comparison operators (=, >, < etc)
The following table lists all supported comparison operators.
| Operator | Description | Examples |
|---|---|---|
= == |
Equal to | |
<> != |
Not equal to | |
| > | Greater than | |
| < | Less than | |
| >= | Greaten than or equal to | |
| <= | Less than or equal to | |
| LIKE | Simple pattern matching | |
| NOT LIKE | Negation of simple pattern matching | |
| RLIKE | Pattern matching using regular expressions (REGEX) | |
| NOT RLIKE | Negation of Pattern matching using regular expressions (REGEX) | |
Logical opertors (AND, OR, NOT)
Complex expessions can be created with the help of logical operators (AND, OR, NOT etc).
| Operator | Description | Examples |
|---|---|---|
AND && |
Logical AND | |
NOT ! |
Negates value | |
OR |
Prentheses "(" and ")" are supported inside expressions, like:
caller-ip=192.168.0.1 AND ( callee-ip = 10.0.0.1/24 OR callee-ip = 80.25.23.10 )
Simple pattern matching (LIKE)
Pattern matching comparison supports following wildcard characters:
| Character | Description |
|---|---|
| % | Matches any number of characters, even zero characters Examples:
|
| _ | Matches exactly one character Examples:
|
To test for literal instances of a wildcard character, precede it by the escape character '\'.
| String | Description |
|---|---|
| \% | Matches exactly one '%' character
|
| \_ | Matches exactly one '' character
|
| \\ | Matches exactly one '\' character
|
Regular expressions pattern matching (RLIKE)
A regular expression is a powerful way of specifying a pattern for a complex search.
Examples:
callee-number RLIKE '^011(22|34).*$'
... will match any call, which was made to phone number starting either with 01122 or 01134
caller-ip NOT RLIKE '^192\.168\.(0|1)\..*$'
... will match any call, which was originated from IP 192.168.0.* or 192.168.1.*
MiaRec uses Henry Spencer's implementation of regular expressions, which is aimed at conformance with POSIX 1003.2.
Metacharacters
A regular expression for the RLIKE operator may use any of the following metacharacters and constructs:
| Metacharacter | Description |
|---|---|
| . | Matches any single character. For example:
|
| [ ] | A bracket expression. Matches a single character that is contained within the brackets. For example:
A '-' character between two other characters forms a range that matches all characters from the first character to the second. For example:
These forms can be mixed:
To include a literal '-' character, it must be written first or last, for example, [abc-], [-abc]. To include a literal ] character, it must immediately follow the opening bracket [, for example, []abc]. |
| [^ ] | Matches a single character that is not contained within the brackets. For example:
As above, literal characters and ranges can be mixed, like [^abcx-z] |
| * | Matches the preceding element zero or more times. For example:
|
| ( )* | Matches zero of more instances of the characters sequence, specified inside parentheses. For example:
|
| + | Matches the preceding element one or more times. For example:
|
| ? | Matches the preceding element zero or one time. For example:
|
| | | The choice (aka alternation or set union) operator matches either the expression before or the expression after the operator. For example:
|
| {n} | Matches the preceding element exactly n times. For example:
|
| {m, n} | Matches the preceding element at least m and not more than n times. For example:
|
| {m, } | Matches the preceding element at least m times. For example:
|
| ^ | Matches the beginning of a string. For example:
|
| $ | Matches the end of a string. For example:
|
| \ | Backslash () character is used for escaping metacharacters. For example:
|
POSIX character classes
The POSIX standard defines some classes or categories as shown in the following table
| POSIX character class | ASCII equivalent | Description |
|---|---|---|
| [:alnum:] | [A-Za-z0-9] |
Alphanumeric characters |
| [:alpha:] | [A-Za-z] |
Alphabetic characters |
| [:blank:] | [ \t] |
Space and tab |
| [:cntrl:] | [\x00-\x1F\x7F] |
Control characters |
| [:digit:] | [0-9] |
Digits |
| [:graph:] | [\x21-\x7E] |
Visible characters |
| [:lower:] | [a-z] |
Lowercase letters |
| [:print:] | [\x20-\x7E] |
Visible characters and spaces |
| [:punct:] | []\[!"#$%&'()\*+,./:;<=>?@\\^\_\``{\|}\~-] |
Punctuation characters |
| [:space:] | [ \t\r\n\v\f] |
Whitespace characters |
| [:upper:] | [A-Z] |
Uppercase letters |
| [:xdigit:] | [A-Fa-f0-9] |
Hexadecimal digits |
POSIX character classes can only be used within bracket expressions ([ ]). For example:
[[:upper:]ab]
... will match the uppercase letters and lowercase "a" and "b".
Testing REGEX
Writing a correct REGEX expression may be a challenging task. We recommend to use a special site for testing RLIKE expressions for any syntax errors.