Skip to content

Commit

Permalink
Merge pull request #183 from AlexAT/update_dialog_nexthop
Browse files Browse the repository at this point in the history
Please comment: fix updating dialog nexthop
  • Loading branch information
juha-h authored Apr 26, 2022
2 parents 50d5a33 + 02f0790 commit e4383ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit e4383ac

Please sign in to comment.