[SR-Users] max_contacts

Daniel-Constantin Mierla miconda at gmail.com
Tue Sep 13 17:21:14 CEST 2011


Hello,

On 9/13/11 5:04 PM, Rafael Rincon wrote:
> Hello Daniel,
>
> per user basis will be great!
changing global value at runtime is possible in 3.1 via config parameter 
reload framework.

For a per user value, you can script it in config, but starting with 
version 1.5, using pseudo-variable class $ul(...):
http://kamailio.org/docs/modules/1.5.x/registrar.html#id3057709

It should look like (well, config for 3.1, but should be valid for :

     # Check if maximum registered contacts per aor exceeded - limit 
value in $avp(max_regs)
     if (reg_fetch_contacts("location", "$tu", "reg"))
     {
         $var(i) = 0;
         $var(found) = 0;
         if($ulc(reg=>count)>0 && is_present_hf("Contact")) {
             $var(contact) = $(ct{tobody.uri});
             while($var(found) == 0 && $var(i) < $ulc(reg=>count)) {
                 if($var(contact)==$(ulc(reg=>addr)[$var(i)]))
                     $var(found) = 1;
                 else
                     $var(i) = $var(i) + 1;
             }
         }
         if ($var(found) == 0 && is_present_hf("Contact")) {
             # - check against max val
             if($ulc(reg=>count)>=$avp(max_regs))
             {
                 # too many registrations
                 sl_send_reply("403", "Too Many Registrations");
                 exit;
             }
         }
     }

The idea is: fetch the contacts and iterate through it to match the 
address. If there is no match, then it is a new contact and check 
against the limit.

Hope it helps!

Cheers,
Daniel

>
> Rafael Rincon
> rrincon at ipcomnetwork.com
> +13054772902 x 111
>
> On Sep 13, 2011, at 11:00 AM, Daniel-Constantin Mierla wrote:
>
>> Hello,
>>
>> On 9/13/11 4:43 PM, Rafael Rincon wrote:
>>> Hello Guys,
>>>
>>> Is there any chance to modify at running time (in a register event) the max_contacts parameter?
>>> I am running OpenSER version 1.4 .
>> if you refer to registrar module parameter max_contacts, no it is not possible. Are you looking to change its value globally or you want it more like per user value?
>>
>> Cheers,
>> Daniel
>>
>> -- 
>> Daniel-Constantin Mierla -- http://www.asipto.com
>> Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kat
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>>
>>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list