Kamailio "revert" "append branch" "rewritehostport"

From open-voip.org

Jump to: navigation, search

The full functions and keywords list can be found at:

http://www.kamailio.org/dokuwiki/doku.php/core-cookbook:devel 

lets expolore some more functions using the call forward on busy script:

if (t_check_status("486")) {
 revert_uri();
 prefix("b");
 #xlog("L_ERR","Stepped into the 486 ruri=");
 rewritehostport("192.168.152.148:5061");
 append_branch();
 route(1);
 exit;
};

in this case the script get "486 busy" from b side. and need to forward the call to another URI (e.g. voicemail).

revert_uri()

indicate to the script to send the packet in the original direction (as the original INVITE"). as now cript need to fork the call and send new INVITE to a new B side (and not back to a side)

rewritehostport

Change the URI for the new forward destination

append_branch

will for the transaction by creating a new request with a new branch. A new transaction is started when forking the message to the new forwarded destination. example (from kamailio site:

# if someone calls B, the call should be forwarded to C too.
   if (method=="INVITE" && uri=~"sip:B@xx.xxx.xx ")
   {
       # copy the current branch (branches[0]) into
       # a new branch (branches[1])
       append_branch();
       # all URI manipulation functions work on branches[0]
       # thus, URI manipulation does not touch the 
       # appended branch (branches[1])
       seturi("sip:C@domain");
       # now: branch 0 = C@domain
       #      branch 1 = B@xx.xx.xx.xx
Personal tools