<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>the uac_replace_from()/_to() require that the From/To headers are
      not changed by the end points. The purpose is RFC3261 requirement
      saying that From/To must not be changed in order to be backward
      compatible with RFC2543 (previous sip specs). If the endpoints
      change them, then they are not used for backward compatibility so
      you can changed them without automatic restore -- just change them
      as you need.</p>
    <p>If one of the endpoints still require not to have the From/To
      changed, but the other endpoint in changing them, then you have to
      use uac module together with dialog and store the From/To values
      in dialog variables instead of the default behaviour that uses RR
      params -- see the readme of uac module.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 04.10.19 20:42, Duarte Rocha wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAAJJHZh8MEMe+QoCQMBHH=bWgWEAb1+R3soXTfoUbaNWXmiGGw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">
        <div class="gmail_quote" dir="auto">
          <div dir="ltr" class="gmail_attr">Greetings,<br>
          </div>
          <div link="#0563C1" vlink="#954F72" lang="PT">
            <div class="m_-356955565038666109WordSection1">
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">This is a repeated problem, but i
                have more info now. Please help understand if there is a
                problem on my code or if there is any kind of Kamailio
                bug.</p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">On the first INVITE of every call i
                apply uac_replace_from() and uac_replace_to() in order
                to normalize numeration. I have the restore_mode set as
                "auto". </p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">The original numeration is :</p>
              <p class="MsoNormal">                To : 351250000000</p>
              <p class="MsoNormal">                From : 351211455000</p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">The INVITE is sent to the client with
                To and From like this and with the Record-Route headers
                (Kamailio has 2 Ips and inserts 2  Record-Routes)
                containing vsf and vst parameters to help the future
                restores : </p>
              <p class="MsoNormal">                </p>
              <p class="MsoNormal">        To: <<a
                  href="mailto:sip%3A%2B351250000000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:+351250000000@111.111.111.111</a>></p>
              <p class="MsoNormal">        From: <<a
                  href="mailto:sip%3A%2B351211455000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:+351211455000@111.111.111.111</a>>;tag=BD583030373631320511EAE6</p>
              <p class="MsoNormal">                              
                Record-Route:
<a class="moz-txt-link-rfc2396E" href="sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62"><sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62></a></p>
              <p class="MsoNormal">        Record-Route:
<a class="moz-txt-link-rfc2396E" href="sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62"><sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62></a></p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">My client, upon receiving the INVITE,
                also does some changes in the numeration and sends a 183
                reply with the following headers : </p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">                              
                Record-Route:
<a class="moz-txt-link-rfc2396E" href="sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62"><sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62></a></p>
              <p class="MsoNormal">        Record-Route:
<a class="moz-txt-link-rfc2396E" href="sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62"><sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62></a></p>
              <p class="MsoNormal">        From: "+351211455000" <<a
                  href="mailto:sip%3AI2116446I_500@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:I2116446I_500@111.111.111.111</a>>;tag=BD583030373631320511EAE6</p>
              <p class="MsoNormal">        To: <<a
                  href="mailto:sip%3A%2B351250000000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:+351250000000@111.111.111.111</a>>;tag=as3e46f684</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               After
                Kamailio processes the reply, To and From are restored
                to it's original values and the reply is relayed : </p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               From:
                <<a href="mailto:sip%3A351211455000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:351211455000@111.111.111.111</a>>;tag=BD583030373631320511EAE6</p>
              <p class="MsoNormal">        To: <<a
                  href="mailto:sip%3A351250000000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:351250000000@111.111.111.111</a>>;tag=as3e46f684</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               Here,
                the restore works perfectly.</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">By the end of the call the client
                sends me a BYE request with Route, From and To like this
                : </p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">                               Route:
