Added support for drilling a hole through a firewall or NAT by sending

one invalid 4 bytes RTP and RTCP packet.


git-svn-id: http://voip.null.ro/svn/yate@1187 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2007-02-01 23:33:30 +00:00
parent e7c3a0f3c2
commit 889990d3ec
5 changed files with 35 additions and 0 deletions

View File

@ -23,6 +23,9 @@
; rtcp: bool: Allocate socket for the RTCP protocol by default
;rtcp=enabled
; drillhole: bool: Attempt to drill a hole through a firewall or NAT
;drillhole=disabled
; defsleep: int: Default in-loop sleep time for new RTP sessions in milliseconds
;defsleep=5

View File

@ -257,6 +257,7 @@ void RTPReceiver::timerTick(const Time& when)
{
}
RTPSender::RTPSender(RTPSession* session, bool randomTs)
: RTPBaseIO(session), m_evTime(0), m_tsLast(0)
{

View File

@ -143,6 +143,7 @@ void RTPGroup::setMinSleep(int msec)
s_sleep = msec;
}
RTPProcessor::RTPProcessor()
: m_group(0)
{
@ -331,6 +332,19 @@ bool RTPTransport::remoteAddr(SocketAddr& addr, bool sniff)
return false;
}
bool RTPTransport::drillHole()
{
if (m_rtpSock.valid() && m_remoteAddr.valid()) {
static const char buf[4] = { 0, 0, 0, 0 };
if (m_rtpSock.sendTo(buf,sizeof(buf),m_remoteAddr) == sizeof(buf)) {
if (m_rtcpSock.valid() && m_remoteRTCP.valid())
m_rtcpSock.sendTo(buf,sizeof(buf),m_remoteRTCP);
return true;
}
}
return false;
}
RTPDejitter::RTPDejitter(RTPReceiver* receiver, unsigned int mindelay, unsigned int maxdelay)
: m_receiver(receiver), m_mindelay(mindelay), m_maxdelay(maxdelay),

View File

@ -254,6 +254,12 @@ public:
inline Socket* rtpSock()
{ return &m_rtpSock; }
/**
* Drill a hole in a firewall or NAT for the RTP and RTCP sockets
* @return True if at least a packet was sent for the RTP socket
*/
bool drillHole();
protected:
/**
* Method called periodically to read data out of sockets
@ -922,6 +928,13 @@ public:
inline Socket* rtpSock()
{ return m_transport ? m_transport->rtpSock() : 0; }
/**
* Drill a hole in a firewall or NAT for the RTP and RTCP sockets
* @return True if at least a packet was sent for the RTP socket
*/
inline bool drillHole()
{ return m_transport && m_transport->drillHole(); }
protected:
/**
* Method called periodically to push any asynchronous data or statistics

View File

@ -80,6 +80,7 @@ static String s_tos;
static bool s_autoaddr = true;
static bool s_anyssrc = false;
static bool s_rtcp = true;
static bool s_drill = false;
static int s_sleep = 5;
static int s_minjitter = 0;
@ -432,6 +433,8 @@ bool YRTPWrapper::startRTP(const char* raddr, unsigned int rport, const Message&
m_rtp->dataPayload(payload);
m_rtp->eventPayload(evpayload);
m_rtp->setTOS(tos);
if (msg.getBoolValue("drillhole",s_drill))
m_rtp->drillHole();
// if (maxJitter > 0)
// m_rtp->setDejitter(minJitter*1000,maxJitter*1000);
m_bufsize = s_bufsize;
@ -842,6 +845,7 @@ void YRTPPlugin::initialize()
s_autoaddr = cfg.getBoolValue("general","autoaddr",true);
s_anyssrc = cfg.getBoolValue("general","anyssrc",false);
s_rtcp = cfg.getBoolValue("general","rtcp",true);
s_drill = cfg.getBoolValue("general","drillhole",false);
s_sleep = cfg.getIntValue("general","defsleep",5);
RTPGroup::setMinSleep(cfg.getIntValue("general","minsleep"));
setup();