XRootD
Loading...
Searching...
No Matches
XrdProtLoad Class Reference

#include <XrdProtLoad.hh>

Inheritance diagram for XrdProtLoad:
Collaboration diagram for XrdProtLoad:

Public Member Functions

 XrdProtLoad (int port=-1)
 ~XrdProtLoad ()
void DoIt ()
XrdProtocolMatch (XrdLink *)
int Process (XrdLink *lp)
void Recycle (XrdLink *lp, int ctime, const char *txt)
int Stats (char *buff, int blen, int do_sync=0)
Public Member Functions inherited from XrdProtocol
 XrdProtocol (const char *jname)
virtual ~XrdProtocol ()
Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
virtual ~XrdJob ()

Static Public Member Functions

static int Load (const char *lname, const char *pname, char *parms, XrdProtocol_Config *pi, bool istls)
static int Port (const char *lname, const char *pname, char *parms, XrdProtocol_Config *pi)
static void Port (int protIdx, int port, bool isTLS)
static int Statistics (char *buff, int blen, int do_sync=0)

Static Public Attributes

static const int PortoMax = 8
static const int ProtoMax = 8

Additional Inherited Members

Public Attributes inherited from XrdJob
const char * Comment
XrdJobNextJob

Detailed Description

Definition at line 36 of file XrdProtLoad.hh.

Constructor & Destructor Documentation

◆ XrdProtLoad()

XrdProtLoad::XrdProtLoad ( int port = -1)

Definition at line 80 of file XrdProtLoad.cc.

80 :
81 XrdProtocol("protocol loader"), myPort(port)
82{
83 int j = 0;
84 bool hastls = false;
85
86// Extract out the protocols associated with this port
87//
88 for (int i = 0; i < (int)portVec.size(); i++)
89 {if (myPort == portVec[i].port)
90 {if (portVec[i].protTLS) hastls = true;
91 else myProt[j++] = portVec[i].protIdx;
92 }
93 }
94
95// Setup to handle tls protocols
96//
97 if (hastls)
98 {myProt[j++] = -1;
99 for (int i = 0; i < (int)portVec.size(); i++)
100 {if (myPort == portVec[i].port && portVec[i].protTLS)
101 myProt[j++] = portVec[i].protIdx;
102 }
103 }
104
105// Put in an end marker
106//
107 myProt[j] = -2;
108}
XrdProtocol(const char *jname)

References XrdProtocol::XrdProtocol().

Here is the call graph for this function:

◆ ~XrdProtLoad()

XrdProtLoad::~XrdProtLoad ( )

Definition at line 110 of file XrdProtLoad.cc.

110{}

Member Function Documentation

◆ DoIt()

void XrdProtLoad::DoIt ( )
inlinevirtual

Implements XrdJob.

Definition at line 40 of file XrdProtLoad.hh.

40{}

◆ Load()

int XrdProtLoad::Load ( const char * lname,
const char * pname,
char * parms,
XrdProtocol_Config * pi,
bool istls )
static

Definition at line 116 of file XrdProtLoad.cc.

118{
119 XrdProtocol *xp;
120 int port = pi->Port;
121
122// Trace this load if so wanted
123//
124 TRACE(DEBUG, "getting protocol object " <<pname);
125
126// First check to see that we haven't exceeded our protocol count
127//
128 if (ProtoCnt >= ProtoMax)
129 {Log.Emsg("Protocol", "Too many protocols have been defined.");
130 return 0;
131 }
132
133// Obtain an instance of this protocol
134//
135 xp = getProtocol(lname, pname, parms, pi);
136 if (!xp) {Log.Emsg("Protocol","Protocol", pname, "could not be loaded");
137 return 0;
138 }
139
140// Add protocol to our table of protocols.
141//
142 ProtName[ProtoCnt] = strdup(pname);
143 Protocol[ProtoCnt] = xp;
144 ProtoCnt++;
145
146// Map the port to this protocol
147//
148 Port(ProtoCnt, port, istls);
149 return ProtoCnt;
150}
#define DEBUG(x)
#define TRACE(act, x)
Definition XrdTrace.hh:63
static int Port(const char *lname, const char *pname, char *parms, XrdProtocol_Config *pi)
static const int ProtoMax
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError Log
Definition XrdConfig.cc:112

References XrdProtocol::XrdProtocol(), DEBUG, XrdGlobal::Log, Port(), XrdProtocol_Config::Port, ProtoMax, and TRACE.

Here is the call graph for this function:

◆ Match()

XrdProtocol * XrdProtLoad::Match ( XrdLink * )
inlinevirtual

Implements XrdProtocol.

Definition at line 50 of file XrdProtLoad.hh.

50{return 0;}

References XrdProtocol::XrdProtocol().

Referenced by Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Port() [1/2]

int XrdProtLoad::Port ( const char * lname,
const char * pname,
char * parms,
XrdProtocol_Config * pi )
static

