Not a really important question, just an observation that caused some headscratching on my first day after a nice vacation.
I'm using an avp to make a redirect decision. Normally this avp contains Dutch telephone numbers (+31[0-9]{7,10}). With a simple: if($avp(dst_redirectnumber)) { #change $ru } this works flawless (normally).
But a client decided, to forward to a Swiss number (+4141743xxxx) but with this number the if condition results in a false. A German number just works fine (+49)
The avp is stuffed in an avp_db_query loop with $avp($avp(i:1))=$avp(i:2) as key/value pair from the table.
I changed above condition to check if the string length of dst_redirectnumber is larger than 0. But I'm at a loss why the false occurs, first guess was an octal conversion (number only contains the digits 0-7) which results in a number "just" above 2^32. But changing a digit to 8 still fails.
Forgot to mention this is version 4.1.3.
On 01/05/2015 04:19 PM, Daniel Tryba wrote:
Not a really important question, just an observation that caused some headscratching on my first day after a nice vacation.
I'm using an avp to make a redirect decision. Normally this avp contains Dutch telephone numbers (+31[0-9]{7,10}). With a simple: if($avp(dst_redirectnumber)) { #change $ru } this works flawless (normally).
But a client decided, to forward to a Swiss number (+4141743xxxx) but with this number the if condition results in a false. A German number just works fine (+49)
The avp is stuffed in an avp_db_query loop with $avp($avp(i:1))=$avp(i:2) as key/value pair from the table.
I changed above condition to check if the string length of dst_redirectnumber is larger than 0. But I'm at a loss why the false occurs, first guess was an octal conversion (number only contains the digits 0-7) which results in a number "just" above 2^32. But changing a digit to 8 still fails.
Check http://www.kamailio.org/docs/modules/4.1.x/modules/siputils.html#siputils.f....
On Monday 05 January 2015 18:57:00 Victor Seva wrote:
Check http://www.kamailio.org/docs/modules/4.1.x/modules/siputils.html#siputils.f .is_e164
Thanks for the pointer but the value doesn't necesarrily contain e164 numbers, for example the value might contain the Dutch harmonized carrier voicemail number (1233).
My question/observation is why are "+31xxxxxxxxx" or "+49xxxxxxxxx" considered true and "+41xxxxxxxxx" evaluated false?
On 06/01/15 10:21, Daniel Tryba wrote:
On Monday 05 January 2015 18:57:00 Victor Seva wrote:
Check http://www.kamailio.org/docs/modules/4.1.x/modules/siputils.html#siputils.f .is_e164
Thanks for the pointer but the value doesn't necesarrily contain e164 numbers, for example the value might contain the Dutch harmonized carrier voicemail number (1233).
My question/observation is why are "+31xxxxxxxxx" or "+49xxxxxxxxx" considered true and "+41xxxxxxxxx" evaluated false?
If it gets over 2^31, it becomes negative and when not an explicit logical expression, there are the rules with negative response code is false and positive is true.
You can use 'defined' or pv_is_set() to test if an avp has a value.
Cheers, Daniel
On Monday 05 January 2015 16:19:51 Daniel Tryba wrote:
I'm using an avp to make a redirect decision. Normally this avp contains
Dutch
telephone numbers (+31[0-9]{7,10}). With a simple: if($avp(dst_redirectnumber)) {
"if" statements only handle boolean conditions. An avp value does not result in a boolean, but a string or integer. You should compare the avp to a specific string or integer value (or $null), or use pv_isset().
(This is since the migration from kamailio 1.5 to sip-router).