00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_XrdProofConn
00013 #define ROOT_XrdProofConn
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #define DFLT_CONNECTMAXTRY 10
00026
00027 #ifdef OLDXRDOUC
00028 # include "XrdSysToOuc.h"
00029 #endif
00030
00031 #ifndef ROOT_XProofProtocol
00032 #include "XProofProtocol.h"
00033 #endif
00034 #ifndef ROOT_XProofProtUtils
00035 #include "XProofProtUtils.h"
00036 #endif
00037 #ifndef XRC_UNSOLMSG_H
00038 #include "XrdClient/XrdClientUnsolMsg.hh"
00039 #endif
00040 #ifndef _XRC_URLINFO_H
00041 #include "XrdClient/XrdClientUrlInfo.hh"
00042 #endif
00043 #ifndef __OUC_STRING_H__
00044 #include "XrdOuc/XrdOucString.hh"
00045 #endif
00046
00047 #include <list>
00048
00049 class XrdClientConnectionMgr;
00050 class XrdClientMessage;
00051 class XrdClientPhyConnection;
00052 class XrdSysRecMutex;
00053 class XrdSecProtocol;
00054 class XrdSysPlugin;
00055
00056
00057 typedef int (*XrdProofConnSender_t)(const char *, int, void *);
00058
00059 class XrdProofConn : public XrdClientAbsUnsolMsgHandler {
00060
00061 friend class TXSocket;
00062 friend class TXUnixSocket;
00063 friend class XrdProofPhyConn;
00064
00065 public:
00066
00067 enum ESrvType { kSTError = -1, kSTNone, kSTXProofd, kSTProofd };
00068
00069 private:
00070
00071 char fMode;
00072 bool fConnected;
00073 int fLogConnID;
00074 kXR_unt16 fStreamid;
00075 int fRemoteProtocol;
00076 int fServerProto;
00077 ESrvType fServerType;
00078
00079 short fSessionID;
00080 XrdOucString fUser;
00081 XrdOucString fHost;
00082 int fPort;
00083 XrdOucString fLastErrMsg;
00084 XErrorCode fLastErr;
00085 char fCapVer;
00086
00087 XrdOucString fLoginBuffer;
00088
00089 XrdSysRecMutex *fMutex;
00090
00091 XrdSysRecMutex *fConnectInterruptMtx;
00092 bool fConnectInterrupt;
00093
00094 XrdClientPhyConnection *fPhyConn;
00095
00096 int fOpenSockFD;
00097
00098 XrdClientAbsUnsolMsgHandler *fUnsolMsgHandler;
00099
00100 XrdProofConnSender_t fSender;
00101 void *fSenderArg;
00102
00103 XrdClientUrlInfo fUrl;
00104
00105 static XrdClientConnectionMgr *fgConnMgr;
00106
00107 static int fgMaxTry;
00108 static int fgTimeWait;
00109
00110 static XrdSysPlugin *fgSecPlugin;
00111 static void *fgSecGetProtocol;
00112
00113 XrdSecProtocol *Authenticate(char *plist, int lsiz);
00114 bool CheckErrorStatus(XrdClientMessage *, int &, const char *, bool);
00115 bool CheckResp(struct ServerResponseHeader *resp,
00116 const char *met, bool);
00117 virtual void Connect();
00118 void ReConnect();
00119 virtual int TryConnect();
00120
00121 ESrvType DoHandShake();
00122 virtual bool GetAccessToSrv();
00123 virtual bool Init(const char *url = 0);
00124 bool Login();
00125 bool MatchStreamID(struct ServerResponseHeader *resp);
00126 XrdClientMessage *SendRecv(XPClientRequest *req,
00127 const void *reqData, char **answData);
00128
00129 void SetInterrupt();
00130
00131 void SetConnectInterrupt();
00132 bool ConnectInterrupt();
00133
00134 public:
00135 XrdProofConn(const char *url, char mode = 'M', int psid = -1, char ver = -1,
00136 XrdClientAbsUnsolMsgHandler * uh = 0, const char *logbuf = 0);
00137 virtual ~XrdProofConn();
00138
00139 virtual void Close(const char *opt = "");
00140
00141 int GetLogConnID() const { return fLogConnID; }
00142 int GetLowSocket();
00143 int GetOpenError() const { return (int)fLastErr; }
00144 int GetServType() const { return (int)fServerType; }
00145 short GetSessionID() const { return fSessionID; }
00146 const char *GetUrl() { return (const char *) fUrl.GetUrl().c_str(); }
00147 const char *GetLastErr() { return fLastErrMsg.c_str(); }
00148
00149 bool IsValid() const;
00150
00151 XReqErrorType LowWrite(XPClientRequest *, const void *, int);
00152
00153
00154 virtual int ReadRaw(void *buf, int len);
00155 virtual XrdClientMessage *ReadMsg();
00156 XrdClientMessage *SendReq(XPClientRequest *req, const void *reqData,
00157 char **answData, const char *CmdName,
00158 bool notifyerr = 1);
00159 virtual void SetAsync(XrdClientAbsUnsolMsgHandler *uh, XrdProofConnSender_t = 0, void * = 0);
00160 void SetSID(kXR_char *sid);
00161 virtual int WriteRaw(const void *buf, int len);
00162
00163 static void GetRetryParam(int &maxtry, int &timewait);
00164 static void SetRetryParam(int maxtry = 5, int timewait = 2);
00165
00166 virtual UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *s,
00167 XrdClientMessage *m);
00168 };
00169
00170 #endif