[OpenSIPS-Users] when does a var goes out of scope.

johan johan at democon.be
Wed Sep 2 10:35:37 EST 2020


As you can see I use dialpan to strip 0,00 or + from fU result is $var(fU).

I seem to get strange and incomprehensible results :

Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]: 
callid=7ocl48d3Gi: Route[normalizeforoutbound]: we change rU +3315 to 
E.164; as the call is outbound, base is fU 33757935187
Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]: 
callid=7ocl48d3Gi: Route[normalizeforoutbound]: we drop 0,00,+ from 
33757935187, result is var(fU)
Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]: 
callid=7ocl48d3Gi: Route[normalizeforoutbound]: result dp_translate 
var(fU) +32460200570

As you can see in the script snippet, $var(fU) is not initialized.


So : would initialization of var(fU) to '' solve my issue.

As a more general question : when does a variable goes excatly out of 
scope ?



dialplan:

*************************** 1. row ***************************
          id: 4
        dpid: 1
          pr: 1
    match_op: 1
   match_exp: ^(00|\+|0).*
match_flags: 0
   subst_exp: ^(00|\+|0)(.*)
    repl_exp: \2
     timerec: NULL
    disabled: 0
       attrs:

script :

route[normalizeforoutbound]
{
     xlog("callid=$ci: Route[normalizeforoutbound]: we change rU $rU to 
E.164; as the call is outbound, base is fU $fU");
     xlog("callid=$ci: Route[normalizeforoutbound]: we drop 0,00,+ from 
$fU, result is var(fU)");
     $var(i)=1;
     dp_translate($(var(i){s.int}),"$fU",$var(fU));
     if ($var(fU)==NULL or $var(fU)=='' or $var(fU)=='<null>')
     {
         xlog("callid=$ci: Route[normalizeforoutbound]: result 
dp_translate var(fU) $var(fU) == NULL -> from header fU $fU has correct 
format, we use fU $fU in query");
         avp_db_query("SELECT country,channels FROM subscriber where 
username like '%$fU'","$avp(countryoutbound);$avp(channels)");
         xlog("callid=$ci: Route[normalizeforoutbound]: SELECT 
country,channels FROM subscriber where username like '%$fU'  -> 
avp(countryoutbound) $avp(countryoutbound), avp(channels) $avp(channels) ");
     }
     else
     {
         xlog("callid=$ci: Route[normalizeforoutbound]: result 
dp_translate var(fU) $var(fU) -> from header fu $fU has incorrect 
format, we use var(fU) $var(fU) in query");
         avp_db_query("SELECT country,channels FROM subscriber where 
username like '%$var(fU)'","$avp(countryoutbound);$avp(channels)");
         xlog("callid=$ci: Route[normalizeforoutbound]: SELECT 
country,channels FROM subscriber where username like '%$var(fU)' -> 
avp(countryoutbound) $avp(countryoutbound), avp(channels) $avp(channels) ");
     }


output:

Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]: 
callid=7ocl48d3Gi: Route[normalizeforoutbound]: we change rU +3315 to 
E.164; as the call is outbound, base is fU 33757935187
Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]: 
callid=7ocl48d3Gi: Route[normalizeforoutbound]: we drop 0,00,+ from 
33757935187, result is var(fU)
Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]: 
callid=7ocl48d3Gi: Route[normalizeforoutbound]: result dp_translate 
var(fU) +32460200570 -> from header fu 33757935187 has incorrect format, 
we use var(fU) +32460200570 in query




More information about the Users mailing list