XRootD
Loading...
Searching...
No Matches
XrdClTls.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3// Author: Michal Simon <simonm@cern.ch>
4//------------------------------------------------------------------------------
5// XRootD is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// XRootD is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17//------------------------------------------------------------------------------
18
19#ifndef __XRD_CL_TLS_HH__
20#define __XRD_CL_TLS_HH__
21
22#include <memory>
23
25
28
29namespace XrdCl
30{
31 class Socket;
32
34 bool InitTLS();
35
36 //----------------------------------------------------------------------------
38 //----------------------------------------------------------------------------
39 class Tls
40 {
41 public:
42
43 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
46 Tls( Socket *socket, AsyncSocketHandler *socketHandler );
47
48 //------------------------------------------------------------------------
50 //------------------------------------------------------------------------
52 {
53 }
54
55 //------------------------------------------------------------------------
57 //------------------------------------------------------------------------
58 XRootDStatus Connect( const std::string &thehost, XrdNetAddrInfo *netInfo );
59
60 //------------------------------------------------------------------------
63 //------------------------------------------------------------------------
64 XRootDStatus Read( char *buffer, size_t size, int &bytesRead );
65
66 //------------------------------------------------------------------------
69 //------------------------------------------------------------------------
70 XRootDStatus ReadV( iovec *iov, int iocnt, int &bytesRead );
71
72 //------------------------------------------------------------------------
75 //------------------------------------------------------------------------
76 XRootDStatus Send( const char *buffer, size_t size, int &bytesWritten );
77
78 //------------------------------------------------------------------------
80 //------------------------------------------------------------------------
81 void Shutdown();
82
83 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 uint8_t MapEvent( uint8_t event );
91
92 //------------------------------------------------------------------------
94 //------------------------------------------------------------------------
95 static void ClearErrorQueue();
96
97 private:
98
99 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
108 enum TlsHSRevert{ None, ReadOnWrite, WriteOnRead };
109
110 //------------------------------------------------------------------------
112 //------------------------------------------------------------------------
113 XRootDStatus ToStatus( XrdTls::RC rc );
114
115 //------------------------------------------------------------------------
117 //------------------------------------------------------------------------
118 Socket *pSocket;
119
120 //------------------------------------------------------------------------
122 //------------------------------------------------------------------------
123 std::unique_ptr<XrdTlsSocket> pTls;
124
125 //------------------------------------------------------------------------
126 // In case during TLS hand-shake WantRead has been returned on write or
127 // WantWrite has been returned on read we need to flip the following events.
128 //
129 // None : all events should be processed normally
130 // ReadOnWrite : on write event the OnRead routines should be called
131 // WriteOnRead : on read event the OnWrite routines should be called
132 //------------------------------------------------------------------------
133 TlsHSRevert pTlsHSRevert;
134
135 //------------------------------------------------------------------------
137 //------------------------------------------------------------------------
138 AsyncSocketHandler *pSocketHandler;
139 };
140}
141
142#endif // __XRD_CL_TLS_HH__
143
A network socket.
TLS layer for socket connection.
Definition XrdClTls.hh:40
XRootDStatus ReadV(iovec *iov, int iocnt, int &bytesRead)
Definition XrdClTls.cc:279
XRootDStatus Read(char *buffer, size_t size, int &bytesRead)
Definition XrdClTls.cc:216
uint8_t MapEvent(uint8_t event)
Definition XrdClTls.cc:402
static void ClearErrorQueue()
Clear the error queue for the calling thread.
Definition XrdClTls.cc:422
XRootDStatus Send(const char *buffer, size_t size, int &bytesWritten)
Definition XrdClTls.cc:294
~Tls()
Destructor.
Definition XrdClTls.hh:51
void Shutdown()
Shutdown the TLS/SSL connection.
Definition XrdClTls.cc:362
XRootDStatus Connect(const std::string &thehost, XrdNetAddrInfo *netInfo)
Establish a TLS/SSL session and perform host verification.
Definition XrdClTls.cc:162
bool InitTLS()
Definition XrdClTls.cc:96
none object for initializing empty Optional