Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
CTCPStunThread Class Reference

#include <tcpserver.h>

Collaboration diagram for CTCPStunThread:

Public Member Functions

 CTCPStunThread ()
 
 ~CTCPStunThread ()
 
HRESULT Init (const TransportAddressSet &tsaListen, const TransportAddressSet &tsaHandler, IStunAuth *pAuth, int maxConnections, boost::shared_ptr< RateLimiter > &spLimiter)
 
HRESULT Start ()
 
HRESULT Stop ()
 

Private Types

typedef FastHashDynamic< int, StunConnection * > StunThreadConnectionMap
 

Private Member Functions

HRESULT CreatePipes ()
 
HRESULT NotifyThreadViaPipe ()
 
void ClosePipes ()
 
HRESULT SetListenSocketsOnEpoll (bool fEnable)
 
HRESULT CreateListenSockets ()
 
void CloseListenSockets ()
 
CStunSocketGetListenSocket (int sock)
 
void Run ()
 
void Reset ()
 
StunConnectionAcceptConnection (CStunSocket *pListenSocket)
 
void ProcessConnectionEvent (int sock, uint32_t eventflags)
 
HRESULT ReceiveBytesForConnection (StunConnection *pConn)
 
HRESULT WriteBytesForConnection (StunConnection *pConn)
 
void CloseAllConnections (StunThreadConnectionMap *pConnMap)
 
void SweepDeadConnections ()
 
void ThreadCleanup ()
 
int GetTimeoutSeconds ()
 
bool IsConnectionCountAtMax ()
 
void CloseConnection (StunConnection *pConn)
 
bool RateCheck (const CSocketAddress &addr)
 

Static Private Member Functions

static void * ThreadFunction (void *pThis)
 

Private Attributes

int _pipe [2]
 
CRefCountedPtr< IPolling_spPolling
 
bool _fListenSocketsOnEpoll
 
boost::shared_ptr< RateLimiter_spLimiter
 
TransportAddressSet _tsaListen
 
CStunSocket _socketListenArray [4]
 
int _socketTable [4]
 
int _countSocks
 
bool _fNeedToExit
 
CRefCountedPtr< IStunAuth_spAuth
 
SocketRole _role
 
TransportAddressSet _tsa
 
int _maxConnections
 
pthread_t _pthread
 
bool _fThreadIsValid
 
CConnectionPool _connectionpool
 
StunThreadConnectionMap _hashConnections1
 
StunThreadConnectionMap _hashConnections2
 
StunThreadConnectionMap_pNewConnList
 
StunThreadConnectionMap_pOldConnList
 
time_t _timeLastSweep
 

Static Private Attributes

static const int c_sweepTimeoutSeconds = 60
 

Detailed Description

Definition at line 32 of file tcpserver.h.

Member Typedef Documentation

Definition at line 82 of file tcpserver.h.

Constructor & Destructor Documentation

CTCPStunThread::CTCPStunThread ( )

Definition at line 40 of file tcpserver.cpp.

CTCPStunThread::~CTCPStunThread ( )

Definition at line 86 of file tcpserver.cpp.

Member Function Documentation

StunConnection * CTCPStunThread::AcceptConnection ( CStunSocket pListenSocket)
private

Definition at line 484 of file tcpserver.cpp.

void CTCPStunThread::CloseAllConnections ( StunThreadConnectionMap pConnMap)
private

Definition at line 743 of file tcpserver.cpp.

void CTCPStunThread::CloseConnection ( StunConnection pConn)
private

Definition at line 713 of file tcpserver.cpp.

void CTCPStunThread::CloseListenSockets ( )
private

Definition at line 200 of file tcpserver.cpp.

void CTCPStunThread::ClosePipes ( )
private

Definition at line 109 of file tcpserver.cpp.

HRESULT CTCPStunThread::CreateListenSockets ( )
private

Definition at line 171 of file tcpserver.cpp.

HRESULT CTCPStunThread::CreatePipes ( )
private

Definition at line 93 of file tcpserver.cpp.

CStunSocket * CTCPStunThread::GetListenSocket ( int  sock)
private

Definition at line 211 of file tcpserver.cpp.

int CTCPStunThread::GetTimeoutSeconds ( )
private

Definition at line 347 of file tcpserver.cpp.

HRESULT CTCPStunThread::Init ( const TransportAddressSet tsaListen,
const TransportAddressSet tsaHandler,
IStunAuth pAuth,
int  maxConnections,
boost::shared_ptr< RateLimiter > &  spLimiter 
)

