xrootd
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
XrdNetIF Class Reference

#include <XrdNetIF.hh>

Collaboration diagram for XrdNetIF:
Collaboration graph
[legend]

Classes

struct  ifAddrs
 
struct  ifData
 
struct  pInfo
 

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

void Display (const char *pfx="=====> ")
 
int GetDest (char *dest, int dlen, ifType ifT=PublicV6, bool prefn=false)
 
int GetName (const char *&name, ifType ifT=PublicV6)
 
int GetName (char *nbuff, int &nport, ifType ifT=PublicV6)
 
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)
 
 XrdNetIF ()
 Constructor and Destructor.
 
 ~XrdNetIF ()
 

Static Public Member Functions

static int GetIF (XrdOucTList **ifList, const char **eText=0)
 
static int GetIF (char *buff, int blen, const char **eText=0, bool show=false)
 
static int GetIF (char *&ifline, const char **eText=0, bool show=false)
 
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 Privatize (ifType &x)
 
static void PortDefault (int pnum=1094)
 
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 haveNoGI = 0
 ifList == 0 && getifaddrs() is not supported
 
static const int haveIPv4 = 1
 ifList == 0 && non-local ipv4 i/f found (or'd)
 
static const int haveIPv6 = 2
 ifList == 0 && non-local ipv6 i/f found (or'd)
 
static const int havePrv4 = 4
 ifList == 0 && private ipv4 i/f found (or'd)
 
static const int havePrv6 = 8
 ifList == 0 && private ipv6 i/f found (or'd)
 
static const int havePub4 =16
 ifList == 0 && public ipv4 i/f found (or'd)
 
static const int havePub6 =32
 ifList == 0 && public ipv6 i/f found (or'd)
 

Private Member Functions

bool GenAddrs (ifAddrs &ifTab, XrdNetAddrInfo *src)
 
bool GenAddrs (ifAddrs &ifTab, const char *hName, bool wantV6)
 
bool GenIF (XrdNetAddrInfo **src, int srcnum, const char *xName=0)
 
void SetIFPP ()
 
bool SetIF64 (bool retVal)
 

Static Private Member Functions

static const char * GetDomain ()
 
static bool IsOkName (const char *ifn, short &ifIdx)
 
static bool V4LinkLocal (struct sockaddr *saP)
 

Private Attributes

ifDataifName [ifMax]
 
ifDataifDest [ifMax]
 
bool ifxDNS [ifMax]
 
char * ifBuff
 
struct XrdNetIF::pInfo portSfx
 
int ifPort
 
short ifRoute
 
char ifMask
 
char ifAvail
 

Static Private Attributes

static XrdSysErroreDest
 
static const char * myDomain
 
static char * ifCfg [2]
 
static const char * ifTName [ifMax]
 
static const char * ifMaskVec
 
static netType netRoutes
 
static int dfPort
 
static ifData ifNull
 
static bool rPIPA
 

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 

◆ 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 

Constructor & Destructor Documentation

◆ XrdNetIF()

XrdNetIF::XrdNetIF ( )
inline

Constructor and Destructor.

◆ ~XrdNetIF()

XrdNetIF::~XrdNetIF ( )
inline

References 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).

Referenced by XrdCmsNode::ShowIF().

◆ GenAddrs() [1/2]

bool XrdNetIF::GenAddrs ( ifAddrs ifTab,
const char *  hName,
bool  wantV6 
)
private

◆ GenAddrs() [2/2]

bool XrdNetIF::GenAddrs ( ifAddrs ifTab,
XrdNetAddrInfo src 
)
private

◆ GenIF()

bool XrdNetIF::GenIF ( XrdNetAddrInfo **  src,
int  srcnum,
const char *  xName = 0 
)
private

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

◆ GetDomain()

static const char * XrdNetIF::GetDomain ( )
staticprivate

◆ GetIF() [1/3]

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

◆ GetIF() [2/3]

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

◆ GetIF() [3/3]

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

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

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

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

References ifAny, ifAvail, ifName, ifPort, and XrdNetIF::ifData::iLen.

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

References ifAny, ifAvail, ifName, XrdNetIF::ifData::iLen, and XrdNetIF::ifData::iVal.

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

References ifAny, ifDest, and XrdNetIF::ifData::iLen.

◆ InDomain()

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

Referenced by XrdCmsNode::inDomain().

◆ IsOkName()

static bool XrdNetIF::IsOkName ( const char *  ifn,
short &  ifIdx 
)
staticprivate

◆ Mask() [1/2]

char XrdNetIF::Mask ( )
inline

Get the ifType selection mask for this object.

Returns
A single char that represents the selection mask.

References ifMask.

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

References ifAny, and ifMaskVec.

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

References ifAny, and ifTName.

◆ Port() [1/2]

int XrdNetIF::Port ( )
inline

Get the assigned port number

Returns
The port number.

References ifPort.

Referenced by XrdCmsNode::isNode().

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

◆ PortDefault()

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

Set the default assigned port number.

Parameters
pnumThe port number.

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

References PrivateIF.

Referenced by GetIFType().

◆ Routing()

static void XrdNetIF::Routing ( netType  nettype)
static

Set default interface network routing.

Parameters
nettypeNetwork routing (see netType definition).

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

◆ SetIF64()

bool XrdNetIF::SetIF64 ( bool  retVal)
private

◆ SetIFNames()

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

◆ SetIFPP()

void XrdNetIF::SetIFPP ( )
private

◆ SetMsgs()

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

◆ SetRPIPA()

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

◆ V4LinkLocal()

static bool XrdNetIF::V4LinkLocal ( struct sockaddr *  saP)
staticprivate

Member Data Documentation

◆ dfPort

int XrdNetIF::dfPort
staticprivate

◆ eDest

XrdSysError* XrdNetIF::eDest
staticprivate

◆ haveIPv4

const int XrdNetIF::haveIPv4 = 1
static

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

◆ haveIPv6

const int XrdNetIF::haveIPv6 = 2
static

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

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

◆ havePrv4

const int XrdNetIF::havePrv4 = 4
static

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

◆ havePrv6

const int XrdNetIF::havePrv6 = 8
static

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

◆ havePub4

const int XrdNetIF::havePub4 =16
static

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

◆ havePub6

const int XrdNetIF::havePub6 =32
static

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

◆ ifAvail

char XrdNetIF::ifAvail
private

Referenced by GetName(), and GetName().

◆ ifBuff

char* XrdNetIF::ifBuff
private

Referenced by ~XrdNetIF().

◆ ifCfg

char* XrdNetIF::ifCfg[2]
staticprivate

◆ ifDest

ifData* XrdNetIF::ifDest[ifMax]
private

Referenced by HasDest().

◆ ifMask

char XrdNetIF::ifMask
private

Referenced by Mask().

◆ ifMaskVec

const char* XrdNetIF::ifMaskVec
staticprivate

Referenced by Mask().

◆ ifName

ifData* XrdNetIF::ifName[ifMax]
private

Referenced by GetName(), and GetName().

◆ ifNull

ifData XrdNetIF::ifNull
staticprivate

◆ ifPort

int XrdNetIF::ifPort
private

Referenced by GetName(), and Port().

◆ ifRoute

short XrdNetIF::ifRoute
private

◆ ifTName

const char* XrdNetIF::ifTName[ifMax]
staticprivate

Referenced by Name().

◆ ifxDNS

bool XrdNetIF::ifxDNS[ifMax]
private

◆ myDomain

const char* XrdNetIF::myDomain
staticprivate

◆ netRoutes

netType XrdNetIF::netRoutes
staticprivate

◆ portSfx

struct XrdNetIF::pInfo XrdNetIF::portSfx
private

◆ rPIPA

bool XrdNetIF::rPIPA
staticprivate

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