xrootd
XrdTlsSocket.hh
Go to the documentation of this file.
1 #ifndef __XRD_TLS_SOCKET_HH__
2 #define __XRD_TLS_SOCKET_HH__
3 //------------------------------------------------------------------------------
4 // Copyright (c) 2011-2018 by European Organization for Nuclear Research (CERN)
5 // Author: Michal Simon <simonm@cern.ch>
6 //------------------------------------------------------------------------------
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //------------------------------------------------------------------------------
20 
21 #include <string>
22 
23 #include "XrdTls/XrdTls.hh"
24 
25 //----------------------------------------------------------------------------
26 // Forward declarations
27 //----------------------------------------------------------------------------
28 
29 class XrdNetAddrInfo;
30 class XrdSysError;
31 class XrdTlsContext;
32 class XrdTlsPeerCerts;
33 struct XrdTlsSocketImpl;
34 
35 //----------------------------------------------------------------------------
37 //----------------------------------------------------------------------------
38 
40 {
41 public:
42 
43 enum RW_Mode
44 {
49 };
50 
51 enum HS_Mode
52 {
53  TLS_HS_BLOCK = true,
54  TLS_HS_NOBLK = false,
55 };
56 
57 //------------------------------------------------------------------------
73 //------------------------------------------------------------------------
74 
75  XrdTlsSocket( XrdTlsContext &ctx, int sfd, RW_Mode rwm,
76  HS_Mode hsm, bool isClient );
77 
78 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
82 
84 
85 //------------------------------------------------------------------------
87 //------------------------------------------------------------------------
88 
90 
91 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 
99  XrdTls::RC Accept(std::string *eMsg=0);
100 
101 //------------------------------------------------------------------------
111 //------------------------------------------------------------------------
112 
113  XrdTls::RC Connect(const char *thehost=0, std::string *eWhy=0);
114 
115 //------------------------------------------------------------------------
119 //------------------------------------------------------------------------
120 
122 
123 //------------------------------------------------------------------------
132 //------------------------------------------------------------------------
133 
134 XrdTlsPeerCerts *getCerts(bool ver=true);
135 
136 //------------------------------------------------------------------------
157 //------------------------------------------------------------------------
158 
159  const char *Init( XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm,
160  bool isClient, const char *tid="" );
161 
162 //------------------------------------------------------------------------
171 //------------------------------------------------------------------------
172 
173  XrdTls::RC Peek( char *buffer, size_t size, int &bytesPeek );
174 
175 //------------------------------------------------------------------------
185 //------------------------------------------------------------------------
186 
187  int Pending(bool any=true);
188 
189 //------------------------------------------------------------------------
191 //
198 //------------------------------------------------------------------------
199 
200  XrdTls::RC Read( char *buffer, size_t size, int &bytesRead );
201 
202 //------------------------------------------------------------------------
206 //------------------------------------------------------------------------
207 
208  void SetTraceID(const char *tid);
209 
210 //------------------------------------------------------------------------
217 //------------------------------------------------------------------------
218 
219  enum SDType {sdForce = 1, sdImmed = 2, sdWait = 3};
220 
222 
223 //------------------------------------------------------------------------
232 //------------------------------------------------------------------------
233 
234  XrdTls::RC Write( const char *buffer, size_t size, int &bytesOut );
235 
236 //------------------------------------------------------------------------
239 //------------------------------------------------------------------------
240 
242 
243 //------------------------------------------------------------------------
245 //------------------------------------------------------------------------
246 
247  const char *Version();
248 
249 private:
250 
251 void AcceptEMsg(std::string *eWhy, const char *reason);
252 int Diagnose(const char *what, int sslrc, int tcode);
253 std::string Err2Text(int sslerr);
254 bool Wait4OK(bool wantRead);
255 
256 XrdTlsSocketImpl *pImpl;
257 };
258 #endif // __XRD_TLS_IO_HH__
XrdTlsSocket::SetTraceID
void SetTraceID(const char *tid)
XrdTlsSocket::RW_Mode
RW_Mode
Definition: XrdTlsSocket.hh:44
XrdTlsSocket::TLS_RNB_WBL
@ TLS_RNB_WBL
Non-blocking read blocking write.
Definition: XrdTlsSocket.hh:46
XrdTlsSocket::Wait4OK
bool Wait4OK(bool wantRead)
XrdTlsSocket::sdForce
@ sdForce
Definition: XrdTlsSocket.hh:219
XrdTlsSocket::Read
XrdTls::RC Read(char *buffer, size_t size, int &bytesRead)
Read from the TLS connection. If necessary, a handshake will be done.
XrdNetAddrInfo
Definition: XrdNetAddrInfo.hh:54
XrdTlsSocket::sdWait
@ sdWait
Definition: XrdTlsSocket.hh:219
XrdTlsSocket::TLS_RBL_WBL
@ TLS_RBL_WBL
blocking read blocking write
Definition: XrdTlsSocket.hh:48
XrdTlsSocket::NeedHandShake
bool NeedHandShake()
XrdTlsSocket::Diagnose
int Diagnose(const char *what, int sslrc, int tcode)
XrdTlsSocket::~XrdTlsSocket
~XrdTlsSocket()
Destructor.
XrdTlsSocket::Write
XrdTls::RC Write(const char *buffer, size_t size, int &bytesOut)
XrdTlsContext
Definition: XrdTlsContext.hh:37
XrdTlsSocket::XrdTlsSocket
XrdTlsSocket()
XrdTlsSocket::SDType
SDType
Definition: XrdTlsSocket.hh:219
XrdTlsSocket::sdImmed
@ sdImmed
Definition: XrdTlsSocket.hh:219
XrdTlsSocket::TLS_HS_NOBLK
@ TLS_HS_NOBLK
Do not block during handshake.
Definition: XrdTlsSocket.hh:54
XrdTlsSocket::Init
const char * Init(XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm, bool isClient, const char *tid="")
XrdTlsSocket::Shutdown
void Shutdown(SDType=sdImmed)
XrdTls.hh
XrdTlsSocket::Pending
int Pending(bool any=true)
XrdTlsSocket::getCerts
XrdTlsPeerCerts * getCerts(bool ver=true)
XrdTlsSocket
Socket wrapper for TLS I/O.
Definition: XrdTlsSocket.hh:40
XrdTlsSocket::TLS_RBL_WNB
@ TLS_RBL_WNB
blocking read non-blocking write
Definition: XrdTlsSocket.hh:47
XrdTlsSocket::Context
XrdTlsContext * Context()
XrdTlsSocket::Version
const char * Version()
XrdTlsSocket::Connect
XrdTls::RC Connect(const char *thehost=0, std::string *eWhy=0)
XrdTlsSocket::Err2Text
std::string Err2Text(int sslerr)
XrdTlsSocket::TLS_HS_BLOCK
@ TLS_HS_BLOCK
Always block during handshake.
Definition: XrdTlsSocket.hh:53
XrdTlsSocket::Accept
XrdTls::RC Accept(std::string *eMsg=0)
XrdTlsPeerCerts
Definition: XrdTlsPeerCerts.hh:35
XrdSysError
Definition: XrdSysError.hh:90
XrdTlsSocket::AcceptEMsg
void AcceptEMsg(std::string *eWhy, const char *reason)
XrdTlsSocket::Peek
XrdTls::RC Peek(char *buffer, size_t size, int &bytesPeek)
XrdTlsSocket::pImpl
XrdTlsSocketImpl * pImpl
Definition: XrdTlsSocket.hh:256
XrdTlsSocket::HS_Mode
HS_Mode
Definition: XrdTlsSocket.hh:52
XrdTlsSocket::TLS_RNB_WNB
@ TLS_RNB_WNB
Non-blocking read non-blocking write.
Definition: XrdTlsSocket.hh:45
XrdTlsSocket::XrdTlsSocket
XrdTlsSocket(XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm, bool isClient)
XrdTls::RC
RC
Definition: XrdTls.hh:40