<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p>I don't recall how the r-uri domain is restored in this case to
say what $rd should hold, however, what you can do is store the
$rd inside an avp just after use_next_gw():</p>
<p>if (use_next_gw()) {</p>
<p> $avp(rd) = $rd;</p>
<p>}</p>
<p>and then just take the $avp(rd) when handling 401/7.</p>
<p>Cheers,<br>
Daniel<br>
</p>
<br>
<div class="moz-cite-prefix">On 21.03.18 14:40, Jean Cérien wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAL_ph0LHa3_3-BSrEv1+TB6XEkV5A2pm+5RUtw6sVEETgh0N6Q@mail.gmail.com">
<div dir="ltr"><br>
<div>Hello</div>
<div>I have setup 2 gateways in my dr_rules: 5,6 - so the 2nd
one is tried if the first fails.</div>
<div><br>
</div>
<div>The second one requires credentials.</div>
<div><br>
</div>
<div>When the first one fails: I execute the following code:</div>
<div><br>
</div>
<div>failure_route[ROUTEFAIL] {<br>
</div>
<div><br>
</div>
<div>
<div> if ( t_check_status("[345][0-9][0-9]") or
(t_branch_timeout() and !t_branch_replied() )) {</div>
<div> t_on_failure("ROUTEFAIL");</div>
<div> if (use_next_gw()) {</div>
<div>
xlog("L_INFO","failure_route(ROUTEFAIL) @@ routing to: rd:
$rd, ru:$ru, t_relay");</div>
<div> t_relay();</div>
<div> exit;</div>
<div> }</div>
</div>
<div><br>
</div>
<div>then in the same ROUTEFAIL (before this code), I have</div>
<div>
<div><br>
</div>
<div>if (t_check_status("401|407")) {</div>
</div>
<div>xlog("L_INFO","failure_route(ROUTEFAIL) @@ call to
uac_auth(), $si rd: $rd\n");<br>
</div>
<div>.....</div>
<div><br>
</div>
<div>So, when the first gateway replies with a 404, it executes
correctly the first block, finds the second gw and I see in
the log that rd is set to its address. </div>
<div><br>
</div>
<div>Yet, when the 2nd gw replies with 401, rd is set to the
very first gw. However, the pcap traces confirm it is indeed
the second that replies this.</div>
<div><br>
</div>
<div>If this behaviour is correct, I cant seem to find the
source IP of the gateway that replied to me, to retrieve
credentials from the db.</div>
<div><br>
</div>
<div>version: kamailio 5.0.5 / 5.0.6 (tested on both)<br>
</div>
<div><br>
</div>
<div>Thank you for your help</div>
<div>J</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - April 16-18, 2018, Berlin - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
</body>
</html>