reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TlsConnection.hxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
5#ifndef TLS_CONNECTION_HXX
6#define TLS_CONNECTION_HXX
7
8#ifdef USE_SSL
9
10#include <asio.hpp>
11#include <asio/ssl.hpp>
12#include "RequestHandler.hxx"
14
15namespace reTurn {
16
17class ConnectionManager;
18
19typedef asio::ssl::stream<asio::ip::tcp::socket> ssl_socket;
20
23 : public AsyncTlsSocketBase
24{
25public:
27 explicit TlsConnection(asio::io_context& ioService, ConnectionManager& manager, RequestHandler& handler, asio::ssl::context& context);
28 TlsConnection(const TlsConnection&) = delete;
31
34
36 ssl_socket::lowest_layer_type& socket();
37
39 virtual void start();
40
42 virtual void close();
43
45 virtual void stop();
46
47protected:
49 virtual void onServerHandshakeSuccess();
50 virtual void onServerHandshakeFailure(const asio::error_code& e);
51
53 virtual void onReceiveSuccess(const asio::ip::address& address, unsigned short port, const std::shared_ptr<DataBuffer>& data);
54 virtual void onReceiveFailure(const asio::error_code& e);
55
57 virtual void onSendSuccess();
58 virtual void onSendFailure(const asio::error_code& e);
59
62
65
68
69 // Stores the local address and port
70 asio::ip::address mLocalAddress;
71 unsigned short mLocalPort;
72
73private:
74};
75
76}
77
78#endif
79#endif
80
81
82/* ====================================================================
83
84 Copyright (c) 2007-2008, Plantronics, Inc.
85 All rights reserved.
86
87 Redistribution and use in source and binary forms, with or without
88 modification, are permitted provided that the following conditions are
89 met:
90
91 1. Redistributions of source code must retain the above copyright
92 notice, this list of conditions and the following disclaimer.
93
94 2. Redistributions in binary form must reproduce the above copyright
95 notice, this list of conditions and the following disclaimer in the
96 documentation and/or other materials provided with the distribution.
97
98 3. Neither the name of Plantronics nor the names of its contributors
99 may be used to endorse or promote products derived from this
100 software without specific prior written permission.
101
102 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
103 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
104 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
105 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
106 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
107 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
108 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
109 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
110 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
112 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113
114 ==================================================================== */
Manages open connections so that they may be cleanly stopped when the server needs to shut down,...
The common handler for all incoming requests.
Represents a single connection from a client.
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.
TlsConnection(TlsConnection &&)=delete
TlsConnection & operator=(TlsConnection &&)=delete
virtual void stop()
Stop all asynchronous operations associated with the connection.
virtual void onServerHandshakeSuccess()
Handle completion of a handshake operation.
TlsConnection & operator=(const TlsConnection &)=delete
TlsConnection(const TlsConnection &)=delete
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)
asio::ssl::stream< asio::ip::tcp::socket > ssl_socket
void list()
Definition userAdmin.cxx:66