<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello all,<br><br></div>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).<br><br></div>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.<br><br></div>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.<br><br></div>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:<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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.<br></blockquote><div><br></div><div>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?<br></div><br></div>Lastly, is there an analogue for SIP responses?<br><br></div>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?<br><br></div>Thanks in advance,<br><br></div>BR,<br></div>George<br></div>