[SR-Users] ODP: cnxcc

2014-04-27 Thread Andrzej Ciupek
Yes. I want prepaid subscribers be able to create only one channel to prevent 
frauds for simultaneous calls.

Greetings
Andrzej Ciupek

Od: Carlos Ruiz Díazmailto:carlos.ruizd...@gmail.com
Wysłano: ‎2014-‎04-‎26 16:42
Do: Andrzej Ciupekmailto:andrzej.ciu...@hotmail.com
DW: Kamailio (SER) - Users Mailing Listmailto:sr-users@lists.sip-router.org
Temat: Re: [SR-Users] cnxcc

Hi Andrzej,

are you trying to setup cnxcc to check both credit and maximum simultaneous
calls?

Regards,



On Sat, Apr 26, 2014 at 9:26 AM, Andrzej Ciupek
andrzej.ciu...@hotmail.comwrote:

  Hello

 I’am using default config with options from an example. It looks like
 event route isn’t execuded after hangup.

 Apr 26 16:26:14 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:15 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:16 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:17 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:18 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:19 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 Setting up money based credit control
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 Setting up channel based credit control
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 CNXCC ROUTE: 1000 has 2 call(s)

 kamailio.cfg
 …
 …
 # - prepaid call controll -

 #!define DLG_FLAG 28
 #!define CC_FLAG 29

 loadmodule dialog.so

 modparam(dialog, hash_size, 2048)
 modparam(dialog, default_timeout, 3600)
 modparam(dialog, db_mode, 0)
 modparam(dialog, dlg_flag, DLG_FLAG)

 modparam(rtimer, timer, name=ta;interval=1;mode=1;)
 modparam(rtimer, exec, timer=ta;route=SHOW_CHANNEL_COUNT)

 loadmodule cnxcc.so

 modparam(cnxcc, dlg_flag, CC_FLAG)
 modparam(cnxcc, credit_check_period, 1) #check every 1 second

 …
 …
 …
 route {
 …
 …
  if (!allow_source_address(2) and !allow_source_address(1)){
 route(CNXCC);
 route(PSTN);
 }
 …
 }

 route[CNXCC]
 {

 $var(client)= 1000;

 xlog(L_INFO, Setting up money based credit control);

 $var(credit)= 10; # 10$ of credit
 $var(cost_per_sec)  = 1;  # 1$ per sec
 $var(i_pulse)   = 1;  # 1$ to establish the call
 $var(f_pulse)   = 1;  # 1$ per second

 # if only one call is established, that call should last 9 seconds.

 if (!cnxcc_set_max_credit($var(client),
   $var(credit),
   $var(cost_per_sec),
   $var(i_pulse),
   $var(f_pulse))) {
 xlog(Error setting up credit control);
 return;
 }
 $var(count) = -1;

 if (!cnxcc_get_channel_count($var(client), $var(count))) {
 xlog(Error getting customer's channel count);
 }

 xlog(L_INFO, CNXCC ROUTE: $var(client) has $var(count)
 call(s));

 if ($var(retcode)  -1) {
 xlog(Too many channels for customer);
 sl_send_reply(403, Forbidden);

 if (!cnxcc_terminate_all($var(client))) {
 xlog(Error terminating customer's calls);
 } else {
 xlog(Terminating customer's call);
 }

 exit;
 }
 }

 route[SHOW_CHANNEL_COUNT]
 {
 $var(count) = @cnxcc.channels[1000].count;
 xlog(L_INFO, 1000 has $var(count) call(s));
 }

 event_route[dialog:failed]
 {
 xlog(dialog failed);
 }

 event_route[cnxcc:call-shutdown]
 {
 xlog(L_INFO, Shutting down channel by callcontroll);
 xlog(L_INFO, [$ci]: call killed);
 $var(count) = $var(count)-1;
 if (!cnxcc_get_channel_count($var(client), $var(count))) {
 xlog(Error getting customer's channel count);
 }
 xlog(L_INFO, CNXCC ROUTE: $var(client) has $var(count)
 call(s));
 # perform some kind of notification, database update, email
 sending, etc
 }

 Greetings
 Andrzej Ciupek

 *Od:* Carlos Ruiz Díaz carlos.ruizd...@gmail.com
 *Wysłano:* ‎sobota‎, ‎26‎ ‎kwietnia‎ ‎2014 ‎15‎:‎19
 *Do:* Kamailio (SER) - Users Mailing List sr-users@lists.sip-router.org,
 Andrzej Ciupek andrzej.ciu...@hotmail.com

 Hi,

 sorry guys, I forgot about this. I will make my own tests and post the
 results.

 Andrzej, can you post the configuration file you are using?

 Regards,
 Carlos


 On Sat, Apr 26, 2014 at 4:15 AM, Kelvin Chua kel...@gmail.com wrote:

 No, I have not yet found 

Re: [SR-Users] cnxcc

2014-04-27 Thread Andrzej Ciupek
Hello


I’am using default config with options from an example. It looks like event 
route isn’t execuded after hangup.


Apr 26 16:26:14 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:15 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:16 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:17 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:18 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:19 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4611]: INFO: script: 1000 
has 1 call(s)
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script: 
Setting up money based credit control
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script: 
Setting up channel based credit control
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script: CNXCC 
ROUTE: 1000 has 2 call(s)



kamailio.cfg

…

…

# - prepaid call controll -


#!define DLG_FLAG 28
#!define CC_FLAG 29


loadmodule dialog.so
modparam(dialog, hash_size, 2048)
modparam(dialog, default_timeout, 3600)
modparam(dialog, db_mode, 0)
modparam(dialog, dlg_flag, DLG_FLAG)


modparam(rtimer, timer, name=ta;interval=1;mode=1;)
modparam(rtimer, exec, timer=ta;route=SHOW_CHANNEL_COUNT)


loadmodule cnxcc.so
modparam(cnxcc, dlg_flag, CC_FLAG)
modparam(cnxcc, credit_check_period, 1) #check every 1 second



…

…

…

route {

…

…

 if (!allow_source_address(2) and !allow_source_address(1)){
route(CNXCC);
route(PSTN);
}


…

}




route[CNXCC]
{


$var(client)= 1000;


xlog(L_INFO, Setting up money based credit control);


$var(credit)= 10; # 10$ of credit
$var(cost_per_sec)  = 1;  # 1$ per sec
$var(i_pulse)   = 1;  # 1$ to establish the call
$var(f_pulse)   = 1;  # 1$ per second


# if only one call is established, that call should last 9 seconds.


if (!cnxcc_set_max_credit($var(client),
  $var(credit),
  $var(cost_per_sec),
  $var(i_pulse),
  $var(f_pulse))) {
xlog(Error setting up credit control);
return;
}


$var(count) = -1;


if (!cnxcc_get_channel_count($var(client), $var(count))) {
xlog(Error getting customer's channel count);
}


xlog(L_INFO, CNXCC ROUTE: $var(client) has $var(count) call(s));


if ($var(retcode)  -1) {
xlog(Too many channels for customer);
sl_send_reply(403, Forbidden);


if (!cnxcc_terminate_all($var(client))) {
xlog(Error terminating customer's calls);
} else {
xlog(Terminating customer's call);
}


exit;
}
}


route[SHOW_CHANNEL_COUNT]
{
$var(count) = @cnxcc.channels[1000].count;
xlog(L_INFO, 1000 has $var(count) call(s));
}


event_route[dialog:failed]
{
xlog(dialog failed);
}


event_route[cnxcc:call-shutdown]
{
xlog(L_INFO, Shutting down channel by callcontroll);
xlog(L_INFO, [$ci]: call killed);
$var(count) = $var(count)-1;
if (!cnxcc_get_channel_count($var(client), $var(count))) {
xlog(Error getting customer's channel count);
}
xlog(L_INFO, CNXCC ROUTE: $var(client) has $var(count) call(s));
# perform some kind of notification, database update, email sending, etc
}





Greetings

Andrzej Ciupek





Od: Carlos Ruiz Díaz
Wysłano: ‎sobota‎, ‎26‎ ‎kwietnia‎ ‎2014 ‎15‎:‎19
Do: Kamailio (SER) - Users Mailing List, Andrzej Ciupek





Hi,



sorry guys, I forgot about this. I will make my own tests and post the results.




Andrzej, can you post the configuration file you are using?




Regards,

Carlos




On Sat, Apr 26, 2014 at 4:15 AM, Kelvin Chua kel...@gmail.com wrote:


No, I have not yet found the solution for this issue on my setup.

Maybe Carlos can help us out

On Apr 26, 2014 5:10 PM, Andrzej Ciupek andrzej.ciu...@hotmail.com wrote:





Hello

 

Have You solved this issue ?

I’am using Kamailio 4.1.3 and I’am getting the same results. 

 

Greetings

Andrzej Ciupek

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users






-- 

Carlos
http://caruizdiaz.com

http://ngvoice.com

+52 55 3048 3303___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org

Re: [SR-Users] DRouting, routeid is not triggered

2014-04-27 Thread Maciej Bylica
Hi Daniel,

It works... thanks alot for your help.

Mac.


2014-04-25 0:48 GMT+02:00 Maciej Bylica mb...@gazeta.pl:

 Hi Daniel,

 I am about to do this on Fri and will give you feedback soon.

 Thanks
 Mac.



  Can you try the patch from commit:

 -
 http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c3386295d7607a58d37a65b6822bf5f98b3fefa0

 If you are using git, do a git pull, then you can pick the commit in your
 branch (if you are not on master):

 git cherry-pick -x c3386295d7607a58d37a65b6822bf5f98b3fefa0

 Cheers,
 Daniel


 On 24/04/14 17:16, Daniel-Constantin Mierla wrote:

 Hello,

 busy with the release I didn't have time to troubleshoot more yet.

 Cheers,
 Daniel

 On 24/04/14 17:10, Maciej Bylica wrote:

 Hello

  Do you need any other data to verify?

  Thanks.


 2014-04-23 12:11 GMT+02:00 Maciej Bylica mb...@gazeta.pl:

 Hi Daniel,

  Here is debug you requested.

  DEBUG: core [parser/msg_parser.c:623]: parse_msg(): SIP Request:
 DEBUG: core [parser/msg_parser.c:625]: parse_msg(): ámethod: áINVITE
 DEBUG: core [parser/msg_parser.c:627]: parse_msg(): áuri: á á 
 sip:43111223344@10.10.10.5
 DEBUG: core [parser/msg_parser.c:629]: parse_msg(): áversion: SIP/2.0
 DEBUG: core [parser/parse_via.c:1284]: parse_via_param(): Found param
 type 235, rport = n/a; state=6
 DEBUG: core [parser/parse_via.c:1284]: parse_via_param(): Found param
 type 232, branch = z9hG4bKZZDHrKg1B4Q1c; state=16
 DEBUG: core [parser/parse_via.c:2672]: parse_via(): end of header
 reached, state=5
 DEBUG: core [parser/msg_parser.c:513]: parse_headers(): parse_headers:
 Via found, flags=2
 DEBUG: core [parser/msg_parser.c:515]: parse_headers(): parse_headers:
 this is the first via
 DEBUG: core [receive.c:152]: receive_msg(): After parse_msg...
 DEBUG: core [receive.c:193]: receive_msg(): preparing to run routing
 scripts...
 DEBUG: maxfwd [mf_funcs.c:85]: is_maxfwd_present(): value = 69
 DEBUG: maxfwd [maxfwd.c:161]: process_maxfwd_header(): value 69 decreased
 to 16
 DEBUG: core [parser/parse_addr_spec.c:893]: parse_addr_spec(): end of
 header reached, state=10
 DEBUG: core [parser/msg_parser.c:190]: get_hdr_field(): DEBUG:
 get_hdr_field: To [32]; uri=[sip:43111223344@10.10.10.5]
 DEBUG: core [parser/msg_parser.c:192]: get_hdr_field(): DEBUG: to body
 [sip:43111223344@10.10.10.5#015#012]
 DEBUG: core [parser/msg_parser.c:170]: get_hdr_field(): get_hdr_field:
 cseq CSeq: 58787375 INVITE
 DEBUG: core [parser/msg_parser.c:204]: get_hdr_field(): DEBUG:
 get_hdr_body : content_length=203
 DEBUG: core [parser/msg_parser.c:106]: get_hdr_field(): found end of
 header
 DEBUG: core [parser/parse_addr_spec.c:176]: parse_to_param(): DEBUG:
 add_param: tag=1eQFK719e4cyS
 DEBUG: core [parser/parse_addr_spec.c:893]: parse_addr_spec(): end of
 header reached, state=29
 DEBUG: sanity [mod_sanity.c:255]: w_sanity_check(): sanity checks result:
 1
 DEBUG: siputils [checks.c:103]: has_totag(): no


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] permanent 1.5 s timer interval in module pipelimit

2014-04-27 Thread Julia
Hello all,

 

Timer pl_timer in pipelimit.c is defined as MS_TO_TICKS(1500) instead of
timer_interval (in versions 3.3 - 4.1).

 

I found a patch that solves the same problem in the ratelimit module:

 

Module: sip-router
Branch: 3.1
Commit: f027ca95a2a1818cd40e4ed6d4358a76d18252ad
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f027ca9
5a2a1818cd40e4ed6d4358a76d18252ad
http://git.sip-router.org/cgi-bin/gitweb.cgi/...
 
Author: Marius Zbihlei 
Committer: Marius Zbihlei 
Date:   Mon Apr 11 13:45:10 2011 +0300
 
modules/ratelimit Timer was ran at a 1.5 s interval instead of
timer_interval, thus rendering TAILDROP alg unusable

(cherry picked from commit 3a06d7d3561f889c84249eaa5ec7a5b79a2a23bd)

 

 

Regards,

Julia

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Double attempt to record-route

2014-04-27 Thread Alex Balashov

On 09/26/2012 10:20 AM, Juha Heinanen wrote:


I tried to call record_route_preset() in branch route in order to add
contact specific RR headers when request is forked to more than one
contact.  What happened was that I got error message:

Sep 26 17:03:47 wheezy2 /usr/sbin/sip-proxy[2436]: ERROR: rr [rr_mod.c:256]: 
Duble attempt to record-route

Is it really so that record routing is not a branch specific thing?  Is
there a way to solve this problem?


I wonder what happens if you add a Record-Route header manually in the 
branch_route, with append_hf(), e.g.


   append_hf(Record-Route: sip:ip.of.proxy:5060\r\n);

--
Alex Balashov - Principal
Evariste Systems LLC
235 E Ponce de Leon Ave
Suite 106
Decatur, GA 30030
United States
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Double attempt to record-route

2014-04-27 Thread Juha Heinanen
Alex Balashov writes:

 I wonder what happens if you add a Record-Route header manually in the 
 branch_route, with append_hf(), e.g.
 
 append_hf(Record-Route: sip:ip.of.proxy:5060\r\n);

that would work, but is not that simple due to all kinds of r-r params
and socket that depend on many things.

but it looks like the contents of resulting r-r header are branch
specific, i.e., it is possible to call record_route() once in route
block and set r-r params and socket in branch route block.

-- juha



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] avp_db_load() fetch attribute ....

2014-04-27 Thread arun Jayaprakash
Can someone let me know how I can fetch an attribute depending on the value of 
two columns. For eg, in my usr_preference table I have 3 columns; 

username, domain, attribute. 

I need to fetch the attribute if the username = $ru and domain= $rd. Can 
someone let me know how this can be done, thanks.

Arun___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] avp_db_load() fetch attribute ....

2014-04-27 Thread Alex Balashov
Wouldn't you be better off just having your own tables and using your 
own SQL with 'sqlops'?


On 04/27/2014 06:12 PM, arun Jayaprakash wrote:


Can someone let me know how I can fetch an attribute depending on the
value of two columns. For eg, in my usr_preference table I have 3 columns;

username, domain, attribute.

I need to fetch the attribute if the username = $ru and domain= $rd. Can
someone let me know how this can be done, thanks.

Arun


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users




--
Alex Balashov - Principal
Evariste Systems LLC
235 E Ponce de Leon Ave
Suite 106
Decatur, GA 30030
United States
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] cnxcc

2014-04-27 Thread Carlos Ruiz Díaz
Hi Andrzej,

I found a deadlock situation using the script you posted, thanks to an
unusual way of using the functions that the module exports.

About the script itself: I found a few inconsistencies that would have
caused a problem with handing the calls even if there was no bug in the
software. For example:

- if you want to set the maximum amount of calls per user, use the function
cnxcc_set_max_channel

- the call-shutdown event route is only executed if the call runs out of
credit, never for normal call clearing. For that, use dialog:end or
dialog:failed instead.

- you cannot access $var(client) from outside the process that created
it. This means that when the call is killed, $var(client) will have a
NULL value since this event is processed by a completely different process.
If you want to have this information available everywhere, use a shared
memory variable instead ($sht).

I created a sample script [1] that applies your requirements in a slightly
different way:

- it authorizes the call by checking the balance
- it kills the call when the credit is over
- it doesn't allow more than one call per customer

[1] https://gist.github.com/caruizdiaz/11359122

In this example I used a shared memory variable, to give you an idea of how
to persist the customer's ID across processes.

Regards,
Carlos

-




On Sat, Apr 26, 2014 at 10:34 AM, Carlos Ruiz Díaz 
carlos.ruizd...@gmail.com wrote:

 I did find a bug, using your config script, I will fix it this weekend.
 Try with this configuration file [1].

 [1] https://gist.github.com/caruizdiaz/11323017

 In summary, you can't use more than one check mechanisms. It has to be
 credit, time or channels, exclusively.

 Also, I need to test your config with Kam 4.1. I am using the trunk
 version.

 Regards,


 On Sat, Apr 26, 2014 at 10:23 AM, Andrzej Ciupek 
 andrzej.ciu...@hotmail.com wrote:

  Yes. I want prepaid subscribers be able to create only one channel to
 prevent frauds for simultaneous calls.

 Greetings
 Andrzej Ciupek
  --
 Od: Carlos Ruiz Díaz carlos.ruizd...@gmail.com
 Wysłano: ‎2014-‎04-‎26 16:42
 Do: Andrzej Ciupek andrzej.ciu...@hotmail.com
 DW: Kamailio (SER) - Users Mailing List sr-users@lists.sip-router.org
 Temat: Re: [SR-Users] cnxcc

  Hi Andrzej,

  are you trying to setup cnxcc to check both credit and maximum
 simultaneous calls?

  Regards,



 On Sat, Apr 26, 2014 at 9:26 AM, Andrzej Ciupek 
 andrzej.ciu...@hotmail.com wrote:

  Hello

  I’am using default config with options from an example. It looks like
 event route isn’t execuded after hangup.

  Apr 26 16:26:14 kamailio /usr/local/sbin/kamailio[4611]: INFO:
 script: 1000 has 1 call(s)
 Apr 26 16:26:15 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:16 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:17 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:18 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:19 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 Setting up money based credit control
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 Setting up channel based credit control
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 CNXCC ROUTE: 1000 has 2 call(s)

  kamailio.cfg
 …
 …
 # - prepaid call controll -

  #!define DLG_FLAG 28
 #!define CC_FLAG 29

  loadmodule dialog.so

 modparam(dialog, hash_size, 2048)
 modparam(dialog, default_timeout, 3600)
 modparam(dialog, db_mode, 0)
 modparam(dialog, dlg_flag, DLG_FLAG)

  modparam(rtimer, timer, name=ta;interval=1;mode=1;)
 modparam(rtimer, exec, timer=ta;route=SHOW_CHANNEL_COUNT)

  loadmodule cnxcc.so

 modparam(cnxcc, dlg_flag, CC_FLAG)
 modparam(cnxcc, credit_check_period, 1) #check every 1 second

  …
 …
 …
 route {
 …
 …
  if (!allow_source_address(2) and !allow_source_address(1)){
 route(CNXCC);
 route(PSTN);
 }
  …
 }

  route[CNXCC]
 {

  $var(client)= 1000;

  xlog(L_INFO, Setting up money based credit control);

  $var(credit)= 10; # 10$ of credit
 $var(cost_per_sec)  = 1;  # 1$ per sec
 $var(i_pulse)   = 1;  # 1$ to establish the call
 $var(f_pulse)   = 1;  # 1$ per second

  # if only one call is established, that call should last 9
 seconds.

  if (!cnxcc_set_max_credit($var(client),
   $var(credit),
   $var(cost_per_sec),
   $var(i_pulse),
   $var(f_pulse))) {
 xlog(Error setting up credit control);
 

Re: [SR-Users] cnxcc

2014-04-27 Thread Carlos Ruiz Díaz
Kelvin,

can you update your copy and try again? Maybe your problem was related to
this, or maybe not. In either case, I will try to reproduce your issue
later this week :).

Regards,


On Sun, Apr 27, 2014 at 9:27 PM, Carlos Ruiz Díaz carlos.ruizd...@gmail.com
 wrote:

 Hi Andrzej,

 I found a deadlock situation using the script you posted, thanks to an
 unusual way of using the functions that the module exports.

 About the script itself: I found a few inconsistencies that would have
 caused a problem with handing the calls even if there was no bug in the
 software. For example:

 - if you want to set the maximum amount of calls per user, use the
 function cnxcc_set_max_channel

 - the call-shutdown event route is only executed if the call runs out of
 credit, never for normal call clearing. For that, use dialog:end or
 dialog:failed instead.

 - you cannot access $var(client) from outside the process that created
 it. This means that when the call is killed, $var(client) will have a
 NULL value since this event is processed by a completely different process.
 If you want to have this information available everywhere, use a shared
 memory variable instead ($sht).

 I created a sample script [1] that applies your requirements in a slightly
 different way:

 - it authorizes the call by checking the balance
 - it kills the call when the credit is over
 - it doesn't allow more than one call per customer

 [1] https://gist.github.com/caruizdiaz/11359122

 In this example I used a shared memory variable, to give you an idea of
 how to persist the customer's ID across processes.

 Regards,
 Carlos

 -




 On Sat, Apr 26, 2014 at 10:34 AM, Carlos Ruiz Díaz 
 carlos.ruizd...@gmail.com wrote:

 I did find a bug, using your config script, I will fix it this weekend.
 Try with this configuration file [1].

 [1] https://gist.github.com/caruizdiaz/11323017

 In summary, you can't use more than one check mechanisms. It has to be
 credit, time or channels, exclusively.

 Also, I need to test your config with Kam 4.1. I am using the trunk
 version.

 Regards,


 On Sat, Apr 26, 2014 at 10:23 AM, Andrzej Ciupek 
 andrzej.ciu...@hotmail.com wrote:

  Yes. I want prepaid subscribers be able to create only one channel to
 prevent frauds for simultaneous calls.

 Greetings
 Andrzej Ciupek
  --
 Od: Carlos Ruiz Díaz carlos.ruizd...@gmail.com
 Wysłano: ‎2014-‎04-‎26 16:42
 Do: Andrzej Ciupek andrzej.ciu...@hotmail.com
 DW: Kamailio (SER) - Users Mailing List sr-users@lists.sip-router.org
 Temat: Re: [SR-Users] cnxcc

  Hi Andrzej,

  are you trying to setup cnxcc to check both credit and maximum
 simultaneous calls?

  Regards,



 On Sat, Apr 26, 2014 at 9:26 AM, Andrzej Ciupek 
 andrzej.ciu...@hotmail.com wrote:

  Hello

  I’am using default config with options from an example. It looks like
 event route isn’t execuded after hangup.

  Apr 26 16:26:14 kamailio /usr/local/sbin/kamailio[4611]: INFO:
 script: 1000 has 1 call(s)
 Apr 26 16:26:15 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:16 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:17 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:18 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:19 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4611]: INFO: script:
 1000 has 1 call(s)
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 Setting up money based credit control
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 Setting up channel based credit control
 Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: script:
 CNXCC ROUTE: 1000 has 2 call(s)

  kamailio.cfg
 …
 …
 # - prepaid call controll -

  #!define DLG_FLAG 28
 #!define CC_FLAG 29

  loadmodule dialog.so

 modparam(dialog, hash_size, 2048)
 modparam(dialog, default_timeout, 3600)
 modparam(dialog, db_mode, 0)
 modparam(dialog, dlg_flag, DLG_FLAG)

  modparam(rtimer, timer, name=ta;interval=1;mode=1;)
 modparam(rtimer, exec, timer=ta;route=SHOW_CHANNEL_COUNT)

  loadmodule cnxcc.so

 modparam(cnxcc, dlg_flag, CC_FLAG)
 modparam(cnxcc, credit_check_period, 1) #check every 1 second

  …
 …
 …
 route {
 …
 …
  if (!allow_source_address(2) and !allow_source_address(1)){
 route(CNXCC);
 route(PSTN);
 }
  …
 }

  route[CNXCC]
 {

  $var(client)= 1000;

  xlog(L_INFO, Setting up money based credit control);

  $var(credit)= 10; # 10$ of credit
 $var(cost_per_sec)  = 1;  # 1$ per sec
 $var(i_pulse)   = 1;  # 1$ to establish the call
 $var(f_pulse)   = 1;  # 1$ per second

  # if only one call is established, that call should last 9
 seconds.

  if