XRootD
Loading...
Searching...
No Matches
XrdLinkXeq.hh
Go to the documentation of this file.
1#ifndef __XRD_LINKXEQ_H__
2#define __XRD_LINKXEQ_H__
3/******************************************************************************/
4/* */
5/* X r d L i n k X e q . h h */
6/* */
7/* (c) 2018 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include <sys/types.h>
33#include <fcntl.h>
34#include <ctime>
35
36#include "Xrd/XrdLink.hh"
37#include "Xrd/XrdLinkInfo.hh"
38#include "Xrd/XrdPollInfo.hh"
39#include "Xrd/XrdProtocol.hh"
40
41#include "XrdNet/XrdNetAddr.hh"
42
43#include "XrdTls/XrdTls.hh"
45
46/******************************************************************************/
47/* C l a s s D e f i n i t i o n */
48/******************************************************************************/
49
50class XrdSendQ;
51
52class XrdLinkXeq : protected XrdLink
53{
54public:
55
56inline
58
59int Backlog();
60
61int Client(char *buff, int blen);
62
63int Close(bool defer=false);
64
65void DoIt(); // Override
66
67
68 int getIOStats(long long &inbytes, long long &outbytes,
69 int &numstall, int &numtardy)
70 { inbytes = BytesIn + BytesInTot;
71 outbytes = BytesOut+BytesOutTot;
72 numstall = stallCnt + stallCntTot;
73 numtardy = tardyCnt + tardyCntTot;
74 return LinkInfo.InUse;
75 }
76
78
79static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
80
81inline
83
84inline
85const char *Name() const {return (const char *)Lname;}
86
87inline const
88XrdNetAddr *NetAddr() const {return &Addr;}
89
90int Peek(char *buff, int blen, int timeout=-1);
91
92int Recv(char *buff, int blen);
93int Recv(char *buff, int blen, int timeout);
94int Recv(const struct iovec *iov, int iocnt, int timeout);
95
96int RecvAll(char *buff, int blen, int timeout=-1);
97
98bool Register(const char *hName);
99
100int Send(const char *buff, int blen);
101int Send(const struct iovec *iov, int iocnt, int bytes=0);
102
103int Send(const sfVec *sdP, int sdn); // Iff sfOK > 0
104
105void setID(const char *userid, int procid);
106
107void setLocation(XrdNetAddrInfo::LocInfo &loc) {Addr.SetLocation(loc);}
108
109bool setNB();
110
111XrdProtocol *setProtocol(XrdProtocol *pp, bool push);
112
113void setProtName(const char *name);
114
115bool setTLS(bool enable, XrdTlsContext *ctx=0);
116
117 void Shutdown(bool getLock);
118
119static int Stats(char *buff, int blen, bool do_sync=false);
120
121 void syncStats(int *ctime=0);
122
123int TLS_Peek(char *Buff, int Blen, int timeout);
124
125int TLS_Recv(char *Buff, int Blen);
126
127int TLS_Recv(char *Buff, int Blen, int timeout, bool havelock=false);
128
129int TLS_Recv(const struct iovec *iov, int iocnt, int timeout);
130
131int TLS_RecvAll(char *Buff, int Blen, int timeout);
132
133int TLS_Send(const char *Buff, int Blen);
134
135int TLS_Send(const struct iovec *iov, int iocnt, int bytes);
136
137int TLS_Send(const sfVec *sfP, int sfN);
138
139const char *verTLS();
140
141 XrdLinkXeq();
142 ~XrdLinkXeq() {} // Is never deleted!
143
146
147protected:
148
149int RecvIOV(const struct iovec *iov, int iocnt);
150void Reset();
151int sendData(const char *Buff, int Blen);
152int SendIOV(const struct iovec *iov, int iocnt, int bytes);
153int SFError(int rc);
154int TLS_Error(const char *act, XrdTls::RC rc);
155bool TLS_Write(const char *Buff, int Blen);
156
157static const char *TraceID;
158
159// Statistical area (global and local)
160//
161static long long LinkBytesIn;
162static long long LinkBytesOut;
163static long long LinkConTime;
164static long long LinkCountTot;
165static int LinkCount;
166static int LinkCountMax;
167static int LinkTimeOuts;
168static int LinkStalls;
169static int LinkSfIntr;
170 long long BytesIn;
171 long long BytesInTot;
172 long long BytesOut;
173 long long BytesOutTot;
180
181// Protocol section
182//
183XrdProtocol *Protocol; // -> Protocol tied to the link
184XrdProtocol *ProtoAlt; // -> Alternate/stacked protocol
185
186// TLS section
187//
189
190// Identification section
191//
195XrdSendQ *sendQ; // Protected by wrMutex && opMutex
200char Uname[24]; // Uname and Lname must be adjacent!
201char Lname[256];
202};
203#endif
static const char * TraceID
int TLS_Send(const char *Buff, int Blen)
long long BytesOut
int TLS_Error(const char *act, XrdTls::RC rc)
int TLS_Peek(char *Buff, int Blen, int timeout)
int Client(char *buff, int blen)
char Uname[24]
XrdTlsPeerCerts * getPeerCerts()
XrdNetAddrInfo * AddrInfo()
Definition XrdLinkXeq.hh:57
static int LinkCountMax
XrdLinkInfo LinkInfo
const char * Name() const
Definition XrdLinkXeq.hh:85
XrdProtocol * ProtoAlt
int Close(bool defer=false)
XrdNetAddr Addr
int TLS_Recv(char *Buff, int Blen)
int sendData(const char *Buff, int Blen)
long long BytesInTot
bool TLS_Write(const char *Buff, int Blen)
int SendIOV(const struct iovec *iov, int iocnt, int bytes)
XrdProtocol * setProtocol(XrdProtocol *pp, bool push)
static long long LinkCountTot
long long BytesOutTot
void Shutdown(bool getLock)
int Peek(char *buff, int blen, int timeout=-1)
static int LinkCount
void Reset()
int Backlog()
static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0)
XrdSysMutex wrMutex
static int Stats(char *buff, int blen, bool do_sync=false)
XrdSendQ * sendQ
XrdPollInfo PollInfo
void setID(const char *userid, int procid)
int Recv(char *buff, int blen)
static long long LinkBytesIn
int TLS_RecvAll(char *Buff, int Blen, int timeout)
int SFError(int rc)
long long BytesIn
int Send(const char *buff, int blen)
XrdSysMutex rdMutex
const char * verTLS()
bool setNB()
int RecvIOV(const struct iovec *iov, int iocnt)
char Lname[256]
static long long LinkConTime
static int LinkSfIntr
XrdTlsSocket tlsIO
void DoIt()
void setLocation(XrdNetAddrInfo::LocInfo &loc)
XrdProtocol * getProtocol()
Definition XrdLinkXeq.hh:82
int RecvAll(char *buff, int blen, int timeout=-1)
XrdProtocol * Protocol
bool Register(const char *hName)
static XrdSysMutex statsMutex
void setProtName(const char *name)
static int LinkStalls
const XrdNetAddr * NetAddr() const
Definition XrdLinkXeq.hh:88
static long long LinkBytesOut
void syncStats(int *ctime=0)
bool setTLS(bool enable, XrdTlsContext *ctx=0)
int getIOStats(long long &inbytes, long long &outbytes, int &numstall, int &numtardy)
Definition XrdLinkXeq.hh:68
static int LinkTimeOuts
Socket wrapper for TLS I/O.