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

#include <XrdNetAddrInfo.hh>

Inheritance diagram for XrdNetAddrInfo:
Inheritance graph
[legend]
Collaboration diagram for XrdNetAddrInfo:
Collaboration graph
[legend]

Classes

struct  LocInfo
 

Public Types

enum  fmtUse { fmtAuto =0 , fmtName , fmtAddr , fmtAdv6 }
 
enum  IPType { IPv4 = AF_INET , IPv6 = AF_INET6 , IPuX = AF_UNIX }
 

Public Member Functions

const char * Dialect ()
 
int Family () const
 
int Format (char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
 
bool isLoopback ()
 
bool isIPType (IPType ipType) const
 
bool isMapped () const
 
bool isPrivate ()
 
bool isRegistered ()
 
bool isUsingTLS ()
 
const struct LocInfoLocation ()
 
const char * Name (const char *eName=0, const char **eText=0)
 
const XrdNetSockAddrNetAddr ()
 
int Port ()
 
int Protocol ()
 
int Same (const XrdNetAddrInfo *ipAddr, bool plusPort=false)
 
const sockaddr * SockAddr ()
 
SOCKLEN_t SockSize ()
 
int SockFD ()
 
XrdNetAddrInfooperator= (XrdNetAddrInfo const &rhs)
 Assignment operator.
 
 XrdNetAddrInfo (XrdNetAddrInfo const &oP)
 Copy constructor.
 
 XrdNetAddrInfo ()
 Constructor.
 
 XrdNetAddrInfo (const XrdNetAddrInfo *addr)
 
 ~XrdNetAddrInfo ()
 Destructor.
 

Static Public Member Functions

static bool isHostName (const char *name)
 

Static Public Attributes

static const int noPort = 0x0000001
 Do not add port number.
 
static const int noPortRaw = 0x0000002
 Use raw address format (no port)
 
static const int old6Map4 = 0x0000004
 Use deprecated IPV6 mapped format.
 
static const int prefipv4 = 0x0000008
 Use if mapped IPV4 actual format.
 

Protected Member Functions

char * LowCase (char *str)
 
int QFill (char *bAddr, int bLen)
 
int Resolve ()
 

Protected Attributes

XrdNetSockAddr IP
 
union { 
 
   struct sockaddr *   sockAddr 
 
   struct sockaddr_un *   unixPipe 
 
};  
 
char * hostName
 
LocInfo addrLoc
 
unsigned short addrSize
 
unsigned char protType
 
unsigned char protFlgs
 
int sockNum
 
const char * protName
 

Static Protected Attributes

static XrdNetCachednsCache
 
static const char isTLS = 0x01
 Location using TLS.
 

Member Enumeration Documentation

◆ fmtUse

Format our address into a supplied buffer with one of the following layouts (the ':<port>' or ':/path' can be omitted if desired, see fmtOpts param): IP.xx: host_name:<port> IP.v4: a.b.c.d:<port> IP.4to6: [::ffff:a.b.c.d]:<port> | [::a.b.c.d]:<port> IP.v6: [a:b:c:d:e:f:g:h]:<port> IP.Unix: localhost:/<path>

Parameters
bAddraddress of buffer for result
bLenlength of buffer
fmtTypespecifies the type of format desired via fmtUse enum.
fmtOptsadditional formatting options (can be or'd): noPort - do not append the port number to the address. noPortRaw - no port and no brackets for IPv6. old6Map4 - use deprecated IPV6 mapped format '[::x.x.x.x]'
Returns
Success: The number of characters (less null) in Buff.
Failure: 0 (buffer is too small or not a valid address). However, if bLen > 0 the buffer will contain a null terminated string of up to 8 question marks.
Enumerator
fmtAuto 

Hostname if already resolved o/w use fmtAddr.

fmtName 

Hostname if it is resolvable o/w use fmtAddr.

fmtAddr 

Address using suitable ipv4 or ipv6 format.

fmtAdv6 

◆ IPType

Indicate whether or not our address is if the desired type.

Parameters
ipTypeThe IP address version to test (see enum below).
Returns
True: This is the address version of ipType.
False: This is not the address version of ipType.
Enumerator
IPv4 
IPv6 
IPuX 

Constructor & Destructor Documentation

◆ XrdNetAddrInfo() [1/3]

XrdNetAddrInfo::XrdNetAddrInfo ( XrdNetAddrInfo const &  oP)
inline

Copy constructor.

References hostName, and unixPipe.

◆ XrdNetAddrInfo() [2/3]

XrdNetAddrInfo::XrdNetAddrInfo ( )
inline

Constructor.

References XrdNetSockAddr::Addr, IP, and sockAddr.

◆ XrdNetAddrInfo() [3/3]

XrdNetAddrInfo::XrdNetAddrInfo ( const XrdNetAddrInfo addr)
inline

◆ ~XrdNetAddrInfo()

XrdNetAddrInfo::~XrdNetAddrInfo ( )
inline

Destructor.

References XrdNetSockAddr::Addr, hostName, IP, sockAddr, and unixPipe.

Member Function Documentation

◆ Dialect()

const char * XrdNetAddrInfo::Dialect ( )
inline

Provide the protocol languag being spoken (e.g. xroot, http, etc).

Returns
Pointer to the protocol language being used. If unknown, nil ia returned. Use the isUsingTLS() method to see if a secure version of the protocol is being used.

References protName.

◆ Family()

int XrdNetAddrInfo::Family ( ) const
inline

Provide our address family.

Returns
Success: Returns AF_INET, AF_INET6, or AF_UNIX. Failure: Returns 0, address is not valid.

References XrdNetSockAddr::Addr, and IP.

◆ Format()

int XrdNetAddrInfo::Format ( char *  bAddr,
int  bLen,
fmtUse  fmtType = fmtAuto,
int  fmtOpts = 0 
)

◆ isHostName()

static bool XrdNetAddrInfo::isHostName ( const char *  name)
static

Indicate whether or not a string is a possible hostname and not IP address. The return value does not aimply any kind of validity. For instance, a false return indicates this is not a valid hostname does not mean it is a valid IP address.

Parameters
nameThe string to check.
Returns
True: This is a possible hostname (i.e. not IP address).
False: This is not a possible hostname.

◆ isIPType()

bool XrdNetAddrInfo::isIPType ( IPType  ipType) const
inline

References XrdNetSockAddr::Addr, and IP.

◆ isLoopback()

bool XrdNetAddrInfo::isLoopback ( )

Indicate whether or not our address is the loopback address. Use this method to gaurd against UDP packet spoofing.

Returns
True: This is the loopback address.
False: This is not the loopback address.

◆ isMapped()

bool XrdNetAddrInfo::isMapped ( ) const
inline

Indicate whether or not our address is an IPv4 mapped to IPv6 address.

Returns
True: The address is a mapped IPv4 address. False: The address is not a mapped IPv4 address.

References XrdNetSockAddr::Addr, IP, and XrdNetSockAddr::v6.

◆ isPrivate()

bool XrdNetAddrInfo::isPrivate ( )

Indicate whether or not our address is private.

Returns
True: This address is private. False: This address is not private.

◆ isRegistered()

bool XrdNetAddrInfo::isRegistered ( )

Indicate whether or not our address is registered in the DNS.

Returns
True: This address is registered. False: This address is not registered.

◆ isUsingTLS()

bool XrdNetAddrInfo::isUsingTLS ( )

Indicate whether or not the endpoint is using TLS for communications.

Returns
True: This address is using TLS. False: This address is not using TLS.

◆ Location()

const struct LocInfo * XrdNetAddrInfo::Location ( )
inline

◆ LowCase()

char * XrdNetAddrInfo::LowCase ( char *  str)
protected

◆ Name()

const char * XrdNetAddrInfo::Name ( const char *  eName = 0,
const char **  eText = 0 
)

Convert our IP address to the corresponding [host] name.

Parameters
eNamevalue to return when the name cannot be determined.
eTextwhen not null, the reason for a failure is returned.
Returns
Success: Pointer to the name or ip address with eText, if supplied, set to zero. The memory is owned by the object and is deleted when the object is deleted or Set() is called. Failure: eName param and if eText is not zero, returns a pointer to a message describing the reason for the failure. The message is in persistent storage and cannot be modified.

◆ NetAddr()

const XrdNetSockAddr * XrdNetAddrInfo::NetAddr ( )
inline

Provide a pointer to our socket address suitable for use in calls to methods that require our internal format of sock addr. A value is only returned for IPV6/4 addresses and is nill otherwise. The pointer refers to memory allocated by this object and becomes invalid should the object be deleted. Use SockSize() to get its logical length.

References IP, and sockAddr.

◆ operator=()

XrdNetAddrInfo & XrdNetAddrInfo::operator= ( XrdNetAddrInfo const &  rhs)
inline

◆ Port()

int XrdNetAddrInfo::Port ( )

Return the port number for our address.

Returns
Success: The port number, which may be 0 if not set. Failure: -1 address is not an internet address or port is invalid.

◆ Protocol()

int XrdNetAddrInfo::Protocol ( )
inline

Provide our protocol family.

Returns
Success: Returns PF_INET, PF_INET6, or PF_UNIX. Failure: Returns 0, address is not valid.

References protType.

◆ QFill()

int XrdNetAddrInfo::QFill ( char *  bAddr,
int  bLen 
)
protected

◆ Resolve()

int XrdNetAddrInfo::Resolve ( )
protected

◆ Same()

int XrdNetAddrInfo::Same ( const XrdNetAddrInfo ipAddr,
bool  plusPort = false 
)

Check if the IP address in this object is the same as the one passed.

Parameters
ipAddrpoints to the network address object to compare.
plusPortwhen true, port values must also match. In any case, both addresses must be of the same address family.
Returns
Success: True (addresses are the same). Failure: False (addresses are not the same).

Note: implemented in terms of const version

Referenced by XrdCmsNode::isNode(), and XrdCmsNode::isNode().

◆ SockAddr()

const sockaddr * XrdNetAddrInfo::SockAddr ( )
inline

Provide a pointer to our socket address suitable for use in calls to functions that require one (e.g. bind() etc). The pointer refers to memory allocated by this object and becomes invalid should the object be deleted or when Set() is called. Use SockSize() to get its length.

References sockAddr.

◆ SockFD()

int XrdNetAddrInfo::SockFD ( )
inline

Get the associated file descriptor.

Returns
The associated file descriptor. If negative, no association exists.

References sockNum.

◆ SockSize()

SOCKLEN_t XrdNetAddrInfo::SockSize ( )
inline

Provide the length of our socket adress. Useful for system calls needing it.

Returns
Success: Returns the length of the address returned by SockAddr(). Failure: Returns 0, address is not valid.

References addrSize, and SOCKLEN_t.

Member Data Documentation

◆ [union]

union { ... } XrdNetAddrInfo

◆ addrLoc

LocInfo XrdNetAddrInfo::addrLoc
protected

Referenced by Location(), and operator=().

◆ addrSize

unsigned short XrdNetAddrInfo::addrSize
protected

Referenced by operator=(), and SockSize().

◆ dnsCache

XrdNetCache* XrdNetAddrInfo::dnsCache
staticprotected

◆ hostName

char* XrdNetAddrInfo::hostName
protected

◆ IP

XrdNetSockAddr XrdNetAddrInfo::IP
protected

◆ isTLS

const char XrdNetAddrInfo::isTLS = 0x01
staticprotected

Location using TLS.

◆ noPort

const int XrdNetAddrInfo::noPort = 0x0000001
static

Do not add port number.

◆ noPortRaw

const int XrdNetAddrInfo::noPortRaw = 0x0000002
static

Use raw address format (no port)

◆ old6Map4

const int XrdNetAddrInfo::old6Map4 = 0x0000004
static

Use deprecated IPV6 mapped format.

◆ prefipv4

const int XrdNetAddrInfo::prefipv4 = 0x0000008
static

Use if mapped IPV4 actual format.

◆ protFlgs

unsigned char XrdNetAddrInfo::protFlgs
protected

Referenced by operator=().

◆ protName

const char* XrdNetAddrInfo::protName
protected

◆ protType

unsigned char XrdNetAddrInfo::protType
protected

Referenced by operator=(), and Protocol().

◆ sockAddr

struct sockaddr* XrdNetAddrInfo::sockAddr

◆ sockNum

int XrdNetAddrInfo::sockNum
protected

Referenced by operator=(), and SockFD().

◆ unixPipe

struct sockaddr_un* XrdNetAddrInfo::unixPipe

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