1#if defined(HAVE_CONFIG_H)
8#pragma warning(disable : 4267)
18#define RESIPROCATE_SUBSYSTEM ReTurnSubsystem::RETURN
25TlsConnection::TlsConnection(asio::io_context& ioService,
28 asio::ssl::context& context)
30 mConnectionManager(manager),
31 mRequestHandler(handler)
37 DebugLog(<<
"TlsConnection destroyed.");
40ssl_socket::lowest_layer_type&
49 DebugLog(<<
"TlsConnection started.");
60 mSocket.lowest_layer().close(ec);
63 WarningLog(<<
"TlsConnection shutdown, error=" << ec.value() <<
"-" << ec.message());
76 DebugLog(<<
"TlsConnection handshake completed.");
89 WarningLog(<<
"TlsConnection handshake failure, error=" << e.value() <<
"-" << e.message());
109 if(((*data)[0] & 0xC0) == 0)
114 (
char*)&(*data)[0], data->size());
136 constexpr size_t RESPONSE_BUFFER_SIZE = 1024;
138 unsigned int responseSize;
139 responseSize = response.
stunEncodeMessage((
char*)buffer->data(), RESPONSE_BUFFER_SIZE);
140 buffer->truncate(responseSize);
146 WarningLog(<<
"Received invalid StunMessage. Dropping.");
151 unsigned short channelNumber;
152 memcpy(&channelNumber, &(*data)[0], 2);
153 channelNumber = ntohs(channelNumber);
164 WarningLog(<<
"Not enough data for stun message or framed message. Closing connection.");
175 if(e != asio::error::operation_aborted)
177 InfoLog(<<
"TlsConnection::onReceiveFailure: " << e.value() <<
"-" << e.message());
191 if(error != asio::error::operation_aborted)
193 InfoLog(<<
"TlsConnection::onSendFailure: " << error.value() <<
"-" << error.message());
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual void doFramedReceive()
static std::shared_ptr< DataBuffer > allocateBuffer(size_t size)
Utility API.
virtual void doSend(const StunTuple &destination, unsigned short channel, const std::shared_ptr< DataBuffer > &data, const std::size_t bufferStartPos=0)
Use these if you already operating within the ioService thread.
void startIdleTimer(unsigned int timeoutSeconds, std::function< bool()> inUse)
For server connections (TcpConnectionIdleTimeout): the connection is closed, with close(),...
asio::ssl::stream< asio::ip::tcp::socket > mSocket
void doHandshake(unsigned int timeoutSeconds=0)
Starts the server side handshake.
Manages open connections so that they may be cleanly stopped when the server needs to shut down,...
void stop(ConnectionPtr c)
Stop the specified connection.
unsigned long mTlsHandshakeTimeout
unsigned long mTcpConnectionIdleTimeout
The common handler for all incoming requests.
void processTurnData(TurnAllocationManager &turnAllocationManager, unsigned short channelNumber, const StunTuple &localTuple, const StunTuple &remoteTuple, const std::shared_ptr< DataBuffer > &data)
const ReTurnConfig & getConfig()
ProcessResult processStunMessage(AsyncSocketBase *turnSocket, TurnAllocationManager &turnAllocationManager, StunMessage &request, StunMessage &response, bool isRFC3489BackwardsCompatServer=false)
Process a received StunMessage, and produce a reply Returns true if the response message is to be sen...
@ RespondFromAlternateIpPort
@ RespondFromAlternatePort
unsigned int stunEncodeMessage(char *buf, unsigned int bufLen)
virtual void onServerHandshakeFailure(const asio::error_code &e)
ssl_socket::lowest_layer_type & socket()
Get the socket associated with the connection.
virtual void onSendSuccess()
Handle completion of a send operation.
virtual void stop()
Stop all asynchronous operations associated with the connection.
virtual void onServerHandshakeSuccess()
Handle completion of a handshake operation.
unsigned short mLocalPort
virtual void onReceiveFailure(const asio::error_code &e)
TurnAllocationManager mTurnAllocationManager
Manages turn allocations.
RequestHandler & mRequestHandler
The handler used to process the incoming request.
virtual void onReceiveSuccess(const asio::ip::address &address, unsigned short port, const std::shared_ptr< DataBuffer > &data)
Handle completion of a receive operation.
asio::ip::address mLocalAddress
virtual void close()
Override close fn in AsyncTcpSocketBase so that we can remove ourselves from connection manager.
ConnectionManager & mConnectionManager
The manager for this connection.
virtual void start()
Start the first asynchronous operation for the connection.
virtual void onSendFailure(const asio::error_code &e)
dcm! – add UnusedChecking(_enum) below;