From 8f7386e7351ec5b5e4559fc95a23833ab4d574fb Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Wed, 23 Jun 2021 11:21:03 +0200 Subject: [PATCH] fix media loop on half port-detected channel when media is very early --- ProxyChannel.cxx | 19 ++++++++++++++++++- changes.txt | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ProxyChannel.cxx b/ProxyChannel.cxx index f73ff7d3..0aa5b9b8 100644 --- a/ProxyChannel.cxx +++ b/ProxyChannel.cxx @@ -35,6 +35,7 @@ #include "GkStatus.h" #include #include // needed for ceil() on Solaris 11, OpenBSD +#include #ifdef HAS_AVAYA_SUPPORT #include "avaya.h" @@ -13837,6 +13838,14 @@ void UDPProxySocket::SetForwardDestination(const Address & srcIP, WORD srcPort, PTRACE(7, "JW RTP skip overwriting due to completed port detection"); return; } + + // doing port detection and forward source is already set (probably by port detection) and set to same as forward dest -> swap the directions (OR skip the setting ?) + H245_UnicastAddress fSrc = SocketToH245UnicastAddr(fSrcIP, fSrcPort); // for easy comparison + if (m_ignoreSignaledIPs && fSrc == *dstAddr) { + PTRACE(7, "JW RTP swap directions before SetForwardDestination to avoid loop"); + swap(fSrcIP, rSrcIP); swap(fSrcPort, rSrcPort); + swap(fDestIP, rDestIP); swap(fDestPort, rDestPort); + } #endif if (!onlySetDest) { @@ -13894,6 +13903,14 @@ void UDPProxySocket::SetReverseDestination(const Address & srcIP, WORD srcPort, PTRACE(7, "JW RTP skip overwriting due to completed port detection"); return; } + + // doing port detection and reverse source is already set (probably by port detection) and set to same as reverse dest -> swap the directions (OR skip the setting ?) + H245_UnicastAddress rSrc = SocketToH245UnicastAddr(rSrcIP, rSrcPort); // for easy comparison + if (m_ignoreSignaledIPs && rSrc == *dstAddr) { + PTRACE(7, "JW RTP swap directions before SetReverseDestination to avoid loop"); + swap(fSrcIP, rSrcIP); swap(fSrcPort, rSrcPort); + swap(fDestIP, rDestIP); swap(fDestPort, rDestPort); + } #endif if (!onlySetDest) { @@ -14151,7 +14168,7 @@ ProxySocket::Result UDPProxySocket::ReceiveData() } if (m_ignoreSignaledIPs && !m_portDetectionDone) { - //// learn from data we already have (eg. from H.239 signaling) + //// learn from data we already have (eg. from signaling) // set known destination as assumed source if (fSrcIP == 0 && rSrcIP == 0 && fDestIP != 0) { rSrcIP = fDestIP, rSrcPort = fDestPort; diff --git a/changes.txt b/changes.txt index 666e402e..a966a735 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ Changes from 5.7 to 5.8 ======================= +- BUGFIX(ProxyChannel.cxx) fix media loop on half port-detected channel when media is very early - new switches to set the HTTP Content-Type header: [HttpAcct] ContentType=, [HttpPasswordAuth] ContentType= and [Routing::Http] ContentType= - new switch [Proxy] AllowAnyRTPSourcePortForH239From= to handle incorrect RTCP addresses in H.239 OLC (EdgeProtect interop)