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: <script>: var(b): 'sip:602XXXXXXX@xxxx.com' Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO: <script>: fu: 'sip:30XXXXX@xxxx.com' Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO: <script>: New fu: 'sip:30XXXXX@xxxx.com'
http://www.kamailio.org/wiki/cookbooks/3.2.x/pseudovariables#from_uri
$fu is not marked as R/W, thus it is read-only and can not be set.
To change From URI either use textops module to change it manually (may cause problems with some clients) or use http://www.kamailio.org/docs/modules/3.2.x/modules_k/uac.html#id2533055 which restores old From header for caller.
regards Klaus
On 10.04.2012 03:58, 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: <script>: var(b): 'sip:602XXXXXXX@xxxx.com' Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO: <script>: fu: 'sip:30XXXXX@xxxx.com' Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO: <script>: New fu: 'sip:30XXXXX@xxxx.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