<a class="moz-txt-link-rfc2396E" href="sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62"><sip:111.111.111.111;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62></a>,<a class="moz-txt-link-rfc2396E" href="sip:212.13.40.205;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62"><sip:212.13.40.205;r2=on;lr;ftag=BD583030373631320511EAE6;tbk_i=2_2_Y;tbk_o=128_11_Y;vsf=AAAAABgGBAMDAAUBBQAJCnNyAwMcHwIdHQsWHwUMOA--;vst=AAAAABgGBAMHDQgJDQECA3RyAwMcHwIdGgQeHAIFOQ--;did=18e.5d62></a></p>
              <p class="MsoNormal">                               From:
                <<a
                  href="mailto:sip%3A%2B351250000000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:+351250000000@111.111.111.111</a>>;tag=as3e46f684</p>
              <p class="MsoNormal">        To: "+351211455000" <<a
                  href="mailto:sip%3AI2116446I_500@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:I2116446I_500@111.111.111.111</a>>;tag=BD583030373631320511EAE6</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               Here,
                the difference between 183 and BYE seems to be only in
                the Route\Record-Route are built (2 Headers or one
                header with 2 uri).</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               Now,
                there are a couple of problems relaying the BYE that
                seem to me to be related to auto replace.</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               This
                BYE message isn't logged on the onsend-route and it logs
                a couple of errors : </p>
              <p class="MsoNormal">                                              
                ERROR: <core> [core/parser/msg_parser.c:164]:
                get_hdr_field(): bad to header</p>
              <p class="MsoNormal">                                              
                ERROR: <core> [core/parser/msg_parser.c:337]:
                parse_headers(): bad header field [To: "+351211455000"
<<a class="moz-txt-link-freetext" href="sip:Q4525417L_">sip:Q4525417L_</a><:C212.13.38.148>;tag=3DC130303736313205201F18#015#012Call-ID:
                020FAAC7]</p>
              <p class="MsoNormal">                                              
                ERROR: dialog [dlg_handlers.c:666]: pre_match_parse():
                bad request or missing CALLID/TO hdr :-/</p>
              <p class="MsoNormal">                                              
                ERROR: <core> [core/parser/parse_addr_spec.c:719]:
                parse_addr_spec(): unexpected char [<] in status 6:
                ["+351211455000" <<a class="moz-txt-link-freetext" href="sip:Q4525417L_">sip:Q4525417L_</a>] .</p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">                              
                Despite not being logged on onsend_route and creating
                some errors, the BYE is still relayed like this : </p>
              <p class="MsoNormal">                                              
                From: <<a
                  href="mailto:sip%3A351250000000@111.111.111.111"
                  target="_blank" rel="noreferrer"
                  moz-do-not-send="true">sip:351250000000@111.111.111.111</a>>;tag=as3e46f684</p>
              <p class="MsoNormal">                                              
                To: "+351211455000"
                <<a class="moz-txt-link-freetext" href="sip:Q4525417L_">sip:Q4525417L_</a><:C111.111.111.111>;tag=BD583030373631320511EAE6</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               This,
                naturally, generates a "400 Bad Request" reply from the
                next equipment.</p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               I've
                also logged the $tU values along the code for BYE
                requests and it always logs the "I2116446I_500", so i
                don't know if my code can be the cause of this. </p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal">A couple of questions and comments </p>
              <p class="MsoNormal">                               - What
                can i do to better debug this issue? I want to be sure
                if the problem comes from my code of if it is a Kamailio
                issue. Right now i'm not sure where to look.</p>
              <p class="MsoNormal">                               - Can
                a request be sent without passing on onsend_route ? I
                have used this code to "catch" the BYE, which works for
                other BYEs - if( $rm == "BYE") {xerr("On send : To User
                = $tU");}</p>
              <p class="MsoNormal">                              </p>
              <p class="MsoNormal">                               </p>
              <p class="MsoNormal"> </p>
              <p class="MsoNormal">                </p>
              <p class="MsoNormal">                </p>
              <p class="MsoNormal"><span> </span></p>
              <p class="MsoNormal"> </p>
            </div>
          </div>
        </div>
      </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>
Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- <a class="moz-txt-link-freetext" href="https://asipto.com/u/kat">https://asipto.com/u/kat</a></pre>
  </body>
</html>