Kamailio Advanced Training
Click here for more details!

Learn how to build RTC services with Kamailio!

Thursday, January 15, 2009

Send SIP Messages From Config File

You can initiate SIP messages from Kamailio (OpenSER) configuration file ...

uac module provides a new function that allow sending sip requests from configuration file:

- uac_send_req()


It opens the door for a new bunch of things you can do now. I can think of now:

1) send IM alerts on special events

route { 
$uac_req(ruri)= "sip:alert[at]kamailio.org";
$uac_req(hdrs)="Content-Type: text/plain\r\n";
$uac_req(body)="SIP request from:" + $si + ":" + $sp;

2) turn lamps on for some sip phones on some events - e.g., snom:


3) talk server-to-server - here one example can be building a platform with a central server for accounting. Accounting is done at 200ok. So each routing server will build a csv list (time,callid, from tag, to tag, invite from uri, invite r-uri):

onreply_route[1] {
  $uac_req(hdrs)="Content-Type: text/accounting-csv\r\n";
  pv_printf($uac_req(body), "$TS,$ci,$ft,$tt,$T_req($fu),$T_req($ru)");

note that $T_req() is given by tm module, also with Kamailio trunk:


The accounting server:

  # you should check the source IP also
  if(method=="ACCOUNTING" && $rU="store")
             "insert into accounting(timeval,callid,ftag,ttag,src,dst) values ('$(rb{s.select,0,,})','$(rb{s.select,1,,})', ...)",
      send_reply("200", "Stored");   

... and you can put your imagination work ... there are plenty of new and cute features you can add on your service with this functionality ...

No comments:

Post a Comment