For posterity and to help other people since this doesnt appear to be common request, this
is what i did to get it working. Basically, i switched to using uac_redirect.so module,
save the headers returned from the 300 reply, and then send new invite with those headers
using get_redirects().
# Manage incoming replies in transaction context
onreply_route[MANAGE_REPLY] {
xdbg("DBG: incoming reply\n");
if(status=~"[12][0-9][0-9]") {
route(NATMANAGE);
}
if (t_check_status("3[0-9][0-9]")) {
xlog("L_INFO", "DBG: got 3xx redirect");
# grab the header from the 300 redirect and save it to add to invite
$shv(identity) = $hdr(Identity);
xlog("L_INFO","DBG: manage_reply: redirect identity:
[$shv(identity)]");
}
return;
}
# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);
if (t_is_canceled()) exit;
if (t_check_status("3[0-9][0-9]")) {
xlog("L_INFO", "DBG: following 3xx redirect");
xlog("L_INFO","DBG: manage_failure: redirect identity:
[$shv(identity)]");
# add the saved header onto the new invite(s) being sent out
append_hf("Identity: $shv(identity)\r\n");
get_redirects("*:1");
route(RELAY);
exit;
}
return;
}
Rob Green
Chief Information Officer (CIO)
Tel: 1-352-218-1490
Cell: 1-407-620-0932
Email: rob.green(a)nuwave.com
Web:
www.nuwave.com
This communication is the Property of NUWAVE Communications and may contain confidential
or privileged information. Unauthorized use of this communication is strictly prohibited
and may be unlawful. If you have received this communication in Error, Please immediately
notify the sender by reply e-mail and destroy all copies of the communication and any
attachments.
________________________________
From: Rob Green via sr-users <sr-users(a)lists.kamailio.org>
Sent: Friday, June 7, 2024 7:47 PM
To: sr-users(a)lists.kamailio.org <sr-users(a)lists.kamailio.org>
Cc: Rob Green <rob.green(a)nuwave.com>
Subject: [SR-Users] handling 300 redirect requests
sr-users(a)lists.kamailio.org appears similar to someone who previously sent you email, but
may not be that person. Learn why this could be a
risk<https://aka.ms/LearnAboutSenderIdentification>
I am trying to proxy a request from server A to server C with me being server B. i send
the invite from A to B, then i need to send to server R which returns back to me a 300
redirect, which i then need to take the answer from the Contsct and then proxy the
original invite from A to C. server A can not handle 3xx responses and must be proxied.
I havent been able to find any examples where the 300 is intercepted and a new invite to
the target is sent. i have the following code but it results in no new INVITE and the
original session is hung until it is canceled. Any idea what i may be doing wrong? In
the example below i am just hardcoding the uri for the new invite instead of getting from
the Contact as a debug exercise. I am using Kamailio 5.7.3
route[HANDLEREDIRECT] {
xlog("L_INFO", "DBG: HANDLEREDIRECT");
msg_apply_changes();
$var(test) = $hdr(Contact);
xlog("L_INFO","DBG: redirect headers [$var(test)]: from=[$fu]
from_user=[$fU], to=[$tu] to_user=[$tU]");
# send to gateway
$var(new_uri) = "sip:" + $tU + "@" + "gateway";
if ($var(new_uri) != "") {
xlog("DBG: Redirecting to: $var(new_uri)\n");
$ru = $var(new_uri);
$tu = $ru;
record_route();
route(RELAY);
exit;
# i have also tried using
#t_newtran();
# and
#t_relay();
} else {
xlog("DBG: No contact header found in 300 response\n");
}
}
# Manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("DBG: new branch [$T_branch_idx] to $ru\n");
xlog("L_INFO", "DBG: manage branch");
route(NATMANAGE);
return;
}
onreply_route[MANAGE_REPLY] {
xdbg("DBG: incoming reply\n");
xlog("L_INFO", "DBG: manage reply");
if (t_check_status("3[0-9][0-9]")) {
xlog("L_INFO", "DBG: got 3xx redirect");
route(HANDLEREDIRECT);
drop;
}
return;
}
I also tried using uac_redirect module, but it stalls the incoming invite also, and i cant
figure out how to modify the uri from the contact before sending (to add params)
# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);
if (t_is_canceled()) exit;
if (t_check_status("3[0-9][0-9]")) {
xlog("L_INFO", "DBG: following 3xx redirect");
get_redirects("3:1");
t_relay();
exit;
}
}
Rob Green
Chief Information Officer (CIO)
[NUWAVE
Communications]<https://www.nuwave.com/>
Tel: 1-352-218-1490<tel:1-352-218-1490>
Cell: 1-407-620-0932<tel:1-407-620-0932>
Email: rob.green@nuwave.com<mailto:rob.green@nuwave.com>
Web:
www.nuwave.com<http://www.nuwave.com/>
[
LinkedIn]<https://www.linkedin.com/company/1613876/admin/>
[
Twitter]<https://twitter.com/nuwavecomm>
[
Facebook]<https://www.facebook.com/nuwavecommunications>
[Explore iPILOT, Communications in Minutes, not Months.]<http://ipilot.io/>
This communication is the Property of NUWAVE Communications and may contain confidential
or privileged information. Unauthorized use of this communication is strictly prohibited
and may be unlawful. If you have received this communication in Error, Please immediately
notify the sender by reply e-mail and destroy all copies of the communication and any
attachments.