Filter syntax

For all modules, you can define a filter expression which will be evaluated for each SIP message coming.
If the filter matched, the message goes through the module, otherwise it is skipped.

For instance, this filter:

filter=from.uri.domain contains 'sip.linphone.org'

Will only allow the module to see messages that come from the sip.linphone.org domain.

The filter syntax is quite specific to Flexisip. It allows to peek into the SIP messages and see some of their data. You manipulate variables and test them against other variables or constants.

Literals

Literals include the following types:

Stringswrite them surrounded by single quotes: 'linphone.org'
List of stringswhitespace separated words: toto titi tata
integerswrite them normally: 5223
Parenthesisused to separate different nested expressions: ( from.uri.user == 'toto' ) || (from.uri.user == 'titi')
Booleanstrue and false

Variables

 DescriptionRequired
Flexisip version
from.uri.domain 

The domain set in the From: header. For instance,
From: <sip:toto@titi;param1=3>
has domain titi

 
from.uri.user The username set in the From: header. In the above example, user is toto 
from.uri.params The parameters that are appended to the URI of the From: header. Above example would result in param1=3  
to.uri.[domain,user,params] Same as above, but in the To: header  
request.uri.[domain,user,params] Same as above, but in the Request-URI (Request only) 
contact.uri.[domain,user,params]Same as above, but in the Contact-URI2.2
request.methodThe method of the request (REGISTER, SUBSCRIBE, ...)  
direction Gives the direction of the message. Returns 'request' or 'response'  
status.phrase For responses, gives the status phrase ("Registration Successful" for instance)  
status.code For responses, gives the status code  
user-agent For requests, gives the user-agent string  
call-id The call id of the SIP message  
call-id.hash The call id hash of the SIP message  
content-type

Give the content type as in the Content-type: header.

 

Operators and keywords

The operators mostly work with 2 arguments (left-hand-side and right-hand-side).
Some of them only take one argument: numeric and defined.
is_response and is_request take no argument.

Here is the list of the available operators:

OperatorDescriptionExample
||Logical OR (to.uri.domain contains 'linphone') || (from.uri.domain contains 'linphone')
&&Logical AND(to.uri.domain contains 'linphone') && (from.uri.domain contains 'linphone')
Logical NOT!is_request
!(from.uri.username regex '[a-z]+')
defined Tests if the variable is defined defined from.uri.user
contains Tests if the variable contains the element on right hand side from.uri.domain contains 'linphone'
regex 

Tests the left hand side with a regex defined on the right.

The regex grammar used is the implementation of the ECMAScript grammar by C++.

Note that the filter will only be successful if it match the entire character sequence.

from.uri.username regex '[a-z]+'
in Tests the presence of the LHS string in the RHS string list from.uri.username in 'toto titi'
notin Tests the absence of the LHS string in the RHS string list from.uri.username notin 'toto titi'
numeric Tests if the RHS is numeric numeric status.code
is_request Special keyword for testing if the message is a request is_request && request.method-name == 'REGISTER'
is_response Special keyword to test if the message is a response is_response && status.code == 200
Tags: flexisip