[SR-Users] Determining next hop for any SIP message

George Diamantopoulos georgediam at gmail.com
Fri Apr 13 19:58:15 CEST 2018


Hello all,

I've been trying to figure out a cleaner way to determine the next hop for
a SIP message, mainly for use within the NATMANAGE route for multi-homed
kamailio instances (with three or more network interfaces on the kamailio
host).

So far I have achieved this with a series of nested ifs, depending on
whether the message is a request or a response and by calculating the next
hop based on the various headers (R-URI, Route) and variables ($T_req($Ri),
$dd, ) involved in SIP routing.

A simpler way to do it, of course, would be to use the onsend_route, but
that would most likely introduce an unnecessary overhead for all routed
messages.

I recently noticed there a pseudovariable called $nh(key), and I believe I
can use $nh(d) to the same effect. I understand however, that this works
for requests only. Also, the description of this PV in the documentation
reads as follows:

Return attributes of next hop for the SIP request. Address is taken from
> dst_uri, if set, if not from new r-uri or original r-uri.
>

What is not clear to me is if this covers in-dialog requests with the Route
header set as well. Does the inclusion of a route header set the dst_uri
PV? And if yes, is it safe to rely on dst_uri during request processing or
is it set only after completion of script processing?

Lastly, is there an analogue for SIP responses?

If not, is it safe to rely on first Via header to determine next hop for
responses, or are there any other corner cases I need to heed?

Thanks in advance,

BR,
George
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20180413/14584225/attachment.html>


More information about the sr-users mailing list