<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    we can parse the parameter and if fails, then return false.<br>
    <br>
    Not sure if use_domain would be needed anymore, I think it won't
    harm to keep it. The main thing to solve here is that the uri
    parameter for ts_append() is forwarded to lookup_to_dset().<br>
    <br>
    Since I got to it, I attach a patch that adds uri parameter to
    ts_append_to() and forwards the uri to lookup_to_dset().
    ts_append_to() can still be used without uri parameter, which will
    have same behaviour like now<br>
    <br>
    If you think it is ok, I can push it to git. The part with
    use_domain can be decided later.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 22/09/15 15:48, Federico Cabiddu
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFOaF_i9DajLHZJtNh2DM+46mFWHEdy9gDs1=0P2+4oxeK--yQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,
        <div>ok, now I understand :)</div>
        <div>What do you think would be the best way to enforce the
          usage of complete sip uris in ts_append()?</div>
        <div>Do you think that at this point "use_domain" would be
          useless in tsilo?</div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div><br>
        </div>
        <div>Federico</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Tue, Sep 22, 2015 at 3:37 PM,
          Daniel-Constantin Mierla <span dir="ltr"><<a
              moz-do-not-send="true" href="mailto:miconda@gmail.com"
              target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a></a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> And to add the
              relevant code:<br>
              <br>
              modules/tsilo/ts_append.c line 85:<br>
              <br>
                  orig_msg = t->uas.request;<br>
              <br>
                  ret = _regapi.lookup_to_dset(orig_msg, table, NULL);<br>
                  if(ret != 1) {<br>
                      LM_DBG("transaction %u:%u: error updating dset
              (%d)\n", tindex, tlabel, ret);<br>
                      return -1;<br>
                  }<br>
              <br>
              I want to pass the uri parameter given to t_append() to:<br>
              <br>
              ret = _regapi.lookup_to_dset(orig_msg, table, NULL);<br>
              <br>
              instead of NULL.<br>
              <br>
              Cheers,<br>
              Daniel
              <div>
                <div class="h5"><br>
                  <br>
                  <div>On 22/09/15 15:34, Daniel-Constantin Mierla
                    wrote:<br>
                  </div>
                  <blockquote type="cite"> Hello,<br>
                    <br>
                    it was no longer about what tsilo stores internally,
                    but what lookup_to_dset() is given to search for new
                    contact.<br>
                    <br>
                    To explain with an example:<br>
                    <br>
                    Call to <a moz-do-not-send="true">sip:user@domain</a>.<br>
                    <br>
                    After lookup("location"), the r-uri of INVITE is
                    changed to contact address found in location table
                    (let's say it was only one contact there, which is <a
                      moz-do-not-send="true"><a class="moz-txt-link-freetext" href="sip:randomstring@deviceip:deviceport">sip:randomstring@deviceip:deviceport</a></a>).<br>
                    <br>
                    t_relay() is execute and transaction is created,
                    with uas field holding the INVITE with r-uri <a
                      moz-do-not-send="true"><a class="moz-txt-link-freetext" href="sip:randomstring@deviceip:deviceport">sip:randomstring@deviceip:deviceport</a></a>.<br>
                    <br>
                    After a while, a device for same user registers, if
                    I call ts_append(..., <a moz-do-not-send="true">"sip:user@domain"</a>),

                    it finds the INVITE transaction to be associated
                    with <a moz-do-not-send="true">sip:user@domain</a>,
                    but lookup_to_dset() is executed internally by tsilo
                    with the argument being the request from
                    Transaction->uas (and no explicit URI parameter).
                    So the lookup is done for <a moz-do-not-send="true">sip:randomstring@deviceip:deviceport</a>),

                    because that is the r-uri in T-uas reques. Obviously
                    that will fail to find new contacts.<br>
                    <br>
                    Hopefully I could expose the issue better now.<br>
                    <br>
                    Cheers,<br>
                    Daniel<br>
                    <br>
                    <div>On 22/09/15 15:14, Federico Cabiddu wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Hi,
                        <div>I'm not sure I fully understand the
                          problem. See my comments inline</div>
                        <div class="gmail_extra"><br>
                          <div class="gmail_quote">On Tue, Sep 22, 2015
                            at 2:24 PM, Daniel-Constantin Mierla <span
                              dir="ltr"><<a moz-do-not-send="true"
                                href="mailto:miconda@gmail.com"
                                target="_blank">miconda@gmail.com</a>></span>
                            wrote:<br>
                            <blockquote class="gmail_quote"
                              style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello,<br>
                              <br>
                              tsilo is not using the uri parameter for
                              looking up location for new<br>
                              destinations. It passes the uas request
                              from transaction module to<br>
                              registrar lookup_to_dset() function, so
                              the r-uri from that request is used.<br>
                              <br>
                              However, there is at least one scenario
                              that makes tsilo not working<br>
                              properly:<br>
                              <br>
                              - invite comes in<br>
                              - lookup location finds a contact<br>
                              - request is forwarded with a new r-uri
                              (the contact of the location<br>
                              record) -- t_relay() is used and
                              trasaction created, r-uri stored for<br>
                              uas is contact header<br>
                              - a new registration comes and ts_append()
                              is executed, failing to find<br>
                              contacts for r-uri in uas because the
                              r-uri there can be anything<br>
                              pointing to the first device found in
                              location<br>
                            </blockquote>
                            <div><br>
                            </div>
                            <div>This happens because since commit <span
