<div dir="ltr"><div dir="ltr"><div dir="ltr">omg! of course. thx!</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 4 февр. 2020 г. в 18:54, Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org">bogdan@opensips.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">
    <tt>Hi Anton,<br>
      <br>
      by default, the module does auto restore of the FROM/TO hdr. The
      restoring is done in the traffic flowing in the opposite direction
      than the initial request. So, the uac_restore_xx() is NOT an
      uac_undo_xx() !<br>
      <br>
      As I understand, you do serial forking and for you want to do
      different, or not to do, uac_replaces for each branch. If this is
      the case, you need to do the uac_replace_xx() in the branch_route
      - by doing this, the change will impact only that branch, without
      any effect on the other branches.<br>
      <br>
      <br>
      branch_route[change_from]<br>
      {<br>
          if (</tt><tt><tt><tt>$avp(furi)!=NULL)<br>
        </tt></tt>        uac_replace_from("</tt><tt><tt>$avp(furi)</tt>");<br>
      }<br>
      <br>
      route {<br>
          $avp(furi) = "...";<br>
          t_on_branch("change_from");<br>
          </tt><tt>t_on_failure("missed_call");<br>
      }<br>
      <br>
    </tt><br>
    <tt>failure_route[missed_call]<br>
      {<br>
          $ru = "..";<br>
          </tt><br>
    <tt><tt>    $avp(furi) = "...";</tt> # if you want a different FROM
      URI<br>
          </tt><tt><tt><tt>$avp(furi) = NULL; # if you want to keep the
          original URI<br>
          <br>
              ....<br>
        </tt></tt>}<br>
      <br>
      Regards,<br>
    </tt>
    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank">https://www.opensips-solutions.com</a>
OpenSIPS Summit, Amsterdam, May 2020
  <a href="https://www.opensips.org/events/Summit-2020Amsterdam/" target="_blank">https://www.opensips.org/events/Summit-2020Amsterdam/</a>
OpenSIPS Bootcamp, Miami, March 2020
  <a href="https://opensips.org/training/OpenSIPS_Bootcamp_2020/" target="_blank">https://opensips.org/training/OpenSIPS_Bootcamp_2020/</a>

</pre>
    <div>On 2/4/20 3:39 PM, Антон Ершов wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hello friends<br>
        Help me to understand. In request_route i make replace from and
        to fields. 
        <div>After an unsuccessful attempt to invite, I try to direct
          the call to another place and again I need to replace the from
          and to fields. But instead of replacing, new values are simply
          added<br>
        </div>
        <div><br>
        </div>
        <div>route {</div>
        <div>    ...</div>
        <div>    route(rewrite_header);</div>
        <div>    ...</div>
        <div>}</div>
        <div>failure_route[missed_call] {<br>
        </div>
        <div>    setflag(need_uac_restore);</div>
        <div>    ...</div>
        <div>    route(rewrite_header);</div>
        <div>}</div>
        <div>route[rewrite_header] {<br>
        </div>
        <div>    if (isflagset(need_uac_restore)) {<br>
                  xlog("L_INFO", "[ $ci ] - restore from and to
          fields\n");<br>
                  uac_restore_from();<br>
                  uac_restore_to();<br>
              }<br>
        </div>
        <div> 
             uac_replace_from("",<a>"sip:$avp(fromuser)@$avp(fromdomain)"</a>);</div>
        <div>     uac_replace_to("",<a>"sip:$avp(touser)@$avp(todomain)"</a>);</div>
        <div>}</div>
        <div><br>
        </div>
        <div>in the end I get such fields<br>
        </div>
        <div><br>
        </div>
        <div>From:  <<a href="mailto:sip%3A2220222@10.10.10.10" target="_blank">sip:2220222@10.10.10.10</a>><a><sip:5274274@sipofon.loc></a>;tag=fe654d87-7565-408f-9925-98a5bac99e1c<br>
          To: <<a href="mailto:sip%3A3865071@10.10.10.10" target="_blank">sip:3865071@10.10.10.10</a>><a><sip:3865071@sipofon.loc></a><br>
        </div>
        <div><br>
        </div>
        <div>it simply appends the new value to the old and does not
          replace it<br>
        </div>
        <div>changing replace modes in uac module does not change
          behavior<br>
        </div>
        <div>in debug log i see this</div>
        <div><br>
        </div>
        <div>DBG:uac:replace_uri: uri to replace [<<a href="mailto:sip%3A2220222@10.23.100.40" target="_blank">sip:2220222@10.23.100.40</a>>],
          replacement is [<<a href="mailto:sip%3A79385274274@multifon.ru" target="_blank">sip:79385274274@multifon.ru</a>>]<br>
          DBG:dialog:new_dlg_val: inserting
          <739823>=<<a><sip:5274274@sipofon.loc></a>><br>
          DBG:dialog:store_dlg_value_unsafe: var found-> <<<a href="mailto:sip%3A2220222@10.10.10.10" target="_blank">sip:2220222@10.10.10.10</a>>>!<br>
          DBG:uac:replace_uri: uri to replace [<<a href="mailto:sip%3A3865071@10.100.100.100" target="_blank">sip:3865071@10.100.100.100</a>>],
          replacement is [<a><sip:3865071@sipofon.loc></a>]<br>
          DBG:dialog:new_dlg_val: inserting
          <739824>=<<a><sip:3865071@sipofon.loc></a>><br>
          DBG:dialog:store_dlg_value_unsafe: var found-> <<<a href="mailto:sip%3A3865071@10.10.10.10" target="_blank">sip:3865071@10.10.10.10</a>>>!<br>
        </div>
        <div><br>
        </div>
        <div>10.23.100.40 - call initiator</div>
        <div>10.10.10.10 - where should the call go first<br>
        </div>
        <div>10.100.100.100 - opensips<br>
        </div>
        <div>sipofon.loc - where should the call go after failure_route
          has worked<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div>