Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please comment: fix updating dialog nexthop #183

Merged
merged 9 commits into from
Apr 26, 2022
4 changes: 2 additions & 2 deletions core/AmBasicSipDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void AmBasicSipDialog::onRxRequest(const AmSipRequest& req)
if (remote_uri != req.from_uri) {
setRemoteUri(req.from_uri);
if(nat_handling && req.first_hop) {
string nh = req.remote_ip + ":"
string nh = (!req.remote_ip_is_ipv6 ? req.remote_ip : "[" + req.remote_ip + "]") + ":"
+ int2str(req.remote_port)
+ "/" + req.trsp;
setNextHop(nh);
Expand Down Expand Up @@ -515,7 +515,7 @@ void AmBasicSipDialog::updateDialogTarget(const AmSipReply& reply)

setRemoteUri(reply.to_uri);
if(!getNextHop().empty()) {
string nh = reply.remote_ip
string nh = (!reply.remote_ip_is_ipv6 ? reply.remote_ip : "[" + reply.remote_ip + "]")
+ ":" + int2str(reply.remote_port)
+ "/" + reply.trsp;
setNextHop(nh);
Expand Down
2 changes: 2 additions & 0 deletions core/AmSipMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class _AmSipMsgInDlg
trans_ticket tt;

string remote_ip;
bool remote_ip_is_ipv6;
unsigned short remote_port;
string local_ip;
bool local_ip_is_ipv6;
unsigned short local_port;
string trsp;

Expand Down
4 changes: 4 additions & 0 deletions core/SipCtrlInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,11 @@ inline bool _SipCtrlInterface::sip_msg2am_request(const sip_msg *msg,
req.max_forwards = AmConfig::MaxForwards;

req.remote_ip = get_addr_str(&msg->remote_ip);
req.remote_ip_is_ipv6 = (msg->remote_ip.ss_family != AF_INET);
req.remote_port = am_get_port(&msg->remote_ip);

req.local_ip = get_addr_str(&msg->local_ip);
req.local_ip_is_ipv6 = (msg->local_ip.ss_family != AF_INET);
req.local_port = am_get_port(&msg->local_ip);

req.trsp = msg->local_socket->get_transport();
Expand Down Expand Up @@ -735,9 +737,11 @@ inline bool _SipCtrlInterface::sip_msg2am_reply(sip_msg *msg, AmSipReply &reply)
}

reply.remote_ip = get_addr_str(&msg->remote_ip);
reply.remote_ip_is_ipv6 = (msg->remote_ip.ss_family != AF_INET);
reply.remote_port = am_get_port(&msg->remote_ip);

reply.local_ip = get_addr_str(&msg->local_ip);
reply.local_ip_is_ipv6 = (msg->local_ip.ss_family != AF_INET);
reply.local_port = am_get_port(&msg->local_ip);

if(msg->local_socket)
Expand Down