xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdXrootdBridge.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDBRIDGE_HH_
2 #define __XRDXROOTDBRIDGE_HH_
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d B r i d g e . h h */
6 /* */
7 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <cstring>
34 
35 #include "XProtocol/XPtypes.hh"
36 
37 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
48 
49 struct iovec;
50 class XrdLink;
51 class XrdSecEntity;
52 class XrdXrootdProtocol;
53 
54 namespace XrdXrootd
55 {
56 
57 /******************************************************************************/
58 /* X r d X r o o t d : : B r i d g e */
59 /******************************************************************************/
60 
61 class Bridge
62 {
63 public:
64 class Result;
65 
66 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
102 
103 static
104 Bridge *Login(Result *rsltP,
105  XrdLink *linkP,
106  XrdSecEntity *seceP,
107  const char *nameP,
108  const char *protP
109  );
110 
111 //-----------------------------------------------------------------------------
150 //-----------------------------------------------------------------------------
151 
152 virtual bool Run(const char *xreqP,
153  char *xdataP=0,
154  int xdataL=0
155  ) = 0;
156 
157 //-----------------------------------------------------------------------------
170 //-----------------------------------------------------------------------------
171 
172 virtual bool Disc() = 0;
173 
174 //-----------------------------------------------------------------------------
187 //-----------------------------------------------------------------------------
188 
189 virtual int setSF(kXR_char *fhandle, bool seton=false) = 0;
190 
191 //-----------------------------------------------------------------------------
208 //-----------------------------------------------------------------------------
209 
210 virtual void SetWait(int wime, bool notify=false) = 0;
211 
212 /******************************************************************************/
213 /* X r d X r o o t d : : B r i d g e : : C o n t e x t */
214 /******************************************************************************/
215 
216 //-----------------------------------------------------------------------------
223 //-----------------------------------------------------------------------------
224 
225 class Context
226 {
227 public:
228 
231 union{kXR_unt16 num;
233  } sID;
234 
235 //-----------------------------------------------------------------------------
256 //-----------------------------------------------------------------------------
257 
258 virtual int Send(const
259  struct iovec *headP,
260  int headN,
261  const
262  struct iovec *tailP,
263  int tailN
264  )
265 {
266  (void)headP; (void)headN; (void)tailP; (void)tailN;
267  return 1;
268 }
269 
270 //-----------------------------------------------------------------------------
272 //-----------------------------------------------------------------------------
273 
275  : linkP(lP), rCode(req)
276  {memcpy(sID.chr, sid, sizeof(sID.chr));}
277 virtual ~Context() {}
278 };
279 
280 /******************************************************************************/
281 /* X r d X r o o t d : : B r i d g e : : R e s u l t */
282 /******************************************************************************/
283 
284 //-----------------------------------------------------------------------------
291 //-----------------------------------------------------------------------------
292 
293 class Result
294 {
295 public:
296 
297 //-----------------------------------------------------------------------------
324 //-----------------------------------------------------------------------------
325 
326 virtual bool Data(Bridge::Context &info,
327  const
328  struct iovec *iovP,
329  int iovN,
330  int iovL,
331  bool final
332  ) = 0;
333 
334 //-----------------------------------------------------------------------------
344 //-----------------------------------------------------------------------------
345 
346 virtual bool Done(Bridge::Context &info)=0;
347 
348 //-----------------------------------------------------------------------------
361 //-----------------------------------------------------------------------------
362 
363 virtual bool Error(Bridge::Context &info,
364  int ecode,
365  const char *etext
366  ) = 0;
367 
368 //-----------------------------------------------------------------------------
381 //-----------------------------------------------------------------------------
382 
383 virtual int File(Bridge::Context &info,
384  int dlen
385  ) = 0;
386 
387 //-----------------------------------------------------------------------------
399 //-----------------------------------------------------------------------------
400 
401 virtual void Free(Bridge::Context &info,
402  char *buffP,
403  int buffL
404  )
405 {
406  (void)info; (void)buffP; (void)buffL;
407 }
408 
409 //-----------------------------------------------------------------------------
422 //-----------------------------------------------------------------------------
423 
424 virtual bool Redir(Bridge::Context &info,
425  int port,
426  const char *hname
427  ) = 0;
428 
429 //-----------------------------------------------------------------------------
442 //-----------------------------------------------------------------------------
443 
444 virtual bool Wait(Bridge::Context &info,
445  int wtime,
446  const char *wtext
447  )
448 {
449  (void)info; (void)wtime; (void)wtext;
450  return false;
451 }
452 
453 //-----------------------------------------------------------------------------
471 //-----------------------------------------------------------------------------
472 virtual
474  int wtime,
475  const char *wtext
476  )
477 {
478  (void)info; (void)wtime; (void)wtext;
479  return 0;
480 }
481 
482 //-----------------------------------------------------------------------------
484 //-----------------------------------------------------------------------------
485 
486  Result() {}
487 virtual ~Result() {}
488 };
489 
490 //-----------------------------------------------------------------------------
492 //-----------------------------------------------------------------------------
493 
494  Bridge() {}
495 protected:
496 virtual ~Bridge() {}
497 };
498 }
499 #endif
unsigned char kXR_char
Definition: XPtypes.hh:65
virtual int setSF(kXR_char *fhandle, bool seton=false)=0
XrdLink * linkP
-&gt; associated session link object (i.e. connection)
Definition: XrdXrootdBridge.hh:229
virtual bool Error(Bridge::Context &info, int ecode, const char *etext)=0
virtual bool Wait(Bridge::Context &info, int wtime, const char *wtext)
Definition: XrdXrootdBridge.hh:444
virtual void Free(Bridge::Context &info, char *buffP, int buffL)
Definition: XrdXrootdBridge.hh:401
Definition: XrdXrootdBridge.hh:225
virtual int Send(const struct iovec *headP, int headN, const struct iovec *tailP, int tailN)
Definition: XrdXrootdBridge.hh:258
virtual bool Redir(Bridge::Context &info, int port, const char *hname)=0
unsigned short kXR_unt16
Definition: XPtypes.hh:67
virtual bool Disc()=0
Definition: XrdXrootdBridge.hh:61
virtual bool Done(Bridge::Context &info)=0
the result context
Definition: XrdXrootdProtocol.hh:154
Result()
Constructor &amp; Destructor.
Definition: XrdXrootdBridge.hh:486
kXR_unt16 num
associated stream ID as a short
Definition: XrdXrootdBridge.hh:231
union XrdXrootd::Bridge::Context::@153 sID
associated request stream ID
virtual bool Run(const char *xreqP, char *xdataP=0, int xdataL=0)=0
kXR_unt16 rCode
associated &quot;kXR&quot; request code in host byte order
Definition: XrdXrootdBridge.hh:230
Bridge()
Constructor &amp; Destructor.
Definition: XrdXrootdBridge.hh:494
j template void())
Definition: XrdOucJson.hh:4121
Context(XrdLink *lP, kXR_char *sid, kXR_unt16 req)
Constructor and Destructor.
Definition: XrdXrootdBridge.hh:274
static Bridge * Login(Result *rsltP, XrdLink *linkP, XrdSecEntity *seceP, const char *nameP, const char *protP)
Definition: XrdXrootdBridge.hh:293
virtual void SetWait(int wime, bool notify=false)=0
virtual bool Data(Bridge::Context &info, const struct iovec *iovP, int iovN, int iovL, bool final)=0
virtual Bridge::Result * WaitResp(Bridge::Context &info, int wtime, const char *wtext)
Definition: XrdXrootdBridge.hh:473
kXR_char chr[2]
associated stream ID as the original char[2]
Definition: XrdXrootdBridge.hh:232
Definition: XrdSecEntity.hh:63
virtual int File(Bridge::Context &info, int dlen)=0
virtual ~Context()
Definition: XrdXrootdBridge.hh:277
virtual ~Result()
Definition: XrdXrootdBridge.hh:487
virtual ~Bridge()
Definition: XrdXrootdBridge.hh:496