Relay message to external server and use response to populate response to original message

37 views Asked by At

We have this scenario: SBC->Kamailio->3rd party route server(302)

SBC sends invite to Kamailio, which replies with its own 302 redirect if its own database contains relevant details, but in some circumstances it needs to consult 3rd party route server for the correct contact, and use the response from external server to populate the response to SBC:

Kamailio upon checking its own database, and result=SipTrunk:

   if ($dbr(routes=>[$(var(routes_processed)), 0]) == "SipTrunk") {
      xlog("L_INFO", "Route $(var(routes_processed)): SipTrunk with Group ID $dbr(routes=>[$(var(routes_processed)), 2])\n");
      $(var(contact)) = "<sip:+" + $(var(number)) + ";tgrp=" + $dbr(routes=>[$(var(routes_processed)), 2]) + ";trunk-context=" + $si + "@" + $si + ">";

If result=Forward i need to ask 3rd party route server for the correct contacts:

} else if ($dbr(routes=>[$(var(routes_processed)), 0]) == "Forward") {

What would be the correct way to do this? I have checked t_relay functionality, and UAC_REDIRECT

1

There are 1 answers

0
arheops On

There is no "correct" way. You can program whatever you want.

You should use t_relay or the TM module branch(if you want a fork call).

After that, you should make something similar to dispatcher example route change. i.e use on_reply route in which you do another relay/route.

https://github.com/kamailio/kamailio/blob/master/src/modules/dispatcher/doc/dispatcher.cfg