00001 #ifndef __XRD_LINKXEQ_H__
00002 #define __XRD_LINKXEQ_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <sys/types.h>
00033 #include <fcntl.h>
00034 #include <time.h>
00035
00036 #include "Xrd/XrdLink.hh"
00037 #include "Xrd/XrdLinkInfo.hh"
00038 #include "Xrd/XrdPollInfo.hh"
00039 #include "Xrd/XrdProtocol.hh"
00040
00041 #include "XrdNet/XrdNetAddr.hh"
00042
00043 #include "XrdTls/XrdTls.hh"
00044 #include "XrdTls/XrdTlsSocket.hh"
00045
00046
00047
00048
00049
00050 class XrdSendQ;
00051
00052 class XrdLinkXeq : protected XrdLink
00053 {
00054 public:
00055
00056 inline
00057 XrdNetAddrInfo *AddrInfo() {return (XrdNetAddrInfo *)&Addr;}
00058
00059 int Backlog();
00060
00061 int Client(char *buff, int blen);
00062
00063 int Close(bool defer=false);
00064
00065 void DoIt();
00066
00067
00068 int getIOStats(long long &inbytes, long long &outbytes,
00069 int &numstall, int &numtardy)
00070 { inbytes = BytesIn + BytesInTot;
00071 outbytes = BytesOut+BytesOutTot;
00072 numstall = stallCnt + stallCntTot;
00073 numtardy = tardyCnt + tardyCntTot;
00074 return LinkInfo.InUse;
00075 }
00076
00077 XrdTlsPeerCerts *getPeerCerts();
00078
00079 static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
00080
00081 inline
00082 XrdProtocol *getProtocol() {return Protocol;}
00083
00084 inline
00085 const char *Name() const {return (const char *)Lname;}
00086
00087 inline const
00088 XrdNetAddr *NetAddr() const {return &Addr;}
00089
00090 int Peek(char *buff, int blen, int timeout=-1);
00091
00092 int Recv(char *buff, int blen);
00093 int Recv(char *buff, int blen, int timeout);
00094
00095 int RecvAll(char *buff, int blen, int timeout=-1);
00096
00097 bool Register(const char *hName);
00098
00099 int Send(const char *buff, int blen);
00100 int Send(const struct iovec *iov, int iocnt, int bytes=0);
00101
00102 int Send(const sfVec *sdP, int sdn);
00103
00104 void setID(const char *userid, int procid);
00105
00106 void setLocation(XrdNetAddrInfo::LocInfo &loc) {Addr.SetLocation(loc);}
00107
00108 bool setNB();
00109
00110 XrdProtocol *setProtocol(XrdProtocol *pp, bool push);
00111
00112 void setProtName(const char *name);
00113
00114 bool setTLS(bool enable, XrdTlsContext *ctx=0);
00115
00116 void Shutdown(bool getLock);
00117
00118 static int Stats(char *buff, int blen, bool do_sync=false);
00119
00120 void syncStats(int *ctime=0);
00121
00122 int TLS_Peek(char *Buff, int Blen, int timeout);
00123
00124 int TLS_Recv(char *Buff, int Blen);
00125
00126 int TLS_Recv(char *Buff, int Blen, int timeout);
00127
00128 int TLS_RecvAll(char *Buff, int Blen, int timeout);
00129
00130 int TLS_Send(const char *Buff, int Blen);
00131
00132 int TLS_Send(const struct iovec *iov, int iocnt, int bytes);
00133
00134 int TLS_Send(const sfVec *sfP, int sfN);
00135
00136 const char *verTLS();
00137
00138 XrdLinkXeq();
00139 ~XrdLinkXeq() {}
00140
00141 XrdLinkInfo LinkInfo;
00142 XrdPollInfo PollInfo;
00143
00144 protected:
00145
00146 void Reset();
00147 int sendData(const char *Buff, int Blen);
00148 int SendIOV(const struct iovec *iov, int iocnt, int bytes);
00149 int SFError(int rc);
00150 int TLS_Error(const char *act, XrdTls::RC rc);
00151 bool TLS_Write(const char *Buff, int Blen);
00152
00153 static const char *TraceID;
00154
00155
00156
00157 static long long LinkBytesIn;
00158 static long long LinkBytesOut;
00159 static long long LinkConTime;
00160 static long long LinkCountTot;
00161 static int LinkCount;
00162 static int LinkCountMax;
00163 static int LinkTimeOuts;
00164 static int LinkStalls;
00165 static int LinkSfIntr;
00166 long long BytesIn;
00167 long long BytesInTot;
00168 long long BytesOut;
00169 long long BytesOutTot;
00170 int stallCnt;
00171 int stallCntTot;
00172 int tardyCnt;
00173 int tardyCntTot;
00174 int SfIntr;
00175 static XrdSysMutex statsMutex;
00176
00177
00178
00179 XrdProtocol *Protocol;
00180 XrdProtocol *ProtoAlt;
00181
00182
00183
00184 XrdTlsSocket tlsIO;
00185
00186
00187
00188 XrdNetAddr Addr;
00189 XrdSysMutex rdMutex;
00190 XrdSysMutex wrMutex;
00191 XrdSendQ *sendQ;
00192 int HNlen;
00193 bool LockReads;
00194 bool KeepFD;
00195 char isIdle;
00196 char Uname[24];
00197 char Lname[256];
00198 };
00199 #endif