00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_XrdProofdProtocol
00013 #define ROOT_XrdProofdProtocol
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <vector>
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define XPROOFD_VERSBIN 0x000003EE
00035 #define XPROOFD_VERSION "0.6"
00036
00037 #ifdef OLDXRDOUC
00038 # include "XrdSysToOuc.h"
00039 # include "XrdOuc/XrdOucPthread.hh"
00040 #else
00041 # include "XrdSys/XrdSysPthread.hh"
00042 #endif
00043 #include "Xrd/XrdLink.hh"
00044 #include "Xrd/XrdObject.hh"
00045 #include "Xrd/XrdProtocol.hh"
00046 #include "XrdOuc/XrdOucString.hh"
00047 #include "XrdSec/XrdSecInterface.hh"
00048 #include "XProofProtocol.h"
00049
00050 class XrdBuffer;
00051 class XrdProofdClient;
00052 class XrdProofdManager;
00053 class XrdProofdResponse;
00054 class XrdProofdProofServ;
00055 class XrdSrvBuffer;
00056
00057 class XrdProofdProtocol : XrdProtocol {
00058
00059 public:
00060 XrdProofdProtocol();
00061 virtual ~XrdProofdProtocol() {}
00062
00063 void DoIt() {}
00064 XrdProtocol *Match(XrdLink *lp);
00065 int Process(XrdLink *lp);
00066 void Recycle(XrdLink *lp, int x, const char *y);
00067 int Stats(char *buff, int blen, int do_sync);
00068
00069 static int Configure(char *parms, XrdProtocol_Config *pi);
00070
00071
00072 int GetData(const char *dtype, char *buff, int blen);
00073 static XrdBuffer *GetBuff(int quantum, XrdBuffer *argp = 0);
00074 static void ReleaseBuff(XrdBuffer *argp);
00075 static int MaxBuffsz() { return fgMaxBuffsz; }
00076
00077
00078 inline kXR_int32 CID() const { return fCID; }
00079 inline XrdProofdClient *Client() const { return fPClient; }
00080 inline int ConnType() const { return fConnType; }
00081 inline const char *TraceID() const { return fTraceID.c_str(); }
00082 inline bool Internal() { return (fConnType == kXPD_Internal) ? 1 : 0; }
00083 inline bool IsCtrlC() { XrdSysMutexHelper mhp(fCtrlcMutex);
00084 bool rc = fIsCtrlC; fIsCtrlC = 0; return rc; }
00085 inline int Pid() const { return fPid; }
00086 inline void ResetCtrlC() { XrdSysMutexHelper mhp(fCtrlcMutex); fIsCtrlC = 0; }
00087 inline char Status() const { return fStatus; }
00088 inline short int ProofProtocol() const { return fProofProtocol; }
00089 inline bool SuperUser() const { return fSuperUser; }
00090
00091 XrdProofdResponse *Response(kXR_unt16 rid);
00092 inline XPClientRequest *Request() const { return (XPClientRequest *)&fRequest; }
00093 inline XrdBuffer *Argp() const { return fArgp; }
00094 inline XrdLink *Link() const { return fLink; }
00095 inline XrdSecProtocol *AuthProt() const { return fAuthProt; }
00096
00097
00098 inline void SetAdminPath(const char *p) { XrdSysMutexHelper mhp(fMutex); fAdminPath = p; }
00099 inline void SetAuthEntity(XrdSecEntity *se = 0) { fSecEntity.tident = fLink->ID;
00100 fSecClient = (se) ? se : &fSecEntity; }
00101 inline void SetAuthProt(XrdSecProtocol *p) { fAuthProt = p; }
00102 inline void SetClient(XrdProofdClient *c) { fPClient = c; }
00103 inline void SetClntCapVer(unsigned char c) { fClntCapVer = c; }
00104 inline void SetCID(kXR_int32 cid) { fCID = cid; }
00105 inline void SetConnType(int ct) { fConnType = ct; }
00106 inline void SetTraceID() { if (fLink) XPDFORM(fTraceID, "%s: ", fLink->ID); }
00107 inline void SetPid(int pid) { fPid = pid; }
00108 inline void SetProofProtocol(short int pp) { fProofProtocol = pp; }
00109 inline void SetStatus(char s) { fStatus = s; }
00110 inline void SetSuperUser(bool su = 1) { fSuperUser = su; }
00111
00112 static XrdProofdManager *Mgr() { return fgMgr; }
00113 static int EUidAtStartup() { return fgEUidAtStartup; }
00114
00115 private:
00116
00117 XrdProofdResponse *GetNewResponse(kXR_unt16 rid);
00118 int Interrupt();
00119 int Ping();
00120 int Process2();
00121 void Reset();
00122 int SendData(XrdProofdProofServ *xps, kXR_int32 sid = -1, XrdSrvBuffer **buf = 0, bool sb = 0);
00123 int SendDataN(XrdProofdProofServ *xps, XrdSrvBuffer **buf = 0, bool sb = 0);
00124 int SendMsg();
00125 int CtrlC();
00126 void TouchAdminPath();
00127 int Urgent();
00128
00129
00130
00131
00132 XrdObject<XrdProofdProtocol> fProtLink;
00133 XrdBuffer *fArgp;
00134
00135 XrdLink *fLink;
00136 int fPid;
00137
00138 char fStatus;
00139
00140 unsigned char fClntCapVer;
00141 short int fProofProtocol;
00142
00143 bool fSuperUser;
00144
00145 XrdProofdClient *fPClient;
00146 XrdOucString fAdminPath;
00147
00148 XrdOucString fTraceID;
00149
00150 XrdSecEntity *fSecClient;
00151 XrdSecProtocol *fAuthProt;
00152 XrdSecEntity fSecEntity;
00153
00154 kXR_int32 fConnType;
00155
00156 kXR_int32 fCID;
00157
00158 XrdSysRecMutex fMutex;
00159 XrdSysRecMutex fCtrlcMutex;
00160
00161 bool fIsCtrlC;
00162
00163
00164
00165 XPClientRequest fRequest;
00166 std::vector<XrdProofdResponse *> fResponses;
00167
00168
00169
00170
00171 static bool fgConfigDone;
00172 static int fgCount;
00173 static XrdObjectQ<XrdProofdProtocol> fgProtStack;
00174 static XrdBuffManager *fgBPool;
00175 static int fgMaxBuffsz;
00176 static XrdSysRecMutex fgBMutex;
00177
00178 static XrdSysError fgEDest;
00179 static XrdSysLogger *fgLogger;
00180
00181 static int fgEUidAtStartup;
00182
00183
00184
00185 static int fgReadWait;
00186 static XrdProofdManager *fgMgr;
00187
00188 static void PostSession(int on, const char *u, const char *g,
00189 XrdProofdProofServ *xps);
00190 };
00191
00192 #define XPD_SETRESP(p, x) \
00193 kXR_unt16 rid; \
00194 memcpy((void *)&rid, (const void *)&(p->Request()->header.streamid[0]), 2); \
00195 XrdProofdResponse *response = p->Response(rid); \
00196 if (!response) { \
00197 TRACEP(p, XERR, x << ": could not get Response instance for requid:"<< rid); \
00198 return rc; \
00199 }
00200
00201 #define XPD_SETRESPV(p, x) \
00202 kXR_unt16 rid; \
00203 memcpy((void *)&rid, (const void *)&(p->Request()->header.streamid[0]), 2); \
00204 XrdProofdResponse *response = p->Response(rid); \
00205 if (!response) { \
00206 TRACEP(p, XERR, x << ": could not get Response instance for requid:"<< rid); \
00207 return; \
00208 }
00209
00210 #define XPD_CLNT_VERSION_OK(p,v) (v < 0 || (p && p->ProofProtocol() >= v))
00211
00212 #endif