XrdProofConn.h

Go to the documentation of this file.
00001 // @(#)root/proofd:$Id: XrdProofConn.h 32192 2010-02-03 08:50:20Z ganis $
00002 // Author: G. Ganis  June 2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_XrdProofConn
00013 #define ROOT_XrdProofConn
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // XrdProofConn                                                         //
00018 //                                                                      //
00019 // Authors: G. Ganis, CERN, 2005                                        //
00020 //                                                                      //
00021 // Low level handler of connections to xproofd.                         //
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 // Generic sender
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;          // Type of client
00072    bool                fConnected;
00073    int                 fLogConnID;     // Logical connection ID of current object
00074    kXR_unt16           fStreamid;      // Streamid used for normal communications
00075    int                 fRemoteProtocol; // Protocol of remote daemon
00076    int                 fServerProto;   // The server protocol
00077    ESrvType            fServerType;    // Server type as returned by DoHandShake()
00078                                        // (see enum ServerType)
00079    short               fSessionID;     // proofsrv: remote ID of connected session
00080    XrdOucString        fUser;          // Username used for login
00081    XrdOucString        fHost;          // Remote host
00082    int                 fPort;          // Remote port
00083    XrdOucString        fLastErrMsg;    // Msg describing last error
00084    XErrorCode          fLastErr;       // Last error code
00085    char                fCapVer;        // a version number (e.g. a protocol num)
00086 
00087    XrdOucString        fLoginBuffer;   // Buffer to be sent over at login
00088 
00089    XrdSysRecMutex     *fMutex;         // Lock SendRecv actions
00090 
00091    XrdSysRecMutex     *fConnectInterruptMtx;  // Protect access to fConnectInterrupt
00092    bool                fConnectInterrupt;
00093 
00094    XrdClientPhyConnection *fPhyConn;   // underlying physical connection
00095 
00096    int                 fOpenSockFD;    // Underlying socket descriptor
00097 
00098    XrdClientAbsUnsolMsgHandler *fUnsolMsgHandler; // Handler of unsolicited responses
00099 
00100    XrdProofConnSender_t fSender;      // Generic message forwarder
00101    void                *fSenderArg;   // Optional rgument for the message forwarder
00102 
00103    XrdClientUrlInfo    fUrl;           // Connection URL info object with
00104 
00105    static XrdClientConnectionMgr *fgConnMgr; //Connection Manager
00106 
00107    static int          fgMaxTry; //max number of connection attempts
00108    static int          fgTimeWait; //Wait time between an attempt and the other
00109 
00110    static XrdSysPlugin *fgSecPlugin;       // Sec library plugin
00111    static void         *fgSecGetProtocol;  // Sec protocol getter
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    // Send, Recv interfaces
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

Generated on Tue Jul 5 14:51:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1