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