xrootd
Loading...
Searching...
No Matches
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
29class XrdNetAddrInfo;
30class XrdSysError;
31class XrdTlsContext;
32class XrdTlsPeerCerts;
33struct XrdTlsSocketImpl;
34
35//----------------------------------------------------------------------------
37//----------------------------------------------------------------------------
38
40{
41public:
42
50
52{
53 TLS_HS_BLOCK = true,
54 TLS_HS_NOBLK = false,
55};
56
57//------------------------------------------------------------------------
76//------------------------------------------------------------------------
77
78 XrdTlsSocket( XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm,
79 bool isClient, bool serial=true );
80
81//------------------------------------------------------------------------
84//------------------------------------------------------------------------
85
87
88//------------------------------------------------------------------------
90//------------------------------------------------------------------------
91
93
94//------------------------------------------------------------------------
100//------------------------------------------------------------------------
101
102 XrdTls::RC Accept(std::string *eMsg=0);
103
104//------------------------------------------------------------------------
114//------------------------------------------------------------------------
115
116 XrdTls::RC Connect(const char *thehost=0, std::string *eWhy=0);
117
118//------------------------------------------------------------------------
122//------------------------------------------------------------------------
123
125
126//------------------------------------------------------------------------
135//------------------------------------------------------------------------
136
137XrdTlsPeerCerts *getCerts(bool ver=true);
138
139//------------------------------------------------------------------------
163//------------------------------------------------------------------------
164
165 const char *Init( XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm,
166 bool isClient, bool serial=true, const char *tid="" );
167
168//------------------------------------------------------------------------
177//------------------------------------------------------------------------
178
179 XrdTls::RC Peek( char *buffer, size_t size, int &bytesPeek );
180
181//------------------------------------------------------------------------
191//------------------------------------------------------------------------
192
193 int Pending(bool any=true);
194
195//------------------------------------------------------------------------
197//
204//------------------------------------------------------------------------
205
206 XrdTls::RC Read( char *buffer, size_t size, int &bytesRead );
207
208//------------------------------------------------------------------------
212//------------------------------------------------------------------------
213
214 void SetTraceID(const char *tid);
215
216//------------------------------------------------------------------------
223//------------------------------------------------------------------------
224
225 enum SDType {sdForce = 1, sdImmed = 2, sdWait = 3};
226
228
229//------------------------------------------------------------------------
238//------------------------------------------------------------------------
239
240 XrdTls::RC Write( const char *buffer, size_t size, int &bytesOut );
241
242//------------------------------------------------------------------------
245//------------------------------------------------------------------------
246
248
249//------------------------------------------------------------------------
251//------------------------------------------------------------------------
252
253 const char *Version();
254
255private:
256
257void AcceptEMsg(std::string *eWhy, const char *reason);
258int Diagnose(const char *what, int sslrc, int tcode);
259std::string Err2Text(int sslerr);
260bool NeedHS();
261bool Wait4OK(bool wantRead);
262
263XrdTlsSocketImpl *pImpl;
264};
265#endif // __XRD_TLS_IO_HH__
Definition XrdNetAddrInfo.hh:54
Definition XrdSysError.hh:90
Definition XrdTlsContext.hh:37
Definition XrdTlsPeerCerts.hh:35
Socket wrapper for TLS I/O.
Definition XrdTlsSocket.hh:40
std::string Err2Text(int sslerr)
SDType
Definition XrdTlsSocket.hh:225
@ sdImmed
Definition XrdTlsSocket.hh:225
@ sdWait
Definition XrdTlsSocket.hh:225
@ sdForce
Definition XrdTlsSocket.hh:225
HS_Mode
Definition XrdTlsSocket.hh:52
@ TLS_HS_BLOCK
Always block during handshake.
Definition XrdTlsSocket.hh:53
@ TLS_HS_NOBLK
Do not block during handshake.
Definition XrdTlsSocket.hh:54
int Diagnose(const char *what, int sslrc, int tcode)
XrdTlsContext * Context()
XrdTls::RC Accept(std::string *eMsg=0)
void Shutdown(SDType=sdImmed)
~XrdTlsSocket()
Destructor.
XrdTlsSocketImpl * pImpl
Definition XrdTlsSocket.hh:263
RW_Mode
Definition XrdTlsSocket.hh:44
@ TLS_RNB_WBL
Non-blocking read blocking write.
Definition XrdTlsSocket.hh:46
@ TLS_RBL_WNB
blocking read non-blocking write
Definition XrdTlsSocket.hh:47
@ TLS_RBL_WBL
blocking read blocking write
Definition XrdTlsSocket.hh:48
@ TLS_RNB_WNB
Non-blocking read non-blocking write.
Definition XrdTlsSocket.hh:45
bool NeedHandShake()
XrdTls::RC Write(const char *buffer, size_t size, int &bytesOut)
const char * Version()
XrdTlsSocket(XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm, bool isClient, bool serial=true)
XrdTls::RC Read(char *buffer, size_t size, int &bytesRead)
Read from the TLS connection. If necessary, a handshake will be done.
const char * Init(XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm, bool isClient, bool serial=true, const char *tid="")
XrdTls::RC Connect(const char *thehost=0, std::string *eWhy=0)
void AcceptEMsg(std::string *eWhy, const char *reason)
void SetTraceID(const char *tid)
int Pending(bool any=true)
XrdTls::RC Peek(char *buffer, size_t size, int &bytesPeek)
XrdTlsPeerCerts * getCerts(bool ver=true)
bool Wait4OK(bool wantRead)
RC
Definition XrdTls.hh:40