xrootd
XrdClPostMasterInterfaces.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_POST_MASTER_INTERFACES_HH__
26 #define __XRD_CL_POST_MASTER_INTERFACES_HH__
27 
29 
30 #include <stdint.h>
31 #include <ctime>
32 
33 #include "XrdCl/XrdClStatus.hh"
34 #include "XrdCl/XrdClAnyObject.hh"
35 #include "XrdCl/XrdClURL.hh"
36 
37 class XrdNetAddr;
38 
39 namespace XrdCl
40 {
41  class Channel;
42  class Message;
43  class URL;
44  class Socket;
45 
46  //----------------------------------------------------------------------------
48  //----------------------------------------------------------------------------
50  {
51  public:
52  virtual ~MessageFilter() {}
53 
54  //------------------------------------------------------------------------
57  //------------------------------------------------------------------------
58  virtual bool Filter( const Message *msg ) = 0;
59 
60  //------------------------------------------------------------------------
64  //------------------------------------------------------------------------
65  virtual uint16_t GetSid() const = 0;
66  };
67 
68  //----------------------------------------------------------------------------
70  //----------------------------------------------------------------------------
72  {
73  public:
74  //------------------------------------------------------------------------
76  //------------------------------------------------------------------------
77  enum Action
78  {
79  None = 0x0000,
80  Take = 0x0001,
81  Ignore = 0x0002,
82  RemoveHandler = 0x0004,
83  Raw = 0x0008,
85  NoProcess = 0x0010,
88  Corrupted = 0x0020
91  };
94 
95  //------------------------------------------------------------------------
97  //------------------------------------------------------------------------
99  {
100  Ready = 1,
101  Broken = 2,
102  Timeout = 3,
104  };
105 
106  //------------------------------------------------------------------------
108  //------------------------------------------------------------------------
109 
110  virtual ~IncomingMsgHandler() {}
111 
112  //------------------------------------------------------------------------
118  //------------------------------------------------------------------------
119  virtual uint16_t Examine( Message *msg ) = 0;
120 
121  //------------------------------------------------------------------------
130  //------------------------------------------------------------------------
131  virtual uint16_t InspectStatusRsp( Message *msg ) = 0;
132 
133  //------------------------------------------------------------------------
137  //------------------------------------------------------------------------
138  virtual uint16_t GetSid() const = 0;
139 
140  //------------------------------------------------------------------------
144  //------------------------------------------------------------------------
145  virtual void Process( Message *msg ) { (void)msg; };
146 
147  //------------------------------------------------------------------------
157  //------------------------------------------------------------------------
159  Socket *socket,
160  uint32_t &bytesRead )
161  {
162  (void)msg; (void)socket; (void)bytesRead;
163  return Status( stOK, suDone );
164  };
165 
166  //------------------------------------------------------------------------
172  //------------------------------------------------------------------------
173  virtual uint8_t OnStreamEvent( StreamEvent event,
174  XRootDStatus status )
175  {
176  (void)event; (void)status;
177  return 0;
178  };
179  };
180 
181  //----------------------------------------------------------------------------
183  //----------------------------------------------------------------------------
185  {
186  public:
187  virtual ~OutgoingMsgHandler() {}
188 
189  //------------------------------------------------------------------------
191  //------------------------------------------------------------------------
192  virtual void OnStatusReady( const Message *message,
193  XRootDStatus status ) = 0;
194 
195  //------------------------------------------------------------------------
202  //------------------------------------------------------------------------
203  virtual void OnReadyToSend( Message *msg )
204  {
205  (void)msg;
206  };
207 
208  //------------------------------------------------------------------------
212  //------------------------------------------------------------------------
213  virtual bool IsRaw() const { return false; }
214 
215  //------------------------------------------------------------------------
224  //------------------------------------------------------------------------
225  virtual Status WriteMessageBody( Socket *socket,
226  uint32_t &bytesWritten )
227  {
228  (void)socket; (void)bytesWritten;
229  return Status();
230  }
231  };
232 
233  //----------------------------------------------------------------------------
235  //----------------------------------------------------------------------------
237  {
238  public:
239  //------------------------------------------------------------------------
241  //------------------------------------------------------------------------
243  {
247  };
248 
249  //------------------------------------------------------------------------
251  //------------------------------------------------------------------------
252  virtual ~ChannelEventHandler() {};
253 
254  //------------------------------------------------------------------------
262  //------------------------------------------------------------------------
263  virtual bool OnChannelEvent( ChannelEvent event,
264  Status status ) = 0;
265  };
266 
267  //----------------------------------------------------------------------------
269  //----------------------------------------------------------------------------
270 
272  {
273  //--------------------------------------------------------------------------
275  //--------------------------------------------------------------------------
276  HandShakeData( const URL *addr, uint16_t subStream ):
277  step(0), out(0), in(0), url(addr), subStreamId( subStream ),
278  startTime( time(0) ), serverAddr(0)
279  {}
280  uint16_t step;
283  const URL *url;
284  uint16_t subStreamId;
285  time_t startTime;
286  const
288  std::string clientName;
289  std::string streamName;
290  };
291 
292  //----------------------------------------------------------------------------
295  //----------------------------------------------------------------------------
296  struct PathID
297  {
298  PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
299  uint16_t up;
300  uint16_t down;
301  };
302 
303  //----------------------------------------------------------------------------
306  //----------------------------------------------------------------------------
308  {
309  static const uint16_t Name = 1;
310  static const uint16_t Auth = 2;
311  };
312 
313  //----------------------------------------------------------------------------
315  //----------------------------------------------------------------------------
317  {
318  public:
319 
320  //------------------------------------------------------------------------
322  //------------------------------------------------------------------------
324  {
325  NoAction = 0x0000,
326  DigestMsg = 0x0001,
327  AbortStream = 0x0002,
329  CloseStream = 0x0004,
332  ResumeStream = 0x0008,
334  HoldStream = 0x0010,
336  RequestClose = 0x0020
337  };
338 
339 
340  virtual ~TransportHandler() {}
341 
342  //------------------------------------------------------------------------
353  //------------------------------------------------------------------------
354  virtual XRootDStatus GetHeader( Message *message, Socket *socket ) = 0;
355 
356  //------------------------------------------------------------------------
365  //------------------------------------------------------------------------
366  virtual XRootDStatus GetBody( Message *message, Socket *socket ) = 0;
367 
368  //------------------------------------------------------------------------
370  //------------------------------------------------------------------------
371  virtual void InitializeChannel( const URL &url,
372  AnyObject &channelData ) = 0;
373 
374  //------------------------------------------------------------------------
376  //------------------------------------------------------------------------
377  virtual void FinalizeChannel( AnyObject &channelData ) = 0;
378 
379  //------------------------------------------------------------------------
381  //------------------------------------------------------------------------
382  virtual Status HandShake( HandShakeData *handShakeData,
383  AnyObject &channelData ) = 0;
384 
385  //------------------------------------------------------------------------
386  // @return true if handshake has been done and stream is connected,
387  // false otherwise
388  //------------------------------------------------------------------------
389  virtual bool HandShakeDone( HandShakeData *handShakeData,
390  AnyObject &channelData ) = 0;
391 
392  //------------------------------------------------------------------------
394  //------------------------------------------------------------------------
395  virtual bool IsStreamTTLElapsed( time_t inactiveTime,
396  AnyObject &channelData ) = 0;
397 
398  //------------------------------------------------------------------------
401  //------------------------------------------------------------------------
402  virtual Status IsStreamBroken( time_t inactiveTime,
403  AnyObject &channelData ) = 0;
404 
405  //------------------------------------------------------------------------
411  //------------------------------------------------------------------------
412  virtual PathID Multiplex( Message *msg,
413  AnyObject &channelData,
414  PathID *hint = 0 ) = 0;
415 
416  //------------------------------------------------------------------------
422  //------------------------------------------------------------------------
423  virtual PathID MultiplexSubStream( Message *msg,
424  AnyObject &channelData,
425  PathID *hint = 0 ) = 0;
426 
427  //------------------------------------------------------------------------
429  //------------------------------------------------------------------------
430  virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
431 
432  //------------------------------------------------------------------------
434  //------------------------------------------------------------------------
435  virtual void Disconnect( AnyObject &channelData,
436  uint16_t subStreamId ) = 0;
437 
438  //------------------------------------------------------------------------
440  //------------------------------------------------------------------------
441  virtual Status Query( uint16_t query,
442  AnyObject &result,
443  AnyObject &channelData ) = 0;
444 
445  //------------------------------------------------------------------------
447  //------------------------------------------------------------------------
448  virtual uint32_t MessageReceived( Message *msg,
449  uint16_t subStream,
450  AnyObject &channelData ) = 0;
451 
452  //------------------------------------------------------------------------
454  //------------------------------------------------------------------------
455  virtual void MessageSent( Message *msg,
456  uint16_t subStream,
457  uint32_t bytesSent,
458  AnyObject &channelData ) = 0;
459 
460  //------------------------------------------------------------------------
462  //------------------------------------------------------------------------
463  virtual void WaitBeforeExit() = 0;
464 
465  //------------------------------------------------------------------------
467  //------------------------------------------------------------------------
468  virtual bool NeedEncryption( HandShakeData *handShakeData,
469  AnyObject &channelData ) = 0;
470 
471  //------------------------------------------------------------------------
473  //------------------------------------------------------------------------
474  virtual Status GetSignature( Message *toSign, Message *&sign,
475  AnyObject &channelData ) = 0;
476  };
477 }
478 
479 #endif // __XRD_CL_POST_MASTER_INTERFACES_HH__
virtual void MessageSent(Message *msg, uint16_t subStream, uint32_t bytesSent, AnyObject &channelData)=0
Notify the transport about a message having been sent.
Definition: XrdClAnyObject.hh:32
const uint16_t stOK
Everything went OK.
Definition: XrdClStatus.hh:31
Definition: XrdClPostMasterInterfaces.hh:84
virtual void FinalizeChannel(AnyObject &channelData)=0
Finalize channel.
Take ownership over the message.
Definition: XrdClPostMasterInterfaces.hh:80
Message filter.
Definition: XrdClPostMasterInterfaces.hh:49
Definition: XrdClPostMasterInterfaces.hh:82
virtual ~IncomingMsgHandler()
Event types that the message handler may receive.
Definition: XrdClPostMasterInterfaces.hh:110
HandShakeData(const URL *addr, uint16_t subStream)
Constructor.
Definition: XrdClPostMasterInterfaces.hh:276
Stream has been broken and won&#39;t be recovered.
Definition: XrdClPostMasterInterfaces.hh:103
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
const XrdNetAddr * serverAddr
Server address.
Definition: XrdClPostMasterInterfaces.hh:287
time_t startTime
Timestamp of when the handshake started.
Definition: XrdClPostMasterInterfaces.hh:285
virtual ~ChannelEventHandler()
Destructor.
Definition: XrdClPostMasterInterfaces.hh:252
StreamAction
Stream actions that may be triggered by incoming control messages.
Definition: XrdClPostMasterInterfaces.hh:323
const URL * url
Destination URL.
Definition: XrdClPostMasterInterfaces.hh:283
Definition: XrdClOperationTimeout.hh:20
virtual PathID Multiplex(Message *msg, AnyObject &channelData, PathID *hint=0)=0
Definition: XrdClPostMasterInterfaces.hh:296
const uint16_t suDone
Definition: XrdClStatus.hh:38
uint16_t subStreamId
Sub-stream id.
Definition: XrdClPostMasterInterfaces.hh:284
virtual uint32_t MessageReceived(Message *msg, uint16_t subStream, AnyObject &channelData)=0
Check if the message invokes a stream action.
Definition: XrdClPostMasterInterfaces.hh:90
std::string clientName
Client name (an IPv6 representation)
Definition: XrdClPostMasterInterfaces.hh:288
static const uint16_t Name
Transport name, returns const char *.
Definition: XrdClPostMasterInterfaces.hh:309
Message * in
Message that has been received.
Definition: XrdClPostMasterInterfaces.hh:282
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:98
virtual bool NeedEncryption(HandShakeData *handShakeData, AnyObject &channelData)=0
uint16_t up
Definition: XrdClPostMasterInterfaces.hh:299
Definition: XrdNetAddr.hh:41
Procedure execution status.
Definition: XrdClStatus.hh:112
virtual uint16_t Examine(Message *msg)=0
virtual uint16_t GetSid() const =0
uint16_t step
Handshake step.
Definition: XrdClPostMasterInterfaces.hh:280
Send a close request.
Definition: XrdClPostMasterInterfaces.hh:336
virtual Status IsStreamBroken(time_t inactiveTime, AnyObject &channelData)=0
virtual Status Query(uint16_t query, AnyObject &result, AnyObject &channelData)=0
Query the channel.
virtual Status GetSignature(Message *toSign, Message *&sign, AnyObject &channelData)=0
Get signature for given message.
virtual bool Filter(const Message *msg)=0
Data structure that carries the handshake information.
Definition: XrdClPostMasterInterfaces.hh:271
virtual void OnReadyToSend(Message *msg)
Definition: XrdClPostMasterInterfaces.hh:203
Definition: XrdClPostMasterInterfaces.hh:326
virtual bool HandShakeDone(HandShakeData *handShakeData, AnyObject &channelData)=0
virtual ~TransportHandler()
Definition: XrdClPostMasterInterfaces.hh:340
virtual Status HandShake(HandShakeData *handShakeData, AnyObject &channelData)=0
HandHake.
Perform the handshake and the authentication for each physical stream.
Definition: XrdClPostMasterInterfaces.hh:316
Stream has been broken and won&#39;t be recovered.
Definition: XrdClPostMasterInterfaces.hh:246
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:245
Request status.
Definition: XrdClXRootDResponses.hh:218
Definition: XrdClAnyObject.hh:25
Channel event handler.
Definition: XrdClPostMasterInterfaces.hh:236
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:244
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:101
Message handler.
Definition: XrdClPostMasterInterfaces.hh:71
virtual uint16_t SubStreamNumber(AnyObject &channelData)=0
Return a number of substreams per stream that should be created.
virtual Status WriteMessageBody(Socket *socket, uint32_t &bytesWritten)
Definition: XrdClPostMasterInterfaces.hh:225
virtual bool IsStreamTTLElapsed(time_t inactiveTime, AnyObject &channelData)=0
Check if the stream should be disconnected.
uint16_t down
Definition: XrdClPostMasterInterfaces.hh:300
virtual uint16_t InspectStatusRsp(Message *msg)=0
virtual uint8_t OnStreamEvent(StreamEvent event, XRootDStatus status)
Definition: XrdClPostMasterInterfaces.hh:173
Definition: XrdClPostMasterInterfaces.hh:333
Action
Actions to be taken after a message is processed by the handler.
Definition: XrdClPostMasterInterfaces.hh:77
Definition: XrdClPostMasterInterfaces.hh:328
Definition: XrdClPostMasterInterfaces.hh:307
URL representation.
Definition: XrdClURL.hh:30
virtual void WaitBeforeExit()=0
Wait before exit.
No action.
Definition: XrdClPostMasterInterfaces.hh:325
virtual bool OnChannelEvent(ChannelEvent event, Status status)=0
virtual Status ReadMessageBody(Message *msg, Socket *socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:158
virtual ~MessageFilter()
Definition: XrdClPostMasterInterfaces.hh:52
virtual void Process(Message *msg)
Definition: XrdClPostMasterInterfaces.hh:145
Ignore the message.
Definition: XrdClPostMasterInterfaces.hh:81
virtual XRootDStatus GetHeader(Message *message, Socket *socket)=0
virtual XRootDStatus GetBody(Message *message, Socket *socket)=0
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:100
virtual ~OutgoingMsgHandler()
Definition: XrdClPostMasterInterfaces.hh:187
virtual uint16_t GetSid() const =0
Definition: XrdClPostMasterInterfaces.hh:87
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:184
virtual void InitializeChannel(const URL &url, AnyObject &channelData)=0
Initialize channel.
PathID(uint16_t u=0, uint16_t d=0)
Definition: XrdClPostMasterInterfaces.hh:298
ChannelEvent
Events that may have occurred to the channel.
Definition: XrdClPostMasterInterfaces.hh:242
virtual bool IsRaw() const
Definition: XrdClPostMasterInterfaces.hh:213
Definition: XrdClPostMasterInterfaces.hh:331
virtual void Disconnect(AnyObject &channelData, uint16_t subStreamId)=0
The stream has been disconnected, do the cleanups.
virtual void OnStatusReady(const Message *message, XRootDStatus status)=0
The requested action has been performed and the status is available.
Message * out
Message to be sent out.
Definition: XrdClPostMasterInterfaces.hh:281
A network socket.
Definition: XrdClSocket.hh:41
virtual PathID MultiplexSubStream(Message *msg, AnyObject &channelData, PathID *hint=0)=0
Stop sending requests [not yet implemented].
Definition: XrdClPostMasterInterfaces.hh:335
std::string streamName
Name of the stream.
Definition: XrdClPostMasterInterfaces.hh:289
static const uint16_t Auth
Transport name, returns std::string *.
Definition: XrdClPostMasterInterfaces.hh:310