From miconda@gmail.com Tue Apr 10 10:07:54 2012 From: Daniel-Constantin Mierla To: sr-users@lists.kamailio.org Subject: Re: [SR-Users] Variable $fu Kamailio 3.2 Date: Tue, 10 Apr 2012 10:07:46 +0200 Message-ID: <4F83EA52.10606@gmail.com> In-Reply-To: <35kconpg57asdogeca73g13h.1334023536029@email.android.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0191730194==" --===============0191730194== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hello, On 4/10/12 4:05 AM, Alex Balashov wrote: > $fu is not mutable. actually it is starting with v3.2.0. But it is not visible in the script, like the other operations performed on the headers -- they operations are kept as a diff (patch) list, not applied immediately. So, you will see the new From header when the message is sent to the network, before that is the original value. You can use msg_apply_changes() to make the changes visible immediately. Cheers, Daniel > > -- > Alex Balashov - Principal > Evariste Systems LLC > 235 E Ponce de Leon Ave > Suite 106 > Decatur, GA 30030 > Tel: +1-678-954-0670 > Fax: +1-404-961-1892 > Web: http://www.evaristesys.com/, http://www.alexbalashov.com > > "Gilbert T. Gutierrez, Jr." wrote: > >> I wrote the code below to rewrite an extension to a phone number (It is >> called in route[LOCATION]). This code works fine with MULTIDOMAIN >> enabled but when I run it as a single domain the line $fu=$var(b); does >> not seem to work.. You can see that I have several xlog lines >> outputting the variable values into my /var/log/messages. $var(b) has >> the correct value in it, so I do not know what is happening. I have also >> included the /var/log/messages output which I redacted the phone number, >> domain, and extension for security purposes. I am sure I am going about >> this backwards, but can someone provide me some guidance as to what is >> going wrong? >> >> Thank you, >> Gilbert >> >> # Rewrite - Gilbert >> route[REWRITE] { >> # This section rewrites the outbound calling number so that caller id >> works correctly. >> #!ifdef WITH_REWRITE >> # lookup an outbound number to replace the extension with >> $var(b)="NO REV"; >> sql_xquery("ca","select number from pioutalias where >> username='$fU'","ra"); >> # determine if a outbound number exists >> if ($xavp(ra=>number)) { >> $var(b)="sip:" + $xavp(ra=>number) + "@" + $fd; >> xlog("L_INFO","var(b): '$var(b)'"); >> xlog("L_INFO","fu: '$fu'"); >> # Assign the outbound calling number >> $fu=$var(b); >> xlog("L_INFO","New fu: '$fu'"); >> } >> sql_result_free("ra"); >> # see if it found a number and log if it did not >> if ($var(b)=="NO REV") >> xlog("L_INFO","No number found for extension: '$fu'"); >> #!endif >> } >> >> >> /var/log/messages output >> >> Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO: