Hello,
On 4/10/12 10:52 PM, Gilbert T. Gutierrez, Jr. wrote:
Actually I figured it out. Here is the code I used to fix my issue.
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' and domain='$fd'","ra");
# determine if a outbound number exists
if ($xavp(ra=>number)) {
$var(b)="sip:" + $xavp(ra=>number) + "@" + $fd;
subst('/^P-Asserted-Identity:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/P-Asserted-Identity:\1$var(b)\2/ig');
}
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
return;
}
Your response referencing "msg_apply_changes()" lead me to the module
"textops.so" (Though msg_apply_changes() is in module textopsx.so). I
am not sure what the '1' and the '2' in my regular expression do. I
assume they refer to the characters captured in the '(.*)' sections of
the regular expression (I am terrible with regular expressions).
Basically what I needed was to replace the P-Asserted-Identity line in
the header.
yes, \1 and \2 are back references to selected patterns in between ( ),
in your case being (.*) .
P-Asserted-Identity should not be trusted if received from untrusted
peers. I usually go with:
remove_hf("P-Asserted-Identity");
append_hf("P-Asserted-Identity: <sip:$xavp(ra=>number)@$fd>\r\n");
Cheers,
Daniel
On 4/10/2012 1:25 PM, Daniel-Constantin Mierla wrote:
Hello,
On 4/10/12 7:23 PM, Gilbert T. Gutierrez, Jr. wrote:
Daniel and Alex,
Obviously I stumbled into a way to do things that has been illegal
in the past. How do I do this the old way? I have been looking for
examples and hints online but have only found references to modules
and examples using Kamailio compiled as OpenSER. I am using Kamailio
from RPMs so I only have modules and modules_k.
I don't really get what you mean. Do you need a solution for an older
version? openser was the old name for kamailio, all modules that
existed during openser name are in modules/ or modules_k/. Starting
with 3.2.0, you can directly assign value to $fu, previously the
solution was to use uac_replace_from() of uac module, or play with
functions from textops module.
The issue I was having was that my extension (either 3 digit or 7
digit) was showing up as the callerid when I made outside calls. I
created a reverse table that you look up the correct number to show
the callee. I also add the domain to the query when I have
multidomain enabled. On my test box for multidomain which I am
developing in parallel, my code works and $fu is set to what I want
and the callee gets what I want them to see. It is odd to me that it
works on one box with multidomain and not the other with multidomain
disabled.
Do you get any error messages in the log where it does not work? Add
some xlog(...) to print the values used in the operations. debugger
module may help you to see if the action is actually executed.
Btw, if you need the From header to be reverted in the reply,
uac_replace_from() is the better way to go.
Cheers,
Daniel
Thank you,
Gilbert T. Gutierrez, Jr.
Operations Manager
Phoenix Internet
On 4/10/2012 1:07 AM, Daniel-Constantin Mierla wrote:
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."<mailing-li...@phoenixinternet.net>
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:602xxxx...@xxxx.com'
Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO:<script>: fu:
'sip:30xx...@xxxx.com'
Apr 9 14:38:38 tempfax /usr/sbin/kamailio[6088]: INFO:<script>: New
fu: 'sip:30xx...@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
_______________________________________________
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
_______________________________________________
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
_______________________________________________
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
--
Daniel-Constantin Mierla
Kamailio Advanced Training, April 23-26, 2012, Berlin, Germany
http://www.asipto.com/index.php/kamailio-advanced-training/
_______________________________________________
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