xrootd
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 
24 #include "XrdTls/XrdTlsSocket.hh"
25 
28 
29 namespace XrdCl
30 {
31  class Socket;
32 
33  //----------------------------------------------------------------------------
35  //----------------------------------------------------------------------------
36  class Tls
37  {
38  public:
39 
40  //------------------------------------------------------------------------
42  //------------------------------------------------------------------------
43  Tls( Socket *socket, AsyncSocketHandler *socketHandler );
44 
45  //------------------------------------------------------------------------
47  //------------------------------------------------------------------------
48  ~Tls()
49  {
50  }
51 
52  //------------------------------------------------------------------------
54  //------------------------------------------------------------------------
55  XRootDStatus Connect( const std::string &thehost, XrdNetAddrInfo *netInfo );
56 
57  //------------------------------------------------------------------------
60  //------------------------------------------------------------------------
61  XRootDStatus Read( char *buffer, size_t size, int &bytesRead );
62 
63  //------------------------------------------------------------------------
66  //------------------------------------------------------------------------
67  XRootDStatus Send( const char *buffer, size_t size, int &bytesWritten );
68 
69  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
76  uint8_t MapEvent( uint8_t event );
77 
78  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  static void ClearErrorQueue();
82 
83  private:
84 
85  //------------------------------------------------------------------------
93  //------------------------------------------------------------------------
95 
96  //------------------------------------------------------------------------
98  //------------------------------------------------------------------------
100 
101  //------------------------------------------------------------------------
103  //------------------------------------------------------------------------
105 
106  //------------------------------------------------------------------------
108  //------------------------------------------------------------------------
109  std::unique_ptr<XrdTlsSocket> pTls;
110 
111  //------------------------------------------------------------------------
112  // In case during TLS hand-shake WantRead has been returned on write or
113  // WantWrite has been returned on read we need to flip the following events.
114  //
115  // None : all events should be processed normally
116  // ReadOnWrite : on write event the OnRead routines should be called
117  // WriteOnRead : on read event the OnWrite routines should be called
118  //------------------------------------------------------------------------
120 
121  //------------------------------------------------------------------------
123  //------------------------------------------------------------------------
125  };
126 }
127 
128 #endif // __XRD_CL_TLS_HH__
129 
XrdClXRootDResponses.hh
XrdCl::Socket
A network socket.
Definition: XrdClSocket.hh:41
XrdCl::Tls::MapEvent
uint8_t MapEvent(uint8_t event)
XrdCl::Tls::None
@ None
Definition: XrdClTls.hh:94
XrdNetAddrInfo
Definition: XrdNetAddrInfo.hh:54
XrdCl::Tls::ClearErrorQueue
static void ClearErrorQueue()
Clear the error queue for the calling thread.
XrdCl::Tls::Connect
XRootDStatus Connect(const std::string &thehost, XrdNetAddrInfo *netInfo)
Establish a TLS/SSL session and perform host verification.
XrdClAsyncSocketHandler.hh
XrdCl::Tls::pSocket
Socket * pSocket
The underlying vanilla socket.
Definition: XrdClTls.hh:104
XrdTlsSocket.hh
XrdCl::Tls::Read
XRootDStatus Read(char *buffer, size_t size, int &bytesRead)
XrdCl::XRootDStatus
Request status.
Definition: XrdClXRootDResponses.hh:215
XrdCl::Tls::WriteOnRead
@ WriteOnRead
Definition: XrdClTls.hh:94
XrdCl::Tls::pTls
std::unique_ptr< XrdTlsSocket > pTls
The TSL I/O wrapper over socket.
Definition: XrdClTls.hh:109
XrdCl::Tls::pSocketHandler
AsyncSocketHandler * pSocketHandler
Socket handler (for enabling/disabling write notification)
Definition: XrdClTls.hh:124
XrdCl::Tls::Send
XRootDStatus Send(const char *buffer, size_t size, int &bytesWritten)
XrdCl::Tls::Tls
Tls(Socket *socket, AsyncSocketHandler *socketHandler)
Constructor - creates async TLS layer for given socker file descriptor.
XrdCl::AsyncSocketHandler
Definition: XrdClAsyncSocketHandler.hh:39
XrdCl::Tls::~Tls
~Tls()
Destructor.
Definition: XrdClTls.hh:48
XrdCl::Tls::ReadOnWrite
@ ReadOnWrite
Definition: XrdClTls.hh:94
XrdCl
Definition: XrdClAnyObject.hh:26
XrdCl::Tls::TlsHSRevert
TlsHSRevert
Definition: XrdClTls.hh:94
XrdCl::Tls::pTlsHSRevert
TlsHSRevert pTlsHSRevert
Definition: XrdClTls.hh:119
XrdCl::Tls::ToStatus
XRootDStatus ToStatus(XrdTls::RC rc)
Translate OPEN SSL error code into XRootD Status.
XrdCl::Tls
TLS layer for socket connection.
Definition: XrdClTls.hh:37
XrdTls::RC
RC
Definition: XrdTls.hh:40