1. Overview

The module implements text based operations over the SIP message
processed by Kamailio. SIP is a text based protocol and the module
provides a large set of very useful functions to manipulate the
message at text level, e.g., regular expression search and replace,
Perl-like substitutions, checks for method type, header presence,
insert of new header and date, etc.

3.11.
subst('/re/repl/flags')

'/re/repl/flags' - sed like regular
expression. flags can be a combination of i (case insensitive),
g (global) or s (match newline don't treat it as end of line).

're' - is regular expresion

'repl' - is replacement string - may contain pseudo-varibales

'flags' - substitution flags (i - ignore case, g - global)

This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.

Example 1.11. subst usage

...
# replace the uri in to: with the message uri (just an example)
if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1\u\2/ig') ) {};
# replace the uri in to: with the value of avp sip_address (just an example)
if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1$avp(sip_address)\2/ig') ) {};
...

3.12.
subst_uri('/re/repl/flags')

Runs the re substitution on the message uri (like subst but works
only on the uri)

Meaning of the parameters is as follows:

'/re/repl/flags' - sed like regular
expression. flags can be a combination of i (case insensitive),
g (global) or s (match newline don't treat it as end of line).

're' - is regular expresion

'repl' - is replacement string - may contain pseudo-varibales

'flags' - substitution flags (i - ignore case, g - global)

This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.

Example 1.12. subst_uri usage

...
# adds 3463 prefix to numeric uris, and save the original uri (\0 match)
# as a parameter: orig_uri (just an example)
if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:3463\1@\2;orig_uri=\0/i')){$
# adds the avp 'uri_prefix' as prefix to numeric uris, and save the original
# uri (\0 match) as a parameter: orig_uri (just an example)
if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(uri_prefix)\1@\2;orig_uri=\0/i')){$
...

3.13.
subst_user('/re/repl/flags')

Runs the re substitution on the message uri (like subst_uri but works
only on the user portion of the uri)

Meaning of the parameters is as follows:

'/re/repl/flags' - sed like regular
expression. flags can be a combination of i (case insensitive),
g (global) or s (match newline don't treat it as end of line).

're' - is regular expresion

'repl' - is replacement string - may contain pseudo-varibales

'flags' - substitution flags (i - ignore case, g - global)

This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.

3.25.
append_time()

Adds a time header to the reply of the request. You must use it
before functions that are likely to send a reply, e.g., save()
from 'registrar' module. Header format is:
“Date: %a, %d %b %Y %H:%M:%S GMT”, with the legend:

%a abbreviated week of day name (locale)

%d day of month as decimal number

%b abbreviated month name (locale)

%Y year with century

%H hour

%M minutes

%S seconds

Return true if a header was succesfully appended.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE.

Example 1.25. append_time usage

...
append_time();
...

3.26.
append_time_to_request()

Adds a time header to the request. Header format is:
“Date: %a, %d %b %Y %H:%M:%S GMT”, with the legend:

%a abbreviated week of day name (locale)

%d day of month as decimal number

%b abbreviated month name (locale)

%Y year with century

%H hour

%M minutes

%S seconds

Return true if a header was succesfully appended.

This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.

The 'name' can be a list of methods in the form of
'method1|method2|...'. In this case, the function returns true if the
SIP message's method is one from the list. IMPORTANT NOTE: in the list
must be only methods defined in Kamailio with ID (invite, cancel, ack,
bye, options, info, update, register, message, subscribe, notify,
refer, prack, publish; for more see:
http://www.iana.org/assignments/sip-parameters).

If used for replies, the function tests the value of method field from
CSeq header.

Meaning of the parameters is as follows:

name - SIP method name

This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, and BRANCH_ROUTE.

This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.

Example 1.32. is_privacy usage

...
if(is_privacy("id"))
{
# do interesting stuff here
}
...

3.33.
in_list(subject, list, separator)

Function checks if subject string is found in list string where list items are separated by separator string. Subject and list strings may contain pseudo variables. Separator string needs to be one character long. Returns 1 if subject is found and -1 otherwise.