<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>actually you are wrong that you think it is a wrong to tag. The
      entity that generates the final reply sets the to-tag (e.g.,to be
      able to match ack). Even here where you talk about the serial
      forking, you are going to face the case of different to-tag values
      for each branch sent out and replied. But also think about
      parallel forking, that timed out with many active branches, which
      to-tag to use?!?</p>
    <p>So think that kamailio itself is the branch of the incoming
      request, and can create many outgoing branches. If it generates a
      final reply, it does it to the incoming branch. It is not
      forwarding (sending back) a reply from an outgoing branch.</p>
    <p>Obviously, being open source, one can code a specific behaviour
      for some specific needs, but is not SIP specs compliant. If the
      upstream cannot deal with different to-tags, it won't really work
      with serial/parallel forking anyhow.</p>
    <p>As a side remark, seeing the comments, if
      route(ROUTE_ELEMENT_FINAL_FAILURE) is used only in failure_route,
      then transaction is always defined there, because failure_route is
      executed only in the transaction context. Anyhow, if you are using
      in many places, not knowing if transaction was created, you can
      use send_reply() to avoid any test in the config.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 11.12.20 11:04, Ivan Ribakov wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:E2557ECA-B08D-4D67-BF57-B7CAE92A107E@zaleos.net">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Hi all,
      <div class=""><br class="">
      </div>
      <div class="">I’m trying to implement following routing behaviour:</div>
      <div class=""><br class="">
      </div>
      <div class="">- ingress INVITE is sequentially forked to 1 or more
        endpoints</div>
      <div class="">- under certain conditions sequential forking may be
        stopped and pre-defined error returned to the caller</div>
      <div class=""><br class="">
      </div>
      <div class="">Here’s is part of the config responsible for
        handling errors:</div>
      <div class=""><br class="">
      </div>
      <div class="">
        <div style="color: rgb(54, 54, 54); background-color: rgb(255, 255, 255); font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px; white-space: pre;" class=""><div class="">failure_route[ROUTE_ELEMENT_FINAL_FAILURE_HELPER] {</div><div class="">    route(ROUTE_ELEMENT_FINAL_FAILURE)<span style="color: rgb(146, 205, 120);" class="">;</span></div><div class="">}</div><div class="">
</div><div class=""><div style="line-height: 18px;" class=""><div class="">route[ROUTE_ELEMENT_FINAL_FAILURE] {</div><div class="">    <span style="color: rgb(146, 205, 120);" class=""># We need to check if the error happens before the first egress, because T-state is not defined yet so we can not use t_reply</span></div><div class="">    if ($var(before_first_egress) == 0) {</div><div class="">        t_reply(<span style="color: rgb(162, 86, 55);" class="">"$var(sipCode)"</span>, <span style="color: rgb(162, 86, 55);" class="">"$var(sipMessage)"</span>)<span style="color: rgb(146, 205, 120);" class="">;</span></div><div class="">    } else {</div><div class="">        sl_send_reply(<span style="color: rgb(162, 86, 55);" class="">"$var(sipCode)"</span>, <span style="color: rgb(162, 86, 55);" class="">"$var(sipMessage)"</span>)<span style="color: rgb(146, 205, 120);" class="">;</span></div><div class="">    }</div><div class="">}</div></div></div></div>
      </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class="">Here is a simple scenario where delivering call to
        first endpoint times out after receiving 180 Ringing (using
        custom fr_inv_timer value) where:</div>
      <div class="">- .33 is caller</div>
      <div class="">- .208 is Kamailio</div>
      <div class="">- .138 is callee</div>
      <div class=""><br class="">
      </div>
      <div class=""><br>
      </div>
      <div class=""><br class="">
      </div>
      <div class="">Notice that 504 is retransmitted by Kamailio. Here
        is a comparison of 180 and 504 returned by Kamailio:</div>
      <div class=""><br class="">
      </div>
      <div class=""><br>
      </div>
      <div class=""><br class="">
      </div>
      <div class="">As can be seen, 180 was proxied from the callee and
        has callee’s to-tag (tag=CALLEE1), however 504 that was
        generated by Kamailio using t_reply() has a different to-tag
        (presumably generated by Kamailio).</div>
      <div class=""><br class="">
      </div>
      <div class="">How can I tell Kamailio not to generate new to-tag
        but to use the last one that proxied back to the caller?</div>
      <div class=""><br class="">
      </div>
      <div class="">Thanks in advance for any help!</div>
      <div class=""><br class="">
      </div>
      <div class="">Regards,</div>
      <div class="">Ivan</div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-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>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<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>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>