diff --git a/core/AmBasicSipDialog.cpp b/core/AmBasicSipDialog.cpp index 0a1d0abfe..7228a363c 100644 --- a/core/AmBasicSipDialog.cpp +++ b/core/AmBasicSipDialog.cpp @@ -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); @@ -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); diff --git a/core/AmSipMsg.h b/core/AmSipMsg.h index 96d250873..9b68b9c3e 100644 --- a/core/AmSipMsg.h +++ b/core/AmSipMsg.h @@ -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; diff --git a/core/SipCtrlInterface.cpp b/core/SipCtrlInterface.cpp index 6327c10b1..6ef2a686a 100644 --- a/core/SipCtrlInterface.cpp +++ b/core/SipCtrlInterface.cpp @@ -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(); @@ -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)