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 
13 // $Id$
14 
15 class XrdCmsRRQInfo;
16 class XrdCmsNode;
17 struct stat;
18 
19 class XrdCmsReq
20 {
21 public:
22 
23 // Use this to determine if the call is advisory in nature
24 //
25 inline int Advisory() {return ReqAdv;}
26 
27 // Reply with an eror message to the request. An optional length may be given.
28 //
29 void Reply_Error(const char *emsg, int emsglen = 0);
30 
31 // Reply with an error code and an error message to the request. The error
32 // is a string corresponding to an errno.h error code symbol. Valid names are:
33 // ENOENT, EPERM, EACCES, EIO, ENOMEM, ENOSPC, ENAMETOOLONG, ENETUNREACH,
34 // ENOTBLK, EISDIR, and ENOTEMPTY. Any other strings are converted to EINVAL.
35 // This mechanism supports cross platform error number delivery. The second
36 // takes the errno.h error number directly.
37 //
38 void Reply_Error(const char *ecode, const char *emsg, int emsglen = 0);
39 
40 void Reply_Error(int ecode, const char *emsg, int emsglen = 0);
41 
42 // Reply by telling the client everything was successfully completed. No data
43 // is to be sent (do not use Reply_OK() with a data length of zero).
44 //
45 void Reply_OK();
46 
47 // Reply with success and an ASCII text message to the request. An optional data
48 // length may be given.
49 //
50 void Reply_OK(const char *data, int datalen = 0);
51 
52 // Reply with with success along with file stat information
53 //
54 void Reply_OK(struct stat &buf);
55 
56 // Reply by redirecting the client to a different server
57 //
58 void Reply_Redirect(const char *sname, // DNS name:port of server
59  const char *logincgi=0, // CGI tokens for login
60  const char *opencgi=0); // CGI tokens for open
61 
62 void Reply_Redirect(const char *sname, // DNS name of server
63  int port, // Server port number
64  const char *logincgi=0, // CGI tokens for login
65  const char *opencgi=0); // CGI tokens for open
66 
67 // Reply by forcing the client to wait the indicated number of seconds
68 //
69 void Reply_Wait(int sec);
70 
71 // Reply by telling the client to wait up to "sec" seconds for a response. This
72 // method returns a new XrdCmsReq object that must be used to actually provide
73 // the final response. It is automatically deleted when any Reply_xxx() method
74 // is called since the object is only valid for a single reply.
75 //
76 XrdCmsReq *Reply_WaitResp(int sec=0);
77 
78  XrdCmsReq(XrdCmsNode *nP, unsigned int id, char adv=0);
79  XrdCmsReq(XrdCmsReq *rP, unsigned int rn);
81 
82 private:
83 
84 int StatGen(struct stat &sbuf, char *xbuf);
85 void noReply();
86 void Reply(int respCode, unsigned int respVal, const char *respData=0,
87  int respLen=0, struct iovec *iov=0, int iovnum=0);
88 
90 unsigned int ReqID;
91 int ReqNins; // Node instance
92 short ReqNnum; // Node number
93 char ReqAdv;
94 };
95 #endif