Set Matching Patterns
The Matching Patterns define conditions for applying the rule. Conditions can be defined using a pair of the following: the name of the SIP header, condition functions, system environment variables, source IP address, or the source port number, and the string pattern for matching. By defining multiple pairs, you can make the conditions more specific. Regular Expressions are used for defining string matching patterns. The string between parenthesis () in the right side can be referred to in Matching Patterns and Deploy Patterns.
To add a condition in the Matching Patterns section:
- Push […] button (which is between the Variable field and the Value field).
- Select a variable name from the pull-down list or type a variable name directly in the Variable field.
- Type a string pattern to the Value field and then, push the [+] button. Refer to the section “New Rule/ Edit Rule” for more information.
Matching Patterns Syntax:
SIP_header_name = string pattern &environment_variable_name = string pattern $condition_function_name = string pattern $condition_function_name( arguments ) = string pattern
Main regular expressions which can be used in Matching Pattern’s right side are as follows:
Symbols | Meaning |
! | If ‘!’ is placed in the front of the string pattern, it means NOT. |
^ | Match the beginning of the line |
$ | Match the end of the line |
[abc] | Match any character listed between brackets. In this case, a or b or c. |
[^abc] | Match any character except those listed between the brackets. In this case, any characters except a, b and c. |
. | Match any character except new line |
X+ | Match the preceding element (X, in this case) one or more times |
X* | Match the preceding element (X, in this case) zero or more times |
X{n} | Match the preceding element (X, in this case) n times |
Symbols | Meaning |
X{n,} | Match the preceding element (X, in this case) at least n times |
X{n,m} | Match the preceding element (X, in this case) at least n times, but no more than m times |
(chars) | The characters between the brackets will be put in a buffer. To refer to the n-th digit buffer in Deploy Pattern, use %<digit> (for example %1) |
SIP Header Field Name
To use a SIP header as a condition, specify a pair of a SIP header name and a string pattern.
Syntax:
SIP header field name = a string pattern
Example:
From = sip:user@domain\.com[>;]*
If the SIP URI in From: header is “sip:user@domain.com”
To = sip:11@
If the SIP user name in To: header field is “11”
To = sip:9(.+)@
If the SIP user name in To: header field starts with 9
To = sip:(....)@
If the SIP user name in To: header field contains only 4 characters
Supported = timer
If Supported: header field contains the string “timer”,
Expires = ^[0-5]$
If the value of Expires: header field is in the range 0-5
Contact = sip:[A-Za-z]+@
If the user name in Contact header contains only alphabet
Environment Variable
The environment variable is a variable name which starts with ‘&’. The variable name is not case sensitive. Please refer to the section “10. Environment Variables” for reference.
Syntax:
&variable_name = a string pattern
Example:
&sv.name = ^main-sv$
If the value of the server name (Environment variable: sv.name) is “main-sv”.
&net.sip.timeout.ringing = ^5[0-9][0-9][0-9]$
If the value of Ringing Timeout (Environment variable: net.sip.timeout.ringing) is in the range 5000-5999.
Conditional Function
The variable that starts with ‘$’ is treated as a conditional function. The variable name is not case sensitive. Some conditional functions can have an argument.
If you want to create own conditional function, please refer to the “Dial Plan Plug-in Developer’s Guide”. The Built-in functions are described in section 4.3.2 below.
Syntax:
$conditional_function_name = a string pattern $conditional_function_name(argument) = a string pattern
How to call functions:
Function_name( SIP header field name)
If a SIP header field name is set as an argument to a conditional function, the value of the SIP header field will be passed to the function.
Example:
$func( From )
The value of From: header will be passed to the function “func”.
Function_name( &Environment_variable_name )
If an environment variable name is set as an argument to a conditional function, the corresponding value of the variable will be passed to the function. The prefix ‘&’ should be added before an environment variable name.
Example:
$func(&net.sip.timeout.ringing )
The value of environment variable net.sip.timeout.ringing will be passed to the function “func”.
Function_name( $Conditional_function_name )
If a conditional function name is set as an argument to another conditional function, the return value of the “argument” function will be passed to the other conditional function. The prefix ‘$’ should be added before a conditional function name.
Example:
$func1( $func2 )
The return value of the function “func2” will be passed to the function “func1”.
Example:
$func1( $func2( $func3 ) )
The return value of the function “func3” will be passed to the function “func2” and the
return value of the function “func2” will be passed to the function “func1”.
Example:
$func( $func( To ) )
The contents of To: header field will be passed to the function “func” and its return value
will be passed to the function “func” again.
Function_name( “Text_String” )
If a text string is set as an argument, the text string is passed to the function. The text string should be enclosed in double quotes.
Example:
$func( “string” )
The string “string” will be passed to the function “func”.