12 #ifndef ROOT_XrdProofConn
13 #define ROOT_XrdProofConn
25 #define DFLT_CONNECTMAXTRY 10
32 #ifndef __OUC_STRING_H__
33 #include "XrdOuc/XrdOucString.hh"
38 class XrdClientConnectionMgr;
39 class XrdClientMessage;
40 class XrdClientPhyConnection;
46 typedef int (*XrdProofConnSender_t)(
const char *, int,
void *);
48 class XrdProofConn :
public XrdClientAbsUnsolMsgHandler {
50 friend class TXSocket;
51 friend class TXUnixSocket;
52 friend class XrdProofPhyConn;
56 enum ESrvType { kSTError = -1, kSTNone, kSTXProofd, kSTProofd };
72 XrdOucString fLastErrMsg;
76 XrdOucString fLoginBuffer;
78 XrdSysRecMutex *fMutex;
80 XrdSysRecMutex *fConnectInterruptMtx;
81 bool fConnectInterrupt;
83 XrdClientPhyConnection *fPhyConn;
87 XrdClientAbsUnsolMsgHandler *fUnsolMsgHandler;
89 XrdProofConnSender_t fSender;
92 XrdClientUrlInfo fUrl;
94 static XrdClientConnectionMgr *fgConnMgr;
97 static int fgTimeWait;
99 static XrdSysPlugin *fgSecPlugin;
100 static void *fgSecGetProtocol;
102 XrdSecProtocol *Authenticate(
char *plist,
int lsiz);
103 bool CheckErrorStatus(XrdClientMessage *,
int &,
const char *,
bool);
104 bool CheckResp(
struct ServerResponseHeader *resp,
105 const char *met,
bool);
106 virtual void Connect(
int = -1);
108 virtual int TryConnect(
int = -1);
110 ESrvType DoHandShake(XrdClientPhyConnection *p = 0);
111 virtual bool GetAccessToSrv(XrdClientPhyConnection *p = 0);
112 virtual bool Init(
const char *url = 0,
int = -1);
114 bool MatchStreamID(
struct ServerResponseHeader *resp);
115 XrdClientMessage *SendRecv(XPClientRequest *req,
116 const void *reqData,
char **answData);
120 void SetConnectInterrupt();
121 bool ConnectInterrupt();
124 XrdProofConn(
const char *url,
char mode =
'M',
int psid = -1,
char ver = -1,
125 XrdClientAbsUnsolMsgHandler * uh = 0,
const char *logbuf = 0);
126 virtual ~XrdProofConn();
128 virtual void Close(
const char *opt =
"");
130 int GetLogConnID()
const {
return fLogConnID; }
132 int GetOpenError()
const {
return (
int)fLastErr; }
133 int GetServType()
const {
return (
int)fServerType; }
134 short GetSessionID()
const {
return fSessionID; }
135 const char *GetUrl() {
return (
const char *) fUrl.GetUrl().c_str(); }
136 const char *GetLastErr() {
return fLastErrMsg.c_str(); }
138 bool IsValid()
const;
140 XReqErrorType LowWrite(XPClientRequest *,
const void *,
int);
143 virtual int ReadRaw(
void *buf,
int len, XrdClientPhyConnection *p = 0);
144 virtual XrdClientMessage *ReadMsg();
145 XrdClientMessage *SendReq(XPClientRequest *req,
const void *reqData,
146 char **answData,
const char *CmdName,
148 virtual void SetAsync(XrdClientAbsUnsolMsgHandler *uh, XrdProofConnSender_t = 0,
void * = 0);
149 void SetSID(kXR_char *sid);
150 virtual int WriteRaw(
const void *buf,
int len, XrdClientPhyConnection *p = 0);
152 static void GetRetryParam(
int &maxtry,
int &timewait);
153 static void SetRetryParam(
int maxtry = 5,
int timewait = 2);
155 virtual UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *s,
156 XrdClientMessage *m);