<html>
  <head>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-15">
  </head>
  <body>
    <p>Hi all,</p>
    <p>Opensips 1.11 here. I've tried implementing max concurrent calls
      limitation for some of our users, inspired by tutorial found at
      <a class="moz-txt-link-freetext"
href="https://www.opensips.org/Documentation/Tutorials-ConcurrentCallsLimitation">https://www.opensips.org/Documentation/Tutorials-ConcurrentCallsLimitation</a>
      and using AVP to set per-account calls limit.</p>
    <p>In table usr_preferences i've a row like:</p>
    <table width="100%" cellspacing="2" cellpadding="2" border="1">
      <tbody>
        <tr>
          <td valign="top">id<br>
          </td>
          <td valign="top">uuid<br>
          </td>
          <td valign="top">username<br>
          </td>
          <td valign="top">domain<br>
          </td>
          <td valign="top">attribute<br>
          </td>
          <td valign="top">type<br>
          </td>
          <td valign="top">value<br>
          </td>
        </tr>
        <tr>
          <td valign="top">1298<br>
          </td>
          <td valign="top"><br>
          </td>
          <td valign="top">6911<br>
          </td>
          <td valign="top">voip.xxxx.it<br>
          </td>
          <td valign="top">maxcalls<br>
          </td>
          <td valign="top">0<br>
          </td>
          <td valign="top">1<br>
          </td>
        </tr>
      </tbody>
    </table>
    <p>and on dialplan i've:<br>
    </p>
    <pre>####  AVP module
loadmodule "avpops.so"
modparam("avpops","db_url",<a class="moz-txt-link-rfc2396E" href="mailto:mysql://voip:7PDzZ2ADNxZzmzfA@192.168.1.1/opensips">"mysql://voip:7PDzZ2ADNxZzmzfA@192.168.1.1/opensips"</a>)
modparam("avpops","avp_table","usr_preferences")
modparam("avpops","uuid_column", "uuid")
modparam("avpops","use_domain",0)
modparam("avpops","domain_column","domain")
modparam("avpops","attribute_column","attribute")
modparam("avpops","value_column","value")
modparam("avpops","type_column","type")</pre>
    <pre>...
</pre>
    <pre>route() {
[...]
    if (is_method("INVITE")) {
        set_dlg_profile("caller", "$ru");
        get_profile_size("caller", "$ru", "$var(size)");

        ## <-- CONCURRENT CALLS LIMIT BASED ON DESTINATION
        if(avp_db_load("$ru/username","$avp(maxcalls)")) {
        if($var(size) > $avp(maxcalls)) {
            xlog("L_INFO","$ci - User $rU has $var(size) calls (max $avp(maxcalls) calls): BUSY\n");
            sl_send_reply("486", "Busy: try later");
            exit;
        } else {
            xlog("L_INFO","$ci - User $rU has $var(size) calls (max $avp(maxcalls) calls): ALLOW\n");
        }
     }
[...]
}
</pre>
    <p>This way seems to work perfectly except when calls come from our
      mediagateways, that append port to signals, like (captured with
      sngrep):</p>
    <pre>INVITE     <a class="moz-txt-link-abbreviated" href="mailto:333xxxx@172.20.1.4:506">333xxxx@172.20.1.4:506</a> <a class="moz-txt-link-abbreviated" href="mailto:5xxx@voip.xxxx.it:5060">5xxx@voip.xxxx.it:5060</a>   28    172.20.1.4:5060        193.xxxxxxx:5060     REJECTED   28ad94e804782466                                              0:10</pre>
    <pre>INVITE     <a class="moz-txt-link-abbreviated" href="mailto:5023@voip.xxxx.it">5023@voip.xxxx.it</a>        <a class="moz-txt-link-abbreviated" href="mailto:5050@voip.xxx.it">5050@voip.xxx.it</a>        20    193.205.4.182:5060     193.xxxxxxx:5060     CANCELLED <a class="moz-txt-link-abbreviated" href="mailto:455244b218fec81c1f90036f3890af3e@voip.xxx.it">455244b218fec81c1f90036f3890af3e@voip.xxx.it</a>                0:05</pre>
    <pre>INVITE     <a class="moz-txt-link-abbreviated" href="mailto:3527@172.20.1.4:5060">3527@172.20.1.4:5060</a>      <a class="moz-txt-link-abbreviated" href="mailto:2282@voip.xxx.it:5060">2282@voip.xxx.it:5060</a>   20    172.20.1.4:5060        193.xxxxxxx:5060     COMPLETED  7758dace18b36325 
</pre>
    <p>I suppose, but maybe i'm wrong, that the problem is the domain
      part of the RURI that were not correctly matched in dialog
      profile. <br>
    </p>
    <p>Any hint or help kindly appreciated</p>
    <pre class="moz-signature" cols="72">

-- 
Michele Pinassi - Responsabile Cybersecurity Universitą di Siena
Ufficio Esercizio e Tecnologie - CSIRT
<a class="moz-txt-link-abbreviated" href="mailto:irt@unisi.it">irt@unisi.it</a></pre>
  </body>
</html>