<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hello,</p>
    <p>do you want to fetch the username and password from uacreg table?
      If yes, check the function:</p>
    <p>-
<a class="moz-txt-link-freetext" href="https://www.kamailio.org/docs/modules/stable/modules/uac.html#uac.f.uac_reg_request_to(user">https://www.kamailio.org/docs/modules/stable/modules/uac.html#uac.f.uac_reg_request_to(user</a>,
      mode)</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 04/05/16 10:38, Jöran Vinzens wrote:<br>
    </div>
    <blockquote
cite="mid:CAC3=B=twbrH+MzwFoCoSoZ+Cvr7a68vFuno+hd1Da87nSz41Hw@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi All,
        <div><br>
        </div>
        <div>we are trying to use the Kamailio as an UAC on a PBX. It
          should behave just like a normal SIP UAC (e.g. an SNOM phone).</div>
        <div>The reason why we want that, is connecting a service to any
          other PBX with Client features and security (DA).</div>
        <div><br>
        </div>
        <div>Our setup looks like:</div>
        <div><br>
        </div>
        <div>Kamailio UAC w/ register <-> Kamailio OBP/SBC
          <-> PBX</div>
        <div><br>
        </div>
        <div>The register is working fine. We insert the credentials
          into DB and trigger kamailio to reload the config (kamctl
          uac.reload).</div>
        <div>Then the register is sent out including the unauth (401)
          handling. After than we are registered on the PBX. The
          Register is sent though the OBP as configured in DB.</div>
        <div><br>
        </div>
        <div>We are trying to make calls:</div>
        <div><br>
        </div>
        <div>Calls from PBX to Kamailio are working fine but we struggle
          with calls from kamailio torwards PBX.</div>
        <div><br>
        </div>
        <div>We have the l_uuid in a variable and we try to get the PV
          ready for the invite.</div>
        <div><br>
        </div>
        <div>First we need to do is rewrite the "from" URI. We thought
          we can get a proper FROM URI with the uuid we have. But the
          uac_replace_from just sets the $fu as given and does not make
          any logic with UAC credentials.</div>
        <div>To handle the RURI, we trigger uac_reg_lookup with the uuid
          and it replaces the $ru with user-name and domain from the
          data stored in DB. In this case that makes no sense. The $rU
          should be what the user had dialed, the $rd should be the
          server given in uacreg DB table. The OBP given in DB is
          ignored completely.</div>
        <div><br>
        </div>
        <div>After we managed to rewrite everything in SIP as needed we
          try to catch the 407 as it's shown in the module documentation
          with failure route. Here we have not found any way to get the
          credentials for the uuid.</div>
        <div><br>
        </div>
        <div>Now we wonder if we have missed any global setting which
          sets everything right. If anybody has a similar setup and a
          working config, we appreciate any help we can get.</div>
        <div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>our config looks like:</div>
          <div><br>
          </div>
          <div>...</div>
          <div>loadmodule "uac.so"<br>
          </div>
          <div>....</div>
          <div>
            <div>modparam("uac","auth_realm_avp","$avp(arealm)")</div>
            <div>modparam("uac","auth_username_avp","$avp(auser)")</div>
            <div>modparam("uac","auth_password_avp","$avp(apass)")</div>
            <div>modparam("uac","restore_from_avp","$avp(original_uri_from)")</div>
            <div>modparam("uac","restore_to_avp","$avp(original_uri_to)")</div>
            <div>modparam("uac","credential","username:domain:password")</div>
            <div>modparam("uac", "reg_db_url","DBURI")</div>
            <div>modparam("uac", "reg_timer_interval", 60)</div>
            <div>modparam("uac", "reg_retry_interval", 300)</div>
            <div>modparam("uac", "reg_contact_addr", "<a
                moz-do-not-send="true" href="http://1.2.3.4:5060">1.2.3.4:5060</a>")</div>
            <div>...</div>
          </div>
          <div>route {<br>
          </div>
          <div><br>
          </div>
          <div>
            <div>        xlog("L_NOTICE", "INVITE: F=$fu T=$tu
              R=$ru\n");</div>
            <div>        route("QUERY_UUID"); # <- sets $var(UUID) to
              l_uuid of the DB</div>
            <div>        $var(request_user) = $rU;</div>
            <div>        uac_reg_lookup("$var(UUID)", "$ru");</div>
            <div>        $var(request_from_user) = $rU;</div>
            <div>        $rU = $var(request_user);</div>
            <div>       
              uac_replace_from("$var(request_from_user)","<a class="moz-txt-link-freetext" href="sip:$var(request_from_user)@">sip:$var(request_from_user)@</a><a
                moz-do-not-send="true" href="http://1.2.3.4">1.2.3.4</a>");</div>
            <div>        t_on_failure("TRUNKAUTH");<br>
            </div>
            <div>        xlog("L_NOTICE", "INVITE: F=$fu T=$tu R=$ru
               $avp(auser) $avp(apass)\n"); # avp "auser and apass are
              "<null>"</div>
            <div><br>
            </div>
            <div>
              <div>        if (!t_relay()) {</div>
              <div>                xlog("L_ERR", "error to <$tu>
                from <$fu>\n");</div>
              <div>                sl_reply_error();</div>
              <div>        };</div>
            </div>
            <div><br>
            </div>
            <div>}</div>
          </div>
          <div>
            <div>failure_route[TRUNKAUTH] {</div>
            <div>    if (t_is_canceled()) {</div>
            <div>        exit;</div>
            <div>    }</div>
            <div>    if(t_check_status("401|407")) {</div>
            <div>        # $avp(auser) = "test"; <-should be set from
              the l_uuid profile anyhow<br>
            </div>
            <div>        # $avp(apass) = "test";</div>
            <div>        $var(request_user) = $rU;<br>
            </div>
            <div>        if (uac_auth()) {</div>
            <div>                # We do never get here since uac_auth
              never returns true.</div>
            <div>                $rU = $var(request_user);<br>
            </div>
            <div>                route("FORWARD_MESSAGE");</div>
            <div>                exit;</div>
            <div>        }</div>
            <div>        xlog("L_NOTICE", "DAMN!!!");</div>
            <div>    }</div>
            <div>}</div>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
          -- <br>
          <div class="gmail_signature">
            <div dir="ltr">
              <pre>Jöran Vinzens - <a moz-do-not-send="true" href="mailto:vinzens@sipgate.de" target="_blank">vinzens[at]sipgate.de</a>


sipgate GmbH - Gladbacher Str. 74 - 40219 Düsseldorf
HRB Düsseldorf 39841 - Geschäftsführer: Thilo Salmon, Tim Mois
Steuernummer: 106/5724/7147, Umsatzsteuer-ID: DE219349391

<a moz-do-not-send="true" href="http://www.sipgate.de" target="_blank">www.sipgate.de</a> - <a moz-do-not-send="true" href="http://www.sipgate.co.uk" target="_blank">www.sipgate.co.uk</a>
</pre>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.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-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<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>
Kamailio World Conference, Berlin, May 18-20, 2016 - <a class="moz-txt-link-freetext" href="http://www.kamailioworld.com">http://www.kamailioworld.com</a></pre>
  </body>
</html>