piece of code:
........
failure_route[2] {
if (!t_is_canceled()) { revert_uri(); sql_query("main", "select username from subscriber where alias='$tU' and alias_seq='2'", "alias_name"); sql_query("main", "select domain from subscriber where alias='$tU' and alias_seq='2'", "alias_domain");
subst_uri('/^sip:.*@.*$/sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])/'); subst('/^To:.*sip:.*/To: sip:$dbr(alias_name=[0,0])@$dbr(alias_domain=>[0,0])>\r/'); #<-----THIS ONE DOESN'T WORK PROPERLY sql_result_free("alias_name"); sql_result_free("alias_domain"); setflag(10);
if (!lookup("location")) { switch ($retcode) { case -1: case -3: t_reply("404", "Not Found"); exit; case -2: exit; } } append_branch();
route(5); }
}
route[5] { if (!t_relay()) { sl_reply_error(); } exit; }
And with ngrep i can see:
# U 10.10.10.10.:5060 -> 10.10.10.15:53286 INVITE sip:ncm0000a@10.20.5.72:5060 SIP/2.0. Record-Route: sip:10.10.10.10;lr=on;ftag=D1D33F74-16CA;nat=yes. Via: SIP/2.0/UDP 10.10.10.10;branch=z9hG4bKc1ce.a89602e5.1. Via: SIP/2.0/UDP 10.20.5.10:5060;rport=57078;branch=z9hG4bK6F2A7E0. Remote-Party-ID: <sip:85559955500@10.20.5.10 sip%3A85559955500@10.20.5.10
;party=calling;screen=yes;privacy=off.
From: <sip:9955500@10.20.5.10 sip%3A9955500@10.20.5.10>;tag=D1D33F74-16CA. To: <sip:ncm0000b@domain.com sip%3Ancm0000b@domain.com>.To: < sip:ncm0000a@domain.com sip%3Ancm0000a@domain.com>. <---------------DUPLICATE HEADERS Date: Tue, 08 Jun 2010 06:39:41 GMT. Call-ID: 73CF85D3-71FF11DF-B5C1D8D5-9276F617@10.20.5.10. Supported: 100rel,timer,resource-priority,replaces. Min-SE: 1800. Cisco-Guid: 1942740043-1912541663-2892365836-2242214896. User-Agent: Cisco-SIPGateway/IOS-12.x. Accept-Language: ru. Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY, INFO, REGISTER. CSeq: 101 INVITE. Max-Forwards: 69. Timestamp: 1275979181. Contact: sip:85559955500@10.20.5.10:57078. Expires: 180. Allow-Events: telephone-event. Content-Type: application/sdp. Content-Disposition: session;handling=required. Content-Length: 401. ...............
I'm trying to rewrite this one: To: <sip:ncm0000b@domain.comsip%3Ancm0000b@domain.com
.
with this one: To: <sip:ncm0000a@domain.comsip%3Ancm0000a@domain.com>.
I'm a newbie, so, please, show me where is my mistake.
Sincerely yours, Kosilov Fedor.
Hi!
1. I never used subst so I do not know how it is supposed to work 2. Mangling To is often not needed, changing RURI is usually sufficient 3. If I need to change the To header, eg. for tsting purposes, I just delete the existing one and create a new one: remove_hf("To"); append_hf("To: sip:$dbr(alias_name=[0,0])@$dbr(alias_domain=>[0,0])>\r\n");
regards klaus
Am 08.06.2010 09:10, schrieb Kosilov Fedor:
piece of code:
........
failure_route[2] {
if (!t_is_canceled()) { revert_uri(); sql_query("main", "select username from subscriber where alias='$tU' and alias_seq='2'", "alias_name"); sql_query("main", "select domain from subscriber where alias='$tU' and alias_seq='2'", "alias_domain");
subst_uri('/^sip:.*@.*$/sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])/'); subst('/^To:.*sip:.*/To: sip:$dbr(alias_name=[0,0])@$dbr(alias_domain=>[0,0])>\r/'); #<-----THIS ONE DOESN'T WORK PROPERLY sql_result_free("alias_name"); sql_result_free("alias_domain"); setflag(10); if (!lookup("location")) { switch ($retcode) { case -1: case -3: t_reply("404", "Not Found"); exit; case -2: exit; } } append_branch();
route(5); }
}
route[5] { if (!t_relay()) { sl_reply_error(); } exit; }
And with ngrep i can see:
# U 10.10.10.10.:5060 -> 10.10.10.15:53286 http://10.10.10.15:53286 INVITE sip:ncm0000a@10.20.5.72:5060 http://sip:ncm0000a@10.20.5.72:5060 SIP/2.0. Record-Route: sip:10.10.10.10;lr=on;ftag=D1D33F74-16CA;nat=yes. Via: SIP/2.0/UDP 10.10.10.10;branch=z9hG4bKc1ce.a89602e5.1. Via: SIP/2.0/UDP 10.20.5.10:5060;rport=57078;branch=z9hG4bK6F2A7E0. Remote-Party-ID: <sip:85559955500@10.20.5.10 mailto:sip%3A85559955500@10.20.5.10>;party=calling;screen=yes;privacy=off. From: <sip:9955500@10.20.5.10 mailto:sip%3A9955500@10.20.5.10>;tag=D1D33F74-16CA. To: <sip:ncm0000b@domain.com mailto:sip%3Ancm0000b@domain.com>.To: <sip:ncm0000a@domain.com mailto:sip%3Ancm0000a@domain.com>. <---------------DUPLICATE HEADERS Date: Tue, 08 Jun 2010 06:39:41 GMT. Call-ID: 73CF85D3-71FF11DF-B5C1D8D5-9276F617@10.20.5.10 mailto:73CF85D3-71FF11DF-B5C1D8D5-9276F617@10.20.5.10. Supported: 100rel,timer,resource-priority,replaces. Min-SE: 1800. Cisco-Guid: 1942740043-1912541663-2892365836-2242214896. User-Agent: Cisco-SIPGateway/IOS-12.x. Accept-Language: ru. Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY, INFO, REGISTER. CSeq: 101 INVITE. Max-Forwards: 69. Timestamp: 1275979181. Contact: <sip:85559955500@10.20.5.10:57078 http://sip:85559955500@10.20.5.10:57078>. Expires: 180. Allow-Events: telephone-event. Content-Type: application/sdp. Content-Disposition: session;handling=required. Content-Length: 401. ...............
I'm trying to rewrite this one: To: <sip:ncm0000b@domain.com mailto:sip%3Ancm0000b@domain.com>. with this one: To: <sip:ncm0000a@domain.com mailto:sip%3Ancm0000a@domain.com>.
I'm a newbie, so, please, show me where is my mistake.
Sincerely yours, Kosilov Fedor.
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
Thank you for the answer, Klaus
I have tried your way(commented my subst and added your rows), so now it looks like this:
failure_route[2] { if (!t_is_canceled() && t_check_status("486|408")) { $avp(alias_seq)=$avp(alias_seq)+1; xdbg("HERE WE ARE! $avp(alias_seq)\n"); revert_uri(); sql_query("main", "select username from subscriber where alias='$tU' and alias_seq='$avp(alias_seq)'", "alias_name"); sql_query("main", "select domain from subscriber where alias='$tU' and alias_seq='$avp(alias_seq)'", "alias_domain"); if ($dbr(alias_name=>rows) != 0 && $dbr(alias_domain=>rows) != 0) { subst_uri('/^sip:.*@.*$/sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])/'); # subst('/^To:.*sip:.*/To: sip:$dbr(alias_name=[0,0])@$dbr(alias_domain=>[0,0])>\r\n/'); <--COMMENTED OUT THIS ONE remove_hf("To"); # <--ADDED THIS ONE append_hf("To: sip:$dbr(alias_name=[0,0])@$dbr(alias_domain=>[0,0])>\r\n"); # <--ADDED THIS ONE sql_result_free("alias_name"); sql_result_free("alias_domain"); setflag(10); if (!lookup("location")) { switch ($retcode) { case -1: case -3: t_reply("404", "Not Found"); exit; case -2: exit; } } append_branch(); route(5); } } if (is_method("INVITE")) { unforce_rtp_proxy(); }
}
route[5] { if (!t_relay()) { sl_reply_error(); } exit; }
So the code now supposed to delete "To: <sip:ncm0000b@domain.comsip%3Ancm0000b@domain.com
"
and to append "To: < sip:ncm0000a@domain.com sip%3Ancm0000a@domain.com>"
But with ngrep i can see: To: <sip:ncm0000b@domain.com sip%3Ancm0000b@domain.com>.Date: Tue, 08 Jun 2010 09:40:10 GMT.
With timestamp, which seems to me to be unusual.
So maybe it's impossible to rewrite "To" header from failure_route for some reason... (For example according to RFC)
Actually my phones ring, and everything works fine, I am just interested with this behavior of Kamailio.
Thanks again for your reply.
Sincerely yours, Kosilov Fedor.
2010/6/8 Klaus Darilion klaus.mailinglists@pernau.at
remove_hf("To"); append_hf("To: sip:$dbr(alias_name=[0,0])@$dbr(alias_domain=>[0,0])>\r\n");
Am 08.06.2010 11:51, schrieb Kosilov Fedor:
So the code now supposed to delete "To: sip:ncm0000b@domain.com" and to append "To: sip:ncm0000a@domain.com"
yes.
But with ngrep i can see: To: sip:ncm0000b@domain.com.Date: Tue, 08 Jun 2010 09:40:10 GMT.
With timestamp, which seems to me to be unusual.
The timestamp is the next header. Thus, somehow the CRLF gets lost between To header and Date header?
So maybe it's impossible to rewrite "To" header from failure_route for some reason... (For example according to RFC)
AFAIK it should be possible.
I just tested with kamailio 3.0 and it works fine.
Try something simpler, e.g: append_hf("To: sip:ncm0000a@domain.com\r\n");
regards Klaus
Actually my phones ring, and everything works fine, I am just interested with this behavior of Kamailio.
Thanks again for your reply.
Sincerely yours, Kosilov Fedor.
2010/6/8 Klaus Darilion <klaus.mailinglists@pernau.at mailto:klaus.mailinglists@pernau.at>
remove_hf("To"); append_hf("To: <sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])>\r\n");