XRootD
XrdNetIF Class Reference

#include <XrdNetIF.hh>

+ Collaboration diagram for XrdNetIF:

Public Types

enum  ifType {
  PublicV4 = 0 ,
  PrivateV4 = 1 ,
  PublicV6 = 2 ,
  PrivateV6 = 3 ,
  PrivateIF = 1 ,
  ifNum = 4 ,
  Public46 = 4 ,
  Private46 = 5 ,
  Public64 = 6 ,
  Private64 = 7 ,
  ifMax = 8 ,
  ifAny = 8
}
 The enum that is used to index into ifData to get appropriate interface. More...
 
enum  netType {
  netDefault = 0 ,
  netSplit ,
  netCommon ,
  netLocal
}
 

Public Member Functions

 XrdNetIF ()
 Constructor and Destructor. More...
 
 ~XrdNetIF ()
 
void Display (const char *pfx="=====> ")
 
int GetDest (char *dest, int dlen, ifType ifT=PublicV6, bool prefn=false)
 
int GetName (char *nbuff, int &nport, ifType ifT=PublicV6)
 
int GetName (const char *&name, ifType ifT=PublicV6)
 
int GetPublicDest (char *dest, size_t dlen)
 
int GetPublicName (char *nbuff, int &nport)
 
bool HasDest (ifType ifT=PublicV6)
 
char Mask ()
 
int Port ()
 
int Port (int pnum)
 
bool SetIF (XrdNetAddrInfo *src, const char *ifList, int port=0, netType nettype=netDefault, const char *xName=0)
 
bool SetPublicName (const std::string &name)
 

Static Public Member Functions

static int GetIF (char *&ifline, const char **eText=0, bool show=false)
 
static int GetIF (char *buff, int blen, const char **eText=0, bool show=false)
 
static int GetIF (XrdOucTList **ifList, const char **eText=0)
 
static ifType GetIFType (bool conIPv4, bool hasIP64, bool pvtIP)
 
static bool InDomain (XrdNetAddrInfo *epaddr)
 
static char Mask (ifType ifT)
 
static const char * Name (ifType ifT)
 
static void PortDefault (int pnum=1094)
 
static void Privatize (ifType &x)
 
static void Routing (netType nettype)
 
static bool SetIFNames (char *ifnames)
 
static void SetMsgs (XrdSysError *erp)
 
static void SetRPIPA (bool rval)
 

Static Public Attributes