style="color:rgb(178,104,24);font-family:monospace">1e5bad019c450a003e812ee051d84134aad6c5f0, </span>we


                              are using the current uri to store the
                              transaction. </div>
                            <div>That's why I was wondering (probably I
                              have not been clear in my other mail :))
                              if, since now ts_store accepts uris as
                              parameter, we still need this.</div>
                            <div>In this case, the scenario you describe
                              would work flawlessly and, if one need to
                              store the transaction under a new ruri
                              after some kind of message manipulation
                              (like using alias etc) he can always call
                              ts_store with the specific uri he wants to
                              use.</div>
                            <div>Am I missing something?</div>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                    <br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div class="gmail_extra">
                          <div class="gmail_quote">
                            <div><span style="font-family:monospace"><br>
                              </span></div>
                            <div> Some solutions can be found by
                              creating transaction earlier, but not</div>
                            <blockquote class="gmail_quote"
                              style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">easy


                              to tackle always.<br>
                              <br>
                              I think it would be better to just pass
                              the uri parameter from<br>
                              ts_append() to lookup_to_dset(). But I
                              noticed that the uri can be just<br>
                              username if use_domain is 0, which makes
                              things a little more complex,<br>
                              because registrar/usrloc expect full sip
                              uri.<br>
                              <br>
                              The solution would be to 'force' always
                              that the uri parameters for<br>
                              tsilo functions are full SIP uri, and let
                              the code extract only username<br>
                              when use_domain is 0. If someone has only
                              the username in config, it can<br>
                              simply put the uri parameter as <a
                                moz-do-not-send="true"><a class="moz-txt-link-rfc2396E" href="sip:username@localhost">"sip:username@localhost"</a></a>
                              -- domain will<br>
                              be ignored anyhow.<br>
                              <br>
                            </blockquote>
                            <div><br>
                            </div>
                            <div> Agree that this could avoid future
                              headaches and provide more flexibility for
                              other use cases. In this case, should we
                              totally remove the dependency on usrloc
                              "use_domain" parameter?<br>
                            </div>
                            <div> </div>
                            <blockquote class="gmail_quote"
                              style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Alternative,


                              if the parameter is just username, built a
                              temporary uri<br>
                              for it before passing to lookup_to_dset().<br>
                              <br>
                              I find first solution a bit better because
                              the parameter for tsilo<br>
                              functions is called uri and building an
                              internal one can end up in some<br>
                              limitations if it is going to be something
                              that requires tel: or sips:<br>
                              or parameters such as instance.<br>
                              <br>
                            </blockquote>
                            <div><br>
                            </div>
                            <div>Agree.</div>
                            <div> </div>
                            <blockquote class="gmail_quote"
                              style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Any


                              comments/suggestions?<br>
                              <br>
                              Cheers,<br>
                              Daniel<br>
                              <br>
                            </blockquote>
                            <div><br>
                            </div>
                            <div>Cheers,</div>
                            <div><br>
                            </div>
                            <div>Federico </div>
                          </div>
                          <br>
                        </div>
                      </div>
                    </blockquote>
                    <br>
                    <pre cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Kamailio Advanced Training, Sep 28-30, 2015, in Berlin - <a moz-do-not-send="true" href="http://asipto.com/u/kat" target="_blank">http://asipto.com/u/kat</a></pre>
                  </blockquote>
                  <br>
                  <pre cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Kamailio Advanced Training, Sep 28-30, 2015, in Berlin - <a moz-do-not-send="true" href="http://asipto.com/u/kat" target="_blank">http://asipto.com/u/kat</a></pre>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Kamailio Advanced Training, Sep 28-30, 2015, in Berlin - <a class="moz-txt-link-freetext" href="http://asipto.com/u/kat">http://asipto.com/u/kat</a></pre>
  </body>
</html>