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
 
const 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 260 of file XrdNetPMarkFF.cc.

261{
262// If all is well, emit the closing message
263//
264 if (fdOK || odOK)
265 {char utcBuff[40], endBuff[80];
266 snprintf(endBuff, sizeof(endBuff), ffEnd,
267 getUTC(utcBuff, sizeof(utcBuff)));
268 Emit("end", utcBuff, endBuff);
269 }
270
271// Cleanup
272//
273 if (mySad) delete(mySad);
274 if (oDest) free(oDest);
275 if (ffHdr) free(ffHdr);
276 if (ffTail) free(ffTail);
277 if (xtraFH) delete xtraFH;
278};

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 313 of file XrdNetPMarkFF.cc.

314{
315 char appInfo[128], clIP[INET6_ADDRSTRLEN+2], svIP[INET6_ADDRSTRLEN+2];
316 int clPort, svPort;
317 char clType, svType;
318 bool fdok = false, odok = false;
319
320// Preform app if we need to
321//
322 if (!appName) *appInfo = 0;
323 else snprintf(appInfo,sizeof(appInfo),ffApp,sizeof(appInfo)-20,appName);
324
325// Get the file descriptor for the socket
326//
327 sockFD = addr.SockFD();
328
329// Obtain connectivity information about the peer and ourselves. We really
330// should obtain our external address and use that but the issue is that
331// we may have multiple external addresses and the client determines which
332// one actually gets used. So, it's complicated. A TODO.
333//
334 clPort = XrdNetUtils::GetSokInfo( sockFD, clIP, sizeof(clIP), clType);
335 if (clPort < 0)
336 {eDest->Emsg("PMarkFF", clPort, "get peer information.");
337 return false;
338 }
339
340 svPort = XrdNetUtils::GetSokInfo(-sockFD, svIP, sizeof(svIP), svType);
341 if (svPort < 0)
342 {eDest->Emsg("PMarkFF", clPort, "get self information.");
343 return false;
344 }
345
346// If there is no special collector, indicate so
347//
348 if (netMsg) fdok = true;
349
350// If the messages need to flow to the origin, get the destination information
351//
352 if (netOrg)
353 {const XrdNetSockAddr *urSad = addr.NetAddr();
354 if (!urSad) eDest->Emsg("PMarkFF", "unable to get origin address.");
355 else {char buff[1024];
356 mySad = new XrdNetSockAddr;
357 memcpy(mySad, urSad, sizeof(XrdNetSockAddr));
358 mySad->v4.sin_port = htons(static_cast<uint16_t>(ffPortO));
359 snprintf(buff, sizeof(buff), "%s:%d", clIP, ffPortO);
360 oDest = strdup(buff);
361 odok = true;
362 }
363 }
364
365// If we cannot report anywhere then indicate we failed
366//
367 if (!fdok && !odok) return false;
368
369// Format the base firefly template. Note that the client determines the
370// address family that is being used.
371//
372 char utcBuff[40], bseg0[512];
373 int len0 = snprintf(bseg0, sizeof(bseg0), ffFmt0, myHostName,
374 getUTC(utcBuff, sizeof(utcBuff)));
375 if (len0 >= (int)sizeof(bseg0))
376 {eDest->Emsg("PMarkFF", "invalid json; bseg0 truncated.");
377 return false;
378 }
379
380 ffHdr = strdup(bseg0);
381
382 char bseg1[256];
383 int len1 = snprintf(bseg1, sizeof(bseg1), ffFmt1, eCode, aCode, appInfo);
384 if (len1 >= (int)sizeof(bseg1))
385 {eDest->Emsg("PMarkFF", "invalid json; bseg1 truncated.");
386 return false;
387 }
388
389 char bseg2[256];
390 int len2 = snprintf(bseg2, sizeof(bseg2), ffFmt2,
391 clType, svIP, clIP, svPort, clPort);
392 if (len2 >= (int)sizeof(bseg2))
393 {eDest->Emsg("PMarkFF", "invalid json; cl bseg2 truncated.");
394 return false;
395 }
396
397 ffTailsz = len1 + len2;
398 ffTail = (char *)malloc(ffTailsz + 1);
399 strcpy(ffTail, bseg1);
400 strcpy(ffTail+len1, bseg2);
401
402// OK, we now can emit the starting packet
403//
404 fdOK = fdok;
405 odOK = odok;
406 return Emit("start", utcBuff, "");
407}
static XrdSysError eDest(0,"crypto_")
const XrdNetSockAddr * NetAddr()
const char * appName
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: