xrootd
XrdClXRootDTransport.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3// Author: Lukasz Janyst <ljanyst@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
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// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25#ifndef __XRD_CL_XROOTD_TRANSPORT_HH__
26#define __XRD_CL_XROOTD_TRANSPORT_HH__
27
31#include "XrdOuc/XrdOucEnv.hh"
32
33class XrdSysPlugin;
34class XrdSecProtect;
35
36namespace XrdCl
37{
38 struct XRootDChannelInfo;
39 struct PluginUnloadHandler;
40
41 //----------------------------------------------------------------------------
43 //----------------------------------------------------------------------------
45 {
46 static const uint16_t ServerFlags = 1002;
47 static const uint16_t ProtocolVersion = 1003;
48 };
49
50 //----------------------------------------------------------------------------
52 //----------------------------------------------------------------------------
54 {
55 public:
56 //------------------------------------------------------------------------
58 //------------------------------------------------------------------------
60
61 //------------------------------------------------------------------------
63 //------------------------------------------------------------------------
65
66 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
78 virtual Status GetHeader( Message *message, int socket );
79
80 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 virtual Status GetBody( Message *message, int socket );
91
92 //------------------------------------------------------------------------
94 //------------------------------------------------------------------------
95 virtual void InitializeChannel( AnyObject &channelData ); //< we keep this as we need to implement the abstract method
96 virtual void InitializeChannel( const URL &url, AnyObject &channelData );
97
98 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
101 virtual void FinalizeChannel( AnyObject &channelData );
102
103 //------------------------------------------------------------------------
105 //------------------------------------------------------------------------
106 virtual Status HandShake( HandShakeData *handShakeData,
107 AnyObject &channelData );
108
109 //------------------------------------------------------------------------
111 //------------------------------------------------------------------------
112 virtual bool IsStreamTTLElapsed( time_t time,
113 uint16_t streamId,
114 AnyObject &channelData );
115
116 //------------------------------------------------------------------------
119 //------------------------------------------------------------------------
120 virtual Status IsStreamBroken( time_t inactiveTime,
121 uint16_t streamId,
122 AnyObject &channelData );
123
124 //------------------------------------------------------------------------
130 //------------------------------------------------------------------------
131 virtual PathID Multiplex( Message *msg,
132 AnyObject &channelData,
133 PathID *hint = 0 );
134
135 //------------------------------------------------------------------------
141 //------------------------------------------------------------------------
143 uint16_t streamId,
144 AnyObject &channelData,
145 PathID *hint = 0 );
146
147 //------------------------------------------------------------------------
149 //------------------------------------------------------------------------
150 virtual uint16_t StreamNumber( AnyObject &channelData );
151
152 //------------------------------------------------------------------------
154 //------------------------------------------------------------------------
155 virtual uint16_t SubStreamNumber( AnyObject &channelData );
156
157 //------------------------------------------------------------------------
160 //------------------------------------------------------------------------
162 {
163 return true;
164 }
165
166 //------------------------------------------------------------------------
168 //------------------------------------------------------------------------
170
171 //------------------------------------------------------------------------
174 //------------------------------------------------------------------------
176
177 //------------------------------------------------------------------------
179 //------------------------------------------------------------------------
180 static Status UnMarshallBody( Message *msg, uint16_t reqType );
181
182 //------------------------------------------------------------------------
184 //------------------------------------------------------------------------
185 static void UnMarshallHeader( Message *msg );
186
187 //------------------------------------------------------------------------
189 //------------------------------------------------------------------------
190 static void LogErrorResponse( const Message &msg );
191
192 //------------------------------------------------------------------------
194 //------------------------------------------------------------------------
195 static uint16_t NbConnectedStrm( AnyObject &channelData );
196
197 //------------------------------------------------------------------------
199 //------------------------------------------------------------------------
200 virtual void Disconnect( AnyObject &channelData,
201 uint16_t streamId,
202 uint16_t subStreamId );
203
204 //------------------------------------------------------------------------
206 //------------------------------------------------------------------------
207 virtual Status Query( uint16_t query,
208 AnyObject &result,
209 AnyObject &channelData );
210
211 //------------------------------------------------------------------------
213 //------------------------------------------------------------------------
214 static void SetDescription( Message *msg );
215
216 //------------------------------------------------------------------------
218 //------------------------------------------------------------------------
219 virtual uint32_t MessageReceived( Message *msg,
220 uint16_t streamId,
221 uint16_t subStream,
222 AnyObject &channelData );
223
224 //------------------------------------------------------------------------
226 //------------------------------------------------------------------------
227 virtual void MessageSent( Message *msg,
228 uint16_t streamId,
229 uint16_t subStream,
230 uint32_t bytesSent,
231 AnyObject &channelData );
232
233 //------------------------------------------------------------------------
235 //------------------------------------------------------------------------
236 virtual Status GetSignature( Message *toSign, Message *&sign,
237 AnyObject &channelData );
238
239 //------------------------------------------------------------------------
241 //------------------------------------------------------------------------
242 Status GetSignature( Message *toSign, Message *&sign, XRootDChannelInfo *info );
243
244 //------------------------------------------------------------------------
246 //------------------------------------------------------------------------
247 Status ClassifyErrno( int error );
248
249 private:
250
251 //------------------------------------------------------------------------
252 // Hand shake the main stream
253 //------------------------------------------------------------------------
255 AnyObject &channelData );
256
257 //------------------------------------------------------------------------
258 // Hand shake a parallel stream
259 //------------------------------------------------------------------------
261 AnyObject &channelData );
262
263 //------------------------------------------------------------------------
264 // Generate the message to be sent as an initial handshake
265 //------------------------------------------------------------------------
267 XRootDChannelInfo *info );
268
269 //------------------------------------------------------------------------
270 // Generate the message to be sent as an initial handshake
271 // (handshake + kXR_protocol)
272 //------------------------------------------------------------------------
274 XRootDChannelInfo *info );
275
276 //------------------------------------------------------------------------
277 // Process the server initial handshake response
278 //------------------------------------------------------------------------
280 XRootDChannelInfo *info );
281
282 //-----------------------------------------------------------------------
283 // Process the protocol response
284 //------------------------------------------------------------------------
286 XRootDChannelInfo *info );
287
288 //------------------------------------------------------------------------
289 // Generate the bind message
290 //------------------------------------------------------------------------
292 XRootDChannelInfo *info );
293
294 //------------------------------------------------------------------------
295 // Generate the bind message
296 //------------------------------------------------------------------------
298 XRootDChannelInfo *info );
299
300 //------------------------------------------------------------------------
301 // Generate the login message
302 //------------------------------------------------------------------------
304 XRootDChannelInfo *info );
305
306 //------------------------------------------------------------------------
307 // Process the login response
308 //------------------------------------------------------------------------
310 XRootDChannelInfo *info );
311
312 //------------------------------------------------------------------------
313 // Do the authentication
314 //------------------------------------------------------------------------
316 XRootDChannelInfo *info );
317
318 //------------------------------------------------------------------------
319 // Get the initial credentials using one of the protocols
320 //------------------------------------------------------------------------
322 HandShakeData *hsData,
323 XRootDChannelInfo *info );
324
325 //------------------------------------------------------------------------
326 // Clean up the data structures created for the authentication process
327 //------------------------------------------------------------------------
328 Status CleanUpAuthentication( XRootDChannelInfo *info );
329
330 //------------------------------------------------------------------------
331 // Clean up the data structures created for the protection purposes
332 //------------------------------------------------------------------------
333 Status CleanUpProtection( XRootDChannelInfo *info );
334
335 //------------------------------------------------------------------------
336 // Get the authentication function handle
337 //------------------------------------------------------------------------
339
340 //------------------------------------------------------------------------
341 // Generate the end session message
342 //------------------------------------------------------------------------
344 XRootDChannelInfo *info );
345
346 //------------------------------------------------------------------------
347 // Process the end session response
348 //------------------------------------------------------------------------
350 XRootDChannelInfo *info );
351
352 //------------------------------------------------------------------------
353 // Get a string representation of the server flags
354 //------------------------------------------------------------------------
355 static std::string ServerFlagsToStr( uint32_t flags );
356
357 //------------------------------------------------------------------------
358 // Get a string representation of file handle
359 //------------------------------------------------------------------------
360 static std::string FileHandleToStr( const unsigned char handle[4] );
361
362 friend struct PluginUnloadHandler;
364 };
365}
366
367#endif // __XRD_CL_XROOTD_TRANSPORT_HANDLER_HH__
XrdSecProtocol *(* XrdSecGetProt_t)(const char *, XrdNetAddrInfo &, XrdSecParameters &, XrdOucErrInfo *)
Typedef to simplify the encoding of methods returning XrdSecProtocol.
Definition: XrdSecInterface.hh:465
Definition: XrdClAnyObject.hh:33
The message representation used throughout the system.
Definition: XrdClMessage.hh:30
Perform the handshake and the authentication for each physical stream.
Definition: XrdClPostMasterInterfaces.hh:303
URL representation.
Definition: XrdClURL.hh:31
XRootD transport handler.
Definition: XrdClXRootDTransport.hh:54
virtual bool NeedControlConnection()
Definition: XrdClXRootDTransport.hh:161
static Status UnMarshallBody(Message *msg, uint16_t reqType)
Unmarshall the body of the incoming message.
static void SetDescription(Message *msg)
Get the description of a message.
Status CleanUpProtection(XRootDChannelInfo *info)
virtual void InitializeChannel(const URL &url, AnyObject &channelData)
static std::string FileHandleToStr(const unsigned char handle[4])
XRootDTransport()
Constructor.
virtual Status GetSignature(Message *toSign, Message *&sign, AnyObject &channelData)
Get signature for given message.
virtual PathID MultiplexSubStream(Message *msg, uint16_t streamId, AnyObject &channelData, PathID *hint=0)
static Status MarshallRequest(Message *msg)
Marshal the outgoing message.
Status CleanUpAuthentication(XRootDChannelInfo *info)
Message * GenerateLogIn(HandShakeData *hsData, XRootDChannelInfo *info)
~XRootDTransport()
Destructor.
Status ProcessEndSessionResp(HandShakeData *hsData, XRootDChannelInfo *info)
Status HandShakeMain(HandShakeData *handShakeData, AnyObject &channelData)
Status ProcessBindResp(HandShakeData *hsData, XRootDChannelInfo *info)
static std::string ServerFlagsToStr(uint32_t flags)
virtual uint32_t MessageReceived(Message *msg, uint16_t streamId, uint16_t subStream, AnyObject &channelData)
Check if the message invokes a stream action.
virtual Status HandShake(HandShakeData *handShakeData, AnyObject &channelData)
HandShake.
virtual void MessageSent(Message *msg, uint16_t streamId, uint16_t subStream, uint32_t bytesSent, AnyObject &channelData)
Notify the transport about a message having been sent.
PluginUnloadHandler * pSecUnloadHandler
Definition: XrdClXRootDTransport.hh:363
virtual void InitializeChannel(AnyObject &channelData)
Initialize channel.
Status DoAuthentication(HandShakeData *hsData, XRootDChannelInfo *info)
static void LogErrorResponse(const Message &msg)
Log server error response.
Status ClassifyErrno(int error)
Classify errno while reading/writing.
static void UnMarshallHeader(Message *msg)
Unmarshall the header incoming message.
virtual Status Query(uint16_t query, AnyObject &result, AnyObject &channelData)
Query the channel.
Message * GenerateInitialHS(HandShakeData *hsData, XRootDChannelInfo *info)
virtual uint16_t SubStreamNumber(AnyObject &channelData)
Return a number of substreams per stream that should be created.
Status GetCredentials(XrdSecCredentials *&credentials, HandShakeData *hsData, XRootDChannelInfo *info)
static uint16_t NbConnectedStrm(AnyObject &channelData)
Number of currently connected data streams.
virtual PathID Multiplex(Message *msg, AnyObject &channelData, PathID *hint=0)
XrdSecGetProt_t GetAuthHandler()
virtual Status IsStreamBroken(time_t inactiveTime, uint16_t streamId, AnyObject &channelData)
Message * GenerateEndSession(HandShakeData *hsData, XRootDChannelInfo *info)
virtual void Disconnect(AnyObject &channelData, uint16_t streamId, uint16_t subStreamId)
The stream has been disconnected, do the cleanups.
virtual bool IsStreamTTLElapsed(time_t time, uint16_t streamId, AnyObject &channelData)
Check if the stream should be disconnected.
virtual uint16_t StreamNumber(AnyObject &channelData)
Return a number of streams that should be created.
virtual Status GetHeader(Message *message, int socket)
Message * GenerateBind(HandShakeData *hsData, XRootDChannelInfo *info)
Status ProcessProtocolResp(HandShakeData *hsData, XRootDChannelInfo *info)
static Status UnMarshallRequest(Message *msg)
Status GetSignature(Message *toSign, Message *&sign, XRootDChannelInfo *info)
Get signature for given message.
friend struct PluginUnloadHandler
Definition: XrdClXRootDTransport.hh:362
Status ProcessServerHS(HandShakeData *hsData, XRootDChannelInfo *info)
virtual Status GetBody(Message *message, int socket)
Message * GenerateInitialHSProtocol(HandShakeData *hsData, XRootDChannelInfo *info)
Status ProcessLogInResp(HandShakeData *hsData, XRootDChannelInfo *info)
virtual void FinalizeChannel(AnyObject &channelData)
Finalize channel.
Status HandShakeParallel(HandShakeData *handShakeData, AnyObject &channelData)
Definition: XrdSecProtect.hh:56
Definition: XrdSysPlugin.hh:53
Definition: XrdClAnyObject.hh:26
Data structure that carries the handshake information.
Definition: XrdClPostMasterInterfaces.hh:257
Definition: XrdClPostMasterInterfaces.hh:283
Procedure execution status.
Definition: XrdClStatus.hh:110
XRootD related protocol queries.
Definition: XrdClXRootDTransport.hh:45
static const uint16_t ServerFlags
returns server flags
Definition: XrdClXRootDTransport.hh:46
static const uint16_t ProtocolVersion
returns the protocol version
Definition: XrdClXRootDTransport.hh:47
Generic structure to pass security information back and forth.
Definition: XrdSecInterface.hh:51