xrootd
XrdCmsReq.hh
Go to the documentation of this file.
1 #ifndef __XRDCMSREQ_H__
2 #define __XRDCMSREQ_H__
3 /******************************************************************************/
4 /* */
5 /* X r d C m s R e q . h h */
6 /* */
7 /* (c) 2007 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 class XrdCmsRRQInfo;
34 class XrdCmsNode;
35 struct stat;
36 
37 class XrdCmsReq
38 {
39 public:
40 
41 // Use this to determine if the call is advisory in nature
42 //
43 inline int Advisory() {return ReqAdv;}
44 
45 // Reply with an eror message to the request. An optional length may be given.
46 //
47 void Reply_Error(const char *emsg, int emsglen = 0);
48 
49 // Reply with an error code and an error message to the request. The error
50 // is a string corresponding to an errno.h error code symbol. Valid names are:
51 // ENOENT, EPERM, EACCES, EIO, ENOMEM, ENOSPC, ENAMETOOLONG, ENETUNREACH,
52 // ENOTBLK, EISDIR, and ENOTEMPTY. Any other strings are converted to EINVAL.
53 // This mechanism supports cross platform error number delivery. The second
54 // takes the errno.h error number directly.
55 //
56 void Reply_Error(const char *ecode, const char *emsg, int emsglen = 0);
57 
58 void Reply_Error(int ecode, const char *emsg, int emsglen = 0);
59 
60 // Reply by telling the client everything was successfully completed. No data
61 // is to be sent (do not use Reply_OK() with a data length of zero).
62 //
63 void Reply_OK();
64 
65 // Reply with success and an ASCII text message to the request. An optional data
66 // length may be given.
67 //
68 void Reply_OK(const char *data, int datalen = 0);
69 
70 // Reply with with success along with file stat information
71 //
72 void Reply_OK(struct stat &buf);
73 
74 // Reply by redirecting the client to a different server
75 //
76 void Reply_Redirect(const char *sname, // DNS name:port of server
77  const char *logincgi=0, // CGI tokens for login
78  const char *opencgi=0); // CGI tokens for open
79 
80 void Reply_Redirect(const char *sname, // DNS name of server
81  int port, // Server port number
82  const char *logincgi=0, // CGI tokens for login
83  const char *opencgi=0); // CGI tokens for open
84 
85 // Reply by forcing the client to wait the indicated number of seconds
86 //
87 void Reply_Wait(int sec);
88 
89 // Reply by telling the client to wait up to "sec" seconds for a response. This
90 // method returns a new XrdCmsReq object that must be used to actually provide
91 // the final response. It is automatically deleted when any Reply_xxx() method
92 // is called since the object is only valid for a single reply.
93 //
94 XrdCmsReq *Reply_WaitResp(int sec=0);
95 
96  XrdCmsReq(XrdCmsNode *nP, unsigned int id, char adv=0);
97  XrdCmsReq(XrdCmsReq *rP, unsigned int rn);
99 
100 private:
101 
102 int StatGen(struct stat &sbuf, char *xbuf);
103 void noReply();
104 void Reply(int respCode, unsigned int respVal, const char *respData=0,
105  int respLen=0, struct iovec *iov=0, int iovnum=0);
106 
108 unsigned int ReqID;
109 int ReqNins; // Node instance
110 short ReqNnum; // Node number
111 char ReqAdv;
112 };
113 #endif
XrdCmsReq::~XrdCmsReq
~XrdCmsReq()
Definition: XrdCmsReq.hh:98
XrdCmsReq::ReqNins
int ReqNins
Definition: XrdCmsReq.hh:109
XrdCmsReq::ReqNnum
short ReqNnum
Definition: XrdCmsReq.hh:110
XrdCmsReq::XrdCmsReq
XrdCmsReq(XrdCmsNode *nP, unsigned int id, char adv=0)
XrdCmsReq::ReqAdv
char ReqAdv
Definition: XrdCmsReq.hh:111
XrdCmsNode
Definition: XrdCmsNode.hh:56
XrdCmsReq::Reply
void Reply(int respCode, unsigned int respVal, const char *respData=0, int respLen=0, struct iovec *iov=0, int iovnum=0)
XrdCmsReq::StatGen
int StatGen(struct stat &sbuf, char *xbuf)
XrdCmsReq
Definition: XrdCmsReq.hh:37
XrdCmsReq::NodeP
XrdCmsNode * NodeP
Definition: XrdCmsReq.hh:107
XrdCmsReq::Reply_OK
void Reply_OK()
XrdCmsReq::Reply_Error
void Reply_Error(const char *emsg, int emsglen=0)
XrdCmsRRQInfo
Definition: XrdCmsRRQ.hh:46
XrdCmsReq::noReply
void noReply()
XrdCmsReq::Reply_Redirect
void Reply_Redirect(const char *sname, const char *logincgi=0, const char *opencgi=0)
XrdCmsReq::Advisory
int Advisory()
Definition: XrdCmsReq.hh:43
stat
#define stat(a, b)
Definition: XrdPosix.hh:96
XrdCmsReq::Reply_WaitResp
XrdCmsReq * Reply_WaitResp(int sec=0)
XrdCmsReq::Reply_Wait
void Reply_Wait(int sec)
XrdCmsReq::ReqID
unsigned int ReqID
Definition: XrdCmsReq.hh:108