[SR-Users] Important problem with this test : if ($var(i:maxRangeInx)==$null)

Ginhoux, Patrick patrick.ginhoux at fr.unisys.com
Mon Mar 27 16:07:29 CEST 2017


Great thanks to answer so quickly.

I tested the $vn ….in the 5.0.x script instead of $var…., and the results look good.

So I have to review the entire script to change all the ‘$var…. == $null’ entries to ‘$vn…. == $null’. I assume I have to do the same for the ‘!= $null” case. Am I correct ?

Now regarding my old kamailio 3.3.1 script, I notice that the ‘$var…. == $null’ works fine but no more with kamailio 5.0.x . So It’s something that has changed more recently. The 3.3.1 cookbooks doesn’t reference a ‘$vn’ variable.
But may be I misread it.

So if you have comments on this for my understanding, that would be fine.


De : sr-users [mailto:sr-users-bounces at lists.sip-router.org] De la part de Daniel-Constantin Mierla
Envoyé : lundi 27 mars 2017 15:31
À : Kamailio (SER) - Users Mailing List <sr-users at lists.sip-router.org>
Objet : Re: [SR-Users] Important problem with this test : if ($var(i:maxRangeInx)==$null)


$var(...) don't hold null values, they start initialed to 0 and they are reset to 0 (when assigning $null to them) -- this is the design from the beginning which brings benefits in many situation when one doesn't get a chance to init.

If you want a similar variable that works with null, then use $vn(...):

  - https://www.kamailio.org/wiki/cookbooks/5.0.x/pseudovariables#vn_name_-_private_memory_variables_null


On 27/03/2017 15:22, Ginhoux, Patrick wrote:

I’m continue my job to ‘migrate’ my 3.3.1 kamailio.cfg script on a RHEL 6.2 server to the 5.0.x kamailio version on a RHEL 7.1 server, and I encounter a major problem with the ‘== $null’ test in the script.

My original script (3.3.1) contains this sequence :

        $var(i:maxRangeInx) = $sht(mbxrangeHash=>"maxrange");
        xlog(" imbxRangeInx value before test : '$var(i:maxRangeInx)' ");
        if ($var(i:maxRangeInx)==$null) {
        xlog(" imbxRangeInx after test : '$var(i:maxRangeInx)' ");

==> The results are :
imbxRangeInx value before test : ‘0’
imbxRangeInx value after test : ‘99’

I run the same script on my new server and I get ‘0’ before and after the test.

I attempted another kind of test to try to figure out where the problem is. So I write the simple test (with kamailio 5.0.x) :

        $var(i:maxRangeInx) = $sht(mbxrangeHash=>"maxrange");
        $var(toto) = $null;
        if ($var(toto) == $null)
                xlog ("toto true");
                xlog ("toto false");

The result I got is always ‘toto false’.

So it appears to me that the test ‘== $null’ doens’ that gives a good result with kamailio 3.3.1, doesn’t return the same with kamailio 5.0.x.

That is a major issue for me and it let me confused about the possibility to move to kamailio 5.0.x.

Have people an idea / explanation, why this issue ?



SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list

sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>



Daniel-Constantin Mierla

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com<http://www.asipto.com>

Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com<http://www.kamailioworld.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20170327/2cea5c07/attachment.html>

More information about the sr-users mailing list