xrootd
XrdCmsReq.hh
Go to the documentation of this file.
00001 #ifndef __XRDCMSREQ_H__
00002 #define __XRDCMSREQ_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X r d C m s R e q . h h                           */
00006 /*                                                                            */
00007 /* (c) 2007 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 class  XrdCmsRRQInfo;
00034 class  XrdCmsNode;
00035 struct stat;
00036 
00037 class XrdCmsReq
00038 {
00039 public:
00040 
00041 // Use this to determine if the call is advisory in nature
00042 //
00043 inline int Advisory() {return ReqAdv;}
00044 
00045 // Reply with an eror message to the request. An optional length may be given.
00046 //
00047 void       Reply_Error(const char *emsg, int emsglen = 0);
00048 
00049 // Reply with an error code and an error message to the request. The error
00050 // is a string corresponding to an errno.h error code symbol. Valid names are:
00051 // ENOENT, EPERM, EACCES, EIO, ENOMEM, ENOSPC, ENAMETOOLONG, ENETUNREACH,
00052 // ENOTBLK, EISDIR, and ENOTEMPTY. Any other strings are converted to EINVAL.
00053 // This mechanism supports cross platform error number delivery. The second
00054 // takes the errno.h error number directly.
00055 //
00056 void       Reply_Error(const char *ecode, const char *emsg, int emsglen = 0);
00057 
00058 void       Reply_Error(int         ecode, const char *emsg, int emsglen = 0);
00059 
00060 // Reply by telling the client everything was successfully completed. No data
00061 // is to be sent (do not use Reply_OK() with a data length of zero).
00062 //
00063 void       Reply_OK();
00064 
00065 // Reply with success and an ASCII text message to the request. An optional data
00066 // length may be given.
00067 //
00068 void       Reply_OK(const char *data, int datalen = 0);
00069 
00070 // Reply with with success along with file stat information
00071 //
00072 void       Reply_OK(struct stat &buf);
00073 
00074 // Reply by redirecting the client to a different server
00075 //
00076 void       Reply_Redirect(const char *sname,      // DNS name:port of server
00077                           const char *logincgi=0, // CGI tokens for login
00078                           const char *opencgi=0); // CGI tokens for open
00079 
00080 void       Reply_Redirect(const char *sname,      // DNS name of server
00081                                 int   port,       // Server port number
00082                           const char *logincgi=0, // CGI tokens for login
00083                           const char *opencgi=0); // CGI tokens for open
00084 
00085 // Reply by forcing the client to wait the indicated number of seconds
00086 //
00087 void       Reply_Wait(int sec);
00088 
00089 // Reply by telling the client to wait up to "sec" seconds for a response. This
00090 // method returns a new XrdCmsReq object that must be used to actually provide
00091 // the final response. It is automatically deleted when any Reply_xxx() method 
00092 // is called since the object is only valid for a single reply.
00093 //
00094 XrdCmsReq *Reply_WaitResp(int sec=0);
00095 
00096            XrdCmsReq(XrdCmsNode *nP, unsigned int id, char adv=0);
00097            XrdCmsReq(XrdCmsReq  *rP, unsigned int rn);
00098           ~XrdCmsReq() {}
00099 
00100 private:
00101 
00102 int  StatGen(struct stat &sbuf, char *xbuf);
00103 void noReply();
00104 void Reply(int respCode, unsigned int respVal, const char *respData=0,
00105            int respLen=0, struct iovec *iov=0, int iovnum=0);
00106 
00107 XrdCmsNode    *NodeP;
00108 unsigned int   ReqID;
00109 int            ReqNins;  // Node instance
00110 short          ReqNnum;  // Node number
00111 char           ReqAdv;
00112 };
00113 #endif