Hi Bogdan,<br><br>I was able to implement the channel limiting on one DID by using a variable instead of AVP and replacing all instances of $tU to $rU. Now, I want to limit the channels to a set of DIDs and I&#39;m thinking of implementing a &quot;while loop&quot; and &quot;counter&quot; in order to achieve it. Is this an efficient way of doing the limiting on a set of DIDs? One problem I can think with the &quot;while loop&quot; and &quot;counter&quot; will be how to deduct those calls that were already hung up by the caller. Again, inputs will be greatly appreciated.<br>
<br>Thank you very much.<br><br>--conpaj--<br><br><div class="gmail_quote">On Fri, Jan 8, 2010 at 4:53 PM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi<br>
<br>
It is hard to review scripts to see where the problem is, but I will<br>
help you with some hints on troubleshooting.<br>
<br>
First of all you need to be sure you put in the profiles the calls you<br>
wants - put some xlog() around the place where you add the call in the<br>
profile (in the script). Be sure you create the dialog (use<br>
create_dialog() before adding it into profile). After that, you can<br>
check with MI function to see the profile content<br>
(<a href="http://www.opensips.org/html/docs/modules/devel/dialog.html#id272772" target="_blank">http://www.opensips.org/html/docs/modules/devel/dialog.html#id272772</a>)<br>
<div class="im"><br>
Regards,<br>
Bogdan<br>
<br>
Johnson Pajayat wrote:<br>
</div><div><div></div><div class="h5">&gt; Hello Bogdan,<br>
&gt;<br>
&gt; I appreciate a lot your response regarding my inquiry. I&#39;ve been<br>
&gt; reading that tutorial as well as the AVPops and dialog modules<br>
&gt; documentation for about a month now. I tried to adapt that route block<br>
&gt; for inbound calls and here&#39;s a portion of what I have on our OpenSIPS<br>
&gt; 1.5 config file:<br>
&gt;<br>
&gt; -------------------------------------------------------------------------------<br>
&gt; modparam(&quot;dialog&quot;, &quot;dlg_flag&quot;, 4)<br>
&gt; modparam(&quot;dialog&quot;, &quot;profiles_with_value&quot;, &quot;inbound&quot;)<br>
&gt;<br>
&gt; ......<br>
&gt;<br>
&gt;                 } else if (uri=~&quot;sip:1234567890@.*&quot;) {<br>
&gt;                         route(3);<br>
&gt;                         rewritehost(&quot;111.222.111.222&quot;);<br>
&gt;<br>
&gt; .......<br>
&gt;<br>
&gt; route[3]<br>
&gt; {<br>
&gt;         ## have we done our checking on this call?<br>
&gt;         if(!isflagset(31))<br>
&gt;         {<br>
&gt;                 # user has max channel limit set as preference<br>
&gt;                 if(is_avp_set(&quot;$avp(s:channels)/n&quot;) &amp;&amp;<br>
&gt; avp_check(&quot;$avp(s:channels)&quot;, &quot;gt/i:0&quot;))<br>
&gt;                 {<br>
&gt;                         # get the current calls for DID<br>
&gt;                         get_profile_size(&quot;inbound&quot;,&quot;$tU&quot;,&quot;$var(calls)&quot;);<br>
&gt;<br>
&gt;                         # check within limit<br>
&gt;                         if($avp(s:channels) &gt; $var(calls))<br>
&gt;                         {<br>
&gt;                                 xlog(&quot;L_INFO&quot;, &quot;Call control: DID<br>
&gt; &#39;$tU&#39; currently has<br>
&gt;                                    &#39;$var(calls)&#39; of &#39;$avp(s:channels)&#39;<br>
&gt; active calls before this one\n&quot;);<br>
&gt;                                 $var(setprofile) = 1;<br>
&gt;                         }<br>
&gt;                         else<br>
&gt;                         {<br>
&gt;                                 xlog(&quot;L_INFO&quot;, &quot;Call control: DID<br>
&gt; &#39;$tU&#39; channel limit exceeded [$var(calls)/$avp(s:channels)]<br>
&gt; \n&quot;);<br>
&gt;                                 send_reply(&quot;487&quot;, &quot;Request Terminated:<br>
&gt; Channel limit exceeded\n&quot;);<br>
&gt;                                 exit;<br>
&gt;                         }<br>
&gt;                 }<br>
&gt;                 else<br>
&gt;                 {<br>
&gt;                         $var(setprofile) = 0;<br>
&gt;                 }<br>
&gt;<br>
&gt;                 call_control();<br>
&gt;<br>
&gt;                 switch ($retcode)<br>
&gt;                 {<br>
&gt;                         case 2:<br>
&gt;                                 # Call with no limit<br>
&gt;                         case 1:<br>
&gt;                                 # Call with a limit under callcontrol<br>
&gt; management (either prepaid or postpaid)<br>
&gt;                                 break;<br>
&gt;                         case -1:<br>
&gt;                                 # Not enough credit (prepaid call)<br>
&gt;                                 xlog(&quot;L_INFO&quot;, &quot;Call control: not<br>
&gt; enough credit for prepaid call\n&quot;);<br>
&gt;                                 acc_rad_request(&quot;402&quot;);<br>
&gt;                                 sl_send_reply(&quot;402&quot;, &quot;Not enough credit&quot;);<br>
&gt;                                 exit;<br>
&gt;                                 break;<br>
&gt;                         case -2:<br>
&gt;                                 # Locked by call in progress (prepaid<br>
&gt; call)<br>
&gt;                                 xlog(&quot;L_INFO&quot;, &quot;Call control: prepaid<br>
&gt; call locked by another call in progress\n&quot;);<br>
&gt;                                 acc_rad_request(&quot;403&quot;);<br>
&gt;                                 sl_send_reply(&quot;403&quot;, &quot;Call locked by<br>
&gt; another call in progress&quot;);<br>
&gt;                                 exit;<br>
&gt;                                 break;<br>
&gt;                         default:<br>
&gt;                                 # Internal error (message parsing,<br>
&gt; communication, ...)<br>
&gt;                                 xlog(&quot;L_INFO&quot;, &quot;Call control: internal<br>
&gt; server error\n&quot;);<br>
&gt;                                 acc_rad_request(&quot;500&quot;);<br>
&gt;                                 sl_send_reply(&quot;500&quot;, &quot;Internal server<br>
&gt; error&quot;);<br>
&gt;                                 exit;<br>
&gt;                 }<br>
&gt;<br>
&gt;                 if($var(setprofile) &gt; 0)<br>
&gt;                 {<br>
&gt;                         create_dialog();<br>
&gt;                         set_dlg_profile(&quot;inbound&quot;,&quot;$tU&quot;);<br>
&gt;                 }<br>
&gt;<br>
&gt;                 ## mark checking done<br>
&gt;                 setflag(31);<br>
&gt;         }<br>
&gt; }<br>
&gt;<br>
&gt; ----------------------------------------------------------------<br>
&gt;<br>
&gt; And here are the logs appearing on /var/log/messages:<br>
&gt;<br>
&gt; Jan  6 05:53:22 opensips cdrtool[20998]: MaxSessionTime Duration=36000<br>
&gt; CallId=<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a><br>
</div></div>&gt; &lt;mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a>&gt; From=si<br>
&gt; <a href="mailto:p%3A12135551234@124.123.234.229">p:12135551234@124.123.234.229</a> &lt;mailto:<a href="mailto:p%253A12135551234@124.123.234.229">p%3A12135551234@124.123.234.229</a>&gt;<br>
<div class="im">&gt; Gateway=124.123.234.229 To=sip:1234567890@124.123.234.241:5060;user=phone<br>
&gt; Jan  6 05:53:22 opensips cdrtool[20998]: MaxSessionTime=unlimited<br>
&gt; Type=postpaid CallId=<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a><br>
</div>&gt; &lt;mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a>&gt;<br>
<div class="im">&gt; BillingParty=<a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a><br>
</div>&gt; &lt;mailto:<a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a>&gt;<br>
<div class="im">&gt; Jan  6 05:53:22 opensips call-control[21263]: Call id<br>
&gt; <a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a><br>
</div>&gt; &lt;mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a>&gt; of<br>
&gt; <a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a> &lt;mailto:<a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a>&gt; to<br>
<div class="im">&gt;  sip:1234567890@124.123.234.241:5060;user=phone is postpaid not limited<br>
&gt; Jan  6 05:53:22 opensips /usr/local/sbin/opensips[1636]: new branch at<br>
&gt; sip:1234567890@111.222.111.222:5060;user=phone<br>
&gt; Jan  6 05:53:22 opensips /usr/local/sbin/opensips[1640]: incoming reply<br>
&gt; Jan  6 05:53:22 opensips /usr/local/sbin/opensips[1636]: incoming reply<br>
&gt; Jan  6 05:53:22 opensips /usr/local/sbin/opensips[1636]: ACC:<br>
&gt; transaction answered: timestamp=1262786002;method=INVITE;from_t<br>
&gt; ag=14fe61da-25a58684-e5ea4d40;to_tag=as6a53f46c;call_id=<a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a><br>
</div>&gt; &lt;mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a>&gt;;code=200;reason=OK<br>
<div class="im">&gt; Jan  6 05:53:22 opensips /usr/local/sbin/opensips[1637]: Recive call<br>
&gt; variable : &lt;null&gt; &lt;null&gt;<br>
&gt;<br>
&gt; As for the channels limit value, do I have to define it on<br>
&gt; usr_preferences table? I have these records on the said table:<br>
&gt;<br>
&gt; mysql&gt; select * from usr_preferences;<br>
&gt; +----+------+------------+--------+---------------+------+------------+---------------------+<br>
&gt; | id | uuid | username   | domain | attribute     | type | value<br>
&gt; | last_modified       |<br>
&gt; +----+------+------------+--------+---------------+------+------------+---------------------+<br>
&gt; |  1 |      | 1234567890 |        | channels      |    0 | 3<br>
&gt; | 1900-01-01 00:00:01 |<br>
&gt; |  2 |      | 0          |        | called_number |    0 | 12135551234<br>
&gt; | 1900-01-01 00:00:01 |<br>
&gt; +----+------+------------+--------+---------------+------+------------+---------------------+<br>
&gt; 2 rows in set (0.00 sec)<br>
&gt;<br>
&gt; Unfortunately, I&#39;m not quite sure on what section or portion of<br>
&gt; opensips.cfg file I will have to put the loading of user preferences<br>
&gt; to the AVPs. Any inputs or suggestions will be greatly appreciated?<br>
&gt;<br>
&gt; Thank you very much.<br>
&gt;<br>
&gt; --conpaj--<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Jan 6, 2010 at 11:26 PM, Bogdan-Andrei Iancu<br>
</div><div class="im">&gt; &lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a> &lt;mailto:<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi Johnson,<br>
&gt;<br>
&gt;     The idea is to use dialog profiles to keep trace of the ongoing calls<br>
&gt;     (per resource). As a first step take a look at the following tutorial:<br>
&gt;<br>
&gt;            <a href="http://www.opensips.org/Resources/DocsTutConcurrentCalls" target="_blank">http://www.opensips.org/Resources/DocsTutConcurrentCalls</a><br>
&gt;<br>
&gt;     Regards,<br>
&gt;     Bogdan<br>
&gt;<br>
&gt;     Johnson Pajayat wrote:<br>
&gt;     &gt; Hi!<br>
&gt;     &gt;<br>
&gt;     &gt; I&#39;m a newbie with OpenSIPS administration and configuration and I<br>
&gt;     &gt; searched on the mail archives regarding limiting the channels<br>
&gt;     but only<br>
&gt;     &gt; found the site regarding &quot;Concurrent calls limitation&quot;. I&#39;ve been<br>
&gt;     &gt; trying to grasp the whole idea about AVPops and dialog module but<br>
&gt;     &gt; unfortunately I&#39;m having a hard time understanding it. If ever, does<br>
&gt;     &gt; anyone here be kind enough to point me to any available documents or<br>
&gt;     &gt; sample configurations file that will help me limit the channels on<br>
&gt;     &gt; inbound calls to a single or group of DIDs? Implementation will be<br>
&gt;     &gt; done static first and hopefully once I got the whole idea, will be<br>
&gt;     &gt; implementing a dynamic one.<br>
&gt;     &gt;<br>
&gt;     &gt; Thank you very much.<br>
&gt;     &gt;<br>
&gt;     &gt; --conpaj--<br>
&gt;<br>
<br>
<br>
--<br>
</div><div><div></div><div class="h5">Bogdan-Andrei Iancu<br>
<a href="http://www.voice-system.ro" target="_blank">www.voice-system.ro</a><br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br>