xrootd
Loading...
Searching...
No Matches
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
29#include "XrdCl/XrdClMessage.hh"
32#include "XrdOuc/XrdOucEnv.hh"
33
34class XrdSysPlugin;
35class XrdSecProtect;
36
37namespace XrdCl
38{
39 class Tls;
40 class Socket;
41 struct XRootDChannelInfo;
42 struct PluginUnloadHandler;
43
44 //----------------------------------------------------------------------------
46 //----------------------------------------------------------------------------
48 {
49 public:
50 //------------------------------------------------------------------------
52 //------------------------------------------------------------------------
54
55 //------------------------------------------------------------------------
57 //------------------------------------------------------------------------
59
60 //------------------------------------------------------------------------
71 //------------------------------------------------------------------------
72 virtual XRootDStatus GetHeader( Message &message, Socket *socket );
73
74 //------------------------------------------------------------------------
83 //------------------------------------------------------------------------
84 virtual XRootDStatus GetBody( Message &message, Socket *socket );
85
86 //------------------------------------------------------------------------
96 //------------------------------------------------------------------------
97 virtual XRootDStatus GetMore( Message &message, Socket *socket );
98
99 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
102 virtual void InitializeChannel( const URL &url,
103 AnyObject &channelData );
104
105 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
108 virtual void FinalizeChannel( AnyObject &channelData );
109
110 //------------------------------------------------------------------------
112 //------------------------------------------------------------------------
113 virtual XRootDStatus HandShake( HandShakeData *handShakeData,
114 AnyObject &channelData );
115
116 //------------------------------------------------------------------------
117 // @return true if handshake has been done and stream is connected,
118 // false otherwise
119 //------------------------------------------------------------------------
120 virtual bool HandShakeDone( HandShakeData *handShakeData,
121 AnyObject &channelData );
122
123 //------------------------------------------------------------------------
125 //------------------------------------------------------------------------
126 virtual bool IsStreamTTLElapsed( time_t time,
127 AnyObject &channelData );
128
129 //------------------------------------------------------------------------
132 //------------------------------------------------------------------------
133 virtual Status IsStreamBroken( time_t inactiveTime,
134 AnyObject &channelData );
135
136 //------------------------------------------------------------------------
142 //------------------------------------------------------------------------
143 virtual PathID Multiplex( Message *msg,
144 AnyObject &channelData,
145 PathID *hint = 0 );
146
147 //------------------------------------------------------------------------
153 //------------------------------------------------------------------------
155 AnyObject &channelData,
156 PathID *hint = 0 );
157
158 //------------------------------------------------------------------------
160 //------------------------------------------------------------------------
161 virtual uint16_t SubStreamNumber( AnyObject &channelData );
162
163 //------------------------------------------------------------------------
166 //------------------------------------------------------------------------
168 {
169 return true;
170 }
171
172 //------------------------------------------------------------------------
174 //------------------------------------------------------------------------
176 {
177 MarshallRequest( msg->GetBuffer() );
178 msg->SetIsMarshalled( true );
179 return XRootDStatus();
180 }
181
182 //------------------------------------------------------------------------
184 //------------------------------------------------------------------------
185 static XRootDStatus MarshallRequest( char *msg );
186
187 //------------------------------------------------------------------------
190 //------------------------------------------------------------------------
192
193 //------------------------------------------------------------------------
195 //------------------------------------------------------------------------
196 static XRootDStatus UnMarshallBody( Message *msg, uint16_t reqType );
197
198 //------------------------------------------------------------------------
200 //------------------------------------------------------------------------
201 static XRootDStatus UnMarshalStatusBody( Message &msg, uint16_t reqType );
202
203 //------------------------------------------------------------------------
205 //------------------------------------------------------------------------
207
208 //------------------------------------------------------------------------
210 //------------------------------------------------------------------------
211 static void UnMarshallHeader( Message &msg );
212
213 //------------------------------------------------------------------------
215 //------------------------------------------------------------------------
216 static void LogErrorResponse( const Message &msg );
217
218 //------------------------------------------------------------------------
220 //------------------------------------------------------------------------
221 static uint16_t NbConnectedStrm( AnyObject &channelData );
222
223 //------------------------------------------------------------------------
225 //------------------------------------------------------------------------
226 virtual void Disconnect( AnyObject &channelData,
227 uint16_t subStreamId );
228
229 //------------------------------------------------------------------------
231 //------------------------------------------------------------------------
232 virtual Status Query( uint16_t query,
233 AnyObject &result,
234 AnyObject &channelData );
235
236
237 //------------------------------------------------------------------------
239 //------------------------------------------------------------------------
240 static void GenerateDescription( char *msg, std::ostringstream &o );
241
242 //------------------------------------------------------------------------
244 //------------------------------------------------------------------------
245 inline static void SetDescription( Message *msg )
246 {
247 std::ostringstream o;
248 GenerateDescription( msg->GetBuffer(), o );
249 msg->SetDescription( o.str() );
250 }
251
252 //------------------------------------------------------------------------
254 //------------------------------------------------------------------------
255 virtual uint32_t MessageReceived( Message &msg,
256 uint16_t subStream,
257 AnyObject &channelData );
258
259 //------------------------------------------------------------------------
261 //------------------------------------------------------------------------
262 virtual void MessageSent( Message *msg,
263 uint16_t subStream,
264 uint32_t bytesSent,
265 AnyObject &channelData );
266
267 //------------------------------------------------------------------------
269 //------------------------------------------------------------------------
270 virtual Status GetSignature( Message *toSign, Message *&sign,
271 AnyObject &channelData );
272
273 //------------------------------------------------------------------------
275 //------------------------------------------------------------------------
276 virtual Status GetSignature( Message *toSign, Message *&sign,
277 XRootDChannelInfo *info );
278
279 //------------------------------------------------------------------------
281 //------------------------------------------------------------------------
282 virtual void DecFileInstCnt( AnyObject &channelData );
283
284 //------------------------------------------------------------------------
286 //------------------------------------------------------------------------
287 virtual void WaitBeforeExit();
288
289 //------------------------------------------------------------------------
291 //------------------------------------------------------------------------
292 virtual bool NeedEncryption( HandShakeData *handShakeData,
293 AnyObject &channelData );
294
295 //------------------------------------------------------------------------
297 //------------------------------------------------------------------------
298 virtual URL GetBindPreference( const URL &url,
299 AnyObject &channelData );
300
301 private:
302
303 //------------------------------------------------------------------------
304 // Hand shake the main stream
305 //------------------------------------------------------------------------
307 AnyObject &channelData );
308
309 //------------------------------------------------------------------------
310 // Hand shake a parallel stream
311 //------------------------------------------------------------------------
313 AnyObject &channelData );
314
315 //------------------------------------------------------------------------
316 // Generate the message to be sent as an initial handshake
317 // (handshake + kXR_protocol)
318 //------------------------------------------------------------------------
320 XRootDChannelInfo *info,
321 kXR_char expect );
322
323 //------------------------------------------------------------------------
324 // Generate the protocol message
325 //------------------------------------------------------------------------
327 XRootDChannelInfo *info,
328 kXR_char expect );
329
330 //------------------------------------------------------------------------
331 // Initialize protocol request
332 //------------------------------------------------------------------------
334 XRootDChannelInfo *info,
335 kXR_char expect );
336
337 //------------------------------------------------------------------------
338 // Process the server initial handshake response
339 //------------------------------------------------------------------------
341 XRootDChannelInfo *info );
342
343 //------------------------------------------------------------------------
344 // Process the protocol response
345 //------------------------------------------------------------------------
347 XRootDChannelInfo *info );
348
349 //------------------------------------------------------------------------
350 // Process the protocol body:
351 // * 'B' : bind preferences
352 // * 'S' : security requirements
353 //------------------------------------------------------------------------
355 size_t bodysize,
356 XRootDChannelInfo *info );
357
358 //------------------------------------------------------------------------
359 // Generate the bind message
360 //------------------------------------------------------------------------
362 XRootDChannelInfo *info );
363
364 //------------------------------------------------------------------------
365 // Generate the bind message
366 //------------------------------------------------------------------------
368 XRootDChannelInfo *info );
369
370 //------------------------------------------------------------------------
371 // Generate the login message
372 //------------------------------------------------------------------------
374 XRootDChannelInfo *info );
375
376 //------------------------------------------------------------------------
377 // Process the login response
378 //------------------------------------------------------------------------
380 XRootDChannelInfo *info );
381
382 //------------------------------------------------------------------------
383 // Do the authentication
384 //------------------------------------------------------------------------
386 XRootDChannelInfo *info );
387
388 //------------------------------------------------------------------------
389 // Get the initial credentials using one of the protocols
390 //------------------------------------------------------------------------
392 HandShakeData *hsData,
393 XRootDChannelInfo *info );
394
395 //------------------------------------------------------------------------
396 // Clean up the data structures created for the authentication process
397 //------------------------------------------------------------------------
398 Status CleanUpAuthentication( XRootDChannelInfo *info );
399
400 //------------------------------------------------------------------------
401 // Clean up the data structures created for the protection purposes
402 //------------------------------------------------------------------------
403 Status CleanUpProtection( XRootDChannelInfo *info );
404
405 //------------------------------------------------------------------------
406 // Get the authentication function handle
407 //------------------------------------------------------------------------
409
410 //------------------------------------------------------------------------
411 // Generate the end session message
412 //------------------------------------------------------------------------
414 XRootDChannelInfo *info );
415
416 //------------------------------------------------------------------------
417 // Process the end session response
418 //------------------------------------------------------------------------
420 XRootDChannelInfo *info );
421
422 //------------------------------------------------------------------------
423 // Get a string representation of the server flags
424 //------------------------------------------------------------------------
425 static std::string ServerFlagsToStr( uint32_t flags );
426
427 //------------------------------------------------------------------------
428 // Get a string representation of file handle
429 //------------------------------------------------------------------------
430 static std::string FileHandleToStr( const unsigned char handle[4] );
431
432 friend struct PluginUnloadHandler;
434 };
435}
436
437#endif // __XRD_CL_XROOTD_TRANSPORT_HANDLER_HH__
unsigned char kXR_char
Definition XPtypes.hh:65
XrdSecProtocol *(* XrdSecGetProt_t)(const char *hostname, XrdNetAddrInfo &endPoint, XrdSecParameters &sectoken, XrdOucErrInfo *einfo)
Typedef to simplify the encoding of methods returning XrdSecProtocol.
Definition XrdSecInterface.hh:483
Definition XrdClAnyObject.hh:33
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Definition XrdClBuffer.hh:72
The message representation used throughout the system.
Definition XrdClMessage.hh:30
void SetDescription(const std::string &description)
Set the description of the message.
Definition XrdClMessage.hh:87
void SetIsMarshalled(bool isMarshalled)
Set the marshalling status.
Definition XrdClMessage.hh:79
A network socket.
Definition XrdClSocket.hh:43
Perform the handshake and the authentication for each physical stream.
Definition XrdClPostMasterInterfaces.hh:310
URL representation.
Definition XrdClURL.hh:31
Request status.
Definition XrdClXRootDResponses.hh:219
XRootD transport handler.
Definition XrdClXRootDTransport.hh:48
void InitProtocolReq(ClientProtocolRequest *request, XRootDChannelInfo *info, kXR_char expect)
virtual bool NeedControlConnection()
Definition XrdClXRootDTransport.hh:167
static void SetDescription(Message *msg)
Get the description of a message.
Definition XrdClXRootDTransport.hh:245
Status CleanUpProtection(XRootDChannelInfo *info)
virtual void InitializeChannel(const URL &url, AnyObject &channelData)
Initialize channel.
static std::string FileHandleToStr(const unsigned char handle[4])
XRootDTransport()
Constructor.
virtual XRootDStatus GetHeader(Message &message, Socket *socket)
virtual Status GetSignature(Message *toSign, Message *&sign, AnyObject &channelData)
Get signature for given message.
static void UnMarshallHeader(Message &msg)
Unmarshall the header incoming message.
virtual XRootDStatus GetMore(Message &message, Socket *socket)
virtual bool NeedEncryption(HandShakeData *handShakeData, AnyObject &channelData)
virtual void MessageSent(Message *msg, uint16_t subStream, uint32_t bytesSent, AnyObject &channelData)
Notify the transport about a message having been sent.
Message * GenerateInitialHSProtocol(HandShakeData *hsData, XRootDChannelInfo *info, kXR_char expect)
XRootDStatus HandShakeParallel(HandShakeData *handShakeData, AnyObject &channelData)
virtual bool HandShakeDone(HandShakeData *handShakeData, AnyObject &channelData)
Status CleanUpAuthentication(XRootDChannelInfo *info)
XRootDStatus ProcessProtocolResp(HandShakeData *hsData, XRootDChannelInfo *info)
Message * GenerateLogIn(HandShakeData *hsData, XRootDChannelInfo *info)
XRootDStatus HandShakeMain(HandShakeData *handShakeData, AnyObject &channelData)
~XRootDTransport()
Destructor.
virtual void WaitBeforeExit()
Wait until the program can safely exit.
Status ProcessEndSessionResp(HandShakeData *hsData, XRootDChannelInfo *info)
XRootDStatus DoAuthentication(HandShakeData *hsData, XRootDChannelInfo *info)
static std::string ServerFlagsToStr(uint32_t flags)
PluginUnloadHandler * pSecUnloadHandler
Definition XrdClXRootDTransport.hh:433
static XRootDStatus UnMarshalStatusBody(Message &msg, uint16_t reqType)
Unmarshall the body of the status response.
Message * GenerateProtocol(HandShakeData *hsData, XRootDChannelInfo *info, kXR_char expect)
static void LogErrorResponse(const Message &msg)
Log server error response.
XRootDStatus ProcessProtocolBody(char *bodybuff, size_t bodysize, XRootDChannelInfo *info)
virtual Status Query(uint16_t query, AnyObject &result, AnyObject &channelData)
Query the channel.
XRootDStatus ProcessLogInResp(HandShakeData *hsData, XRootDChannelInfo *info)
virtual uint16_t SubStreamNumber(AnyObject &channelData)
Return a number of substreams per stream that should be created.
virtual PathID MultiplexSubStream(Message *msg, AnyObject &channelData, PathID *hint=0)
static uint16_t NbConnectedStrm(AnyObject &channelData)
Number of currently connected data streams.
virtual PathID Multiplex(Message *msg, AnyObject &channelData, PathID *hint=0)
virtual XRootDStatus GetBody(Message &message, Socket *socket)
virtual uint32_t MessageReceived(Message &msg, uint16_t subStream, AnyObject &channelData)
Check if the message invokes a stream action.
XrdSecGetProt_t GetAuthHandler()
Message * GenerateEndSession(HandShakeData *hsData, XRootDChannelInfo *info)
virtual void DecFileInstCnt(AnyObject &channelData)
Decrement file object instance count bound to this channel.
virtual XRootDStatus HandShake(HandShakeData *handShakeData, AnyObject &channelData)
HandShake.
Message * GenerateBind(HandShakeData *hsData, XRootDChannelInfo *info)
XRootDStatus ProcessBindResp(HandShakeData *hsData, XRootDChannelInfo *info)
static void GenerateDescription(char *msg, std::ostringstream &o)
Get the description of a message.
virtual Status GetSignature(Message *toSign, Message *&sign, XRootDChannelInfo *info)
Get signature for given message.
static XRootDStatus UnMarshallBody(Message *msg, uint16_t reqType)
Unmarshall the body of the incoming message.
static XRootDStatus UnMarchalStatusMore(Message &msg)
Unmarshall the correction-segment of the status response for pgwrite.
XRootDStatus ProcessServerHS(HandShakeData *hsData, XRootDChannelInfo *info)
virtual Status IsStreamBroken(time_t inactiveTime, AnyObject &channelData)
friend struct PluginUnloadHandler
Definition XrdClXRootDTransport.hh:432
virtual bool IsStreamTTLElapsed(time_t time, AnyObject &channelData)
Check if the stream should be disconnected.
static XRootDStatus MarshallRequest(char *msg)
Marshal the outgoing message.
static XRootDStatus MarshallRequest(Message *msg)
Marshal the outgoing message.
Definition XrdClXRootDTransport.hh:175
XRootDStatus GetCredentials(XrdSecCredentials *&credentials, HandShakeData *hsData, XRootDChannelInfo *info)
static XRootDStatus UnMarshallRequest(Message *msg)
virtual URL GetBindPreference(const URL &url, AnyObject &channelData)
Get bind preference for the next data stream.
virtual void Disconnect(AnyObject &channelData, uint16_t subStreamId)
The stream has been disconnected, do the cleanups.
virtual void FinalizeChannel(AnyObject &channelData)
Finalize channel.
Definition XrdSecProtect.hh:56
Definition XrdSysPlugin.hh:53
Definition XrdClAction.hh:34
Definition XProtocol.hh:555
Data structure that carries the handshake information.
Definition XrdClPostMasterInterfaces.hh:244
Definition XrdClPostMasterInterfaces.hh:269
Procedure execution status.
Definition XrdClStatus.hh:115
Generic structure to pass security information back and forth.
Definition XrdSecInterface.hh:51