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 ()
XrdProtocol * | Match (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
XrdJob * | NextJob

## 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.

:
XrdProtocol("protocol loader"), myPort(port)
{
int j = 0;
bool hastls = false;
// Extract out the protocols associated with this port
//
for (int i = 0; i < (int)portVec.size(); i++)
{if (myPort == portVec[i].port)
{if (portVec[i].protTLS) hastls = true;
else myProt[j++] = portVec[i].protIdx;
}
}
// Setup to handle tls protocols
//
if (hastls)
{myProt[j++] = -1;
for (int i = 0; i < (int)portVec.size(); i++)
{if (myPort == portVec[i].port && portVec[i].protTLS)
myProt[j++] = portVec[i].protIdx;
}
}
// Put in an end marker
//
myProt[j] = -2;
}
XrdProtocol::XrdProtocol
XrdProtocol(const char *jname)
Definition XrdProtocol.hh:156

References XrdProtocol::XrdProtocol().

Here is the call graph for this function:

## ~XrdProtLoad()

XrdProtLoad::~XrdProtLoad | ( |  | ) |

Definition at line 110 of file XrdProtLoad.cc.

{}

## Member Function Documentation

## DoIt()

void XrdProtLoad::DoIt | ( |  | ) |

inline virtual

Implements XrdJob.

Definition at line 40 of file XrdProtLoad.hh.

{}

## 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.

{
XrdProtocol *xp;
int port = pi->Port;
// Trace this load if so wanted
//
TRACE(DEBUG, "getting protocol object " <<pname);
// First check to see that we haven't exceeded our protocol count
//
if (ProtoCnt >= ProtoMax)
{Log.Emsg("Protocol", "Too many protocols have been defined.");
return 0;
}
// Obtain an instance of this protocol
//
xp = getProtocol(lname, pname, parms, pi);
if (!xp) {Log.Emsg("Protocol","Protocol", pname, "could not be loaded");
return 0;
}
// Add protocol to our table of protocols.
//
ProtName[ProtoCnt] = strdup(pname);
Protocol[ProtoCnt] = xp;
ProtoCnt++;
// Map the port to this protocol
//
Port(ProtoCnt, port, istls);
return ProtoCnt;
}
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
TRACE
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdProtLoad::Port
static int Port(const char *lname, const char *pname, char *parms, XrdProtocol_Config *pi)
Definition XrdProtLoad.cc:156
XrdProtLoad::ProtoMax
static const int ProtoMax
Definition XrdProtLoad.hh:63
XrdProtocol_Config::Port
int Port
Definition XrdProtocol.hh:73
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
XrdGlobal::Log
XrdSysError Log
Definition XrdConfig.cc:113

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 * |  | ) |

inline virtual

Implements XrdProtocol.

Definition at line 50 of file XrdProtLoad.hh.

{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.

{
int port;
// Obtain the port number to be used by this protocol
//
port = getProtocolPort(lname, pname, parms, pi);
// Trace this call if so wanted
//
TRACE(DEBUG, "protocol " <<pname <<" wants to use port " <<port);
// Make sure we can use the port
//
if (port < 0) Log.Emsg("Protocol","Protocol", pname,
"port number could not be determined");
return port;
}

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.

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

References DEBUG, XrdGlobal::Log, and TRACE.

## Process()

int XrdProtLoad::Process | ( | XrdLink * | lp | ) |

virtual

Implements XrdProtocol.

Definition at line 196 of file XrdProtLoad.cc.

{
XrdProtocol *pp = 0;
signed char *pVec = myProt;
int i = 0;
// Try to find a protocol match for this connection
//
while(*pVec != -2)
{if (*pVec == -1)
{if (!(lp->setTLS(true)))
{lp->setEtext("TLS negotiation failed.");
return -1;
}
} else {i = *pVec;
if ((pp = Protocol[i]->Match(lp))) break;
else if (lp->isFlawed()) return -1;
}
pVec++;
}
// Verify that we have an actual protocol
//
if (!pp) {lp->setEtext("matching protocol not found"); return -1;}
// Now attach the new protocol object to the link
//
lp->setProtocol(pp);
lp->setProtName(ProtName[i]);
// Trace this load if so wanted
//
TRACE(DEBUG, "matched port " <<myPort <<" protocol " <<ProtName[i]);
// Activate this link
//
if (!lp->Activate()) {lp->setEtext("activation failed"); return -1;}
// Take a short-cut and process the initial request as a sticky request
//
return pp->Process(lp);
}
XrdLink::setProtocol
XrdProtocol * setProtocol(XrdProtocol *pp, bool runit=false, bool push=false)
Definition XrdLink.cc:426
XrdLink::isFlawed
bool isFlawed() const
Definition XrdLink.cc:249
XrdLink::setEtext
int setEtext(const char *text)
Definition XrdLink.cc:393
XrdLink::setTLS
bool setTLS(bool enable, XrdTlsContext *ctx=0)
Enable or disable TLS on the link.
Definition XrdLink.cc:487
XrdLink::setProtName
void setProtName(const char *name)
Definition XrdLink.cc:443
XrdLink::Activate
bool Activate()
Definition XrdLink.cc:131
XrdProtLoad::Match
XrdProtocol * Match(XrdLink *)
Definition XrdProtLoad.hh:50
XrdProtocol::Process
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.

{
// Document non-protocol errors
//
if (lp && reason)
Log.Emsg("Protocol", lp->ID, "terminated", reason);
}
XrdLink::ID
char * ID
Pointer to the client's link identity.
Definition XrdLink.hh:210

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.

{
int i, k, totlen = 0;
for (i = 0; i < ProtoCnt && (blen > 0 || !buff); i++)
{k = Protocol[i]->Stats(buff, blen, do_sync);
totlen += k; buff += k; blen -= k;
}
return totlen;
}

## Stats()

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

inline virtual

Implements XrdProtocol.

Definition at line 56 of file XrdProtLoad.hh.

{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:

- XrdProtLoad.hh
- XrdProtLoad.cc