reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
reTurn::TurnTcpSocket Class Reference

#include <TurnTcpSocket.hxx>

Inheritance diagram for reTurn::TurnTcpSocket:
[legend]

Public Member Functions

 TurnTcpSocket (const asio::ip::address &address=UnspecifiedIpAddress, unsigned short port=0)
 
virtual unsigned int getSocketDescriptor ()
 
virtual asio::error_code connect (const std::string &address, unsigned short port)
 
void setConnectTimeout (unsigned int milliseconds)
 Milliseconds the TCP connect to each address connect() tries may take - and, for TLS, the handshake - before it fails with asio::error::timed_out.
 
- Public Member Functions inherited from reTurn::TurnSocket
 TurnSocket (const asio::ip::address &address=UnspecifiedIpAddress, unsigned short port=0)
 
virtual ~TurnSocket ()
 
asio::error_code requestSharedSecret (char *username, unsigned int usernameSize, char *password, unsigned int passwordSize)
 
void setUsernameAndPassword (const char *username, const char *password, bool shortTermAuth=false)
 
void setSoftware (const char *software)
 
asio::error_code bindRequest ()
 
asio::error_code createAllocation (unsigned int lifetime=UnspecifiedLifetime, unsigned int bandwidth=UnspecifiedBandwidth, unsigned char requestedProps=StunMessage::PropsNone, uint64_t reservationToken=UnspecifiedToken, StunTuple::TransportType requestedTransportType=StunTuple::None)
 
asio::error_code refreshAllocation ()
 
asio::error_code destroyAllocation ()
 
StunTuple & getRelayTuple ()
 
StunTuple & getReflexiveTuple ()
 
unsigned int getLifetime ()
 
unsigned int getBandwidth ()
 
asio::error_code setActiveDestination (const asio::ip::address &address, unsigned short port)
 
asio::error_code clearActiveDestination ()
 
asio::error_code send (const char *buffer, unsigned int size)
 
asio::error_code sendTo (const asio::ip::address &address, unsigned short port, const char *buffer, unsigned int size)
 
asio::error_code receive (char *buffer, unsigned int &size, unsigned int timeout, asio::ip::address *sourceAddress=0, unsigned short *sourcePort=0)
 
asio::error_code receiveFrom (const asio::ip::address &address, unsigned short port, char *buffer, unsigned int &size, unsigned int timeout)
 

Protected Member Functions

virtual asio::error_code rawWrite (const char *buffer, unsigned int size)
 
virtual asio::error_code rawWrite (const std::vector< asio::const_buffer > &buffers)
 
virtual asio::error_code rawRead (unsigned int timeout, unsigned int *bytesRead, asio::ip::address *sourceAddress=0, unsigned short *sourcePort=0)
 
virtual void readHeader ()
 
virtual void readBody (unsigned int len)
 
virtual void cancelSocket ()
 
virtual void handleReadHeader (const asio::error_code &e)
 Handle completion of a read operation for first 32 bits.
 
asio::error_code openAndBind (asio::ip::tcp::socket &socket)
 Opens socket and binds it to the local binding (address and port), for a connection attempt.
 
asio::ip::tcp protocol () const
 The protocol (IPv4 or IPv6) of the local binding.
 
