– Kamailio SIP Server –

Jan Janak wrote:

“The latest development version of SER has support for branch_route sections and tm module contains new function called t_on_branch.

The branch_route section is a section that can be defined in the configuration file, just like failure_route or onreply_route sections:

branch_route[1] {

if (uri == "sip:a at iptel.org") {
	append_hf("P-RURI: sip:a at iptel.org\r\n");
};

}

branch_route sections can be activated using t_on_branch, for example:

t_on_branch(“1”); t_relay(); break;

branch_route sections are executed for each downstream branch. In other words, if SER forks a message to 3 destinations then the branch_route section will be executed 3 times:

               a
           +-*----->
           |   b

—→ SER ———-+-*—–>

           |   c
           +-*----->

* - branch_route will be executed here.

It is not possible to stop the processing or generate a reply in branch_route sections at the moment, you can only do last-minute modifications to the SIP message and it will be forwarded automatically once branch_route section finishes.

branch_route sections can be used to perform actions that are branch specific, for examply you can add a header field to a message only in a particular branch and leave other branches unmodified, based on the Request-URI.

In the future we could implement better NAT traversal (where RTP proxy will only be applied to branches where it is really needed), proper PSTN gateway checks, and so on.

Attached is a short example file that demonstrates the use of t_on_branch and branch_route sections.

Jan.

route {

# send it out now; use stateful forwarding as it works reliably
# even for UDP2TCP
xdbg("Appending branches\n");
append_branch("sip:a at iptel.org");
append_branch("sip:b at iptel.org");
t_on_branch("1");
if (!t_relay()) {
	sl_reply_error();
};

}

branch_route[1] {

if (uri == "sip:a at iptel.org") {
	append_hf("Test: foo\r\n");
};
xdbg("Executing branch %ru\n");

} ”