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

#include <XrdNetPMarkFF.hh>

+ Inheritance diagram for XrdNetPMarkFF:
+ Collaboration diagram for XrdNetPMarkFF:

Public Member Functions

 XrdNetPMarkFF (XrdNetPMark::Handle &h, const char *tid)
 
virtual ~XrdNetPMarkFF ()
 
void addHandle (XrdNetPMark::Handle *fh)
 
bool Start (XrdNetAddrInfo &addr)
 
- Public Member Functions inherited from XrdNetPMark::Handle
 Handle (const char *app=0, int ecode=0, int acode=0)
 
 Handle (Handle &h)
 
virtual ~Handle ()
 
bool getEA (int &ec, int &ac)
 
bool Valid ()
 

Additional Inherited Members

- Protected Attributes inherited from XrdNetPMark::Handle
int aCode
 
char * appName
 
int eCode
 

Detailed Description

Definition at line 38 of file XrdNetPMarkFF.hh.

Constructor & Destructor Documentation

◆ XrdNetPMarkFF()

XrdNetPMarkFF::XrdNetPMarkFF ( XrdNetPMark::Handle & h,
const char * tid )
inline

Definition at line 46 of file XrdNetPMarkFF.hh.

47 : XrdNetPMark::Handle(h), tident(tid) {}

References XrdNetPMark::Handle::Handle().

+ Here is the call graph for this function:

◆ ~XrdNetPMarkFF()

XrdNetPMarkFF::~XrdNetPMarkFF ( )
virtual

Definition at line 271 of file XrdNetPMarkFF.cc.

272{
273// If all is well, emit the closing message
274//
275 if (fdOK || odOK)
276 {char utcBuff[40], endBuff[80];
277 snprintf(endBuff, sizeof(endBuff), ffEnd,
278 getUTC(utcBuff, sizeof(utcBuff)));
279 Emit("end", utcBuff, endBuff);
280 }
281
282// Cleanup
283//
284 if (mySad) delete(mySad);
285 if (oDest) free(oDest);
286 if (ffHdr) free(ffHdr);
287 if (ffTail) free(ffTail);
288 if (xtraFH) delete xtraFH;
289};

Member Function Documentation

◆ addHandle()

void XrdNetPMarkFF::addHandle ( XrdNetPMark::Handle * fh)
inline

Definition at line 42 of file XrdNetPMarkFF.hh.

42{xtraFH = fh;}

◆ Start()

bool XrdNetPMarkFF::Start ( XrdNetAddrInfo & addr)

Definition at line 328 of file XrdNetPMarkFF.cc.

329{
330 char appInfo[128], clIP[INET6_ADDRSTRLEN+2], svIP[INET6_ADDRSTRLEN+2];
331 int clPort, svPort;
332 char clType, svType;
333 bool fdok = false, odok = false;
334
335// Preform app if we need to
336//
337 if (!appName) *appInfo = 0;
338 else snprintf(appInfo,sizeof(appInfo),ffApp,sizeof(appInfo)-20,appName);
339
340// Get the file descriptor for the socket
341//
342 sockFD = addr.SockFD();
343
344// Obtain connectivity information about the peer and ourselves. We really
345// should obtain our external address and use that but the issue is that
346// we may have multiple external addresses and the client determines which
347// one actually gets used. So, it's complicated. A TODO.
348//
349 clPort = XrdNetUtils::GetSokInfo( sockFD, clIP, sizeof(clIP), clType);
350 if (clPort < 0)
351 {eDest->Emsg("PMarkFF", clPort, "get peer information.");
352 return false;
353 }
354
355 svPort = XrdNetUtils::GetSokInfo(-sockFD, svIP, sizeof(svIP), svType);
356 if (svPort < 0)
357 {eDest->Emsg("PMarkFF", clPort, "get self information.");
358 return false;
359 }
360
361// If there is no special collector, indicate so
362//
363 if (netMsg) fdok = true;
364
365// If the messages need to flow to the origin, get the destination information
366//
367 if (netOrg)
368 {const XrdNetSockAddr *urSad = addr.NetAddr();
369 if (!urSad) eDest->Emsg("PMarkFF", "unable to get origin address.");
370 else {char buff[1024];
371 mySad = new XrdNetSockAddr;
372 memcpy(mySad, urSad, sizeof(XrdNetSockAddr));
373 mySad->v4.sin_port = htons(static_cast<uint16_t>(ffPortO));
374 snprintf(buff, sizeof(buff), "%s:%d", clIP, ffPortO);
375 oDest = strdup(buff);
376 odok = true;
377 }
378 }
379
380// If we cannot report anywhere then indicate we failed
381//
382 if (!fdok && !odok) return false;
383
384// Format the base firefly template. Note that the client determines the
385// address family that is being used.
386//
387 char utcBuff[40], bseg0[512];
388 int len0 = snprintf(bseg0, sizeof(bseg0), ffFmt0, myHostName,
389 getUTC(utcBuff, sizeof(utcBuff)));
390 if (len0 >= (int)sizeof(bseg0))
391 {eDest->Emsg("PMarkFF", "invalid json; bseg0 truncated.");
392 return false;
393 }
394
395 ffHdr = strdup(bseg0);
396
397 char bseg1[256];
398 int len1 = snprintf(bseg1, sizeof(bseg1), ffFmt1, eCode, aCode, appInfo);
399 if (len1 >= (int)sizeof(bseg1))
400 {eDest->Emsg("PMarkFF", "invalid json; bseg1 truncated.");
401 return false;
402 }
403
404// Note that by convention FF packets the supplier of the data is designated
405// as the source. We only know this at this point for http requests and even
406// then it's hardly accurate. So, for put requests the src if the client.
407// Ottherwise, we designate the server as the source.
408//
409 char bseg2[256];
410 int len2;
411 if (appName && !strcmp(appName, "http-put"))
412 {len2 = snprintf(bseg2, sizeof(bseg2), ffFmt2,
413 clType, clIP, svIP, clPort, svPort);
414 } else {
415 len2 = snprintf(bseg2, sizeof(bseg2), ffFmt2,
416 clType, svIP, clIP, svPort, clPort);
417 }
418 if (len2 >= (int)sizeof(bseg2))
419 {eDest->Emsg("PMarkFF", "invalid json; cl bseg2 truncated.");
420 return false;
421 }
422
423 ffTailsz = len1 + len2;
424 ffTail = (char *)malloc(ffTailsz + 1);
425 strcpy(ffTail, bseg1);
426 strcpy(ffTail+len1, bseg2);
427
428// OK, we now can emit the starting packet
429//
430 fdOK = fdok;
431 odOK = odok;
432 return Emit("start", utcBuff, "");
433}
static XrdSysError eDest(0,"crypto_")
const XrdNetSockAddr * NetAddr()
static int GetSokInfo(int fd, char *theAddr, int theALen, char &theType)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
const char * myHostName

References XrdNetPMark::Handle::aCode, XrdNetPMark::Handle::appName, XrdNetPMark::Handle::eCode, eDest, XrdNetPMarkConfig::ffPortO, XrdNetUtils::GetSokInfo(), XrdNetPMarkConfig::myHostName, XrdNetAddrInfo::NetAddr(), XrdNetPMarkConfig::netMsg, XrdNetPMarkConfig::netOrg, and XrdNetAddrInfo::SockFD().

Referenced by XrdNetPMarkCfg::Begin().

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

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