xrootd
XrdClXRootDTransport.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_XROOTD_TRANSPORT_HH__
20 #define __XRD_CL_XROOTD_TRANSPORT_HH__
21 
22 #include "XrdCl/XrdClPostMaster.hh"
23 #include "XProtocol/XProtocol.hh"
25 #include "XrdOuc/XrdOucEnv.hh"
26 
27 namespace XrdCl
28 {
29  struct XRootDChannelInfo;
30 
31  //----------------------------------------------------------------------------
33  //----------------------------------------------------------------------------
34  struct XRootDQuery
35  {
36  static const uint16_t SIDManager = 1001;
37  static const uint16_t ServerFlags = 1002;
38  static const uint16_t ProtocolVersion = 1003;
39  };
40 
41  //----------------------------------------------------------------------------
43  //----------------------------------------------------------------------------
45  {
46  public:
47  //------------------------------------------------------------------------
49  //------------------------------------------------------------------------
51 
52  //------------------------------------------------------------------------
54  //------------------------------------------------------------------------
56 
57  //------------------------------------------------------------------------
68  //------------------------------------------------------------------------
69  virtual Status GetHeader( Message *message, int socket );
70 
71  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  virtual Status GetBody( Message *message, int socket );
82 
83  //------------------------------------------------------------------------
85  //------------------------------------------------------------------------
86  virtual void InitializeChannel( AnyObject &channelData );
87 
88  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  virtual void FinalizeChannel( AnyObject &channelData );
92 
93  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
96  virtual Status HandShake( HandShakeData *handShakeData,
97  AnyObject &channelData );
98 
99  //------------------------------------------------------------------------
101  //------------------------------------------------------------------------
102  virtual bool IsStreamTTLElapsed( time_t time,
103  AnyObject &channelData );
104 
105  //------------------------------------------------------------------------
111  //------------------------------------------------------------------------
112  virtual PathID Multiplex( Message *msg,
113  AnyObject &channelData,
114  PathID *hint = 0 );
115 
116  //------------------------------------------------------------------------
122  //------------------------------------------------------------------------
123  virtual PathID MultiplexSubStream( Message *msg,
124  AnyObject &channelData,
125  PathID *hint = 0 );
126 
127  //------------------------------------------------------------------------
129  //------------------------------------------------------------------------
130  virtual uint16_t StreamNumber( AnyObject &channelData );
131 
132  //------------------------------------------------------------------------
134  //------------------------------------------------------------------------
135  virtual uint16_t SubStreamNumber( AnyObject &channelData );
136 
137  //------------------------------------------------------------------------
140  //------------------------------------------------------------------------
141  virtual bool NeedControlConnection()
142  {
143  return true;
144  }
145 
146  //------------------------------------------------------------------------
148  //------------------------------------------------------------------------
149  static Status MarshallRequest( Message *msg );
150 
151  //------------------------------------------------------------------------
154  //------------------------------------------------------------------------
155  static Status UnMarshallRequest( Message *msg );
156 
157  //------------------------------------------------------------------------
159  //------------------------------------------------------------------------
160  static Status UnMarshallBody( Message *msg, uint16_t reqType );
161 
162  //------------------------------------------------------------------------
164  //------------------------------------------------------------------------
165  static void UnMarshallHeader( Message *msg );
166 
167  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  static void LogErrorResponse( const Message &msg );
171 
172  //------------------------------------------------------------------------
174  //------------------------------------------------------------------------
175  virtual void Disconnect( AnyObject &channelData,
176  uint16_t streamId,
177  uint16_t subStreamId );
178 
179  //------------------------------------------------------------------------
181  //------------------------------------------------------------------------
182  virtual Status Query( uint16_t query,
183  AnyObject &result,
184  AnyObject &channelData );
185 
186  //------------------------------------------------------------------------
188  //------------------------------------------------------------------------
189  static void SetDescription( Message *msg );
190 
191  //------------------------------------------------------------------------
193  //------------------------------------------------------------------------
194  virtual uint32_t StreamAction( Message *msg, AnyObject &channelData );
195 
196  private:
197 
198  //------------------------------------------------------------------------
199  // Hand shake the main stream
200  //------------------------------------------------------------------------
201  Status HandShakeMain( HandShakeData *handShakeData,
202  AnyObject &channelData );
203 
204  //------------------------------------------------------------------------
205  // Hand shake a parallel stream
206  //------------------------------------------------------------------------
207  Status HandShakeParallel( HandShakeData *handShakeData,
208  AnyObject &channelData );
209 
210  //------------------------------------------------------------------------
211  // Generate the message to be sent as an initial handshake
212  //------------------------------------------------------------------------
214  XRootDChannelInfo *info );
215 
216  //------------------------------------------------------------------------
217  // Generate the message to be sent as an initial handshake
218  // (handshake + kXR_protocol)
219  //------------------------------------------------------------------------
221  XRootDChannelInfo *info );
222 
223  //------------------------------------------------------------------------
224  // Process the server initial handshake response
225  //------------------------------------------------------------------------
227  XRootDChannelInfo *info );
228 
229  //-----------------------------------------------------------------------
230  // Process the protocol response
231  //------------------------------------------------------------------------
233  XRootDChannelInfo *info );
234 
235  //------------------------------------------------------------------------
236  // Generate the bind message
237  //------------------------------------------------------------------------
239  XRootDChannelInfo *info );
240 
241  //------------------------------------------------------------------------
242  // Generate the bind message
243  //------------------------------------------------------------------------
245  XRootDChannelInfo *info );
246 
247  //------------------------------------------------------------------------
248  // Generate the login message
249  //------------------------------------------------------------------------
251  XRootDChannelInfo *info );
252 
253  //------------------------------------------------------------------------
254  // Process the login response
255  //------------------------------------------------------------------------
257  XRootDChannelInfo *info );
258 
259  //------------------------------------------------------------------------
260  // Do the authentication
261  //------------------------------------------------------------------------
263  XRootDChannelInfo *info );
264 
265  //------------------------------------------------------------------------
266  // Get the initial credentials using one of the protocols
267  //------------------------------------------------------------------------
268  Status GetCredentials( XrdSecCredentials *&credentials,
269  HandShakeData *hsData,
270  XRootDChannelInfo *info );
271 
272  //------------------------------------------------------------------------
273  // Clean up the data structures created for the authentication process
274  //------------------------------------------------------------------------
276 
277  //------------------------------------------------------------------------
278  // Get the authentication function handle
279  //------------------------------------------------------------------------
280  typedef XrdSecProtocol *(*XrdSecGetProt_t)( const char *,
281  const sockaddr &,
282  const XrdSecParameters &,
283  XrdOucErrInfo * );
284 
286 
287  //------------------------------------------------------------------------
288  // Get a string representation of the server flags
289  //------------------------------------------------------------------------
290  static std::string ServerFlagsToStr( uint32_t flags );
291 
292  //------------------------------------------------------------------------
293  // Get a string representation of file handle
294  //------------------------------------------------------------------------
295  static std::string FileHandleToStr( const unsigned char handle[4] );
296 
299  };
300 }
301 
302 #endif // __XRD_CL_XROOTD_TRANSPORT_HANDLER_HH__