Definition at line 230 of file tcpserver.cpp.

bool CTCPStunThread::IsConnectionCountAtMax ( )
private

Definition at line 353 of file tcpserver.cpp.

HRESULT CTCPStunThread::NotifyThreadViaPipe ( )
private

Definition at line 124 of file tcpserver.cpp.

void CTCPStunThread::ProcessConnectionEvent ( int  sock,
uint32_t  eventflags 
)
private

Definition at line 430 of file tcpserver.cpp.

bool CTCPStunThread::RateCheck ( const CSocketAddress addr)
private

Definition at line 463 of file tcpserver.cpp.

HRESULT CTCPStunThread::ReceiveBytesForConnection ( StunConnection pConn)
private

Definition at line 555 of file tcpserver.cpp.

void CTCPStunThread::Reset ( )
private

Definition at line 47 of file tcpserver.cpp.

void CTCPStunThread::Run ( )
private

Definition at line 362 of file tcpserver.cpp.

HRESULT CTCPStunThread::SetListenSocketsOnEpoll ( bool  fEnable)
private

Definition at line 138 of file tcpserver.cpp.

HRESULT CTCPStunThread::Start ( )

Definition at line 298 of file tcpserver.cpp.

HRESULT CTCPStunThread::Stop ( )

Definition at line 318 of file tcpserver.cpp.

void CTCPStunThread::SweepDeadConnections ( )
private

Definition at line 753 of file tcpserver.cpp.

void CTCPStunThread::ThreadCleanup ( )
private

Definition at line 779 of file tcpserver.cpp.

void * CTCPStunThread::ThreadFunction ( void *  pThis)
staticprivate

Definition at line 341 of file tcpserver.cpp.

HRESULT CTCPStunThread::WriteBytesForConnection ( StunConnection pConn)
private

Definition at line 645 of file tcpserver.cpp.

Member Data Documentation

CConnectionPool CTCPStunThread::_connectionpool
private

Definition at line 69 of file tcpserver.h.

int CTCPStunThread::_countSocks
private

Definition at line 53 of file tcpserver.h.

bool CTCPStunThread::_fListenSocketsOnEpoll
private

Definition at line 43 of file tcpserver.h.

bool CTCPStunThread::_fNeedToExit
private

Definition at line 59 of file tcpserver.h.

bool CTCPStunThread::_fThreadIsValid
private

Definition at line 67 of file tcpserver.h.

StunThreadConnectionMap CTCPStunThread::_hashConnections1
private

Definition at line 84 of file tcpserver.h.

StunThreadConnectionMap CTCPStunThread::_hashConnections2
private

Definition at line 85 of file tcpserver.h.

int CTCPStunThread::_maxConnections
private

Definition at line 64 of file tcpserver.h.

int CTCPStunThread::_pipe[2]
private

Definition at line 37 of file tcpserver.h.

StunThreadConnectionMap* CTCPStunThread::_pNewConnList
private

Definition at line 87 of file tcpserver.h.

StunThreadConnectionMap* CTCPStunThread::_pOldConnList
private

Definition at line 88 of file tcpserver.h.

pthread_t CTCPStunThread::_pthread
private

Definition at line 66 of file tcpserver.h.

SocketRole CTCPStunThread::_role
private

Definition at line 61 of file tcpserver.h.

CStunSocket CTCPStunThread::_socketListenArray[4]
private

Definition at line 51 of file tcpserver.h.

int CTCPStunThread::_socketTable[4]
private

Definition at line 52 of file tcpserver.h.

CRefCountedPtr<IStunAuth> CTCPStunThread::_spAuth
private

Definition at line 60 of file tcpserver.h.

boost::shared_ptr<RateLimiter> CTCPStunThread::_spLimiter
private

Definition at line 45 of file tcpserver.h.

CRefCountedPtr<IPolling> CTCPStunThread::_spPolling
private

Definition at line 42 of file tcpserver.h.

time_t CTCPStunThread::_timeLastSweep
private

Definition at line 89 of file tcpserver.h.

TransportAddressSet CTCPStunThread::_tsa
private

Definition at line 63 of file tcpserver.h.

TransportAddressSet CTCPStunThread::_tsaListen
private

Definition at line 50 of file tcpserver.h.

const int CTCPStunThread::c_sweepTimeoutSeconds = 60
staticprivate

Definition at line 34 of file tcpserver.h.


The documentation for this class was generated from the following files: