/[resiprocate]/main/reTurn/AsyncTlsSocketBase.hxx
ViewVC logotype

Contents of /main/reTurn/AsyncTlsSocketBase.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9485 - (show annotations) (download)
Sat Apr 7 00:34:03 2012 UTC (7 years, 7 months ago) by dpocock
File MIME type: text/plain
File size: 3620 byte(s)
Switch over to autotools build system from dpocock-autotools branch
1
2 #if defined(HAVE_CONFIG_H)
3 #include "config.h"
4 #endif
5
6 #ifdef USE_SSL
7 #ifndef ASYNC_TLS_SOCKET_BASE_HXX
8 #define ASYNC_TLS_SOCKET_BASE_HXX
9
10 #include <asio.hpp>
11 #include <asio/ssl.hpp>
12 #include <boost/bind.hpp>
13
14 #include "AsyncSocketBase.hxx"
15
16 namespace reTurn {
17
18 class AsyncTlsSocketBase : public AsyncSocketBase
19 {
20 public:
21 AsyncTlsSocketBase(asio::io_service& ioService, asio::ssl::context& context, bool validateServerCertificateHostname);
22 virtual ~AsyncTlsSocketBase();
23
24 virtual unsigned int getSocketDescriptor();
25
26 virtual asio::error_code bind(const asio::ip::address& address, unsigned short port);
27 virtual void connect(const std::string& address, unsigned short port);
28
29 void doHandshake();
30
31 virtual void transportReceive();
32 virtual void transportFramedReceive();
33 virtual void transportSend(const StunTuple& destination, std::vector<asio::const_buffer>& buffers);
34 virtual void transportClose();
35
36 virtual const asio::ip::address getSenderEndpointAddress();
37 virtual unsigned short getSenderEndpointPort();
38
39 protected:
40 virtual void handleReadHeader(const asio::error_code& e);
41 virtual void handleServerHandshake(const asio::error_code& e);
42 virtual void handleTcpResolve(const asio::error_code& ec, asio::ip::tcp::resolver::iterator endpoint_iterator);
43 virtual void handleConnect(const asio::error_code& ec, asio::ip::tcp::resolver::iterator endpoint_iterator);
44 virtual void handleClientHandshake(const asio::error_code& ec, asio::ip::tcp::resolver::iterator endpoint_iterator);
45 virtual bool validateServerCertificateHostname();
46
47 virtual void onServerHandshakeSuccess() { assert(false); }
48 virtual void onServerHandshakeFailure(const asio::error_code& e) { assert(false); }
49
50 asio::ssl::stream<asio::ip::tcp::socket> mSocket;
51 asio::ip::tcp::resolver mResolver;
52
53 private:
54 std::string mHostname;
55 bool mValidateServerCertificateHostname;
56 };
57
58 }
59
60 #endif
61 #endif
62
63 /* ====================================================================
64
65 Copyright (c) 2007-2008, Plantronics, Inc.
66 All rights reserved.
67
68 Redistribution and use in source and binary forms, with or without
69 modification, are permitted provided that the following conditions are
70 met:
71
72 1. Redistributions of source code must retain the above copyright
73 notice, this list of conditions and the following disclaimer.
74
75 2. Redistributions in binary form must reproduce the above copyright
76 notice, this list of conditions and the following disclaimer in the
77 documentation and/or other materials provided with the distribution.
78
79 3. Neither the name of Plantronics nor the names of its contributors
80 may be used to endorse or promote products derived from this
81 software without specific prior written permission.
82
83 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
84 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
85 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
86 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
87 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
88 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
89 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
90 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
91 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
92 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
93 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94
95 ==================================================================== */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27