asio::error_code waitForConnectStep (asio::error_code &result, const std::function< void()> &cancel)
 For a step of connect() started as an asynchronous operation that sets result (initially asio::error::would_block) when it completes: runs the io_context until it does, or until the connect timeout passes - when cancel() is called (eg.
 
- Protected Member Functions inherited from reTurn::TurnSocket
void startReadTimer (unsigned int timeout)
 
void handleRawRead (const asio::error_code &errorCode, size_t bytesRead)
 
void handleRawReadTimeout (const asio::error_code &errorCode)
 
void queueReceived (unsigned int size)
 

Protected Attributes

unsigned int mConnectTimeout = 10000
 
size_t mPadding = 0
 
- Protected Attributes inherited from reTurn::TurnSocket
StunTuple mLocalBinding
 
StunTuple mConnectedTuple
 
resip::Data mUsername
 
resip::Data mPassword
 
resip::Data mHmacKey
 
resip::Data mRealm
 
resip::Data mNonce
 
resip::Data mSoftware
 
unsigned int mRequestedLifetime
 
unsigned int mRequestedBandwidth
 
unsigned char mRequestedProps
 
uint64_t mReservationToken
 
StunTuple::TransportType mRequestedTransportType
 
bool mHaveAllocation
 
time_t mAllocationRefreshTime
 
StunTuple mRelayTuple
 
StunTuple mReflexiveTuple
 
unsigned int mLifetime
 
unsigned int mBandwidth
 
ChannelManager mChannelManager
 
ChannelBindingRefreshTimeMap mChannelBindingRefreshTimes
 
RemotePeer * mActiveDestination
 
asio::io_context mIOService
 
asio::steady_timer mReadTimer
 
size_t mBytesRead
 
asio::error_code mReadErrorCode
 
char mReadBuffer [8192]
 
char mWriteBuffer [8192]
 
bool mConnected
 
std::deque< std::vector< char > > mReceivedWhileWaiting
 

Additional Inherited Members

- Static Public Attributes inherited from reTurn::TurnSocket
static unsigned int UnspecifiedLifetime = 0xFFFFFFFF
 
static unsigned int UnspecifiedBandwidth = 0xFFFFFFFF
 
static unsigned short UnspecifiedToken = 0
 
static asio::ip::address UnspecifiedIpAddress = asio::ip::make_address("0.0.0.0")
 
- Protected Types inherited from reTurn::TurnSocket
typedef std::map< unsigned short, time_t > ChannelBindingRefreshTimeMap
 
- Static Protected Attributes inherited from reTurn::TurnSocket
static const size_t MaxReceivedWhileWaiting = 100
 

Detailed Description

Definition at line 14 of file TurnTcpSocket.hxx.

Constructor & Destructor Documentation

◆ TurnTcpSocket()

reTurn::TurnTcpSocket::TurnTcpSocket ( const asio::ip::address &  address = UnspecifiedIpAddress,
unsigned short  port = 0 
)
explicit

Definition at line 16 of file TurnTcpSocket.cxx.

Member Function Documentation

◆ cancelSocket()

void reTurn::TurnTcpSocket::cancelSocket ( )
protectedvirtual

Implements reTurn::TurnSocket.

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 168 of file TurnTcpSocket.cxx.

◆ connect()

asio::error_code reTurn::TurnTcpSocket::connect ( const std::string &  address,
unsigned short  port 
)
virtual

Implements reTurn::TurnSocket.

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 71 of file TurnTcpSocket.cxx.

◆ getSocketDescriptor()

virtual unsigned int reTurn::TurnTcpSocket::getSocketDescriptor ( )
inlinevirtual

Implements reTurn::TurnSocket.

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 20 of file TurnTcpSocket.hxx.

◆ handleReadHeader()

void reTurn::TurnTcpSocket::handleReadHeader ( const asio::error_code &  e)
protectedvirtual

Handle completion of a read operation for first 32 bits.

Definition at line 175 of file TurnTcpSocket.cxx.

◆ openAndBind()

asio::error_code reTurn::TurnTcpSocket::openAndBind ( asio::ip::tcp::socket &  socket)
protected

Opens socket and binds it to the local binding (address and port), for a connection attempt.

The socket isn't opened before connect(), which makes a new one for each address it tries.

Definition at line 31 of file TurnTcpSocket.cxx.

◆ protocol()

asio::ip::tcp reTurn::TurnTcpSocket::protocol ( ) const
protected

The protocol (IPv4 or IPv6) of the local binding.

Definition at line 25 of file TurnTcpSocket.cxx.

◆ rawRead()

asio::error_code reTurn::TurnTcpSocket::rawRead ( unsigned int  timeout,
unsigned int *  bytesRead,
asio::ip::address *  sourceAddress = 0,
unsigned short *  sourcePort = 0 
)
protectedvirtual

Implements reTurn::TurnSocket.

Definition at line 129 of file TurnTcpSocket.cxx.

◆ rawWrite() [1/2]

asio::error_code reTurn::TurnTcpSocket::rawWrite ( const char *  buffer,
unsigned int  size 
)
protectedvirtual

Implements reTurn::TurnSocket.

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 113 of file TurnTcpSocket.cxx.

◆ rawWrite() [2/2]

asio::error_code reTurn::TurnTcpSocket::rawWrite ( const std::vector< asio::const_buffer > &  buffers)
protectedvirtual

Implements reTurn::TurnSocket.

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 121 of file TurnTcpSocket.cxx.

◆ readBody()

void reTurn::TurnTcpSocket::readBody ( unsigned int  len)
protectedvirtual

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 161 of file TurnTcpSocket.cxx.

◆ readHeader()

void reTurn::TurnTcpSocket::readHeader ( )
protectedvirtual

Reimplemented in reTurn::TurnTlsSocket.

Definition at line 154 of file TurnTcpSocket.cxx.

◆ setConnectTimeout()

void reTurn::TurnTcpSocket::setConnectTimeout ( unsigned int  milliseconds)
inline

Milliseconds the TCP connect to each address connect() tries may take - and, for TLS, the handshake - before it fails with asio::error::timed_out.

Default 10 seconds.

Definition at line 28 of file TurnTcpSocket.hxx.

◆ waitForConnectStep()

asio::error_code reTurn::TurnTcpSocket::waitForConnectStep ( asio::error_code &  result,
const std::function< void()> &  cancel 
)
protected

For a step of connect() started as an asynchronous operation that sets result (initially asio::error::would_block) when it completes: runs the io_context until it does, or until the connect timeout passes - when cancel() is called (eg.

to close the socket), and timed_out is returned

Definition at line 46 of file TurnTcpSocket.cxx.

Member Data Documentation

◆ mConnectTimeout

unsigned int reTurn::TurnTcpSocket::mConnectTimeout = 10000
protected

Definition at line 54 of file TurnTcpSocket.hxx.

◆ mPadding

size_t reTurn::TurnTcpSocket::mPadding = 0
protected

Definition at line 56 of file TurnTcpSocket.hxx.


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