#include <XrdProtLoad.hh>
|
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) |
|
Definition at line 36 of file XrdProtLoad.hh.
◆ XrdProtLoad()
XrdProtLoad::XrdProtLoad |
( |
int | port = -1 | ) |
|
Definition at line 80 of file XrdProtLoad.cc.
80 :
82{
83 int j = 0;
84 bool hastls = false;
85
86
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
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
106
107 myProt[j] = -2;
108}
XrdProtocol(const char *jname)
◆ ~XrdProtLoad()
XrdProtLoad::~XrdProtLoad |
( |
| ) |
|
◆ DoIt()
void XrdProtLoad::DoIt |
( |
| ) |
|
|
inlinevirtual |
◆ 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{
121
122
123
124 TRACE(
DEBUG,
"getting protocol object " <<pname);
125
126
127
129 {
Log.
Emsg(
"Protocol",
"Too many protocols have been defined.");
130 return 0;
131 }
132
133
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
141
142 ProtName[ProtoCnt] = strdup(pname);
143 Protocol[ProtoCnt] = xp;
144 ProtoCnt++;
145
146
147
148 Port(ProtoCnt, port, istls);
149 return ProtoCnt;
150}
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)
References DEBUG, XrdSysError::Emsg(), XrdGlobal::Log, Port(), XrdProtocol_Config::Port, ProtoMax, and TRACE.
◆ Match()
◆ 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
162
163 port = getProtocolPort(lname, pname, parms, pi);
164
165
166
167 TRACE(
DEBUG,
"protocol " <<pname <<
" wants to use port " <<port);
168
169
170
171 if (port < 0)
Log.
Emsg(
"Protocol",
"Protocol", pname,
172 "port number could not be determined");
173 return port;
174}
References DEBUG, XrdSysError::Emsg(), XrdGlobal::Log, and TRACE.
Referenced by Load().
◆ 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, XrdSysError::Emsg(), XrdGlobal::Log, and TRACE.
◆ Process()
int XrdProtLoad::Process |
( |
XrdLink * | lp | ) |
|
|
virtual |
Implements XrdProtocol.
Definition at line 196 of file XrdProtLoad.cc.
197{
199 signed char *pVec = myProt;
200 int i = 0;
201
202
203
204 while(*pVec != -2)
205 {if (*pVec == -1)
207 {lp->
setEtext(
"TLS negotiation failed.");
208 return -1;
209 }
210 } else {i = *pVec;
211 if ((pp = Protocol[i]->
Match(lp)))
break;
213 }
214 pVec++;
215 }
216
217
218
219 if (!pp) {lp->
setEtext(
"matching protocol not found");
return -1;}
220
221
222
225
226
227
228 TRACE(
DEBUG,
"matched port " <<myPort <<
" protocol " <<ProtName[i]);
229
230
231
233
234
235
237}
XrdProtocol * setProtocol(XrdProtocol *pp, bool runit=false, bool push=false)
int setEtext(const char *text)
bool setTLS(bool enable, XrdTlsContext *ctx=0)
Enable or disable TLS on the link.
void setProtName(const char *name)
XrdProtocol * Match(XrdLink *)
virtual int Process(XrdLink *lp)=0
References XrdLink::Activate(), DEBUG, XrdLink::isFlawed(), Match(), XrdProtocol::Process(), XrdLink::setEtext(), XrdLink::setProtName(), XrdLink::setProtocol(), XrdLink::setTLS(), and TRACE.
◆ Recycle()
void XrdProtLoad::Recycle |
( |
XrdLink * | lp, |
|
|
int | ctime, |
|
|
const char * | txt ) |
|
virtual |
◆ 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}
virtual int Stats(char *buff, int blen, int do_sync=0)=0
References XrdProtocol::Stats().
◆ Stats()
int XrdProtLoad::Stats |
( |
char * | buff, |
|
|
int | blen, |
|
|
int | do_sync = 0 ) |
|
inlinevirtual |
◆ PortoMax
const int XrdProtLoad::PortoMax = 8 |
|
static |
◆ ProtoMax
const int XrdProtLoad::ProtoMax = 8 |
|
static |
The documentation for this class was generated from the following files: