Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
Cibin,
Yes, that is what $RANDOM is for. It returns a 32-bit signed integer (range 0 - 2^31), so you can divide it by the appropriate value to get something in the length range you're after. -- Alex Balashov | Principal | Evariste Systems LLC 1447 Peachtree Street NE, Suite 700 Atlanta, GA 30309 United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Sent from my BlackBerry.
Thanks a lot Alex,
Now using this random generated number, can I modify the ANI something like this on INVITE
if(!($fU=~"^(+1|1[1-9][0-9]{10})$")) { $fU = ($RANDOM / 73249615); }
Regards Cibin
On 22-Mar-2016, at 12:28 PM, Alex Balashov abalashov@evaristesys.com wrote:
Cibin,
Yes, that is what $RANDOM is for. It returns a 32-bit signed integer (range 0 - 2^31), so you can divide it by the appropriate value to get something in the length range you're after. -- Alex Balashov | Principal | Evariste Systems LLC 1447 Peachtree Street NE, Suite 700 Atlanta, GA 30309 United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Sent from my BlackBerry.
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
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
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
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
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
-- Daniel-Constantin Mierla http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.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
On 22/03/16 08:40, Cibin Paul wrote:
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
I didn't say that app_lua is faster than $RANDOM -- what I said is that app_lua is also fast.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Yes, look also at uac module for functions to replace From URI.
Cheers, Daniel
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
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
-- Daniel-Constantin Mierla http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.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
Thanks Daniel for the pointer. I will check both modules
Regards Cibin
On 22-Mar-2016, at 1:13 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
On 22/03/16 08:40, Cibin Paul wrote:
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
I didn't say that app_lua is faster than $RANDOM -- what I said is that app_lua is also fast.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Yes, look also at uac module for functions to replace From URI.
Cheers, Daniel
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
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
-- Daniel-Constantin Mierla http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.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
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com http://www.kamailioworld.com/
Daniel,
I tried using $RANDOM. It is always giving a random value between 9 digits to 10 digits How can I get a random value between 10 digits to 13 digits.
Regards Cibin
On 22-Mar-2016, at 1:19 PM, Cibin Paul paul_cibin@me.com wrote:
Thanks Daniel for the pointer. I will check both modules
Regards Cibin
On 22-Mar-2016, at 1:13 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
On 22/03/16 08:40, Cibin Paul wrote:
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
I didn't say that app_lua is faster than $RANDOM -- what I said is that app_lua is also fast.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Yes, look also at uac module for functions to replace From URI.
Cheers, Daniel
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.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
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com http://www.kamailioworld.com/
The problem is not with RANDOM. $fU is not taking more than 10 digit number. What could be the reason?
$var(x) = 123456789012;
$fU = $var(x); uac_replace_from("$var(x)","”);
The above code is assigning cli with 2147483647. Could you please help me on this
Regards Cibin
On 23-Mar-2016, at 3:33 PM, Cibin Paul paul_cibin@me.com wrote:
Daniel,
I tried using $RANDOM. It is always giving a random value between 9 digits to 10 digits How can I get a random value between 10 digits to 13 digits.
Regards Cibin
On 22-Mar-2016, at 1:19 PM, Cibin Paul paul_cibin@me.com wrote:
Thanks Daniel for the pointer. I will check both modules
Regards Cibin
On 22-Mar-2016, at 1:13 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
On 22/03/16 08:40, Cibin Paul wrote:
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
I didn't say that app_lua is faster than $RANDOM -- what I said is that app_lua is also fast.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Yes, look also at uac module for functions to replace From URI.
Cheers, Daniel
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
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
-- Daniel-Constantin Mierla http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.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
-- Daniel-Constantin Mierla http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.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
On Wed, Mar 23, 2016 at 04:49:09PM +0530, Cibin Paul wrote:
$var(x) = 123456789012;
$fU = $var(x); uac_replace_from("$var(x)","”);
The above code is assigning cli with 2147483647. Could you please help me on this
Seeing the value 2147483647 should trigger some neurons (it is 2^31-1) from now on.
You are looking at the wrapping of signed 32bit integers where 2^31-1 is the max value. The workaround for these kind of problems is handling the values as string instead of integers/longs/whatever numeric with contrained storage space (like Daniel suggested).
The $random gives an integer value, so max length is 10. Actually, vars in config file can be either integer or string. If you want a larger length you can build it as tring from two other random values. Like:
$var(r1) = $RANDOM; $var(r2) = $RANDOM;
$var(largerandom) = "" + $var(r1) + $var(r2);
Note the empty string "" used as first element in the right side of the above assignment -- that will make the result to be string, otherwise will be another int, rounded after overflow.
To get string from concatenating two integers you can use alternatives as pv_printf(...) or $_s(...).
Cheers, Daniel
On 23/03/16 11:03, Cibin Paul wrote:
Daniel,
I tried using $RANDOM. It is always giving a random value between 9 digits to 10 digits How can I get a random value between 10 digits to 13 digits.
Regards Cibin
On 22-Mar-2016, at 1:19 PM, Cibin Paul <paul_cibin@me.com mailto:paul_cibin@me.com> wrote:
Thanks Daniel for the pointer. I will check both modules
Regards Cibin
On 22-Mar-2016, at 1:13 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
On 22/03/16 08:40, Cibin Paul wrote:
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
I didn't say that app_lua is faster than $RANDOM -- what I said is that app_lua is also fast.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Yes, look also at uac module for functions to replace From URI.
Cheers, Daniel
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote:
Hi,
How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise
Regards Cibin
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#%21/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#%21/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016
Perfect. That solved my issue. You are saviour
Thanks & Regards Cibin
On 23-Mar-2016, at 4:49 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
The $random gives an integer value, so max length is 10. Actually, vars in config file can be either integer or string. If you want a larger length you can build it as tring from two other random values. Like:
$var(r1) = $RANDOM; $var(r2) = $RANDOM;
$var(largerandom) = "" + $var(r1) + $var(r2);
Note the empty string "" used as first element in the right side of the above assignment -- that will make the result to be string, otherwise will be another int, rounded after overflow.
To get string from concatenating two integers you can use alternatives as pv_printf(...) or $_s(...).
Cheers, Daniel
On 23/03/16 11:03, Cibin Paul wrote:
Daniel,
I tried using $RANDOM. It is always giving a random value between 9 digits to 10 digits How can I get a random value between 10 digits to 13 digits.
Regards Cibin
On 22-Mar-2016, at 1:19 PM, Cibin Paul < mailto:paul_cibin@me.compaul_cibin@me.com mailto:paul_cibin@me.com> wrote:
Thanks Daniel for the pointer. I will check both modules
Regards Cibin
On 22-Mar-2016, at 1:13 PM, Daniel-Constantin Mierla < mailto:miconda@gmail.commiconda@gmail.com mailto:miconda@gmail.com> wrote:
On 22/03/16 08:40, Cibin Paul wrote:
Thanks Daniel,
I will try app_lua as you said this being faster compared to $RANDOM.
I didn't say that app_lua is faster than $RANDOM -- what I said is that app_lua is also fast.
Now if I want to modify the caller id number (ANI) , can I assign the newly generated number to the variable $fU?
Yes, look also at uac module for functions to replace From URI.
Cheers, Daniel
Regards Cibin
On 22-Mar-2016, at 12:50 PM, Daniel-Constantin Mierla < mailto:miconda@gmail.commiconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello,
besides $RANDOM from cfgutils as pointed already, you can use an embedded interpreter (e.g., app_lua is really fast).
If you need some unique values, but not only numbers, see uuid module.
Cheers, Daniel
On 22/03/16 07:54, Cibin Paul wrote: > Hi, > > How can I generate a random number say of length 10-14 in Kamailio. Can I use cfgutils for this. Please advise > > Regards > Cibin > > > > _______________________________________________ > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list > sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#%21/miconda - http://www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com http://www.kamailioworld.com/
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#%21/miconda - http://www.linkedin.com/in/micondahttp://www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com/http://www.kamailioworld.com http://www.kamailioworld.com/
-- Daniel-Constantin Mierla http://www.asipto.com http://www.asipto.com/ http://twitter.com/#!/miconda http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com http://www.kamailioworld.com/