static const int haveIPv4 = 1
 ifList == 0 && non-local ipv4 i/f found (or'd) More...
 
static const int haveIPv6 = 2
 ifList == 0 && non-local ipv6 i/f found (or'd) More...
 
static const int haveNoGI = 0
 ifList == 0 && getifaddrs() is not supported More...
 
static const int havePrv4 = 4
 ifList == 0 && private ipv4 i/f found (or'd) More...
 
static const int havePrv6 = 8
 ifList == 0 && private ipv6 i/f found (or'd) More...
 
static const int havePub4 =16
 ifList == 0 && public ipv4 i/f found (or'd) More...
 
static const int havePub6 =32
 ifList == 0 && public ipv6 i/f found (or'd) More...
 

Detailed Description

Definition at line 49 of file XrdNetIF.hh.

Member Enumeration Documentation

◆ ifType

The enum that is used to index into ifData to get appropriate interface.

Enumerator
PublicV4 
PrivateV4 
PublicV6 
PrivateV6 
PrivateIF 
ifNum 
Public46 
Private46 
Public64 
Private64 
ifMax 
ifAny 

Definition at line 65 of file XrdNetIF.hh.

65  {PublicV4 = 0, //<! Public IPv4 network
66  PrivateV4 = 1, //<! Private IPv4 network
67  PublicV6 = 2, //<! Public IPv6 network
68  PrivateV6 = 3, //<! Private IPv6 network
69  PrivateIF = 1, //<! Bit to change PublicVx -> PrivateVx
70  ifNum = 4, //<! Count of actual interface types
71  Public46 = 4, //<! Public v4|6 network (dual stack)
72  Private46 = 5, //<! Private v4|6 network (dual stack)
73  Public64 = 6, //<! Public v6|4 network (dual stack)
74  Private64 = 7, //<! Private v6|4 network (dual stack)
75  ifMax = 8, //<! Total elements in if vector
76  ifAny = 8}; //<! Used to select any avilable i/f
@ PrivateV4
Definition: XrdNetIF.hh:66
@ Public46
Definition: XrdNetIF.hh:71
@ PublicV4
Definition: XrdNetIF.hh:65
@ Private64
Definition: XrdNetIF.hh:74
@ Public64
Definition: XrdNetIF.hh:73
@ PrivateIF
Definition: XrdNetIF.hh:69
@ Private46
Definition: XrdNetIF.hh:72
@ PrivateV6
Definition: XrdNetIF.hh:68
@ PublicV6
Definition: XrdNetIF.hh:67

◆ netType

Routing() and SetIF() parameter.

netDefault - netSplit for Routing() and Routing() value for SetIF(). netSplit - public and private addresses are routed separately so that substitution of one type of address for another is not allowed. netCommon - clients with private addresses also have public addresses. Source and target addresses should match but a public address may be used in the absence of a private address. netLocal - private addresses are registered and can be used by public clients within this domain. Clients with public addresses can be routed to private addresses.

Enumerator
netDefault 
netSplit 
netCommon 
netLocal 

Definition at line 364 of file XrdNetIF.hh.

@ netSplit
Definition: XrdNetIF.hh:364
@ netDefault
Definition: XrdNetIF.hh:364
@ netCommon
Definition: XrdNetIF.hh:364
@ netLocal
Definition: XrdNetIF.hh:364

Constructor & Destructor Documentation

◆ XrdNetIF()

XrdNetIF::XrdNetIF ( )
inline

Constructor and Destructor.

Definition at line 431 of file XrdNetIF.hh.

431 : ifBuff(0), ifMask(0), ifAvail(0) {}

◆ ~XrdNetIF()

XrdNetIF::~XrdNetIF ( )
inline

Definition at line 433 of file XrdNetIF.hh.

433 {if (ifBuff) free(ifBuff);}

Member Function Documentation

◆ Display()

void XrdNetIF::Display ( const char *  pfx = "=====> ")

Display the final interface configuration.

Parameters
pfxThe desired message prefix (default is as shown).

Definition at line 142 of file XrdNetIF.cc.

143 {
144  static const char *ifN[] = {"pub4", "prv4", "pub6", "prv6"};
145  static const char *ifT[] = {"all4", 0, "all6", 0};
146  static const char *nNM[] = {"local", "split", "common", "local"};
147  const char *iHX[hasNum] = {"", "", "", ""};
148  const char *ifRType, *hName = "";
149  char buff[256];
150  bool nameOK = false;
151 
152 // If we have no error routing object, just return
153 //
154  if (!eDest) return;
155 
156 // Get a hostname
157 //
158  for (int i = 0; i < (int)ifNum; i++)
159  {if (ifName[i] != &ifNull)
160  {hName = ifName[i]->iVal;
161  if (ifxDNS[i]) {nameOK = true; break;}
162  }
163  }
164 
165 // Compute selection mask
166 //
167  for (int i = 0; i < hasNum; i++)
168  if (ifMask & sMask[i]) iHX[i] = sName[i];
169 
170 // Print results
171 //
172  sprintf(buff, ": %s %s%s%s%s", nNM[ifRoute], iHX[0],iHX[1],iHX[2],iHX[3]);
173  eDest->Say(pfx, "Routing for ", hName, buff);
174 
175  for (int i = 0; i < (int)ifNum; i++)
176  {if (ifName[i] != &ifNull)
177  {if (ifT[i] && ifDest[i] == ifDest[i+1]) {ifRType = ifT[i]; i++;}
178  else ifRType = ifN[i];
179  sprintf(buff, "Route %s: ", ifRType);
180  eDest->Say(pfx, buff, (nameOK ? hName : ifName[i]->iVal),
181  " Dest=", ifDest[i]->iVal, portSfx.val);
182  }
183  }
184 }
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141

References ifNum, and XrdSysError::Say().

Referenced by XrdXrootdProtocol::Configure(), and XrdCmsNode::ShowIF().

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

◆ GetDest()

int XrdNetIF::GetDest ( char *  dest,
int  dlen,
ifType  ifT = PublicV6,
bool  prefn = false 
)

Get the interface address with a port number.

Parameters
destPointer to the buffer where dest will be placed.
dlenThe length of the buffer.
ifTDesired ifType (PublicV6 is the default)
prefnWhen true, a hostname:port is returned if possible
Returns
The length of the name whose pointer is placed in name. A value of zero indicates that no such interface exists or the buffer was too small.

Definition at line 389 of file XrdNetIF.cc.

390 {
391  ifType ifX = (ifT >= ifAny ? static_cast<ifType>(ifAvail) : ifT);
392  ifData *ifP = (prefn && ifxDNS[ifX] ? ifName[ifX] : ifDest[ifX]);
393  int n;
394 
395 // Compute length and make sure we don't overflow
396 //
397  n = ifP->iLen + portSfx.len;
398  if (!(ifP->iLen) || n >= dlen) return 0;
399 
400 // Return result with port appended
401 //
402  strcpy(dest, ifP->iVal);
403  strcpy(dest +ifP->iLen, portSfx.val);
404  return n;
405 }
ifType
The enum that is used to index into ifData to get appropriate interface.
Definition: XrdNetIF.hh:65

References ifAny.

Referenced by XrdSsiSfs::fsctl(), and XrdOfs::fsctl().

+ Here is the caller graph for this function:

◆ GetIF() [1/3]

int XrdNetIF::GetIF ( char *&  ifline,
const char **  eText = 0,
bool  show = false 
)
static

Obtain an easily transmittable IP routable interfaces to this machine.

Parameters
iflineReference to a char * pointer that will get the result.
eTextWhen not nil, is where to place error message text.
showWhen true configured interfaces are also displayed.
Returns
Success: Number of bytes in the returned string ecluding the null. The caller is responsible for unallocating it via free(). Failure: Zero is returned. If eText is supplied, the error message, in persistent storage, is returned. *ifline is set to 0.

Definition at line 589 of file XrdNetIF.cc.

590 {
591  char buff[4096];
592  int n;
593 
594  if ((n = GetIF(buff, sizeof(buff), eText, show))) ifline = strdup(buff);
595  else ifline = 0;
596 
597 // Warn about no interfaces
598 //
599  if (!ifline && show && eDest)
600  eDest->Say("Config ", "No usable interfaces; using DNS registered "
601  "address as the interface.");
602  return n;
603 }
static int GetIF(XrdOucTList **ifList, const char **eText=0)
Definition: XrdNetIF.cc:429

References eDest, GetIF(), and XrdSysError::Say().

+ Here is the call graph for this function:

◆ GetIF() [2/3]

int XrdNetIF::GetIF ( char *  buff,
int  blen,
const char **  eText = 0,
bool  show = false 
)
static

Obtain an easily transmittable IP routable interfaces to this machine.

Parameters
buffPointer to buffer to hold result which can be fed to SetIF.
blenThe length of the buffer (4K is really sufficient).
eTextWhen not nil, is where to place error message text.
showWhen true configured interfaces are also displayed.
Returns
Success: Number of bytes placed in buff, excluding the null. Failure: Zero is returned. If eText is supplied, the error message, in persistent storage, is returned.

Definition at line 536 of file XrdNetIF.cc.

537 {
538  XrdOucTList *ifP, *ifN;
539  const char *ifName[3] = {ifCfg[0], ifCfg[1], "anon"};
540  char *bP = buff;
541  int n, bLeft = blen-8;
542  bool ifOK[3] = {false, false, false};
543 
544 #ifndef HAVE_GETIFADDRS
545 // Display warning on how we are getting the interface addresses
546 //
547  if (eDest && show)
548  eDest->Say("Config Warning: using DNS registered address as interface!");
549 #endif
550 
551 // Create the interface list here
552 //
553  *buff = 0;
554  if (GetIF(&ifN, eText))
555  {while((ifP = ifN))
556  {n = ifP->sval[0];
557  if (bLeft > n+2)
558  {if (bP != buff) {*bP++ = ' '; bLeft--;}
559  strcpy(bP, ifP->text);
560  bP += n; bLeft -= (n+1);
561  }
562  ifOK[ifP->sval[2]] = true;
563  if (show && eDest)
564  {const char *kind = (ifP->sval[1] ? " private" : " public ");
565  eDest->Say("Config ", ifName[ifP->sval[2]], kind,
566  " network interface: ", ifP->text);
567  }
568  ifN = ifP->next; delete ifP;
569  }
570  }
571 
572 // Warn about missing interfaces
573 //
574  if (show && eDest)
575  {for (n = 0; n < 2; n++)
576  {if (!ifOK[n] && ifCfg[n])
577  eDest->Say("Config ", ifCfg[n],
578  " interface not found or is not usable.");
579  }
580  }
581 
582 // Return result
583 //
584  return bP-buff;
585 }
XrdOucTList * next
Definition: XrdOucTList.hh:45
char * text
Definition: XrdOucTList.hh:46

References eDest, GetIF(), XrdOucTList::next, XrdSysError::Say(), and XrdOucTList::text.

+ Here is the call graph for this function:

◆ GetIF() [3/3]

int XrdNetIF::GetIF ( XrdOucTList **  ifList,
const char **  eText = 0 
)
static

Definition at line 429 of file XrdNetIF.cc.

430 {
431  static const int prvIF[] = {havePrv4, havePrv6};
432  static const int pubIF[] = {havePub4, havePub6};
433 
434  char ipBuff[256];
435  short ifIdx = 0, sval[4] = {0, 0, 0, 0};
436  short iLen;
437  int ifT, haveIF = 0;
438 
439 #ifdef HAVE_GETIFADDRS
440 
441 // Obtain the list of interfaces
442 //
443  XrdNetAddr netAddr;
444  struct ifaddrs *ifBase, *ifP;
445  XrdOucTList *tLP, *tList = 0, *tLast = 0;
446  int n = 0;
447  bool anyIF = (ifCfg[0] == 0 && ifCfg[1] == 0);
448 
449  if (getifaddrs(&ifBase) < 0)
450  {if (eText) *eText = XrdSysE2T(errno);
451  if (ifList) *ifList = 0;
452  if (eDest) eDest->Emsg("GetIF", errno, "get interface addresses.");
453  return 0;
454  }
455 
456 // Report only those interfaces that are up and are not loop-back devices and
457 // have been specified by actual name
458 //
459  ifP = ifBase;
460  while(ifP)
461  {if ((ifP->ifa_addr != 0)
462  && (!ifList || anyIF || IsOkName(ifP->ifa_name, ifIdx))
463  && (ifP->ifa_flags & (IFF_UP))
464  && (ifP->ifa_flags & (IFF_RUNNING))
465  && !(ifP->ifa_flags & (IFF_LOOPBACK))
466  && ((ifP->ifa_addr->sa_family == AF_INET &&
467  !V4LinkLocal(ifP->ifa_addr))
468  ||
469  (ifP->ifa_addr->sa_family == AF_INET6 &&
470  !(IN6_IS_ADDR_LINKLOCAL(&((sockaddr_in6 *)(ifP->ifa_addr))->sin6_addr)))
471  )
472  )
473  {if (ifP->ifa_addr->sa_family == AF_INET){haveIF |= haveIPv4;ifT=0;}
474  else {haveIF |= haveIPv6; ifT = 1;}
475  if (ifList)
476  {netAddr.Set(ifP->ifa_addr);
477  if ((iLen = netAddr.Format(ipBuff, sizeof(ipBuff),
479  {sval[2] = (anyIF ? 3 : ifIdx);
480  sval[1] = (netAddr.isPrivate() ? 1 : 0);
481  sval[0] = iLen;
482  haveIF |= (sval[1] ? prvIF[ifT] : pubIF[ifT]);
483  tLP = new XrdOucTList(ipBuff, sval);
484  if (tList) tLast->next = tLP;
485  else tList = tLP;
486  tLast = tLP;
487  n++;
488  }
489  } else {
490  netAddr.Set(ifP->ifa_addr);
491  haveIF |= (netAddr.isPrivate() ? prvIF[ifT] : pubIF[ifT]);
492  }
493  }
494  ifP = ifP->ifa_next;
495  }
496 
497 // All done
498 //
499  if (ifBase) freeifaddrs(ifBase);
500  if (eText) *eText = 0;
501  if (!ifList) return haveIF;
502  *ifList = tList;
503  return n;
504 
505 #else
506 
507 // If we just need to provide the interface type, indicate we cannot
508 //
509  if (!ifList) return haveNoGI;
510 
511 // For platforms that don't support getifaddrs() use our address
512 //
513  XrdNetAddr netAddr((int)0);
514 
515 // Simply return our formatted address as the interface address
516 //
517  if ((iLen = netAddr.Format(ipBuff, sizeof(ipBuff),
519  {if (eText) *eText = 0;
520  sval[0] = iLen;
521  *ifList = new XrdOucTList(ipBuff, sval);
522  return 1;
523  }
524 
525 // Something bad happened and it shouldn't have
526 //
527  if (eText) *eText = "unknown error";
528  if (eDest) eDest->Emsg("GetIF", "Unable to get interface address; "
529  "check if IPV6 enabled!");
530  return 0;
531 #endif
532 }
static XrdSysError eDest(0,"crypto_")
const char * XrdSysE2T(int errcode)
Definition: XrdSysE2T.cc:104
static const int noPort
Do not add port number.
int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
@ fmtAddr
Address using suitable ipv4 or ipv6 format.
const char * Set(const char *hSpec, int pNum=PortInSpec)
Definition: XrdNetAddr.cc:216
static const int haveNoGI
ifList == 0 && getifaddrs() is not supported
Definition: XrdNetIF.hh:194
static const int haveIPv4
ifList == 0 && non-local ipv4 i/f found (or'd)
Definition: XrdNetIF.hh:196
static const int havePub6
ifList == 0 && public ipv6 i/f found (or'd)
Definition: XrdNetIF.hh:206
static const int havePub4
ifList == 0 && public ipv4 i/f found (or'd)
Definition: XrdNetIF.hh:204
static const int haveIPv6
ifList == 0 && non-local ipv6 i/f found (or'd)
Definition: XrdNetIF.hh:198
static const int havePrv6
ifList == 0 && private ipv6 i/f found (or'd)
Definition: XrdNetIF.hh:202
static const int havePrv4
ifList == 0 && private ipv4 i/f found (or'd)
Definition: XrdNetIF.hh:200
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95

References eDest, XrdSysError::Emsg(), XrdNetAddrInfo::fmtAddr, XrdNetAddrInfo::Format(), haveIPv4, haveIPv6, haveNoGI, havePrv4, havePrv6, havePub4, havePub6, XrdNetAddrInfo::isPrivate(), XrdNetAddrInfo::noPort, XrdNetAddr::Set(), and XrdSysE2T().

Referenced by XrdConfig::Configure(), GetIF(), XrdNetUtils::NetConfig(), and XrdNetUtils::SetAuto().

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

◆ GetIFType()

static ifType XrdNetIF::GetIFType ( bool  conIPv4,
bool  hasIP64,
bool  pvtIP 
)
inlinestatic

Get the ifType for client connection.

Parameters
conIPv4True if connected via IPv4, false means IPv6.
hasIP64True if the client has an IPv4 and IPv6 address.
pvtIPTrue if the ip address is private.
Returns
The ifType correspodning to the passed arguments.

Definition at line 250 of file XrdNetIF.hh.

251  {ifType ifT;
252  if (conIPv4) ifT = (hasIP64 ? Public46 : PublicV4);
253  else ifT = (hasIP64 ? Public64 : PublicV6);
254  if (pvtIP) Privatize(ifT);
255  return ifT;
256  }
static void Privatize(ifType &x)
Definition: XrdNetIF.hh:330

References Privatize(), Public46, Public64, PublicV4, and PublicV6.

Referenced by XrdSsiSfs::fsctl(), and XrdOfs::fsctl().

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

◆ GetName() [1/2]

int XrdNetIF::GetName ( char *  nbuff,
int &  nport,
ifType  ifT = PublicV6 
)
inline

Copy the interface name and return port number.

Parameters
nbuffReference to buffer where the name will be placed. It must be atleast 256 bytes in length.
nportPlace where the port number will be placed.
ifTDesired ifType (PublicV6 is the default)
Returns
The length of the name copied into the buffer. A value of zero indicates that no such interface exists.

Definition at line 133 of file XrdNetIF.hh.

134  {if (ifT >= ifAny) ifT = static_cast<ifType>(ifAvail);
135  strcpy(nbuff, ifName[ifT]->iVal); nport = ifPort;
136  return ifName[ifT]->iLen;
137  }

References ifAny.

◆ GetName() [2/2]

int XrdNetIF::GetName ( const char *&  name,
ifType  ifT = PublicV6 
)
inline

Get the interface name without a port number.

Parameters
nameReference to where a pointer to the name will be placed
ifTDesired ifType (PublicV6 is the default)
Returns
The length of the name whose pointer is placed in name. A value of zero indicates that no such interface exists.

Definition at line 115 of file XrdNetIF.hh.

116  {if (ifT >= ifAny) ifT = static_cast<ifType>(ifAvail);
117  name = ifName[ifT]->iVal;
118  return ifName[ifT]->iLen;
119  }

References ifAny.

◆ GetPublicDest()

int XrdNetIF::GetPublicDest ( char *  dest,
size_t  dlen 
)

Get the public interface name with a port number.

Parameters
destPointer to the buffer where dest will be placed.
dlenThe length of the buffer.
Returns
The length of the name whose pointer is placed in name. A value of zero indicates that the buffer was too small.

Definition at line 412 of file XrdNetIF.cc.

413 {
414  auto n = m_PublicName.size() + portSfx.len;
415  if (m_PublicName.empty() || n >= dlen) return 0;
416 
417  strcpy(dest, m_PublicName.c_str());
418  strcpy(dest + m_PublicName.size(), portSfx.val);
419 
420  return n;
421 }

Referenced by XrdCmsCluster::List().

+ Here is the caller graph for this function:

◆ GetPublicName()

int XrdNetIF::GetPublicName ( char *  nbuff,
int &  nport 
)
inline

Get the interface public hostname, not relying on reverse DNS of the IP addresses.

Parameters
nbuffReference to buffer where the name will be placed. It must be at least 256 bytes in length.
nportPlace where the port number will be placed.
Returns
The length of the name copied into the buffer. A value of zero indicates that no such interface exists.

Definition at line 150 of file XrdNetIF.hh.

151 {
152  strcpy(nbuff, m_PublicName.c_str());
153  nport = ifPort;
154  return m_PublicName.size();
155 }

Referenced by XrdCmsCluster::Select().

+ Here is the caller graph for this function:

◆ HasDest()

bool XrdNetIF::HasDest ( ifType  ifT = PublicV6)
inline

Determine whether or not an interface exists.

Parameters
ifT-> Desired ifType (PublicV6 is the default)
Returns
true -> desired dest exists. false -> desired dest does not exist.

Definition at line 267 of file XrdNetIF.hh.

268  {return ifT >= ifAny || ifDest[ifT]->iLen != 0;}

References ifAny.

Referenced by XrdCmsCluster::List().

+ Here is the caller graph for this function:

◆ InDomain()

bool XrdNetIF::InDomain ( XrdNetAddrInfo epaddr)
static

Determine if an endpoint is this domain based on hostname.

Parameters
epaddrPointer to the endpoint NetAddrInfo object.
Returns
true The endpoint is in this domain.
false Either the endpoint is not in this domain, is a private address, or is not registered in DNS.

Definition at line 622 of file XrdNetIF.cc.

623 {
624  const char *hnP;
625 
626 // Do not attempt to resolve private addresses as they are always in the domain.
627 //
628  if (epaddr->isPrivate()) return true;
629 
630 // Checkout the domain
631 //
632  if (!myDomain || !(hnP = epaddr->Name(0)) || !(hnP = index(hnP, '.')))
633  return false;
634 
635 // Match the domain and returnthe result
636 //
637  return strcmp(myDomain, hnP+1) == 0;
638 }
const char * Name(const char *eName=0, const char **eText=0)

References XrdNetAddrInfo::isPrivate(), XrdNetPMarkConfig::myDomain, and XrdNetAddrInfo::Name().

Referenced by XrdCmsNode::inDomain(), XrdSecProtector::New4Server(), XrdXrootdProtocol::Process2(), and XrdSecProtector::ProtResp().

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

◆ Mask() [1/2]

char XrdNetIF::Mask ( )
inline

Get the ifType selection mask for this object.

Returns
A single char that represents the selection mask.

Definition at line 288 of file XrdNetIF.hh.

288 {return ifMask;}

Referenced by XrdCmsCluster::Select().

+ Here is the caller graph for this function:

◆ Mask() [2/2]

static char XrdNetIF::Mask ( ifType  ifT)
inlinestatic

Convert an ifType to its corresponding selection mask.

Parameters
ifTThe ifType to convert.
Returns
A single char that represents the selection mask.

Definition at line 298 of file XrdNetIF.hh.

299  {if (ifT >= ifAny) return 0x0f;
300  return ifMaskVec[ifT];
301  }

References ifAny.

◆ Name()

static const char* XrdNetIF::Name ( ifType  ifT)
inlinestatic

Get the human readable for for an ifType.

Parameters
ifTThe ifType to convert.
Returns
A pointer to the human readable name. The string resides in static storage and is always valid.

Definition at line 312 of file XrdNetIF.hh.

312  {if (ifT >= ifAny) return "any";
313  return ifTName[ifT];
314  }

References ifAny.

Referenced by XrdCmsNode::do_Locate().

+ Here is the caller graph for this function:

◆ Port() [1/2]

int XrdNetIF::Port ( )
inline

Get the assigned port number

Returns
The port number.

Definition at line 322 of file XrdNetIF.hh.

322 {return ifPort;}

Referenced by XrdXrootdProtocol::Configure(), XrdCmsNode::isNode(), XrdCmsCluster::List(), and SetIF().

+ Here is the caller graph for this function:

◆ Port() [2/2]

int XrdNetIF::Port ( int  pnum)

Set the assigned port number. This method is not thread safe!

Parameters
pnumThe port number.
Returns
The previous port number.

Definition at line 657 of file XrdNetIF.cc.

658 {
659  int prevport = ifPort;
660 
661 // Check if anything is really changing
662 //
663  pnum &= 0x0000ffff;
664  if (pnum == prevport) return prevport;
665 
666 // Format the port number (can't be more than 5 characters)
667 //
668  portSfx.len = sprintf(portSfx.val, ":%d", pnum);
669  ifPort = pnum;
670 
671 // All done
672 //
673  return prevport;
674 }

◆ PortDefault()

void XrdNetIF::PortDefault ( int  pnum = 1094)
static

Set the default assigned port number.

Parameters
pnumThe port number.

Definition at line 680 of file XrdNetIF.cc.

680 {dfPort = pnum;}

◆ Privatize()

static void XrdNetIF::Privatize ( ifType x)
inlinestatic

Make an iofType refer to the private network.

Parameters
xThe iftype variable that will have the private bit set.

Definition at line 330 of file XrdNetIF.hh.

330 {x = ifType(x | PrivateIF);}

References PrivateIF.

Referenced by XrdCmsNode::do_Locate(), XrdCmsNode::do_Select(), and GetIFType().

+ Here is the caller graph for this function:

◆ Routing()

void XrdNetIF::Routing ( XrdNetIF::netType  nettype)
static

Set default interface network routing.

Parameters
nettypeNetwork routing (see netType definition).

Definition at line 686 of file XrdNetIF.cc.

687 {
688 
689 // Set the routing type
690 //
691  netRoutes = (nettype == netDefault ? netLocal : nettype);
692 
693 // Based on the routing we need to set the appropriate selection mask vector
694 //
695  if (netRoutes == netLocal) ifMaskVec = ifMaskLocal;
696  else if (netRoutes == netSplit) ifMaskVec = ifMaskSplit;
697  else ifMaskVec = ifMaskComm;
698 }

References netDefault, netLocal, and netSplit.

◆ SetIF()

bool XrdNetIF::SetIF ( XrdNetAddrInfo src,
const char *  ifList,
int  port = 0,
netType  nettype = netDefault,
const char *  xName = 0 
)

Set the ifData structure based on the interface string generated by GetIF().

Parameters
srcThe network information of host supplying the if string.
ifListThe interface string, it must be null terminated.
portThe port associated with the interfaces; as follows: <0 -> Use previous setting if any. =0 -> use default port (the default). >0 -> Use the number passed.
nettypeDetermines how undefined interfaces are resolved. See the netType definition.
xNamethe known registered host name should ip address translation fail.
Returns
Success: True. Failure: False and if eText is supplied, the error message, in persistent storage, is returned.

Definition at line 704 of file XrdNetIF.cc.

706 {
707  XrdNetAddrInfo *netIF[4] = {0,0,0,0}; //pub 0:v4, prv 1:v4 pub 2:v6 prv 3:v6
708  XrdNetAddr netAdr[4];
709  const char *ifErr = 0, *ifBeg = ifList, *ifEnd, *ifAdr, *ifBad = 0;
710  int i, n, ifCnt = 1;
711  char abuff[64];
712 
713 // Setup the port number (this sets ifPort)
714 //
715  if (port >= 0) Port((port ? port : dfPort));
716 
717 // Set routing mode for this interface
718 //
719  ifRoute = static_cast<short>(nettype == netDefault ? netRoutes : nettype);
720 
721 // If no list is supplied then fill out based on the source address
722 //
723  if (!ifList || !(*ifList))
724  {XrdNetAddrInfo *ifVec[8];
725  XrdNetAddr *iP;
726  const char *hName = src->Name();
727  if (!(src->isRegistered()) && xName) hName = xName;
728  ifCnt = 0;
729  if (!hName
730  || XrdNetUtils::GetAddrs(hName,&iP,ifCnt,XrdNetUtils::allIPv64,ifPort)
731  || !ifCnt) return SetIF64(GenIF(&src, 1));
732  if (ifCnt > 8) ifCnt = 8;
733  for (i = 0; i < ifCnt; i++) ifVec[i] = &iP[i];
734  bool aOK = GenIF(ifVec, ifCnt, hName);
735  delete [] iP;
736  return SetIF64(aOK);
737  }
738 
739 // Prefrentially use the connect address as the primary interface. This
740 // avoids using reported interfaces that may have strange routing.
741 //
742  i = (src->isIPType(XrdNetAddrInfo::IPv4) || src->isMapped() ? 0 : 2);
743  if (src->isPrivate()) i |= 1;
744  netIF[i] = src;
745 
746 // Process the iflist (up to four interfaces)
747 //
748  do {while (*ifBeg && *ifBeg == ' ') ifBeg++;
749  if ( !(*ifBeg)) break;
750  if (!(ifEnd = index(ifBeg, ' '))) {ifAdr = ifBeg; ifBeg = "";}
751  else {n = ifEnd - ifBeg;
752  if (n >= (int)sizeof(abuff))
753  {ifAdr = 0; ifBad = ifBeg; ifErr = "invalid";}
754  else {strncpy(abuff, ifBeg, n); abuff[n] = 0; ifAdr = abuff;}
755  ifBeg = ifEnd+1;
756  }
757  if (!ifAdr || (ifErr = netAdr[ifCnt].Set(ifAdr, ifPort)))
758  {if (eDest)
759  {if (!ifAdr) ifAdr = ifBad;
760  eDest->Emsg("SetIF", "Unable to use interface", ifAdr, ifErr);
761  }
762  continue;
763  }
764  i = (netAdr[ifCnt].isIPType(XrdNetAddrInfo::IPv4) ||
765  netAdr[ifCnt].isMapped() ? 0 : 2);
766  if (netAdr[ifCnt].isPrivate()) i |= 1;
767  if (!netIF[i]) netIF[i] = &netAdr[ifCnt--];
768  } while(ifCnt >= 0);
769 
770 // Set the interface data
771 //
772  return SetIF64(GenIF(netIF, 4));
773 }
bool isMapped() const
bool isIPType(IPType ipType) const
int Port()
Definition: XrdNetIF.hh:322
static const char * GetAddrs(const char *hSpec, XrdNetAddr *aListP[], int &aListN, AddrOpts opts=allIPMap, int pNum=PortInSpec)
Definition: XrdNetUtils.cc:239

References XrdNetUtils::allIPv64, eDest, XrdSysError::Emsg(), XrdNetUtils::GetAddrs(), XrdNetAddrInfo::IPv4, XrdNetAddrInfo::isIPType(), XrdNetAddrInfo::isMapped(), XrdNetAddrInfo::isPrivate(), XrdNetAddrInfo::isRegistered(), XrdNetAddrInfo::Name(), netDefault, and Port().

+ Here is the call graph for this function:

◆ SetIFNames()

bool XrdNetIF::SetIFNames ( char *  ifnames)
static

Set the public and private network interface names.

Parameters
ifnamesPointer to the comma seperated interface names. This string is modified.
Returns
true Names have been set.
false Invalid interface name list.

Definition at line 779 of file XrdNetIF.cc.

780 {
781  char *comma;
782 
783 // Parse the interface names
784 //
785  if ((comma = index(ifnames, ',')))
786  {if (comma == ifnames || !(*(comma+1)))
787  {if (eDest) eDest->Say("Config","Invalid interface name - ",ifnames);
788  return false;
789  }
790  }
791 
792 // Free old names, if any
793 //
794  if (ifCfg[0]) free(ifCfg[0]);
795  if (ifCfg[1]) free(ifCfg[1]);
796 
797 // Copy the new names
798 //
799  if (comma)
800  {*comma = 0;
801  ifCfg[1] = (strcmp(ifnames, comma+1) ? strdup(comma+1) : 0);
802  *comma = ',';
803  } else ifCfg[1] = 0;
804  ifCfg[0] = strdup(ifnames);
805  return true;
806 }

References eDest, and XrdSysError::Say().

+ Here is the call graph for this function:

◆ SetMsgs()

void XrdNetIF::SetMsgs ( XrdSysError erp)
static

Specify where messages are to be sent.

Parameters
erpPointer to the error message object. By default, no error messages are printed. This is not a thread-safe call and the err disposition must be set at initialization time.

Definition at line 886 of file XrdNetIF.cc.

886 {eDest = erp;}

References eDest.

Referenced by XrdConfig::Configure().

+ Here is the caller graph for this function:

◆ SetPublicName()

bool XrdNetIF::SetPublicName ( const std::string &  name)
inline

Sets the 'public name' to use associated with this interface.

Parameters
nameNew public name to utilize.
Returns
True if the name is a valid hostname; false otherwise.

Definition at line 164 of file XrdNetIF.hh.

165 {
166  // TODO: Actually validate this is an acceptable DNS name.
167  if (name.size() > 255) return false;
168  m_PublicName = name;
169  return true;
170 }

◆ SetRPIPA()

void XrdNetIF::SetRPIPA ( bool  rval)
static

Specify wheter or not private IP addresses should be resolved.

Parameters
rvalWhen true, private IP addresses are resolved. Otherwise, the IP addresses is used as the hostname.

Definition at line 892 of file XrdNetIF.cc.

892 {rPIPA = rval;}

Member Data Documentation

◆ haveIPv4

const int XrdNetIF::haveIPv4 = 1
static

ifList == 0 && non-local ipv4 i/f found (or'd)

Definition at line 196 of file XrdNetIF.hh.

Referenced by GetIF(), XrdNetUtils::NetConfig(), and XrdNetUtils::SetAuto().

◆ haveIPv6

const int XrdNetIF::haveIPv6 = 2
static

ifList == 0 && non-local ipv6 i/f found (or'd)

Definition at line 198 of file XrdNetIF.hh.

Referenced by GetIF(), XrdNetUtils::NetConfig(), and XrdNetUtils::SetAuto().

◆ haveNoGI

const int XrdNetIF::haveNoGI = 0
static

ifList == 0 && getifaddrs() is not supported

Obtain an easily digestable list of IP routable interfaces to this machine.

Parameters
ifListPlace where the list of interfaces will be placed. If ifList is null, returns configured interface types.
eTextWhen not nil, is where to place error message text.
Returns
Success: ifList != 0: returns the count of interfaces in the list. *ifList->sval[0] strlen(ifList->text) *ifList->sval[1] when != 0 the address is private. *ifList->text the interface address is standard format. The list of objects belongs to the caller and must be deleted when no longer needed.

ifList == 0: returns types of configured non-local i/f. This is or'd values of the static const ints haveXXXX.

Failure: Zero is returned. If eText is supplied, the error message, in persistent storage, is returned.

Definition at line 194 of file XrdNetIF.hh.

Referenced by GetIF().

◆ havePrv4

const int XrdNetIF::havePrv4 = 4
static

ifList == 0 && private ipv4 i/f found (or'd)

Definition at line 200 of file XrdNetIF.hh.

Referenced by GetIF().

◆ havePrv6

const int XrdNetIF::havePrv6 = 8
static

ifList == 0 && private ipv6 i/f found (or'd)

Definition at line 202 of file XrdNetIF.hh.

Referenced by GetIF().

◆ havePub4

const int XrdNetIF::havePub4 =16
static

ifList == 0 && public ipv4 i/f found (or'd)

Definition at line 204 of file XrdNetIF.hh.

Referenced by GetIF(), and XrdNetUtils::NetConfig().

◆ havePub6

const int XrdNetIF::havePub6 =32
static

ifList == 0 && public ipv6 i/f found (or'd)

Definition at line 206 of file XrdNetIF.hh.

Referenced by GetIF(), and XrdNetUtils::NetConfig().


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