xrootd
XrdClPostMasterInterfaces.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_POST_MASTER_INTERFACES_HH__
20 #define __XRD_CL_POST_MASTER_INTERFACES_HH__
21 
22 #include <stdint.h>
23 #include <ctime>
24 
25 #include "XrdCl/XrdClStatus.hh"
26 #include "XrdCl/XrdClAnyObject.hh"
27 #include "XrdCl/XrdClURL.hh"
28 
29 namespace XrdCl
30 {
31  class Channel;
32  class Message;
33  class URL;
34 
35  //----------------------------------------------------------------------------
37  //----------------------------------------------------------------------------
39  {
40  public:
41  virtual ~MessageFilter() {}
42 
43  //------------------------------------------------------------------------
46  //------------------------------------------------------------------------
47  virtual bool Filter( const Message *msg ) = 0;
48  };
49 
50  //----------------------------------------------------------------------------
52  //----------------------------------------------------------------------------
54  {
55  public:
56  //------------------------------------------------------------------------
58  //------------------------------------------------------------------------
59  enum Action
60  {
61  Take = 0x0001,
62  Ignore = 0x0002,
63  RemoveHandler = 0x0004,
64  Raw = 0x0008,
66  NoProcess = 0x0010
69  };
72 
73  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
77  {
78  Ready = 1,
79  Broken = 2,
80  Timeout = 3,
82  };
83 
84  //------------------------------------------------------------------------
86  //------------------------------------------------------------------------
87 
88  virtual ~IncomingMsgHandler() {}
89 
90  //------------------------------------------------------------------------
96  //------------------------------------------------------------------------
97  virtual uint16_t Examine( Message *msg ) = 0;
98 
99  //------------------------------------------------------------------------
103  //------------------------------------------------------------------------
104  virtual void Process( Message *msg ) {};
105 
106  //------------------------------------------------------------------------
116  //------------------------------------------------------------------------
118  int socket,
119  uint32_t &bytesRead )
120  {
121  return Status( stOK, suDone );
122  };
123 
124  //------------------------------------------------------------------------
131  //------------------------------------------------------------------------
132  virtual uint8_t OnStreamEvent( StreamEvent event,
133  uint16_t streamNum,
134  Status status )
135  {
136  return 0;
137  };
138  };
139 
140  //----------------------------------------------------------------------------
142  //----------------------------------------------------------------------------
144  {
145  public:
146  virtual ~OutgoingMsgHandler() {}
147 
148  //------------------------------------------------------------------------
150  //------------------------------------------------------------------------
151  virtual void OnStatusReady( const Message *message,
152  Status status ) = 0;
153 
154  //------------------------------------------------------------------------
162  //------------------------------------------------------------------------
163  virtual void OnReadyToSend( Message *msg, uint16_t streamNum ) {};
164 
165  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  virtual bool IsRaw() const { return false; }
171 
172  //------------------------------------------------------------------------
181  //------------------------------------------------------------------------
182  virtual Status WriteMessageBody( int socket,
183  uint32_t &bytesRead )
184  {
185  return Status();
186  }
187  };
188 
189  //----------------------------------------------------------------------------
191  //----------------------------------------------------------------------------
193  {
194  public:
195  //------------------------------------------------------------------------
197  //------------------------------------------------------------------------
199  {
203  };
204 
205  //------------------------------------------------------------------------
207  //------------------------------------------------------------------------
208  virtual ~ChannelEventHandler() {};
209 
210  //------------------------------------------------------------------------
218  //------------------------------------------------------------------------
219  virtual bool OnChannelEvent( ChannelEvent event,
220  Status status,
221  uint16_t stream ) = 0;
222  };
223 
224  //----------------------------------------------------------------------------
226  //----------------------------------------------------------------------------
228  {
229  //--------------------------------------------------------------------------
231  //--------------------------------------------------------------------------
232  HandShakeData( const URL *addr, uint16_t stream, uint16_t subStream ):
233  step(0), out(0), in(0), url(addr), streamId(stream),
234  subStreamId( subStream ), startTime( time(0) ), serverAddr(0)
235  {}
236  uint16_t step;
239  const URL *url;
240  uint16_t streamId;
241  uint16_t subStreamId;
242  time_t startTime;
243  const void *serverAddr;
244  std::string clientName;
245  std::string streamName;
246  };
247 
248  //----------------------------------------------------------------------------
251  //----------------------------------------------------------------------------
252  struct PathID
253  {
254  PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
255  uint16_t up;
256  uint16_t down;
257  };
258 
259  //----------------------------------------------------------------------------
262  //----------------------------------------------------------------------------
264  {
265  static const uint16_t Name = 1;
266  static const uint16_t Auth = 2;
267  };
268 
269  //----------------------------------------------------------------------------
271  //----------------------------------------------------------------------------
273  {
274  public:
275 
276  //------------------------------------------------------------------------
278  //------------------------------------------------------------------------
280  {
281  NoAction = 0x0000,
282  DigestMsg = 0x0001,
283  AbortStream = 0x0002,
285  CloseStream = 0x0004,
288  ResumeStream = 0x0008,
290  HoldStream = 0x0010
292  };
293 
294 
295  virtual ~TransportHandler() {}
296 
297  //------------------------------------------------------------------------
308  //------------------------------------------------------------------------
309  virtual Status GetHeader( Message *message, int socket ) = 0;
310 
311  //------------------------------------------------------------------------
320  //------------------------------------------------------------------------
321  virtual Status GetBody( Message *message, int socket ) = 0;
322 
323  //------------------------------------------------------------------------
325  //------------------------------------------------------------------------
326  virtual void InitializeChannel( AnyObject &channelData ) = 0;
327 
328  //------------------------------------------------------------------------
330  //------------------------------------------------------------------------
331  virtual void FinalizeChannel( AnyObject &channelData ) = 0;
332 
333  //------------------------------------------------------------------------
335  //------------------------------------------------------------------------
336  virtual Status HandShake( HandShakeData *handShakeData,
337  AnyObject &channelData ) = 0;
338 
339  //------------------------------------------------------------------------
341  //------------------------------------------------------------------------
342  virtual bool IsStreamTTLElapsed( time_t inactiveTime,
343  AnyObject &channelData ) = 0;
344 
345  //------------------------------------------------------------------------
351  //------------------------------------------------------------------------
352  virtual PathID Multiplex( Message *msg,
353  AnyObject &channelData,
354  PathID *hint = 0 ) = 0;
355 
356  //------------------------------------------------------------------------
362  //------------------------------------------------------------------------
363  virtual PathID MultiplexSubStream( Message *msg,
364  AnyObject &channelData,
365  PathID *hint = 0 ) = 0;
366 
367  //------------------------------------------------------------------------
369  //------------------------------------------------------------------------
370  virtual uint16_t StreamNumber( AnyObject &channelData ) = 0;
371 
372  //------------------------------------------------------------------------
374  //------------------------------------------------------------------------
375  virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
376 
377  //------------------------------------------------------------------------
379  //------------------------------------------------------------------------
380  virtual void Disconnect( AnyObject &channelData,
381  uint16_t streamId,
382  uint16_t subStreamId ) = 0;
383 
384  //------------------------------------------------------------------------
386  //------------------------------------------------------------------------
387  virtual Status Query( uint16_t query,
388  AnyObject &result,
389  AnyObject &channelData ) = 0;
390 
391  //------------------------------------------------------------------------
393  //------------------------------------------------------------------------
394  virtual uint32_t StreamAction( Message *msg, AnyObject &channelData ) = 0;
395  };
396 }
397 
398 #endif // __XRD_CL_POST_MASTER_INTERFACES_HH__