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'm thinking of implementing a "while loop" and "counter" 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 "while loop" and "counter" 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"><<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>></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">> Hello Bogdan,<br>
><br>
> I appreciate a lot your response regarding my inquiry. I've been<br>
> reading that tutorial as well as the AVPops and dialog modules<br>
> documentation for about a month now. I tried to adapt that route block<br>
> for inbound calls and here's a portion of what I have on our OpenSIPS<br>
> 1.5 config file:<br>
><br>
> -------------------------------------------------------------------------------<br>
> modparam("dialog", "dlg_flag", 4)<br>
> modparam("dialog", "profiles_with_value", "inbound")<br>
><br>
> ......<br>
><br>
> } else if (uri=~"sip:1234567890@.*") {<br>
> route(3);<br>
> rewritehost("111.222.111.222");<br>
><br>
> .......<br>
><br>
> route[3]<br>
> {<br>
> ## have we done our checking on this call?<br>
> if(!isflagset(31))<br>
> {<br>
> # user has max channel limit set as preference<br>
> if(is_avp_set("$avp(s:channels)/n") &&<br>
> avp_check("$avp(s:channels)", "gt/i:0"))<br>
> {<br>
> # get the current calls for DID<br>
> get_profile_size("inbound","$tU","$var(calls)");<br>
><br>
> # check within limit<br>
> if($avp(s:channels) > $var(calls))<br>
> {<br>
> xlog("L_INFO", "Call control: DID<br>
> '$tU' currently has<br>
> '$var(calls)' of '$avp(s:channels)'<br>
> active calls before this one\n");<br>
> $var(setprofile) = 1;<br>
> }<br>
> else<br>
> {<br>
> xlog("L_INFO", "Call control: DID<br>
> '$tU' channel limit exceeded [$var(calls)/$avp(s:channels)]<br>
> \n");<br>
> send_reply("487", "Request Terminated:<br>
> Channel limit exceeded\n");<br>
> exit;<br>
> }<br>
> }<br>
> else<br>
> {<br>
> $var(setprofile) = 0;<br>
> }<br>
><br>
> call_control();<br>
><br>
> switch ($retcode)<br>
> {<br>
> case 2:<br>
> # Call with no limit<br>
> case 1:<br>
> # Call with a limit under callcontrol<br>
> management (either prepaid or postpaid)<br>
> break;<br>
> case -1:<br>
> # Not enough credit (prepaid call)<br>
> xlog("L_INFO", "Call control: not<br>
> enough credit for prepaid call\n");<br>
> acc_rad_request("402");<br>
> sl_send_reply("402", "Not enough credit");<br>
> exit;<br>
> break;<br>
> case -2:<br>
> # Locked by call in progress (prepaid<br>
> call)<br>
> xlog("L_INFO", "Call control: prepaid<br>
> call locked by another call in progress\n");<br>
> acc_rad_request("403");<br>
> sl_send_reply("403", "Call locked by<br>
> another call in progress");<br>
> exit;<br>
> break;<br>
> default:<br>
> # Internal error (message parsing,<br>
> communication, ...)<br>
> xlog("L_INFO", "Call control: internal<br>
> server error\n");<br>
> acc_rad_request("500");<br>
> sl_send_reply("500", "Internal server<br>
> error");<br>
> exit;<br>
> }<br>
><br>
> if($var(setprofile) > 0)<br>
> {<br>
> create_dialog();<br>
> set_dlg_profile("inbound","$tU");<br>
> }<br>
><br>
> ## mark checking done<br>
> setflag(31);<br>
> }<br>
> }<br>
><br>
> ----------------------------------------------------------------<br>
><br>
> And here are the logs appearing on /var/log/messages:<br>
><br>
> Jan 6 05:53:22 opensips cdrtool[20998]: MaxSessionTime Duration=36000<br>
> CallId=<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a><br>
</div></div>> <mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a>> From=si<br>
> <a href="mailto:p%3A12135551234@124.123.234.229">p:12135551234@124.123.234.229</a> <mailto:<a href="mailto:p%253A12135551234@124.123.234.229">p%3A12135551234@124.123.234.229</a>><br>
<div class="im">> Gateway=124.123.234.229 To=sip:1234567890@124.123.234.241:5060;user=phone<br>
> Jan 6 05:53:22 opensips cdrtool[20998]: MaxSessionTime=unlimited<br>
> Type=postpaid CallId=<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a><br>
</div>> <mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@124.123.234.229">28a35ce1-4d7a175-25a58684@124.123.234.229</a>><br>
<div class="im">> BillingParty=<a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a><br>
</div>> <mailto:<a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a>><br>
<div class="im">> Jan 6 05:53:22 opensips call-control[21263]: Call id<br>
> <a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a><br>
</div>> <mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a>> of<br>
> <a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a> <mailto:<a href="mailto:12135551234@124.123.234.229">12135551234@124.123.234.229</a>> to<br>
<div class="im">> sip:1234567890@124.123.234.241:5060;user=phone is postpaid not limited<br>
> Jan 6 05:53:22 opensips /usr/local/sbin/opensips[1636]: new branch at<br>
> sip:1234567890@111.222.111.222:5060;user=phone<br>
> Jan 6 05:53:22 opensips /usr/local/sbin/opensips[1640]: incoming reply<br>
> Jan 6 05:53:22 opensips /usr/local/sbin/opensips[1636]: incoming reply<br>
> Jan 6 05:53:22 opensips /usr/local/sbin/opensips[1636]: ACC:<br>
> transaction answered: timestamp=1262786002;method=INVITE;from_t<br>
> 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>> <mailto:<a href="mailto:28a35ce1-4d7a175-25a58684@64.77.234.229">28a35ce1-4d7a175-25a58684@64.77.234.229</a>>;code=200;reason=OK<br>
<div class="im">> Jan 6 05:53:22 opensips /usr/local/sbin/opensips[1637]: Recive call<br>
> variable : <null> <null><br>
><br>
> As for the channels limit value, do I have to define it on<br>
> usr_preferences table? I have these records on the said table:<br>
><br>
> mysql> select * from usr_preferences;<br>
> +----+------+------------+--------+---------------+------+------------+---------------------+<br>
> | id | uuid | username | domain | attribute | type | value<br>
> | last_modified |<br>
> +----+------+------------+--------+---------------+------+------------+---------------------+<br>
> | 1 | | 1234567890 | | channels | 0 | 3<br>
> | 1900-01-01 00:00:01 |<br>
> | 2 | | 0 | | called_number | 0 | 12135551234<br>
> | 1900-01-01 00:00:01 |<br>
> +----+------+------------+--------+---------------+------+------------+---------------------+<br>
> 2 rows in set (0.00 sec)<br>
><br>
> Unfortunately, I'm not quite sure on what section or portion of<br>
> opensips.cfg file I will have to put the loading of user preferences<br>
> to the AVPs. Any inputs or suggestions will be greatly appreciated?<br>
><br>
> Thank you very much.<br>
><br>
> --conpaj--<br>
><br>
><br>
> On Wed, Jan 6, 2010 at 11:26 PM, Bogdan-Andrei Iancu<br>
</div><div class="im">> <<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a> <mailto:<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>>> wrote:<br>
><br>
> Hi Johnson,<br>
><br>
> The idea is to use dialog profiles to keep trace of the ongoing calls<br>
> (per resource). As a first step take a look at the following tutorial:<br>
><br>
> <a href="http://www.opensips.org/Resources/DocsTutConcurrentCalls" target="_blank">http://www.opensips.org/Resources/DocsTutConcurrentCalls</a><br>
><br>
> Regards,<br>
> Bogdan<br>
><br>
> Johnson Pajayat wrote:<br>
> > Hi!<br>
> ><br>
> > I'm a newbie with OpenSIPS administration and configuration and I<br>
> > searched on the mail archives regarding limiting the channels<br>
> but only<br>
> > found the site regarding "Concurrent calls limitation". I've been<br>
> > trying to grasp the whole idea about AVPops and dialog module but<br>
> > unfortunately I'm having a hard time understanding it. If ever, does<br>
> > anyone here be kind enough to point me to any available documents or<br>
> > sample configurations file that will help me limit the channels on<br>
> > inbound calls to a single or group of DIDs? Implementation will be<br>
> > done static first and hopefully once I got the whole idea, will be<br>
> > implementing a dynamic one.<br>
> ><br>
> > Thank you very much.<br>
> ><br>
> > --conpaj--<br>
><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>