I am attempting to put together code which will allow us to redirect a call to a different tn if the route failed.
Example: User dials 11235551234 Kamailio uses LCR to route to 192.168.0.100 (404 error) Change $rU to 11235550000 in failure_route
The only way I can get $rU to show up in the SIP message is to call append_branch() which is not a solution because I now end up with two SIP messages one that is correct and one that is incorrect.
Here is the failure_route I am using. Any input would be appreciated.
failure_route[ECRC] { if (t_is_canceled()) { xlog("L_INFO", "Call has been canceled in 'ECRC'."); exit; }
xlog("L_INFO", "SIP Response Code: $T_reply_code");
# We should fail over if we received one of these response codes. if (!t_check_status("[45][0-9][0-9]")) { xlog("L_INFO", "Not a failover error."); exit; }
# Translate the dialed number into the ECRC DID. dp_translate("1", "$rU/$rU");
# Load the gateways for normal dialing. xlog("L_INFO", "Trying to find LCR route for $rU"); if (! load_gws("1", "$rU")) { xlog("Unable to load routing"); t_reply("503", "Unable to load routing"); exit; }
xlog("L_INFO", "Trying gateway '$avp(i:709)'"); if (!next_gw()) { xlog("L_INFO", "No LCR route for $rU"); t_reply("404", "No available gateways"); exit; }
$rd=$dd; $rp=$dp; $du=$ru; xlog("L_INFO", "ru: $ru"); xlog("L_INFO", "du: $du"); #at this point $ru and $du contain the correct uri. append_branch();
# Send out the request. xlog("L_INFO", "Now we're sending the request out."); if (!t_relay()) { xlog("L_INFO" "Relay failed!"); t_reply("502", "Bad Gateway"); exit; } }
Now I have two SIP messages one containing the correct phone number: INVITE sip:11235550000@xxx.xxx.xxx.xxx SIP/2.0 Record-Route: sip:xxx.xxx.xxx.xxx;lr=on Via: SIP/2.0/UDP xxx.xxx.xxx.xxx;branch=z9hG4bK2e2f.4145be65.2 Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;branch=z9hG4bK28aa7440;rport=5060 Max-Forwards: 69 From: "Steven Wheeler" sip:6124243265@xxx.xxx.xxx.xxx;tag=as30b3d6f5 To: sip:11235551234@xxx.xxx.xxx.xxx:5060 ...
And one containing the wrong phone number: INVITE sip:11235551234@xxx.xxx.xxx.xxx SIP/2.0 Record-Route: sip:xxx.xxx.xxx.xxx;lr=on Via: SIP/2.0/UDP xxx.xxx.xxx.xxx;branch=z9hG4bK2e2f.4145be65.3 Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;branch=z9hG4bK28aa7440;rport=5060 Max-Forwards: 69 From: "Steven Wheeler" sip:6124243265@xxx.xxx.xxx.xxx;tag=as30b3d6f5 To: sip:11235551234@xxx.xxx.xxx.xxx:5060 ...
Steven Wheeler swheeler@usinternet.com 952-253-3252
Am 16.03.2011 21:09, schrieb Steven Wheeler:
$rd=$dd; $rp=$dp; $du=$ru;
This one I do not understand. Also I do not see the code where you change $dU?
Anyway, it seems that 2 branches are added: maybe one by lcr module internally via next_gw and one manually? You can try to change $dU before calling next_gw and omit the append_branch() call.
regards klaus
Hello,
for the question of this thread it is important to know the version of kamailio used. In older versions, append_branch was called on purpose upon changes in failure route, in latest one, changes to routing URIs will be detected and a new branch is created by t_relay().
I do not know if latest lcr does internally append_branch(), but if it does and you change afterwards r-uri, then you will get two branches.
On 3/18/11 7:00 PM, Klaus Darilion wrote:
Am 16.03.2011 21:09, schrieb Steven Wheeler:
$rd=$dd; $rp=$dp; $du=$ru;
This one I do not understand. Also I do not see the code where you change $dU?
$dX - is the pseudo-variable for internal destination uri field (or outbound proxy address) -- this will not be shown in the sip message at all. Since user part of a SIP URI has no relevance in the IP routing, $dU (which you may think it is the user part of dst uri) is not exported as PV.
Cheers, Daniel
Anyway, it seems that 2 branches are added: maybe one by lcr module internally via next_gw and one manually? You can try to change $dU before calling next_gw and omit the append_branch() call.
regards klaus
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