Definition at line 156 of file XrdProtLoad.cc.

158{
159 int port;
160
161// Obtain the port number to be used by this protocol
162//
163 port = getProtocolPort(lname, pname, parms, pi);
164
165// Trace this call if so wanted
166//
167 TRACE(DEBUG, "protocol " <<pname <<" wants to use port " <<port);
168
169// Make sure we can use the port
170//
171 if (port < 0) Log.Emsg("Protocol","Protocol", pname,
172 "port number could not be determined");
173 return port;
174}

References DEBUG, XrdGlobal::Log, and TRACE.

Referenced by Load().

Here is the caller graph for this function:

◆ Port() [2/2]

void XrdProtLoad::Port ( int protIdx,
int port,
bool isTLS )
static

Definition at line 178 of file XrdProtLoad.cc.

179{
180 if (protIdx > 0 && protIdx <= ProtoCnt && port > 0)
181 {portMap pMap(port, protIdx-1, isTLS);
182 portVec.push_back(pMap);
183 TRACE(DEBUG, "enabling " <<(isTLS ? "tls port " : "port ") <<port
184 <<" for protocol " <<ProtName[protIdx-1]);
185 } else {
186 char buff[256];
187 snprintf(buff, sizeof(buff), "prot=%d port=%d;", protIdx, port);
188 Log.Emsg("Protocol", "Invalid Port() parms:", buff, "port not mapped!");
189 }
190}

References DEBUG, XrdGlobal::Log, and TRACE.

◆ Process()

int XrdProtLoad::Process ( XrdLink * lp)
virtual

Implements XrdProtocol.

Definition at line 196 of file XrdProtLoad.cc.

197{
198 XrdProtocol *pp = 0;
199 signed char *pVec = myProt;
200 int i = 0;
201
202// Try to find a protocol match for this connection
203//
204 while(*pVec != -2)
205 {if (*pVec == -1)
206 {if (!(lp->setTLS(true)))
207 {lp->setEtext("TLS negotiation failed.");
208 return -1;
209 }
210 } else {i = *pVec;
211 if ((pp = Protocol[i]->Match(lp))) break;
212 else if (lp->isFlawed()) return -1;
213 }
214 pVec++;
215 }
216
217// Verify that we have an actual protocol
218//
219 if (!pp) {lp->setEtext("matching protocol not found"); return -1;}
220
221// Now attach the new protocol object to the link
222//
223 lp->setProtocol(pp);
224 lp->setProtName(ProtName[i]);
225
226// Trace this load if so wanted
227//
228 TRACE(DEBUG, "matched port " <<myPort <<" protocol " <<ProtName[i]);
229
230// Activate this link
231//
232 if (!lp->Activate()) {lp->setEtext("activation failed"); return -1;}
233
234// Take a short-cut and process the initial request as a sticky request
235//
236 return pp->Process(lp);
237}
XrdProtocol * Match(XrdLink *)
virtual int Process(XrdLink *lp)=0

References XrdProtocol::XrdProtocol(), XrdLink::Activate(), DEBUG, XrdLink::isFlawed(), Match(), XrdProtocol::Process(), XrdLink::setEtext(), XrdLink::setProtName(), XrdLink::setProtocol(), XrdLink::setTLS(), and TRACE.

Here is the call graph for this function:

◆ Recycle()

void XrdProtLoad::Recycle ( XrdLink * lp,
int ctime,
const char * txt )
virtual

Implements XrdProtocol.

Definition at line 243 of file XrdProtLoad.cc.

244{
245
246// Document non-protocol errors
247//
248 if (lp && reason)
249 Log.Emsg("Protocol", lp->ID, "terminated", reason);
250}

References XrdLink::ID, and XrdGlobal::Log.

◆ Statistics()

int XrdProtLoad::Statistics ( char * buff,
int blen,
int do_sync = 0 )
static

Definition at line 256 of file XrdProtLoad.cc.

257{
258 int i, k, totlen = 0;
259
260 for (i = 0; i < ProtoCnt && (blen > 0 || !buff); i++)
261 {k = Protocol[i]->Stats(buff, blen, do_sync);
262 totlen += k; buff += k; blen -= k;
263 }
264
265 return totlen;
266}

◆ Stats()

int XrdProtLoad::Stats ( char * buff,
int blen,
int do_sync = 0 )
inlinevirtual

Implements XrdProtocol.

Definition at line 56 of file XrdProtLoad.hh.

56{return 0;}

Member Data Documentation

◆ PortoMax

const int XrdProtLoad::PortoMax = 8
static

Definition at line 64 of file XrdProtLoad.hh.

Referenced by XrdConfigProt::AddPort().

◆ ProtoMax

const int XrdProtLoad::ProtoMax = 8
static

Definition at line 63 of file XrdProtLoad.hh.

Referenced by Load().


The documentation for this class was generated from the following files: