00001 #ifndef __XRDXROOTDBRIDGE_HH_ 00002 #define __XRDXROOTDBRIDGE_HH_ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d B r i d g e . h h */ 00006 /* */ 00007 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <string.h> 00034 00035 #include "XProtocol/XPtypes.hh" 00036 00037 //----------------------------------------------------------------------------- 00047 //----------------------------------------------------------------------------- 00048 00049 struct iovec; 00050 class XrdLink; 00051 class XrdSecEntity; 00052 class XrdXrootdProtocol; 00053 00054 namespace XrdXrootd 00055 { 00056 00057 /******************************************************************************/ 00058 /* X r d X r o o t d : : B r i d g e */ 00059 /******************************************************************************/ 00060 00061 class Bridge 00062 { 00063 public: 00064 class Result; 00065 00066 //----------------------------------------------------------------------------- 00101 //----------------------------------------------------------------------------- 00102 00103 static 00104 Bridge *Login(Result *rsltP, 00105 XrdLink *linkP, 00106 XrdSecEntity *seceP, 00107 const char *nameP, 00108 const char *protP 00109 ); 00110 00111 //----------------------------------------------------------------------------- 00150 //----------------------------------------------------------------------------- 00151 00152 virtual bool Run(const char *xreqP, 00153 char *xdataP=0, 00154 int xdataL=0 00155 ) = 0; 00156 00157 //----------------------------------------------------------------------------- 00170 //----------------------------------------------------------------------------- 00171 00172 virtual bool Disc() = 0; 00173 00174 //----------------------------------------------------------------------------- 00187 //----------------------------------------------------------------------------- 00188 00189 virtual int setSF(kXR_char *fhandle, bool seton=false) = 0; 00190 00191 //----------------------------------------------------------------------------- 00208 //----------------------------------------------------------------------------- 00209 00210 virtual void SetWait(int wime, bool notify=false) = 0; 00211 00212 /******************************************************************************/ 00213 /* X r d X r o o t d : : B r i d g e : : C o n t e x t */ 00214 /******************************************************************************/ 00215 00216 //----------------------------------------------------------------------------- 00223 //----------------------------------------------------------------------------- 00224 00225 class Context 00226 { 00227 public: 00228 00229 XrdLink *linkP; 00230 kXR_unt16 rCode; 00231 union{kXR_unt16 num; 00232 kXR_char chr[2]; 00233 } sID; 00234 00235 //----------------------------------------------------------------------------- 00256 //----------------------------------------------------------------------------- 00257 00258 virtual int Send(const 00259 struct iovec *headP, 00260 int headN, 00261 const 00262 struct iovec *tailP, 00263 int tailN 00264 ) 00265 { 00266 (void)headP; (void)headN; (void)tailP; (void)tailN; 00267 return 1; 00268 } 00269 00270 //----------------------------------------------------------------------------- 00272 //----------------------------------------------------------------------------- 00273 00274 Context(XrdLink *lP, kXR_char *sid, kXR_unt16 req) 00275 : linkP(lP), rCode(req) 00276 {memcpy(sID.chr, sid, sizeof(sID.chr));} 00277 virtual ~Context() {} 00278 }; 00279 00280 /******************************************************************************/ 00281 /* X r d X r o o t d : : B r i d g e : : R e s u l t */ 00282 /******************************************************************************/ 00283 00284 //----------------------------------------------------------------------------- 00291 //----------------------------------------------------------------------------- 00292 00293 class Result 00294 { 00295 public: 00296 00297 //----------------------------------------------------------------------------- 00324 //----------------------------------------------------------------------------- 00325 00326 virtual bool Data(Bridge::Context &info, 00327 const 00328 struct iovec *iovP, 00329 int iovN, 00330 int iovL, 00331 bool final 00332 ) = 0; 00333 00334 //----------------------------------------------------------------------------- 00344 //----------------------------------------------------------------------------- 00345 00346 virtual bool Done(Bridge::Context &info)=0; 00347 00348 //----------------------------------------------------------------------------- 00361 //----------------------------------------------------------------------------- 00362 00363 virtual bool Error(Bridge::Context &info, 00364 int ecode, 00365 const char *etext 00366 ) = 0; 00367 00368 //----------------------------------------------------------------------------- 00381 //----------------------------------------------------------------------------- 00382 00383 virtual int File(Bridge::Context &info, 00384 int dlen 00385 ) = 0; 00386 00387 //----------------------------------------------------------------------------- 00399 //----------------------------------------------------------------------------- 00400 00401 virtual void Free(Bridge::Context &info, 00402 char *buffP, 00403 int buffL 00404 ) 00405 { 00406 (void)info; (void)buffP; (void)buffL; 00407 } 00408 00409 //----------------------------------------------------------------------------- 00422 //----------------------------------------------------------------------------- 00423 00424 virtual bool Redir(Bridge::Context &info, 00425 int port, 00426 const char *hname 00427 ) = 0; 00428 00429 //----------------------------------------------------------------------------- 00442 //----------------------------------------------------------------------------- 00443 00444 virtual bool Wait(Bridge::Context &info, 00445 int wtime, 00446 const char *wtext 00447 ) 00448 { 00449 (void)info; (void)wtime; (void)wtext; 00450 return false; 00451 } 00452 00453 //----------------------------------------------------------------------------- 00471 //----------------------------------------------------------------------------- 00472 virtual 00473 Bridge::Result *WaitResp(Bridge::Context &info, 00474 int wtime, 00475 const char *wtext 00476 ) 00477 { 00478 (void)info; (void)wtime; (void)wtext; 00479 return 0; 00480 } 00481 00482 //----------------------------------------------------------------------------- 00484 //----------------------------------------------------------------------------- 00485 00486 Result() {} 00487 virtual ~Result() {} 00488 }; 00489 00490 //----------------------------------------------------------------------------- 00492 //----------------------------------------------------------------------------- 00493 00494 Bridge() {} 00495 protected: 00496 virtual ~Bridge() {} 00497 }; 00498 } 00499 #endif